Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 311 lines (305 sloc) 24.649 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
<?xml version="1.0"?>
<entry name="datepicker" type="widget" widget-element="datepicker">
<title>Datepicker Widget</title>
<desc>Select a date from a popup or inline calendar</desc>
<longdesc>
<p>The jQuery UI Datepicker is a highly configurable plugin that adds datepicker functionality to your pages. You can customize the date format and language, restrict the selectable date ranges and add in buttons and other navigation options easily.</p>

<p>By default, the datepicker calendar opens in a small overlay when the associated text field gains focus. For an inline calendar, simply attach the datepicker to a div or span.</p>

<h3>Keyboard interaction</h3>
<p>While the datepicker is open, the following key commands are available:</p>
<ul>
<li>PAGE UP: Move to the previous month.</li>
<li>PAGE DOWN: Move to the next month.</li>
<li>CTRL+PAGE UP: Move to the previous year.</li>
<li>CTRL+PAGE DOWN: Move to the next year.</li>
<li>CTRL+HOME: Move to the current month. Open the datepicker if closed.</li>
<li>CTRL+LEFT: Move to the previous day.</li>
<li>CTRL+RIGHT: Move to the next day.</li>
<li>CTRL+UP: Move to the previous week.</li>
<li>CTRL+DOWN: Move the next week.</li>
<li>ENTER: Select the focused date.</li>
<li>CTRL+END: Close the datepicker and erase the date.</li>
<li>ESCAPE: Close the datepicker without selection.</li>
</ul>

<h3 id="utility-functions">Utility functions</h3>
<ul>
<li>$.datepicker.setDefaults( settings ) - Set settings for all datepicker instances.</li>
<li>$.datepicker.formatDate( format, date, settings ) - Format a date into a string value with a specified format.</li>
<li>$.datepicker.parseDate( format, value, settings ) - Extract a date from a string value with a specified format.</li>
<li>$.datepicker.iso8601Week( date ) - Determine the week of the year for a given date: 1 to 53.</li>
<li>$.datepicker.noWeekends - Set as beforeShowDay function to prevent selection of weekends.</li>
</ul>

