This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
perso-hebdo/js/pickadate.js-3.5.3/date.htm

750 lines
37 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<meta charset="utf-8">
<meta name="author" content="Amsul - http://amsul.ca">
<meta name="viewport" content="width=device-width">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<title>pickadate.js / date</title>
<link rel="shortcut icon" href="demo/images/favicon.ico">
<link rel="stylesheet" href="demo/styles/css/main.css">
<link rel="stylesheet" href="lib/themes/default.css" id="theme_base">
<link rel="stylesheet" href="lib/themes/default.date.css" id="theme_date">
<link rel="stylesheet" href="lib/themes/default.time.css" id="theme_time">
<!--[if lt IE 9]>
<script>document.createElement('section')</script>
<![endif]-->
<body>
<header class="section section--header section--splash">
<div class="section__block section__block--scoped">
<nav class="menu menu--header page-target" id="menu">
<ul class="menu__list menu__list--header">
<li class="menu__item menu__item--touch menu__item--logo"><a class="menu__link menu__link--dimmed" href="index.htm"><span class="logocon"><span class="logocon__p">p</span><span class="logocon__u"></span></span></a></li>
<li class="menu__item menu__item--touch menu__item--toggle">
<a class="menu__link menu__link--dimmed page-target__display" href="#menu"><span class="page-target__toggle"></span></a>
<a class="menu__link menu__link--dimmed page-target__display--flip" href="#"><span class="page-target__toggle"></span></a>
</li>
<li class="menu__item menu__item--clear"></li>
<li class="menu__item menu__item--responsive page-target__reveal"><a class="menu__link menu__link--dimmed menu__link--active" href="date.htm">Date picker</a></li>
<li class="menu__item menu__item--responsive page-target__reveal"><a class="menu__link menu__link--dimmed" href="time.htm">Time picker</a></li>
<li class="menu__item menu__item--responsive page-target__reveal"><a class="menu__link menu__link--dimmed" href="api.htm">API</a></li>
<li class="menu__item menu__item--responsive page-target__reveal"><a class="menu__link menu__link--dimmed" href="v2-(deprecated)/index.htm">v2 docs</a></li>
<li class="menu__item menu__item--responsive page-target__reveal"><a class="menu__link menu__link--dimmed" href="https://github.com/amsul/pickadate.js">Github</a></li>
<li class="menu__item menu__item--responsive page-target__reveal menu__item--trail">
<span class="menu__link">Themes: <input class="theme-toggle__input" type="radio" id="show_theme_default" name="show_theme" value="default" checked hidden><label class="theme-toggle__label theme-toggle__label--first" for="show_theme_default">default</label><input class="theme-toggle__input" type="radio" id="show_theme_classic" name="show_theme" value="classic" hidden><label class="theme-toggle__label theme-toggle__label--last" for="show_theme_classic" class="checked-negative">classic</label></span>
</li>
</ul>
</nav>
</div> <!-- .section__block -->
</header> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h1 class="heading heading--divide-center heading--divide-first"><span class="heading__text">The Date Picker<a class="heading__anchor" name="picker" href="#picker">&sect;</a></span></h1>
<h3 class="heading heading--thin">The basic setup requires targetting an <code class="tag-name">input</code> element and invoking the&nbsp;picker:</h3>
<pre class="pre--demo"><code data-language="javascript">$('.datepicker').pickadate()</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="" class="fieldset__input js__datepicker" type=text placeholder="Try me&hellip;"></div></fieldset>
<div class="section__block section__block--notification">
<p>Along with v3, the v2 options and API have effectively been deprecated. Read up on the <a href="https://github.com/amsul/pickadate.js/blob/3.5.3/CHANGELOG.md">full changelog here</a>.</p>
<p>One of the most critical changes is that the “month” used to create dates, just as in JavaScripts native Date object, now has <a href="https://github.com/amsul/pickadate.js/blob/3.5.3/CHANGELOG.md#zero-as-index">zero-as-index</a>.</p>
</div>
</div> <!-- .section__block -->
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Options<a class="heading__anchor" name="options" href="#options">&sect;</a></span></h2>
<p>With the basic invocation above, these are the default settings:</p>
<pre><code data-language="javascript">// <a href="#strings">Strings</a> and <a href="#translations">translations</a>
monthsFull: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
weekdaysFull: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
weekdaysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
showMonthsShort: undefined,
showWeekdaysFull: undefined,
// <a href="#buttons">Buttons</a>
today: 'Today',
clear: 'Clear',
// <a href="#accessibility-labels">Accessibility labels</a>
labelMonthNext: 'Next month',
labelMonthPrev: 'Previous month',
labelMonthSelect: 'Select a month',
labelYearSelect: 'Select a year',
// <a href="#formats">Formats</a>
format: 'd mmmm, yyyy',
formatSubmit: undefined,
hiddenPrefix: undefined,
hiddenSuffix: '_submit',
hiddenName: undefined,
// <a href="#editable">Editable input</a>
editable: undefined,
// <a href="#selectors">Dropdown selectors</a>
selectYears: undefined,
selectMonths: undefined,
// <a href="#first-weekday">First day of the week</a>
firstDay: undefined,
// <a href="#limits">Date limits</a>
min: undefined,
max: undefined,
// <a href="#disable-dates">Disable dates</a>
disable: undefined,
// <a href="#container">Root container</a>
container: undefined,
// <a href="#events">Events</a>
onStart: undefined,
onRender: undefined,
onOpen: undefined,
onClose: undefined,
onSet: undefined,
onStop: undefined,
// <a href="#classes">Classes</a>
klass: {
// The element states
input: 'picker__input',
active: 'picker__input--active',
// The root picker and states *
picker: 'picker',
opened: 'picker--opened',
focused: 'picker--focused',
// The picker holder
holder: 'picker__holder',
// The picker frame, wrapper, and box
frame: 'picker__frame',
wrap: 'picker__wrap',
box: 'picker__box',
// The picker header
header: 'picker__header',
// Month navigation
navPrev: 'picker__nav--prev',
navNext: 'picker__nav--next',
navDisabled: 'picker__nav--disabled',
// Month &amp; year labels
month: 'picker__month',
year: 'picker__year',
// Month &amp; year dropdowns
selectMonth: 'picker__select--month',
selectYear: 'picker__select--year',
// Table of dates
table: 'picker__table',
// Weekday labels
weekdays: 'picker__weekday',
// Day states
day: 'picker__day',
disabled: 'picker__day--disabled',
selected: 'picker__day--selected',
highlighted: 'picker__day--highlighted',
now: 'picker__day--today',
infocus: 'picker__day--infocus',
outfocus: 'picker__day--outfocus',
// The picker footer
footer: 'picker__footer',
// Today &amp; clear buttons
buttonClear: 'picker__button--clear',
buttonToday: 'picker__button--today'
}</code></pre>
<div class="section__block section__block--notification">
<p><b>*</b> It is important to not add any stylings to the pickers root element. Instead, target the <code>.picker__holder</code> element (or any other within) based on the state of the root element.</p>
</div>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Strings<a class="heading__anchor" name="strings" href="#strings">&sect;</a></span></h2>
<p>Change the month and weekday labels as you find suitable:</p>
<pre class="pre--demo"><code data-language="javascript">$('.datepicker').pickadate({
weekdaysShort: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
showMonthsShort: true
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="date_demo__weekdaysShort" class="fieldset__input " type=text placeholder="Try me&hellip;"></div></fieldset>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Buttons<a class="heading__anchor" name="buttons" href="#buttons">&sect;</a></span></h2>
<p>Change the text or hide a button completely by passing a false-y value:</p>
<pre class="pre--demo"><code data-language="javascript">$('.datepicker').pickadate({
today: '',
clear: 'Clear selection'
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="date_demo__buttons" class="fieldset__input " type=text placeholder="Try me&hellip;"></div></fieldset>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Accessibility labels<a class="heading__anchor" name="accessibility-labels" href="#accessibility-labels">&sect;</a></span></h2>
<p>Change the <code>title</code> attributes to several elements within the picker:</p>
<pre class="pre--demo"><code data-language="javascript">$('.datepicker').pickadate({
labelMonthNext: 'Go to the next month',
labelMonthPrev: 'Go to the previous month',
labelMonthSelect: 'Pick a month from the dropdown',
labelYearSelect: 'Pick a year from the dropdown',
selectMonths: true,
selectYears: true
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="date_demo__accessibility-labels" class="fieldset__input " type=text placeholder="Try me&hellip;"></div></fieldset>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Translations<a class="heading__anchor" name="translations" href="#translations">&sect;</a></span></h2>
<p>The picker can be extended to add support for internationalization. Translations for <a href="https://github.com/amsul/pickadate.js/blob/3.5.3/lib/translations">39 languages</a> are available out of the box, which you can include in one of two ways:</p>
<pre class="pre--demo"><code data-language="javascript">// Extend the default picker options for <u>all instances</u>.
$.extend($.fn.pickadate.defaults, {
monthsFull: ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'],
weekdaysShort: ['Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'],
today: 'aujourd\'hui',
clear: 'effacer',
formatSubmit: 'yyyy/mm/dd'
})
// Or, pass the months and weekdays as an array for <u>each invocation</u>.
$('.datepicker').pickadate({
monthsFull: ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'],
weekdaysShort: ['Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'],
today: 'aujourd\'hui',
clear: 'effacer',
formatSubmit: 'yyyy/mm/dd'
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="date_demo__translations" class="fieldset__input " type=text placeholder="Try me&hellip;"></div></fieldset>
<div class="section__block section__block--notification">
<p>When using translations, <a href="#formats">specify the <code>formatSubmit</code> and <code class="attribute">data-value</code></a> to ensure the date parses correctly regardless of locale.</p>
</div>
<h3 class="heading heading--divide"><span class="heading__text">RTL languages<a class="heading__anchor--bigger" name="translations_rtl" href="#translations_rtl">&sect;</a></span></h3>
<p>For languages that flow from right-to-left (RTL), youll need to switch the arrows and text direction by linking along the <code>rtl.css</code> file:</p>
<pre class="pre--demo"><code data-language="html">&lt;!-- Add the stylings *after* the pickadate theme files --&gt;
&lt;link rel="stylesheet" href="lib/themes/rtl.css"&gt;
&lt;!-- Add the language *after* the pickadate script files --&gt;
&lt;script src="lib/translations/ar.js"&gt;&lt;/script&gt;</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="date_demo__translations_rtl" class="fieldset__input " type=text placeholder="Try me&hellip;"></div></fieldset>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Formats<a class="heading__anchor" name="formats" href="#formats">&sect;</a></span></h2>
<p>Display a human-friendly format and use an alternate one to submit to the server.</p>
<p>This is done by creating a new hidden <code class="tag-name">input</code> element with the same <code class="attribute">name</code> attribute as the original with an optional prefix/suffix:</p>
<pre class="pre--demo"><code data-language="javascript">$('.datepicker').pickadate({
// Escape any <a href="#formatting-rules">“rule” characters</a> with an exclamation mark (!).
format: 'You selecte!d: dddd, dd mmm, yyyy',
formatSubmit: 'yyyy/mm/dd',
hiddenPrefix: 'prefix__',
hiddenSuffix: '__suffix'
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="date_demo__formats--a" class="fieldset__input " name=date_input type=text placeholder="Try me&hellip;"></div></fieldset>
<h3 class="heading heading--divide"><span class="heading__text">Send the hidden <code class="attribute">value</code> only<a class="heading__anchor" name="formats_use_hidden_only" href="#formats_use_hidden_only">&sect;</a></span></h3>
<p>A majority of the time, the value that needs to be sent to the server is just the hidden value and not the visible one. To make this happen, use the <code>hiddenName</code> option.</p>
<p>This essentially nullifies the <code>hiddenPrefix</code> and <code>hiddenSuffix</code>, strips the <code class="attribute">name</code> attribute from the source <code class="tag-name">input</code>, and then sets it as the <code class="attribute">name</code> of the hidden <code class="tag-name">input</code>:</p>
<pre class="pre--demo"><code data-language="javascript">$('.datepicker').pickadate({
formatSubmit: 'yyyy/mm/dd',
hiddenName: true
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="date_demo__formats--b" class="fieldset__input " name=date_input type=text placeholder="Try me&hellip;"></div></fieldset>
<h3 class="heading heading--divide"><span class="heading__text">Pre-fill values using custom formats or translations<a class="heading__anchor--bigger" name="formats_prefill" href="#formats_prefill">&sect;</a><a name="formats_translations" href="#formats_translations"></a></span></h3>
<p>When using a custom <a href="#formatting-rules">formatting rule</a> for the <code>format</code> option or when using <a href="#translations">translations</a>, the <code class="tag-name">input</code> element should be given a <code class="attribute">data-value</code> attribute formatted using the <code>formatSubmit</code> the elements <code class="attribute">value</code> can be left blank. This helps to parse the date from custom formats into various languages:</p>
<pre class="pre--demo"><code data-language="html">&lt;input data-value="2013/04/20"></code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="date_demo__formats--c" class="fieldset__input " name=date_demo__formats type=text data-value="2013/04/20" placeholder="Try me&hellip;"></div></fieldset>
<h3 class="heading heading--divide"><span class="heading__text">Formatting Rules<a class="heading__anchor--bigger" name="formatting-rules" href="#formatting-rules">&sect;</a></span></h3>
<p>To use a formatting rule, make sure to keep a delimiter between each rule. This ensures each rules value can be parsed correctly. Example:<br><b>Bad</b>: <code>yyyymmdd</code>; <b>Good</b>: <code>yyyy-mm-dd</code>.</p>
<p>The following rules can be used to format any date:</p>
<table class="table">
<thead>
<tr>
<th>Rule</th>
<th>Description</th>
<th>Result</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>d</code></td>
<td>Date of the month</td>
<td>1 &ndash; 31</td>
</tr>
<tr>
<td><code>dd</code></td>
<td>Date of the month with a leading zero</td>
<td>01 &ndash; 31</td>
</tr>
<tr>
<td><code>ddd</code></td>
<td>Day of the week in short form</td>
<td>Sun &ndash; Sat</td>
</tr>
<tr>
<td><code>dddd</code></td>
<td>Day of the week in full form</td>
<td>Sunday &ndash; Saturday</td>
</tr>
</tbody>
<tbody>
<tr>
<td><code>m</code></td>
<td>Month of the year</td>
<td>1 &ndash; 12</td>
</tr>
<tr>
<td><code>mm</code></td>
<td>Month of the year with a leading zero</td>
<td>01 &ndash; 12</td>
</tr>
<tr>
<td><code>mmm</code></td>
<td>Month name in short form</td>
<td>Jan &ndash; Dec</td>
</tr>
<tr>
<td><code>mmmm</code></td>
<td>Month name in full form</td>
<td>January &ndash; December</td>
</tr>
</tbody>
<tbody>
<tr>
<td><code>yy</code></td>
<td>Year in short form <b>*</b></td>
<td>00 &ndash; 99</td>
</tr>
<tr>
<td><code>yyyy</code></td>
<td>Year in full form</td>
<td>2000 &ndash; 2999</td>
</tr>
</tbody>
</table>
<div class="section__block section__block--notification">
<p><b>*</b> If you use the <code>yy</code> rule in the <code>format</code> option, you <b>must</b> specify the <code>yyyy</code> rule in the <a href="#formats"><code>formatSubmit</code> option</a> with the appropriate <a href="#formats_prefill"><code>data-value</code> attribute</a> to ensure the date parses accurately.</p>
<p>Never use the <code>yy</code> rule in the <code>formatSubmit</code> option.</p>
</div>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Editable input<a class="heading__anchor" name="editable" href="#editable">&sect;</a></span></h2>
<p>By default, typing into the input is disabled by giving it a <code class="attribute">readOnly</code> attribute. Doing so ensures that virtual keyboards dont pop open on touch devices. It is also a confirmation that values passed to the server will be of a consistent format.</p>
<p>However, this behavior can be changed using the <code>editable</code> option:</p>
<pre class="pre--demo"><code data-language="javascript">$('.datepicker').pickadate({
editable: true
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="date_demo__editable" class="fieldset__input " type=text placeholder="Try me&hellip;"></div></fieldset>
<div class="section__block section__block--notification">
<p>An important thing to note here is that this disables keyboard bindings on the input element, such as arrow keys opening the picker. You will have to add your own bindings as you see fit.</p>
</div>
<h3 class="heading heading--divide"><span class="heading__text">Using HTML5 attributes<a class="heading__anchor--bigger" name="html5-attributes" href="#html5-attributes">&sect;</a></span></h3>
<p>Because each <code class="tag-name">input</code> is <a href="#editable"><code class="attribute">readOnly</code> by default</a>, HTML5 attributes, such as <code class="attribute">required</code> and <code class="attribute">pattern</code>, do not get enforced.</p>
<p>To enable default browser behavior on these attributes, set the <a href="#editable"><code>editable</code> property to <code class="constant">true</code></a>.</p>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Dropdown Selectors<a class="heading__anchor" name="selectors" href="#selectors">&sect;</a></span></h2>
<p>Display <code class="tag-name">select</code> menus to pick the month and year. Anything truth-y enables the selectors and anything false-y switches them into text:</p>
<pre class="pre--demo"><code data-language="javascript">$('.datepicker').pickadate({
selectYears: true,
selectMonths: true
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="date_demo__selectors--a" class="fieldset__input " type=text placeholder="Try me&hellip;"></div></fieldset>
<div class="section__block section__block--notification">
<p>When <code>selectYears</code> is truthy, the year selector appears <i>before</i> the month. <a href="https://github.com/amsul/pickadate.js/issues/384">Read here</a> for more details on why.</p>
</div>
<p>You can also specify the number of years to show in the dropdown using an even integer - half before and half after the year in focus:</p>
<pre class="pre--demo"><code data-language="javascript">$('.datepicker').pickadate({
// `true` defaults to 10.
selectYears: 4
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="date_demo__selectors--b" class="fieldset__input " type=text placeholder="Try me&hellip;"></div></fieldset>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">First Weekday<a class="heading__anchor" name="first-weekday" href="#first-weekday">&sect;</a></span></h2>
<p>The first day of the week can be set to either Sunday or Monday. Anything truth-y sets it as Monday and anything false-y as Sunday:</p>
<pre class="pre--demo"><code data-language="javascript">$('.datepicker').pickadate({
firstDay: 1
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="date_demo__firstDay" class="fieldset__input " type=text placeholder="Try me&hellip;"></div></fieldset>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Date Limits<a class="heading__anchor" name="limits" href="#limits">&sect;</a></span></h2>
<p>Set the minimum and maximum selectable dates on the picker.</p>
<h3 class="heading heading--divide"><span class="heading__text">Using JavaScript dates<a class="heading__anchor--bigger" name="limits-use-dates" href="#limits-use-dates">&sect;</a></span></h3>
<pre class="pre--demo"><code data-language="javascript">$('.datepicker').pickadate({
min: new Date(2013,3,20),
max: new Date(2013,7,14)
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="date_demo__limits--a" class="fieldset__input " type=text placeholder="Try me&hellip;"></div></fieldset>
<h3 class="heading heading--divide"><span class="heading__text">Using arrays formatted as <code>[YEAR,MONTH,DATE]</code><a class="heading__anchor--bigger" name="limits-use-arrays" href="#limits-use-arrays">&sect;</a></span></h3>
<pre class="pre--demo"><code data-language="javascript">$('.datepicker').pickadate({
min: [2013,3,20],
max: [2013,7,14]
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="date_demo__limits--b" class="fieldset__input " type=text placeholder="Try me&hellip;"></div></fieldset>
<h3 class="heading heading--divide"><span class="heading__text">Using integers or a boolean<a class="heading__anchor--bigger" name="limits-relative" href="#limits-relative">&sect;</a></span></h3>
<pre class="pre--demo"><code data-language="javascript">$('.datepicker').pickadate({
// An integer (positive/negative) sets it relative to today.
min: -15,
// `true` sets it to today. `false` removes any limits.
max: true
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="date_demo__limits--c" class="fieldset__input " type=text placeholder="Try me&hellip;"></div></fieldset>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Disable Dates<a class="heading__anchor" name="disable-dates" href="#disable-dates">&sect;</a></span></h2>
<p>Disable a specific or arbitrary set of dates selectable on the picker.</p>
<h3 class="heading heading--divide"><span class="heading__text">Using JavaScript dates<a class="heading__anchor--bigger" name="disable-dates-use-dates" href="#disable-dates-use-dates">&sect;</a></span></h3>
<pre class="pre--demo"><code data-language="javascript">$('.datepicker').pickadate({
disable: [
new Date(2013,3,13),
new Date(2013,3,29)
]
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="date_demo__disable-dates--a" class="fieldset__input " type=text placeholder="Try me&hellip;"></div></fieldset>
<h3 class="heading heading--divide"><span class="heading__text">Using arrays formatted as <code>[YEAR,MONTH,DATE]</code><a class="heading__anchor--bigger" name="disable-dates-use-arrays" href="#disable-dates-use-arrays">&sect;</a></span></h3>
<pre class="pre--demo"><code data-language="javascript">$('.datepicker').pickadate({
disable: [
[2013,3,3],
[2013,3,12],
[2013,3,20]
]
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="date_demo__disable-dates--b" class="fieldset__input " type=text placeholder="Try me&hellip;"></div></fieldset>
<h3 class="heading heading--divide"><span class="heading__text">Using integers as days of the week (1 to 7)<a class="heading__anchor--bigger" name="disable-dates-use-integers" href="#disable-dates-use-integers">&sect;</a></span></h3>
<pre class="pre--demo"><code data-language="javascript">$('.datepicker').pickadate({
disable: [
1, 4, 7
]
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="date_demo__disable-dates--c" class="fieldset__input " type=text placeholder="Try me&hellip;"></div></fieldset>
<h3 class="heading heading--divide"><span class="heading__text">Using objects as a range of dates<a class="heading__anchor--bigger" name="disable-dates-use-ranges" href="#disable-dates-use-ranges">&sect;</a></span></h3>
<pre class="pre--demo"><code data-language="javascript">$('.datepicker').pickadate({
disable: [
{ from: [2014,2,14], to: [2014,2,27] }
]
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="date_demo__disable-dates--d" class="fieldset__input " type=text placeholder="Try me&hellip;"></div></fieldset>
<p>The values for <code>from</code> &amp; <code>to</code> can be:</p>
<ul>
<li>A JavaScript Date object,</li>
<li>An array formatted as <code>[YEAR,MONTH,DATE]</code>,</li>
<li>And <code class="constant">true</code> to set it as “today”.</li>
</ul>
<p>The values can also be integers representing dates relative to the other:</p>
<ul>
<li><code>to</code> can only be positive: <pre><code data-language="javascript">{ from: [2014,3,12], to: 10 }</code></pre></li>
<li><code>from</code> can only be negative: <pre><code data-language="javascript">{ from: -10, to: true }</code></pre></li>
</ul>
<h3 class="heading heading--divide"><span class="heading__text"><i><u>Disabling all</u></i> with a set of exceptions<a class="heading__anchor--bigger" name="disable-dates-all" href="#disable-dates-all">&sect;</a></span></h3>
<p>Enable only a specific or arbitrary set of dates by setting <code class="constant">true</code> as the first item in the collection:</p>
<pre class="pre--demo"><code data-language="javascript">$('.datepicker').pickadate({
disable: [
true,
1, 4, 7,
[2013,3,3],
[2013,3,12],
[2013,3,20],
new Date(2013,3,13),
new Date(2013,3,29)
]
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="date_demo__disable-dates--e" class="fieldset__input " type=text placeholder="Try me&hellip;"></div></fieldset>
<h3 class="heading heading--divide"><span class="heading__text">Disabling ranges with exceptions<a class="heading__anchor--bigger" name="disable-dates-inverted" href="#disable-dates-inverted">&sect;</a></span></h3>
<p>Enable dates that fall within a range of disabled dates by adding the <code class="string">inverted</code> parameter to the item within the collection:</p>
<pre class="pre--demo"><code data-language="javascript">$('.datepicker').pickadate({
disable: [
5,
[2013, 10, 21, 'inverted'],
{ from: [2014, 3, 15], to: [2014, 3, 25] },
[2014, 3, 20, 'inverted'],
{ from: [2014, 3, 17], to: [2014, 3, 18], inverted: true }
]
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="date_demo__disable-dates--f" class="fieldset__input " type=text placeholder="Try me&hellip;"></div></fieldset>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">container<a class="heading__anchor" name="container" href="#container">&sect;</a></span></h2>
<p>By default, the pickers root element is inserted right after the <code class="keyword">input</code> element. Specify where to insert the root element by passing any valid CSS selector to this option:</p>
<div id="root-outlet" style="position:relative"></div>
<pre class="pre--demo"><code data-language="javascript">$('.datepicker').pickadate({
container: '#root-outlet'
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="date_demo__container" class="fieldset__input " type=text placeholder="Try me&hellip;"></div></fieldset>
<div class="section__block section__block--notification">
<p>This is especially important when the <code class="keyword">input</code> falls within a <code class="keyword">label</code> element because click events bubble up to the <code class="keyword">label</code> element and re-open the picker.</p>
</div>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">events<a class="heading__anchor" name="events" href="#events">&sect;</a></span></h2>
<p>Fire off events as the user interacts with the picker:</p>
<pre class="pre--demo"><code data-language="javascript">$('.datepicker').pickadate({
onStart: function() {
console.log('Hello there :)')
},
onRender: function() {
console.log('Whoa.. rendered anew')
},
onOpen: function() {
console.log('Opened up')
},
onClose: function() {
console.log('Closed now')
},
onStop: function() {
console.log('See ya.')
},
onSet: function(context) {
console.log('Just set stuff:', context)
}
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="date_demo__events" class="fieldset__input " type=text placeholder="Open your console and try me&hellip;"></div></fieldset>
<p>The <code class="function">onSet</code> event is the only callback that is passed a <code>context</code> argument that provides details as to which properties are being “set”.</p>
<p>Within scope of all six of these events, <code class="keyword">this</code> refers to <a href="api.htm">the picker</a>.</p>
<p>To learn more on how to use the picker object, read the <a href="api.htm">API</a> documentation.</p>
</div> <!-- .section__block -->
</section> <!-- .section -->
<footer class="section section--footer">
<div class="section__block section__block--scoped text-center">
<h2 class="heading heading--one heading--divide-center"><span class="heading__text peace">&#x270C;</span></h2>
<p class="heading heading--three heading--thin">Made by <a href="http://twitter.com/amsul_">Amsul</a></p>
<p>Code licensed under <a href="http://amsul.ca/MIT">MIT</a></p>
<div class="text-tiny text-dimmed">
<p>Pattern from <a href="http://subtlepatterns.com/">Subtle Patterns</a>&nbsp;&nbsp;&nbsp;&nbsp;Syntax highlighting with <a href="http://craig.is/making/rainbows">Rainbow.js</a></p>
<p><a href="http://selz.co/1g80kCZ">Share some &hearts;</a></p>
</div>
</div> <!-- .section__block -->
</footer> <!-- .section -->
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script>window.jQuery||document.write('<script src="tests/jquery.2.0.0.js"><\/script>')</script>
<script src="lib/picker.js"></script>
<script src="lib/picker.date.js"></script>
<script src="lib/picker.time.js"></script>
<script src="lib/legacy.js"></script>
<script src="demo/scripts/demo.js"></script>
<script src="demo/scripts/rainbow.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-36321179-2']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>