SOURCE CODE: Date Picker
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Date Picker | JavaScript Examples | UIZE JavaScript Framework</title>
<meta name="keywords" content="widget form Uize.Widget.Picker.Date"/>
<meta name="description" content="The date picker widget lets users pick dates within configured date ranges, inside a shared date picker dialog. Many configurations are demonstrated."/>
<link rel="alternate" type="application/rss+xml" title="UIZE JavaScript Framework - Latest News" href="http://www.uize.com/latest-news.rss"/>
<link rel="stylesheet" href="../css/page.css"/>
<link rel="stylesheet" href="../css/page.example.css"/>
<link rel="stylesheet" href="../css/widget.dialog.css"/>
<link rel="stylesheet" href="../css/widget.dialog.picker.css"/>
<link rel="stylesheet" href="../css/widget.picker.date.css"/>
<link rel="stylesheet" href="../css/widget.calendar.css"/>
<link rel="stylesheet" href="css/params-table.css"/>
<style type="text/css">
.dialog .calendarContainer {
border:none;
}
table.paramsTable td.fieldLabel {
padding:0 7px;
}
table.paramsTable td {
padding:0;
}
</style>
</head>
<body>
<script type="text/javascript" src="../js/Uize.js"></script>
<h1 class="document-title">
<a id="page-homeLink" href="../index.html" title="UIZE JavaScript Framework home"></a>
<a href="../javascript-examples.html" class="breadcrumb breadcrumbWithArrow">JAVASCRIPT EXAMPLES</a>
Date Picker
<div id="page-actions" class="pageActions">
<a href="source-code/date-picker.html" class="buttonLink">SOURCE</a>
</div>
</h1>
<div class="main">
<!-- explanation copy -->
<div class="explanation">
<p>In this example, many instances of the <a href="../reference/Uize.Widget.Picker.Date.html"><code>Uize.Widget.Picker.Date</code></a> class are being wired up to let you select dates, with each date picker configured slightly differently.</p>
</div>
<!-- HTML for the date picker form field -->
<form>
<table class="paramsTable" style="margin:auto;">
<thead>
<tr>
<td colspan="2" class="tableHeading">Each Date Picker is Configured Differently</td>
</tr>
</thead>
<tr>
<td class="fieldLabel">select any date</td>
<td>
<input id="page_datePickerAnyDate-input" type="text"/><a id="page_datePickerAnyDate_selector" href="javascript://" class="datePickerIcon"><img src="../images/blank.gif"></a>
</td>
</tr>
<tr>
<td class="fieldLabel">select a day up until today</td>
<td>
<input id="page_datePickerUntilToday-input" type="text"/><a id="page_datePickerUntilToday_selector" href="javascript://" class="datePickerIcon"><img src="../images/blank.gif"></a>
</td>
</tr>
<tr>
<td class="fieldLabel">select a day from today onwards</td>
<td>
<input id="page_datePickerFromToday-input" type="text"/><a id="page_datePickerFromToday_selector" href="javascript://" class="datePickerIcon"><img src="../images/blank.gif"></a>
</td>
</tr>
<tr>
<td class="fieldLabel">select a day this week</td>
<td>
<input id="page_datePickerThisWeek-input" type="text"/><a id="page_datePickerThisWeek_selector" href="javascript://" class="datePickerIcon"><img src="../images/blank.gif"></a>
</td>
</tr>
<tr>
<td class="fieldLabel">select a day this month</td>
<td>
<input id="page_datePickerThisMonth-input" type="text"/><a id="page_datePickerThisMonth_selector" href="javascript://" class="datePickerIcon"><img src="../images/blank.gif"></a>
</td>
</tr>
<tr>
<td class="fieldLabel">select a day this year</td>
<td>
<input id="page_datePickerThisYear-input" type="text"/><a id="page_datePickerThisYear_selector" href="javascript://" class="datePickerIcon"><img src="../images/blank.gif"></a>
</td>
</tr>
<tr>
<td class="fieldLabel">date picker with initial value</td>
<td>
<input id="page_datePickerInitialValue-input" type="text" value="2009-01-01"/><a id="page_datePickerInitialValue_selector" href="javascript://" class="datePickerIcon"><img src="../images/blank.gif"></a>
</td>
</tr>
<tr>
<td class="fieldLabel">custom display format -- {YYYY}/{monthNo}/{dayNo}</td>
<td>
<input id="page_datePickerCustomFormatYyyyMonthNoDayNo-input" type="text" value="2008/2/29"/><a id="page_datePickerCustomFormatYyyyMonthNoDayNo_selector" href="javascript://" class="datePickerIcon"><img src="../images/blank.gif"></a>
</td>
</tr>
<tr>
<td class="fieldLabel">custom display format -- {dayNo}/{monthNo}/{YYYY}</td>
<td>
<input id="page_datePickerCustomFormatDayNoMonthNoYyyy-input" type="text" value="29/2/2008"/><a id="page_datePickerCustomFormatDayNoMonthNoYyyy_selector" href="javascript://" class="datePickerIcon"><img src="../images/blank.gif"></a>
</td>
</tr>
<tr>
<td class="fieldLabel">date picker with pretty format</td>
<td>
<input id="page_datePickerPrettyFormat-input" type="text" value="21 January 1981"/><a id="page_datePickerPrettyFormat_selector" href="javascript://" class="datePickerIcon"><img src="../images/blank.gif"></a>
</td>
</tr>
<tr>
<td class="fieldLabel">date picker with no manual input</td>
<td>
<input id="page_datePickerNoManualInput-input" type="text"/><a id="page_datePickerNoManualInput_selector" href="javascript://" class="datePickerIcon"><img src="../images/blank.gif"></a>
</td>
</tr>
</table>
</form>
</div>
<!-- JavaScript code to wire up the page UI -->
<script type="text/javascript">
Uize.module ({
required:[
'UizeSite.Page.Example.library',
'UizeSite.Page.Example',
'Uize.Widget.Picker.Date',
'Uize.Date'
],
builder:function () {
/*** create the example page widget ***/
var page = window.page = UizeSite.Page.Example ();
/*** add the date picker widgets ***/
// all our date pickers use the same dialog widget class for the uize.com Web site
Uize.Widget.Picker.Date.set ({dialogWidgetClass:'UizeSite.DialogDate'});
var today = new Date;
/*** date picker - pick any date ***/
page.addChild ('datePickerAnyDate',Uize.Widget.Picker.Date);
/*** date picker - pick a day up until today ***/
page.addChild ('datePickerUntilToday',Uize.Widget.Picker.Date,{maxValue:today});
/*** date picker - pick a day from today onwards ***/
page.addChild ('datePickerFromToday',Uize.Widget.Picker.Date,{minValue:today});
/*** date picker - pick a day this week ***/
page.addChild ('datePickerThisWeek',Uize.Widget.Picker.Date,Uize.Date.getRangeAround ('','week'));
/*** date picker - pick a day this month ***/
page.addChild ('datePickerThisMonth',Uize.Widget.Picker.Date,Uize.Date.getRangeAround ('','month'));
/*** date picker - pick a day this year ***/
page.addChild ('datePickerThisYear',Uize.Widget.Picker.Date,Uize.Date.getRangeAround ('','year'));
/*** date picker - with initial value ***/
page.addChild ('datePickerInitialValue',Uize.Widget.Picker.Date);
/*** date picker - custom display format -- {YYYY}/{monthNo}/{dayNo} ***/
page.addChild (
'datePickerCustomFormatYyyyMonthNoDayNo',
Uize.Widget.Picker.Date,{displayFormat:'{YYYY}/{monthNo}/{dayNo}'}
);
/*** date picker - custom display format (DD/MM/YYYY) ***/
page.addChild (
'datePickerCustomFormatDayNoMonthNoYyyy',
Uize.Widget.Picker.Date,{displayFormat:'{dayNo}/{monthNo}/{YYYY}'}
);
/*** date picker - pretty display format ***/
page.addChild (
'datePickerPrettyFormat',Uize.Widget.Picker.Date,{displayFormat:'{dayNo} {monthName} {YYYY}'}
);
/*** date picker - no manual input ***/
page.addChild ('datePickerNoManualInput',Uize.Widget.Picker.Date,{allowManualEntry:false});
/*** wire up the page widget ***/
page.wireUi ();
}
});
</script>
</body>
</html>