<h3>Localization</h3>
<p>Datepicker provides support for localizing its content to cater for different languages and date formats. Each localization is contained within its own file with the language code appended to the name, e.g., <code>jquery.ui.datepicker-fr.js</code> for French. The desired localization file should be included after the main datepicker code. Each localization file adds its settings to the set of available localizations and automatically applies them as defaults for all instances.</p>
<p>The <code>$.datepicker.regional</code> attribute holds an array of localizations, indexed by language code, with <code>""</code> referring to the default (English). Each entry is an object with the following attributes: <code>closeText</code>, <code>prevText</code>, <code>nextText</code>, <code>currentText</code>, <code>monthNames</code>, <code>monthNamesShort</code>, <code>dayNames</code>, <code>dayNamesShort</code>, <code>dayNamesMin</code>, <code>weekHeader</code>, <code>dateFormat</code>, <code>firstDay</code>, <code>isRTL</code>, <code>showMonthAfterYear</code>, and <code>yearSuffix</code>.</p>
<p>You can restore the default localizations with:</p>
<code>$.datepicker.setDefaults( $.datepicker.regional[ "" ] );</code>
<p>And can then override an individual datepicker for a specific locale:</p>
<code>$( selector ).datepicker( $.datepicker.regional[ "fr" ] );</code>
</longdesc>
<note id="functional-css"/>
<added>1.0</added>
<options>
<option name="altField" default='""' example-value='"#actualDate"'>
<desc>An input element that is to be updated with the selected date from the datepicker. Use the <a href="#option-altFormat"><code>altFormat</code></a> option to change the format of the date within this field. Leave as blank for no alternate field.</desc>
<type name="Selector"/>
<type name="jQuery"/>
<type name="Element"/>
</option>
<option name="altFormat" type="String" default='""' example-value='"yy-mm-dd"'>
<desc>The <a href="#option-dateFormat"><code>dateFormat</code></a> to be used for the <a href="#option-altField"><code>altField</code></a> option. This allows one date format to be shown to the user for selection purposes, while a different format is actually sent behind the scenes. For a full list of the possible formats see the [[UI/Datepicker/formatDate|formatDate]] function</desc>
</option>
<option name="appendText" type="String" default='""' example-value='"(yyyy-mm-dd)"'>
<desc>The text to display after each date field, e.g., to show the required format.</desc>
</option>
<option name="autoSize" type="Boolean" default="false" example-value="true">
<desc>Set to <code>true</code> to automatically resize the input field to accommodate dates in the current <a href="#option-dateFormat"><code>dateFormat</code></a>.</desc>
</option>
<option name="buttonImage" type="String" default='""' example-value='"/images/datepicker.gif"'>
<desc>The URL for the popup button image. If set, the <a href="#option-buttonText"><code>buttonText</code></a> option becomes the <code>alt</code> value and is not directly displayed.</desc>
</option>
<option name="buttonImageOnly" type="Boolean" default="false" example-value="true">
<desc>Whether the button image should be rendered by itself instead of inside a button element.</desc>
</option>
<option name="buttonText" type="String" default='"..."' example-value='"Choose"'>
<desc>The text to display on the trigger button. Use in conjunction with the <a href="#option-showOn"><code>showOn</code></a> option set to <code>"button"</code> or <code>"both"</code>.</desc>
</option>
<option name="calculateWeek" type="Function" default="jQuery.datepicker.iso8601Week" example-value='myWeekCalc'>
<desc>A function to calculate the week of the year for a given date. The default implementation uses the ISO 8601 definition: weeks start on a Monday; the first week of the year contains the first Thursday of the year.</desc>
</option>
<option name="changeMonth" type="Boolean" default="false" example-value="true">
<desc>Whether the month should be rendered as a dropdown instead of text.</desc>
</option>
<option name="changeYear" type="Boolean" default="false" example-value="true">
<desc>Whether the year should be rendered as a dropdown instead of text. Use the <a href="#option-yearRange"><code>yearRange</code></a> option to control which years are made available for selection.</desc>
</option>
<option name="closeText" type="String" default='"Done"' example-value='"Close"'>
<desc>The text to display for the close link. Use the <a href="#option-showButtonPanel"><code>showButtonPanel</code></a> option to display this button.</desc>
</option>
<option name="constrainInput" type="Boolean" default="true" example-value="false">
<desc>When <code>true</code>, entry in the input field is constrained to those characters allowed by the current <a href="#option-dateFormat"><code>dateFormat</code></a> option.</desc>
</option>
<option name="currentText" type="String" default='"Today"' example-value='"Now"'>
<desc>The text to display for the current day link. Use the <a href="#option-showButtonPanel"><code>showButtonPanel</code></a> option to display this button.</desc>
</option>
<option name="dateFormat" type="String" default='"mm/dd/yy"' example-value='"yy-mm-dd"'>
<desc>The format for parsed and displayed dates. For a full list of the possible formats see the <code>[[UI/Datepicker/formatDate|formatDate]]</code> function.</desc>
</option>
<option name="dayNames" type="Array" default='[ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]' example-value='[ "Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi" ]'>
<desc>The list of long day names, starting from Sunday, for use as requested via the <a href="#option-dateFormat"><code>dateFormat</code></a> option.</desc>
</option>
<option name="dayNamesMin" type="Array" default='[ "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" ]' example-value='[ "Di", "Lu", "Ma", "Me", "Je", "Ve", "Sa" ]'>
<desc>The list of minimised day names, starting from Sunday, for use as column headers within the datepicker.</desc>
</option>
<option name="dayNamesShort" type="Array" default='[ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ]' example-value='[ "Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam" ]'>
<desc>The list of abbreviated day names, starting from Sunday, for use as requested via the <a href="#option-dateFormat"><code>dateFormat</code></a> option.</desc>
</option>
<option name="defaultDate" default="null" example-value="+7">
<desc>Set the date to highlight on first opening if the field is blank. Specify either an actual date via a Date object or as a string in the current <code>[[UI/Datepicker#option-dateFormat|dateFormat]]</code>, or a number of days from today (e.g. +7) or a string of values and periods ('y' for years, 'm' for months, 'w' for weeks, 'd' for days, e.g. '+1m +7d'), or null for today.</desc>
<type name="Date">
<desc>A date object containing the default date.</desc>
</type>
<type name="Number">
<desc>A number of days from today. For example <code>2</code> represents two days from today and <code>-1</code> represents yesterday.</desc>
</type>
<type name="String">
<desc>A string in the format defined by the <a href="#option-dateFormat"><code>dateFormat</code></a> option, or a relative date. Relative dates must contain value and period pairs; valid periods are <code>"y"</code> for years, <code>"m"</code> for months, <code>"w"</code> for weeks, and <code>"d"</code> for days. For example, <code>"+1m +7d"</code> represents one month and seven days from today.</desc>
</type>
</option>
<option name="duration" default='"normal"' example-value='"slow"'>
<desc>Control the speed at which the datepicker appears, it may be a time in milliseconds or a string representing one of the three predefined speeds ("slow", "normal", "fast").</desc>
<type nmae="Number"/>
<type name="String"/>
</option>
<option name="firstDay" type="Integer" default="0" example-value="1">
<desc>Set the first day of the week: Sunday is <code>0</code>, Monday is <code>1</code>, etc.</desc>
</option>
<option name="gotoCurrent" type="Boolean" default="false" example-value="true">
<desc>When <code>true</code>, the current day link moves to the currently selected date instead of today.</desc>
</option>
<option name="hideIfNoPrevNext" type="Boolean" default="false" example-value="true">
<desc>Normally the previous and next links are disabled when not applicable (see the <a href="#option-minDate"><code>minDate</code></a> and <a href="#option-maxDate"><code>maxDate</code></a> options). You can hide them altogether by setting this attribute to <code>true</code>.</desc>
</option>
<option name="isRTL" type="Boolean" default="false" example-value="true">
<desc>Whether the current language is drawn from right to left.</desc>
</option>
<option name="maxDate" default="null" example-value='"+1m +1w"'>
<desc>The maximum selectable date. When set to <code>null</code>, there is no maximum.</desc>
<type name="Date">
<desc>A date object containing the maximum date.</desc>
</type>
<type name="Number">
<desc>A number of days from today. For example <code>2</code> represents two days from today and <code>-1</code> represents yesterday.</desc>
</type>
<type name="String">
<desc>A string in the format defined by the <a href="#option-dateFormat"><code>dateFormat</code></a> option, or a relative date. Relative dates must contain value and period pairs; valid periods are <code>"y"</code> for years, <code>"m"</code> for months, <code>"w"</code> for weeks, and <code>"d"</code> for days. For example, <code>"+1m +7d"</code> represents one month and seven days from today.</desc>
</type>
</option>
<option name="minDate" default="null" example-value="new Date(2007, 1 - 1, 1)">
<desc>The minimum selectable date. When set to <code>null</code>, there is no minimum.</desc>
<type name="Date">
<desc>A date object containing the minimum date.</desc>
</type>
<type name="Number">
<desc>A number of days from today. For example <code>2</code> represents two days from today and <code>-1</code> represents yesterday.</desc>
</type>
<type name="String">
<desc>A string in the format defined by the <a href="#option-dateFormat"><code>dateFormat</code></a> option, or a relative date. Relative dates must contain value and period pairs; valid periods are <code>"y"</code> for years, <code>"m"</code> for months, <code>"w"</code> for weeks, and <code>"d"</code> for days. For example, <code>"+1m +7d"</code> represents one month and seven days from today.</desc>
</type>
</option>
<option name="monthNames" type="Array" default='[ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]' example-value='[ "Januar", "Februar", "Marts", "April", "Maj", "Juni", "Juli", "August", "September", "Oktober", "November", "December" ]'>
<desc>The list of full month names, for use as requested via the <a href="#option-dateFormat"><code>dateFormat</code></a> option.</desc>
</option>
<option name="monthNamesShort" type="Array" default='[ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ]' example-value='[ "Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec" ]'>
<desc>The list of abbreviated month names, as used in the month header on each datepicker and as requested via the <a href="#option-dateFormat"><code>dateFormat</code></a> option.</desc>
</option>
<option name="navigationAsDateFormat" type="Boolean" default="false" example-value="true">
<desc>Whether the <a href="#option-prevText"><code>prevText</code></a> and <a href="#option-nextText"><code>nextText</code></a> options should be parsed as dates by the <code>[[UI/Datepicker/formatDate|formatDate]]</code> function, allowing them to display the target month names for example.</desc>
</option>
<option name="nextText" type="String" default='"Next"' example-value='"Later"'>
<desc>The text to display for the next month link. With the standard ThemeRoller styling, this value is replaced by an icon.</desc>
</option>
<option name="numberOfMonths" default="1" example-value="[ 2, 3 ]">
<desc>The number of months to show at once.</desc>
<type name="Number">
<desc>The number of months to display in a single row.</desc>
</type>
<type name="Array">
<desc>An array defining the number of rows and columns to display.</desc>
</type>
</option>
<option name="prevText" type="String" default='"Prev"' example-value='"Earlier"'>
<desc>The text to display for the previous month link. With the standard ThemeRoller styling, this value is replaced by an icon.</desc>
</option>
<option name="selectOtherMonths" type="Boolean" default="false" example-value="true">
<desc>Whether days in other months shown before or after the current month are selectable. This only applies if the <a href="#option-showOtherMonths"><code>showOtherMonths</code></a> option is set to <code>true</code>.</desc>
</option>
<option name="shortYearCutoff" default='"+10"' example-value="50">
<desc>The cutoff year for determining the century for a date (used in conjunction with <code>[[UI/Datepicker#option-dateFormat|dateFormat]]</code> 'y'). Any dates entered with a year value less than or equal to the cutoff year are considered to be in the current century, while those greater than it are deemed to be in the previous century.</desc>
<type name="Number">
<desc>A value between <code>0</code> and <code>99</code> indicating the cutoff year.</desc>
</type>
<type name="String">
<desc>A relative number of years from the current year, e.g., <code>"+3"</code> or <code>"-5"</code>.</desc>
</type>
</option>
<option name="showAnim" type="String" default='"show"' example-value='"fold"'>
<desc>The name of the animation used to show and hide the datepicker. Use <code>"show"</code> (the default), <code>"slideDown"</code>, <code>"fadeIn"</code>, any of the <a href="/category/effects/">jQuery UI effects</a>. Set to an empty string to disable animation.</desc>
</option>
<option name="showButtonPanel" type="Boolean" default="false" example-value="true">
<desc>Whether to show the button panel.</desc>
</option>
<option name="showCurrentAtPos" type="Number" default="0" example-value="3">
<desc>When displaying multiple months via the <a href="#option-numberOfMonths"><code>numberOfMonths</code></a> option, the <code>showCurrentAtPos</code> option defines which position to display the current month in.</desc>
</option>
<option name="showMonthAfterYear" type="Boolean" default="false" example-value="true">
<desc>Whether to show the month after the year in the header.</desc>
</option>
<option name="showOn" type="String" default='"focus"' example-value='"both"'>
<desc>When the datepicker should appear. The datepicker can appear when the field receives focus (<code>"focus"</code>), when a button is clicked (<code>"button"</code>), or when either event occurs (<code>"both"</code>).</desc>
</option>
<option name="showOptions" type="Object" default="{}" example-value='{ direction: "up" }'>
<desc>If using one of the jQuery UI effects for the <a href="#option-showAnim"><code>showAnim</code></a> option, you can provide additional settings for that animation via this option.</desc>
</option>
<option name="showOtherMonths" type="Boolean" default="false" example-value="true">
<desc>Whether to display dates in other months (non-selectable) at the start or end of the current month. To make these days selectable use the <a href="#option-selectOtherMonths"><code>selectOtherMonths</code></a> option.</desc>
</option>
<option name="showWeek" type="Boolean" default="false" example-value="true">
<desc>When <code>true</code>, a column is added to show the week of the year. The <a href="#option-calculateWeek"><code>calculateWeek</code></a> option determines how the week of the year is calculated. You may also want to change the <a href="#option-firstDay"><code>firstDay</code></a> option.</desc>
</option>
<option name="stepMonths" type="Number" default="1" example-value="3">
<desc>Set how many months to move when clicking the previous/next links.</desc>
</option>
<option name="weekHeader" type="String" default='"Wk"' example-value='"W"'>
<desc>The text to display for the week of the year column heading. Use the <a href="#option-showWeek"><code>showWeek</code></a> option to display this column.</desc>
</option>
<option name="yearRange" type="String" default='"c-10:c+10"' example-value='"2002:2012"'>
<desc>The range of years displayed in the year drop-down: either relative to today's year (<code>"-nn:+nn"</code>), relative to the currently selected year (<code>"c-nn:c+nn"</code>), absolute (<code>"nnnn:nnnn"</code>), or combinations of these formats (<code>"nnnn:-nn"</code>). Note that this option only affects what appears in the drop-down, to restrict which dates may be selected use the <a href="#option-minDate"><code>minDate</code></a> and/or <a href="#option-maxDate"><code>maxDate</code></a> options.</desc>
</option>
<option name="yearSuffix" type="String" default='""' example-value='"CE"'>
<desc>Additional text to display after the year in the month headers.</desc>
</option>

<!-- events -->
<option name="beforeShow" type="Function" default="null">
<argument name="input" type="Element"/>
<argument name="inst" type="Object"/>
<desc>A function that takes an input field and current datepicker instance and returns an options object to update the datepicker with. It is called just before the datepicker is displayed.</desc>
</option>
<option name="beforeShowDay" type="Function" default="null">
<argument name="date" type="Date"/>
<desc>A function takes a date as a parameter and must return an array with <code>[0]</code> equal to <code>true</code>/<code>false</code> indicating whether or not this date is selectable, <code>[1]</code> equal to a CSS class name or <code>""</code> for the default presentation, and <code>[2]</code> an optional popup tooltip for this date. It is called for each day in the datepicker before it is displayed.</desc>
</option>
<option name="onChangeMonthYear" type="Function" default="null">
<argument name="year" type="Integer"/>
<argument name="month" type="Integer"/>
<argument name="inst" type="Object"/>
<desc>Called when the datepicker moves to a new month and/or year. The function receives the selected year, month (1-12), and the datepicker instance as parameters. <code>this</code> refers to the associated input field.</desc>
</option>
<option name="onClose" type="Function" default="null">
<argument name="dateText" type="String"/>
<argument name="inst" type="Object"/>
<desc>Called when the datepicker is closed, whether or not a date is selected. The function receives the selected date as text (<code>""</code> if none) and the datepicker instance as parameters. <code>this</code> refers to the associated input field.</desc>
</option>
<option name="onSelect" type="Function" default="null">
<argument name="dateText" type="String"/>
<argument name="inst" type="Object"/>
<desc>Called when the datepicker is selected. The function receives the selected date as text and the datepicker instance as parameters. <code>this</code> refers to the associated input field.</desc>
</option>
</options>
<methods>
<xi:include href="../includes/widget-method-destroy.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
<method name="dialog" example-params='"10/12/2012"'>
<desc>Opens the datepicker in a dialog box.</desc>
<argument name="date">
<desc>The initial date.</desc>
<type name="String"/>
<type name="Date"/>
</argument>
<argument name="onSelect" type="Function" optional="true">
<desc>A callback function when a date is selected. The function receives the date text and date picker instance as parameters.</desc>
</argument>
<argument name="settings" type="Options" optional="true">
<desc>The new settings for the date picker.</desc>
</argument>
<argument name="pos" type="Number[2] or MouseEvent" optional="true">
<desc>The position of the top/left of the dialog as <code>[x, y]</code> or a <code>MouseEvent</code> that contains the coordinates. If not specified the dialog is centered on the screen.</desc>
</argument>
</method>
<method name="isDisabled" return="Boolean" example-return-var="isDisabled">
<desc>Determine whether a date picker has been disabled.</desc>
</method>
<method name="hide">
<desc>Close a previously opened date picker.</desc>
</method>
<method name="show">
<desc>Open the date picker. If the datepicker is attached to an input, the input must be visible for the datepicker to be shown.</desc>
</method>
<method name="refresh">
<desc>Redraw the date picker, after having made some external modifications.</desc>
</method>
<method name="getDate" return="Date" example-return-var="currentDate">
<desc>Returns the current date for the datepicker or <code>null</code> if no date has been selected.</desc>
</method>
<method name="setDate" example-params='"10/12/2012"'>
<desc>Sets the date for the datepicker. The new date may be a <code>Date</code> object or a string in the current <a href="#option-dateFormat">date format</a> (e.g., <code>"01/26/2009"</code>), a number of days from today (e.g., <code>+7</code>) or a string of values and periods (<code>"y"</code> for years, <code>"m"</code> for months, <code>"w"</code> for weeks, <code>"d"</code> for days, e.g., <code>"+1m +7d"</code>), or <code>null</code> to clear the selected date.</desc>
<argument name="date">
<desc>The new date.</desc>
<type name="String"/>
<type name="Date"/>
</argument>
</method>
<xi:include href="../includes/widget-method-option.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
<xi:include href="../includes/widget-method-widget.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
</methods>
<example>
<height>300</height>
<desc>A simple jQuery UI Datepicker.</desc>
<code><![CDATA[
$( "#datepicker" ).datepicker();
]]></code>
<html><![CDATA[
<div id="datepicker"></div>
]]></html>
</example>
<category slug="widgets"/>
</entry>
Something went wrong with that request. Please try again.