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/api.htm

1235 lines
74 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 / api</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" 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 menu__link--active" 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 API<a class="heading__anchor" name="picker" href="#picker">&sect;</a></span></h1>
<h3 class="heading heading--thin">You can play with the picker API to extend and create custom functionality:</h3>
<pre><code data-language="javascript">var $input = $('.datepicker').pickadate()
// Use the picker object directly.
var picker = $input.pickadate('picker')
picker.<a href="#api-methods">methodName</a>(argument1, argument2, ...)
picker.<a href="#api-objects">objectName</a>
// Or pass through the elements plugin data.
$input.pickadate(<a href="#api-methods">methodName</a>, argument1, argument2, ...)
$input.pickadate(<a href="#api-objects">objectName</a>)</code></pre>
<div class="section__block section__block--notification">
<p>For most examples on this page, the date picker is used, but the same API applies to the time picker as well.</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">Methods<a class="heading__anchor" name="api-methods" href="#api-methods">&sect;</a></span></h2>
<p>There are <i>eleven</i> methods available on the picker:</p>
<ol>
<li><code class="function"><a href="#method-open-close">open</a></code></li>
<li><code class="function"><a href="#method-open-close">close</a></code></li>
<li><code class="function"><a href="#method-start-stop">start</a></code></li>
<li><code class="function"><a href="#method-start-stop">stop</a></code></li>
<li><code class="function"><a href="#method-render">render</a></code></li>
<li><code class="function"><a href="#method-clear">clear</a></code></li>
<li><code class="function"><a href="#method-get">get</a></code></li>
<li><code class="function"><a href="#method-set">set</a></code></li>
<li><code class="function"><a href="#method-on">on</a></code></li>
<li><code class="function"><a href="#method-off">off</a></code></li>
<li><code class="function"><a href="#method-trigger">trigger</a></code></li>
</ol>
<p>All these methods (except <code class="function">get</code>) return the picker object and are therefore chainable:</p>
<pre><code data-language="javascript">picker.open().clear().close()...</code></pre>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Objects<a class="heading__anchor" name="api-objects" href="#api-objects">&sect;</a></span></h2>
<p>There are <i>four</i> objects available through the picker:</p>
<ol>
<li><code><a href="#object-node">$node</a></code></li>
<li><code><a href="#object-root">$root</a></code></li>
<li><code><a href="#object-hidden">_hidden</a></code></li>
<li><code><a href="#object-component">component</a></code></li>
</ol>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h1 class="heading heading--divide-center"><span class="heading__text">The Methods<a class="heading__anchor" name="methods" href="#methods">&sect;</a></span></h1>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Open and Close<a class="heading__anchor" name="method-open-close" href="#method-open-close">&sect;</a></span></h2>
<p>Open and close the picker holder. To check if its already open, use <a href="#method-get">the <code class="function">get</code> method</a>.</p>
<pre class="pre--demo"><code data-language="javascript">picker.open()
picker.close()
// If a “click” is involved, prevent the event bubbling.
event.stopPropagation()
// If we want to maintain focus on the input,
// prevent the default action on “mousedown”.
event.preventDefault()</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-open-close class="fieldset__button button button--small">Open</button><input id="demo__api-open-close" class="fieldset__input " type=text value="" placeholder="Try me&hellip;"></div></fieldset>
</div> <!-- .section__block -->
<div class="section__block section__block--scoped">
<h3 class="heading heading--divide"><span class="heading__text">Close with focus<a class="heading__anchor--bigger" name="method-close-focus" href="#method-close-focus">&sect;</a></span></h3>
<p>Close the picker while keeping focus on the <code class="tag-name">input</code> element by passing a truth-y argument.</p>
<pre class="pre--demo"><code data-language="javascript">picker.close(true)</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-close-focus class="fieldset__button button button--small">Close with focus</button><input id="demo__api-close-focus" class="fieldset__input " type=text value="" placeholder="Try me&hellip;"></div></fieldset>
</div> <!-- .section__block -->
<div class="section__block section__block--scoped">
<h3 class="heading heading--divide"><span class="heading__text">Open without focus<a class="heading__anchor--bigger" name="method-open-focus" href="#method-open-focus">&sect;</a></span></h3>
<p>Open the picker without focusing onto the <code class="tag-name">input</code> element by passing <code class="constant">false</code> as the first argument. Opening the picker this way, theres a few things to note:</p>
<p><b>(1)</b> The only way to close it is with a separate custom binding in this example, on document click.</p>
<p><b>(2)</b> <a href="#events-callbacks">The “opening” events</a> are still triggered however, using <a href="#method-get">the <code>get</code> method</a> to see if the picker is open will return <code class="constant">false</code>.</p>
<p><b>(3)</b> If any of the picker elements is focused/clicked, it resumes normal behavior.</p>
<pre class="pre--demo"><code data-language="javascript">picker.open(false)
$(document).on('click', function() {
picker.close()
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-open-focus class="fieldset__button button button--small">Open without focus</button><input id="demo__api-open-focus" class="fieldset__input " type=text value="" 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">Start and Stop<a class="heading__anchor" name="method-start-stop" href="#method-start-stop">&sect;</a></span></h2>
<p>Destroy and rebuild the picker. To check if its already started, use <a href="#method-get">the <code class="function">get</code> method</a>.</p>
<pre class="pre--demo"><code data-language="javascript">picker.stop()
picker.start()</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-start-stop class="fieldset__button button button--small">Stop</button><input id="demo__api-start-stop" class="fieldset__input " type=date value="" placeholder="Try me&hellip;"></div></fieldset>
<div class="section__block section__block--notification">
<p>Destroying the picker also clears any <a href="#events-callbacks">events callbacks</a> bound on it.</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">Render<a class="heading__anchor" name="method-render" href="#method-render">&sect;</a></span></h2>
<p>Refresh the picker after adding something to the holder.</p>
<pre class="pre--demo"><code data-language="javascript">picker.render()</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-render class="fieldset__button button button--small">Add stuff</button><input id="demo__api-render" class="fieldset__input " type=text value="" placeholder="Try me&hellip;"></div></fieldset>
<p>By default, only the “face” of the picker (i.e. the <code>box</code> element), has its contents re-rendered. To render the entire picker from the <code>root</code> up, pass <code class="constant">true</code> as the first argument:</p>
<pre><code data-language="javascript">picker.render(true)</code></pre>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Clear<a class="heading__anchor" name="method-clear" href="#method-clear">&sect;</a></span></h2>
<p>Clear the value in the pickers <code class="tag-name">input</code> element.</p>
<pre class="pre--demo"><code data-language="javascript">picker.clear()</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-clear class="fieldset__button button button--small">Clear</button><input id="demo__api-clear" class="fieldset__input " type=text value="15 February, 2014" placeholder="Try me&hellip;"></div></fieldset>
<p>This is a shorthand that uses <a href="#method-set">the <code class="function">set</code> method</a> behind the scenes.</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">Get<a class="heading__anchor" name="method-get" href="#method-get">&sect;</a></span></h2>
<p>Get the properties, objects, and states of the picker.</p>
<pre><code data-language="javascript">picker.get(thing)</code></pre>
<p>The <code>thing</code> argument is an optional string and can be one of the following:</p>
<ul>
<li><code><a href="#method-get-value">value</a></code> (default)</li>
<li><code><a href="#method-get-select">select</a></code> <b>*</b></li>
<li><code><a href="#method-get-highlight">highlight</a></code> <b>*</b></li>
<li><code><a href="#method-get-view">view</a></code> <b>*</b></li>
<li><code><a href="#method-get-min">min</a></code> <b>*</b></li>
<li><code><a href="#method-get-max">max</a></code> <b>*</b></li>
<li><code><a href="#method-get-open">open</a></code></li>
<li><code><a href="#method-get-start">start</a></code></li>
<li><code><a href="#method-get-id">id</a></code></li>
<li><code><a href="#method-get-disable">disable</a></code></li>
<li><code><a href="#method-get-enable">enable</a></code></li>
</ul>
<h3 class="heading heading--divide"><span class="heading__text"><b>*</b> Item Objects<a class="heading__anchor--bigger" name="item-objects" href="#item-objects">&sect;</a></span></h3>
<p>The <code>thing</code>s denoted in the list above with an asterisk (<b>*</b>) return a picker item object that can be formatted by passing a second string argument using the <a href="date.htm#formats">date</a> or <a href="time.htm#formats">time</a> formatting rules:</p>
<pre><code data-language="javascript">picker.get(thing, format)</code></pre>
<p>Each “date” or “time” within the picker has an item object accompanying it behind the scenes.</p>
<p>Heres a <b>date picker item object</b> for <u>20 April, 2013</u>:</p>
<pre><code data-language="javascript">{
// The full year.
year: 2013,
// The month with zero-as-index.
month: 3,
// The date of the month.
date: 20,
// The day of the week with zero-as-index.
day: 6,
// The underlying JavaScript Date object.
obj: { 'Sat, 20 Apr 2013 04:00:00 GMT' },
// The “pick” value used for comparisons.
pick: 1366430400000
}</code></pre>
<p>Heres a <b>time picker item object</b> for <u>4:20 PM</u>:</p>
<pre><code data-language="javascript">{
// Hour of the day from 0 to 23.
hour: 16,
// The minutes of the hour from 0 to 59 (based on the interval).
mins: 20,
// The “pick” value used for comparisons.
pick: 980
}</code></pre>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Get <code class="string">value</code><a class="heading__anchor" name="method-get-value" href="#method-get-value">&sect;</a></span></h2>
<p>Returns the string value of the pickers <code>input</code> element.</p>
<pre class="pre--demo"><code data-language="javascript">picker.get() // Short for `picker.get('value')`.</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-get--value class="fieldset__button button button--small">Log the value</button><input id="demo__api-get--value" class="fieldset__input " type=text value="15 February, 2014" placeholder="Open your console and try me&hellip;"></div></fieldset>
</div> <!-- .section__block -->
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Get <code class="string">select</code><a class="heading__anchor" name="method-get-select" href="#method-get-select">&sect;</a></span></h2>
<p>Returns the <a href="#item-objects">item object</a> or formatted string of the date that is <b>visually selected</b>.</p>
<p>Defaults to <code class="null">null</code> when theres no <a href="#method-get-value"><code class="string">value</code></a>.</p>
<pre class="pre--demo"><code data-language="javascript">picker.get('select')
picker.get('select', 'yyyy/mm/dd')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-get--select class="fieldset__button button button--small">Log the select</button><button id=button__api-get--select-format class="fieldset__button button button--small">Log the select formatted</button><input id="demo__api-get--select" class="fieldset__input " type=text value="" placeholder="Open your console and try me&hellip;"></div></fieldset>
</div> <!-- .section__block -->
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Get <code class="string">highlight</code><a class="heading__anchor" name="method-get-highlight" href="#method-get-highlight">&sect;</a></span></h2>
<p>Returns the <a href="#item-objects">item object</a> or formatted string of the date that is <b>visually highlighted</b>.</p>
<p>Defaults to “today” (or “now” for the time picker) when theres no <a href="#method-get-value"><code class="string">value</code></a>.</p>
<pre class="pre--demo"><code data-language="javascript">picker.get('highlight')
picker.get('highlight', 'yyyy/mm/dd')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-get--highlight class="fieldset__button button button--small">Log the highlight</button><button id=button__api-get--highlight-format class="fieldset__button button button--small">Log the highlight formatted</button><input id="demo__api-get--highlight" class="fieldset__input " type=text value="" placeholder="Open your console and try me&hellip;"></div></fieldset>
</div> <!-- .section__block -->
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Get <code class="string">view</code><a class="heading__anchor" name="method-get-view" href="#method-get-view">&sect;</a></span></h2>
<p>Returns the <a href="#item-objects">item object</a> or formatted string of the date that determines the <b>current view</b>.</p>
<p>Defaults to the first day of the current month (or “now” for the time picker) when theres no <a href="#method-get-value"><code class="string">value</code></a>.</p>
<pre class="pre--demo"><code data-language="javascript">picker.get('view')
picker.get('view', 'yyyy/mm/dd')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-get--view class="fieldset__button button button--small">Log the view</button><button id=button__api-get--view-format class="fieldset__button button button--small">Log the view formatted</button><input id="demo__api-get--view" class="fieldset__input " type=text value="" placeholder="Open your console and try me&hellip;"></div></fieldset>
</div> <!-- .section__block -->
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Get <code class="string">min</code><a class="heading__anchor" name="method-get-min" href="#method-get-min">&sect;</a></span></h2>
<p>Returns the <a href="#item-objects">item object</a> or formatted string of the date that determines the <b>lower limit</b>.</p>
<p>Defaults to a <code class="keyword">-Infinity</code> <a href="#item-objects">item object</a> when it is not explicitly set in the <a href="date.htm#limits">options</a> or through the pickers <a href="#method-set-min">API</a>.</p>
<pre class="pre--demo"><code data-language="javascript">picker.get('min')
picker.get('min', 'yyyy/mm/dd')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-get--min class="fieldset__button button button--small">Log the min</button><button id=button__api-get--min-format class="fieldset__button button button--small">Log the min formatted</button><input id="demo__api-get--min" class="fieldset__input " type=text value="" placeholder="Open your console and try me&hellip;"></div></fieldset>
</div> <!-- .section__block -->
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Get <code class="string">max</code><a class="heading__anchor" name="method-get-max" href="#method-get-max">&sect;</a></span></h2>
<p>Returns the <a href="#item-objects">item object</a> or formatted string of the date that determines the <b>upper limit</b>.</p>
<p>Defaults to an <code class="keyword">Infinity</code> <a href="#item-objects">item object</a> when it is not explicitly set in the <a href="date.htm#limits">options</a> or through the pickers <a href="#method-set-max">API</a>.</p>
<pre class="pre--demo"><code data-language="javascript">picker.get('max')
picker.get('max', 'yyyy/mm/dd')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-get--max class="fieldset__button button button--small">Log the max</button><button id=button__api-get--max-format class="fieldset__button button button--small">Log the max formatted</button><input id="demo__api-get--max" class="fieldset__input " type=text value="" placeholder="Open your console and try me&hellip;"></div></fieldset>
</div> <!-- .section__block -->
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Get <code class="string">open</code><a class="heading__anchor" name="method-get-open" href="#method-get-open">&sect;</a></span></h2>
<p>Returns a boolean value of whether the picker is open or not.</p>
<pre class="pre--demo"><code data-language="javascript">picker.get('open')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-get--open class="fieldset__button button button--small">Log the open state</button><input id="demo__api-get--open" class="fieldset__input " type=text value="" placeholder="Open your console and try me&hellip;"></div></fieldset>
</div> <!-- .section__block -->
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Get <code class="string">start</code><a class="heading__anchor" name="method-get-start" href="#method-get-start">&sect;</a></span></h2>
<p>Returns a boolean value of whether the picker has started or not.</p>
<pre class="pre--demo"><code data-language="javascript">picker.get('start')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-get--start class="fieldset__button button button--small">Log the start state</button><button id=button__api-get--start-stop class="fieldset__button button button--small">Stop picker</button><input id="demo__api-get--start" class="fieldset__input " type=date value="" placeholder="Open your console and try me&hellip;"></div></fieldset>
</div> <!-- .section__block -->
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Get <code class="string">id</code><a class="heading__anchor" name="method-get-id" href="#method-get-id">&sect;</a></span></h2>
<p>Returns a unique string that is the ID of the picker and its element. If the element has no ID, it is set to something random.</p>
<pre class="pre--demo"><code data-language="javascript">picker.get('id')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-get--id class="fieldset__button button button--small">Log the picker ID</button><input id="demo__api-get--id" class="fieldset__input " type=text value="" placeholder="Open your console and try me&hellip;"></div></fieldset>
</div> <!-- .section__block -->
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><a name="method-get-enable"></a><span class="heading__text">Get <code class="string">disable</code> and <code class="string">enable</code><a class="heading__anchor" name="method-get-disable" href="#method-get-disable">&sect;</a></span></h2>
<p>Both these things work together to determine which <a href="#item-objects">item objects</a> to disable on the picker:</p>
<pre class="pre--demo"><code data-language="javascript">// Array passed in options to disable dates
var datesToDisable = [ 1, 4, 7, [2013,3,8], [2013,3,19], new Date(2013,3,26) ]
// Returns `1` to represent a base “enabled” state
picker.get('enable')
// Returns the collection of dates to disable
picker.get('disable')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-get--disable class="fieldset__button button button--small">Log the base state and collection</button><input id="demo__api-get--disable" class="fieldset__input " type=text value="" placeholder="Open your console and try me&hellip;"></div></fieldset>
<p>However, when <a href="date.htm#disable-dates-all">all dates are disabled and a select few are enabled</a>, it behaves differently:</p>
<pre class="pre--demo"><code data-language="javascript">// Array passed in options to disable all dates except a few
var datesToDisable = [ true, 1, 4, 7, [2013,3,8], [2013,3,19], new Date(2013,3,26) ]
// Returns `-1` to represent a base “flipped” state
picker.get('enable')
// Returns the collection of dates to *not* disable
picker.get('disable')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-get--enable class="fieldset__button button button--small">Log the base state and collection</button><input id="demo__api-get--enable" class="fieldset__input " type=text value="" placeholder="Open your console and 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">Set<a class="heading__anchor" name="method-set" href="#method-set">&sect;</a></span></h2>
<p>Set the properties, objects, and states of the picker.</p>
<pre><code data-language="javascript">// One at a time
picker.set(thing, value)
// Multiple at once
picker.set({
thing: value,
thing: value,
thing: value
})</code></pre>
<p>The <code>value</code> is based on the <code>thing</code> being set. The <code>thing</code>, is a string that can be:</p>
<ul>
<li><code><a href="#method-set-clear">clear</a></code></li>
<li><code><a href="#method-set-select">select</a></code> <b>*</b></li>
<li><code><a href="#method-set-highlight">highlight</a></code> <b>*</b></li>
<li><code><a href="#method-set-view">view</a></code></li>
<li><code><a href="#method-set-min">min</a></code> <b>*</b></li>
<li><code><a href="#method-set-max">max</a></code> <b>*</b></li>
<li><code><a href="#method-set-disable-enable">disable</a></code> <b>*</b></li>
<li><code><a href="#method-set-disable-enable">enable</a></code> <b>*</b></li>
<li><code><a href="#method-set-interval">interval</a></code> (time picker only) <b>*</b></li>
</ul>
<h3 class="heading heading--divide"><span class="heading__text"><b>*</b> cascading changes<a class="heading__anchor--bigger" name="cascading-changes" href="#cascading-changes">&sect;</a></span></h3>
<p>When the <code>thing</code>s denoted in the list above with an asterisk (<b>*</b>) are set, they cascade into updating other things using the same value.</p>
<h3 class="heading heading--divide"><span class="heading__text">muted callbacks<a class="heading__anchor--bigger" name="muted-callbacks" href="#muted-callbacks">&sect;</a></span></h3>
<p>By default, any callbacks bound with <a href="#method-on">the <code class="function">on</code> method</a> will be fired when its relevant <code>thing</code> is set. To silenty set a <code>thing</code>, pass an options object with the <code>muted</code> parameter set to <code class="constant">true</code>:</p>
<pre><code data-language="javascript">// One at a time
picker.set(thing, value, { muted: true })
// Multiple at once
picker.set({
thing: value,
thing: value,
thing: value
}, { muted: true })
</code></pre>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Set <code class="string">clear</code><a class="heading__anchor" name="method-set-clear" href="#method-set-clear">&sect;</a></span></h2>
<p>Clear the value in the pickers <code class="tag-name">input</code> element.</p>
<pre class="pre--demo"><code data-language="javascript">picker.set('clear')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set-clear class="fieldset__button button button--small">Clear</button><input id="demo__api-set-clear" class="fieldset__input " type=text value="15 February, 2014" placeholder="Try me&hellip;"></div></fieldset>
<p>This is the full form of <a href="#method-clear">the <code class="function">clear</code> method</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">Set <code class="string">select</code><a class="heading__anchor" name="method-set-select" href="#method-set-select">&sect;</a></span></h2>
<p>Setting <code class="string">select</code> has <a href="#cascading-changes">cascading changes</a> that update the <code>highlight</code>, the <code>view</code>, and the value of the <code class="tag-name">input</code> element based on the settings <code>format</code>.</p>
<h3 class="heading heading--divide"><span class="heading__text">Select a date <a href="#item-objects">item object</a><a class="heading__anchor--bigger" name="method-set-select-date" href="#method-set-select-date">&sect;</a></span></h3>
<pre class="pre--demo"><code data-language="javascript">// Using arrays formatted as [YEAR,MONTH,DATE].
picker.set('select', [2013,3,20])
// Using JavaScript Date objects.
picker.set('select', new Date(2013, 3, 30))
// Using positive integers as UNIX timestamps.
picker.set('select', 1366898887654)
// Using a string along with the parsing format (defaults to <a href="date.htm#formats">`format` option</a>).
picker.set('select', '2014-04-20', { format: 'yyyy-mm-dd' })</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--select-date-array class="fieldset__button button button--small">Select using an array</button><button id=button__api-set--select-date-js class="fieldset__button button button--small">Select using a JS Date</button><button id=button__api-set--select-date-integer class="fieldset__button button button--small">Select using an integer</button><button id=button__api-set--select-date-string class="fieldset__button button button--small">Select using a string and format</button><input id="demo__api-set--select-date" class="fieldset__input " type=text value="" placeholder="Try me&hellip;"></div></fieldset>
<h3 class="heading heading--divide"><span class="heading__text">Select a time <a href="#item-objects">item object</a><a class="heading__anchor--bigger" name="method-set-select-time" href="#method-set-select-time">&sect;</a></span></h3>
<pre class="pre--demo"><code data-language="javascript">// Using arrays formatted as [HOUR,MINUTE].
picker.set('select', [3,0])
// Using JavaScript Date objects.
picker.set('select', new Date(2013, 3, 20, 10, 30))
// Using positive integers as minutes.
picker.set('select', 540)
// Using a string along with the parsing format (defaults to <a href="time.htm#formats">`format` option</a>).
picker.set('select', '04-30', { format: 'hh-i' })</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--select-time-array class="fieldset__button button button--small">Select using an array</button><button id=button__api-set--select-time-js class="fieldset__button button button--small">Select using a JS Date</button><button id=button__api-set--select-time-integer class="fieldset__button button button--small">Select using an integer</button><button id=button__api-set--select-time-string class="fieldset__button button button--small">Select using a string and format</button><input id="demo__api-set--select-time" class="fieldset__input " type=text value="" 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">Set <code class="string">highlight</code><a class="heading__anchor" name="method-set-highlight" href="#method-set-highlight">&sect;</a></span></h2>
<p>Setting <code class="string">highlight</code> has a <a href="#cascading-changes">cascading change</a> that updates the <a href="#item-objects">item object</a> that sets the <code>view</code> of the picker.</p>
<h3 class="heading heading--divide"><span class="heading__text">Highlight a date <a href="#item-objects">item object</a><a class="heading__anchor--bigger" name="method-set-highlight-date" href="#method-set-highlight-date">&sect;</a></span></h3>
<pre class="pre--demo"><code data-language="javascript">// Using arrays formatted as [YEAR,MONTH,DATE].
picker.set('highlight', [2013,3,20])
// Using JavaScript Date objects.
picker.set('highlight', new Date(2013, 3, 30))
// Using positive integers as UNIX timestamps.
picker.set('highlight', 1366898887654)
// Using a string along with the parsing format (defaults to <a href="date.htm#formats">`format` option</a>).
picker.set('highlight', '2014-04-20', { format: 'yyyy-mm-dd' })</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--highlight-date-array class="fieldset__button button button--small">Highlight using an array</button><button id=button__api-set--highlight-date-js class="fieldset__button button button--small">Highlight using a JS Date</button><button id=button__api-set--highlight-date-integer class="fieldset__button button button--small">Highlight using an integer</button><button id=button__api-set--highlight-date-string class="fieldset__button button button--small">Highlight using a string and format</button><input id="demo__api-set--highlight-date" class="fieldset__input " type=text value="" placeholder="Try me&hellip;"></div></fieldset>
<h3 class="heading heading--divide"><span class="heading__text">Highlight a time <a href="#item-objects">item object</a><a class="heading__anchor--bigger" name="method-set-highlight-time" href="#method-set-highlight-time">&sect;</a></span></h3>
<pre class="pre--demo"><code data-language="javascript">// Using arrays formatted as [HOUR,MINUTE].
picker.set('highlight', [15,30])
// Using JavaScript Date objects.
picker.set('highlight', new Date(2013, 3, 20, 10, 30))
// Using positive integers as minutes.
picker.set('highlight', 1080)
// Using a string along with the parsing format (defaults to <a href="time.htm#formats">`format` option</a>).
picker.set('highlight', '04-30', { format: 'hh-i' })</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--highlight-time-array class="fieldset__button button button--small">Highlight using an array</button><button id=button__api-set--highlight-time-js class="fieldset__button button button--small">Highlight using a JS Date</button><button id=button__api-set--highlight-time-integer class="fieldset__button button button--small">Highlight using an integer</button><button id=button__api-set--highlight-time-string class="fieldset__button button button--small">Highlight using a string and format</button><input id="demo__api-set--highlight-time" class="fieldset__input " type=text value="" 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">Set <code class="string">view</code><a class="heading__anchor" name="method-set-view" href="#method-set-view">&sect;</a></span></h2>
<p>Setting <code class="string">view</code> has no <a href="#cascading-changes">cascading changes</a> and the <code class="string">highlight</code> remains unaffected.</p>
<h3 class="heading heading--divide"><span class="heading__text">Viewset a date <a href="#item-objects">item object</a><a class="heading__anchor--bigger" name="method-set-view-date" href="#method-set-view-date">&sect;</a></span></h3>
<p>The <code>value</code> passed gets normalized to the first date of the month to bring into view.</p>
<pre class="pre--demo"><code data-language="javascript">// Using arrays formatted as [YEAR,MONTH,DATE].
picker.set('view', [2000,3,20])
// Using JavaScript Date objects.
picker.set('view', new Date(1988,7,14))
// Using positive integers as UNIX timestamps.
picker.set('view', 1587355200000)
// Using a string along with the parsing format (defaults to <a href="date.htm#formats">`format` option</a>).
picker.set('view', '2014-04-20', { format: 'yyyy-mm-dd' })</code></code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--view-date-array class="fieldset__button button button--small">Viewset using an array</button><button id=button__api-set--view-date-js class="fieldset__button button button--small">Viewset using a JS Date</button><button id=button__api-set--view-date-integer class="fieldset__button button button--small">Viewset using an integer</button><button id=button__api-set--view-date-string class="fieldset__button button button--small">Viewset using a string and format</button><input id="demo__api-set--view-date" class="fieldset__input " type=text value="" placeholder="Try me&hellip;"></div></fieldset>
<h3 class="heading heading--divide"><span class="heading__text">Viewset a time <a href="#item-objects">item object</a><a class="heading__anchor--bigger" name="method-set-view-time" href="#method-set-view-time">&sect;</a></span></h3>
<pre class="pre--demo"><code data-language="javascript">// Using arrays formatted as [HOUR,MINUTE].
picker.set('view', [15,30])
// Using JavaScript Date objects.
picker.set('view', new Date(2013, 3, 20, 10, 30))
// Using positive integers as minutes.
picker.set('view', 1080)
// Using a string along with the parsing format (defaults to <a href="time.htm#formats">`format` option</a>).
picker.set('view', '04-30', { format: 'hh-i' })</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--view-time-array class="fieldset__button button button--small">Viewset using an array</button><button id=button__api-set--view-time-js class="fieldset__button button button--small">Viewset using a JS Date</button><button id=button__api-set--view-time-integer class="fieldset__button button button--small">Viewset using an integer</button><button id=button__api-set--view-time-string class="fieldset__button button button--small">Viewset using a string and format</button><input id="demo__api-set--view-time" class="fieldset__input " type=text value="" 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">Set <code class="string">min</code><a class="heading__anchor" name="method-set-min" href="#method-set-min">&sect;</a></span></h2>
<p>Setting <code class="string">min</code> has <a href="#cascading-changes">cascading changes</a> on the <code class="string">select</code>, <code class="string">highlight</code>, and <code class="string">view</code> only when the particular <a href="#item-objects">item object</a> goes out of range.</p>
<h3 class="heading heading--divide"><span class="heading__text">Limit the min date <a class="heading__anchor--bigger" name="method-set-min-date" href="#method-set-min-date">&sect;</a></span></h3>
<pre class="pre--demo"><code data-language="javascript">// Using arrays formatted as [YEAR,MONTH,DATE].
picker.set('min', [2013,3,20])
// Using JavaScript Date objects.
picker.set('min', new Date(2013,7,14))
// Using formatted strings.
picker.set('min', '8 January, 2014'))
// Using integers as days relative to today.
picker.set('min', -4)
// Using `true` for “today”.
picker.set('min', true)
// Using `false` to remove.
picker.set('min', false)</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--min-date-array class="fieldset__button button button--small">Limit using an array</button><button id=button__api-set--min-date-js class="fieldset__button button button--small">Limit using a JS Date</button><button id=button__api-set--min-date-string class="fieldset__button button button--small">Limit using a string</button><button id=button__api-set--min-date-integer class="fieldset__button button button--small">Limit using an integer</button><button id=button__api-set--min-date-true class="fieldset__button button button--small">Limit using `true`</button><button id=button__api-set--min-date-false class="fieldset__button button button--small">Limit using `false`</button><input id="demo__api-set--min-date" class="fieldset__input " type=text value="" placeholder="Try me&hellip;"></div></fieldset>
<h3 class="heading heading--divide"><span class="heading__text">Limit the min time <a class="heading__anchor--bigger" name="method-set-min-time" href="#method-set-min-time">&sect;</a></span></h3>
<pre class="pre--demo"><code data-language="javascript">// Using arrays formatted as [HOUR,MINUTE].
picker.set('min', [15,30])
// Using JavaScript Date objects.
picker.set('min', new Date(2013, 3, 20, 10, 30))
// Using formatted strings.
picker.set('min', '4:30 PM'))
// Using integers as intervals relative from now.
picker.set('min', -4)
// Using `true` for “now”.
picker.set('min', true)
// Using `false` to remove.
picker.set('min', false)</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--min-time-array class="fieldset__button button button--small">Limit using an array</button><button id=button__api-set--min-time-js class="fieldset__button button button--small">Limit using a JS Date</button><button id=button__api-set--min-time-string class="fieldset__button button button--small">Limit using a string</button><button id=button__api-set--min-time-integer class="fieldset__button button button--small">Limit using an integer</button><button id=button__api-set--min-time-true class="fieldset__button button button--small">Limit using `true`</button><button id=button__api-set--min-time-false class="fieldset__button button button--small">Limit using `false`</button><input id="demo__api-set--min-time" class="fieldset__input " type=text value="" 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">Set <code class="string">max</code><a class="heading__anchor" name="method-set-max" href="#method-set-max">&sect;</a></span></h2>
<p>Setting <code class="string">max</code> has <a href="#cascading-changes">cascading changes</a> on the <code class="string">select</code>, <code class="string">highlight</code>, and <code class="string">view</code> only when the particular <a href="#item-objects">item object</a> goes out of range.</p>
<h3 class="heading heading--divide"><span class="heading__text">Limit the max date <a class="heading__anchor--bigger" name="method-set-max-date" href="#method-set-max-date">&sect;</a></span></h3>
<pre class="pre--demo"><code data-language="javascript">// Using arrays formatted as [YEAR,MONTH,DATE].
picker.set('max', [2013,3,20])
// Using JavaScript Date objects.
picker.set('max', new Date(2013,7,14))
// Using formatted strings.
picker.set('max', '20 April, 2016'))
// Using integers as days relative to today.
picker.set('max', 4)
// Using `true` for “today”.
picker.set('max', true)
// Using `false` to remove.
picker.set('max', false)</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--max-date-array class="fieldset__button button button--small">Limit using an array</button><button id=button__api-set--max-date-js class="fieldset__button button button--small">Limit using a JS Date</button><button id=button__api-set--max-date-string class="fieldset__button button button--small">Limit using a string</button><button id=button__api-set--max-date-integer class="fieldset__button button button--small">Limit using an integer</button><button id=button__api-set--max-date-true class="fieldset__button button button--small">Limit using `true`</button><button id=button__api-set--max-date-false class="fieldset__button button button--small">Limit using `false`</button><input id="demo__api-set--max-date" class="fieldset__input " type=text value="" placeholder="Try me&hellip;"></div></fieldset>
<h3 class="heading heading--divide"><span class="heading__text">Limit the max time <a class="heading__anchor--bigger" name="method-set-max-time" href="#method-set-max-time">&sect;</a></span></h3>
<pre class="pre--demo"><code data-language="javascript">// Using arrays formatted as [HOUR,MINUTE].
picker.set('max', [15,30])
// Using JavaScript Date objects.
picker.set('max', new Date(2013, 3, 20, 10, 30))
// Using formatted strings.
picker.set('max', '11:30 AM'))
// Using integers as intervals relative from now.
picker.set('max', 4)
// Using `true` for “now”.
picker.set('max', true)
// Using `false` to remove.
picker.set('max', false)</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--max-time-array class="fieldset__button button button--small">Limit using an array</button><button id=button__api-set--max-time-js class="fieldset__button button button--small">Limit using a JS Date</button><button id=button__api-set--max-time-string class="fieldset__button button button--small">Limit using a string</button><button id=button__api-set--max-time-integer class="fieldset__button button button--small">Limit using an integer</button><button id=button__api-set--max-time-true class="fieldset__button button button--small">Limit using `true`</button><button id=button__api-set--max-time-false class="fieldset__button button button--small">Limit using `false`</button><input id="demo__api-set--max-time" class="fieldset__input " type=text value="" 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"><a name="method-set-enable"></a><span class="heading__text">Set <code class="string">disable</code> and <code class="string">enable</code><a class="heading__anchor" name="method-set-disable-enable" href="#method-set-disable-enable">&sect;</a></span></h2>
<p>Setting <code class="string">disable</code> or <code class="string">enable</code> has <a href="#cascading-changes">cascading changes</a> on the <code class="string">select</code>, <code class="string">highlight</code>, and <code class="string">view</code> only when the currently selected <a href="#item-objects">item object</a> becomes disabled.</p>
<div class="section__block section__block--notification">
<p>An important thing to note here is that “setting” something as enabled or disabled adds the new elements to the collection of items to disable rather than completely replacing them with the new collection.</p>
</div>
<h3 class="heading heading--divide"><span class="heading__text">Disable/enable dates <a class="heading__anchor--bigger" name="method-set-disable-enable-dates" href="#method-set-disable-enable-dates">&sect;</a></span></h3>
<p>You can disable sets of dates and then enable the entire set or specific dates within those sets by the following methods:</p>
<ul>
<li>
<p>Specific dates:</p>
<pre class="pre--demo"><code data-language="javascript">picker.set('disable', [
// Using a collection of arrays formatted as [YEAR,MONTH,DATE]
[2014,9,3], [2014,9,9], [2014,9,20],
// Using JavaScript Date objects
new Date(2013,9,13), new Date(2013,9,24)
])
picker.set('enable', [
[2014,9,9],
[2014,9,13],
new Date(2013,9,20)
])</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--disable-date-specific class="fieldset__button button button--small">Disable specific dates</button><button id=button__api-set--enable-date-specific class="fieldset__button button button--small">Enable specific dates</button><input id="demo__api-set--disable-enable-date-specific" class="fieldset__input " type=text value="" placeholder="Try me&hellip;"></div></fieldset>
</li>
<li>
<p>Ranges of dates:</p>
<pre class="pre--demo"><code data-language="javascript">picker.set('disable', [
// Using integers as the days of the week (1 to 7)
1, 4, 7,
// Using a range object with a “from” and “to” property
{ from: [2014,2,14], to: [2014,2,27] }
])
picker.set('enable', [
4,
{ from: [2014,2,24], to: [2014,2,27] }
])</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--disable-date-ranges class="fieldset__button button button--small">Disable dates ranges</button><button id=button__api-set--enable-date-ranges class="fieldset__button button button--small">Enable dates ranges</button><input id="demo__api-set--disable-enable-date-ranges" class="fieldset__input " type=text value="" placeholder="Try me&hellip;"></div></fieldset>
</li>
<li>
<p>“Flip” the enabled and disabled dates:</p>
<pre class="pre--demo"><code data-language="javascript">picker.set('disable', 'flip')
picker.set('enable', 'flip')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--disable-date-flip class="fieldset__button button button--small">Flip the enabled &amp; disabled dates</button><input id="demo__api-set--disable-enable-date-flip" class="fieldset__input " type=text value="" placeholder="Try me&hellip;"></div></fieldset>
</li>
<li>
<p>All the dates:</p>
<pre class="pre--demo"><code data-language="javascript">// Disable all the dates
picker.set('disable', true)
picker.set('enable', false)
// Enable all the dates
picker.set('enable', true)
picker.set('disable', false)</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--disable-date-all class="fieldset__button button button--small">Disable all dates</button><button id=button__api-set--enable-date-all class="fieldset__button button button--small">Enable all dates</button><input id="demo__api-set--disable-enable-date-all" class="fieldset__input " type=text value="" placeholder="Try me&hellip;"></div></fieldset>
</li>
</ul>
<h3 class="heading heading--divide"><span class="heading__text">Disable/enable times <a class="heading__anchor--bigger" name="method-set-disable-enable-times" href="#method-set-disable-enable-times">&sect;</a></span></h3>
<p>You can disable sets of times and then enable the entire set or specific times within those sets by the following methods:</p>
<ul>
<li>
<p>Specific times:</p>
<pre class="pre--demo"><code data-language="javascript">picker.set('disable', [
// Using a collection of arrays formatted as [HOUR,MINUTES]
[2,30], [4,30], [9,0],
// Using JavaScript Date objects
new Date(2013,9,13,6), new Date(2013,9,13,12,30)
])
picker.set('enable', [
[4,30], [6,0],
new Date(2013,9,13,9)
])</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--disable-time-specific class="fieldset__button button button--small">Disable specific times</button><button id=button__api-set--enable-time-specific class="fieldset__button button button--small">Enable specific times</button><input id="demo__api-set--disable-enable-time-specific" class="fieldset__input " type=text value="" placeholder="Try me&hellip;"></div></fieldset>
</li>
<li>
<p>Ranges of times:</p>
<pre class="pre--demo"><code data-language="javascript">picker.set('disable', [
// Using integers as hours of the day (from 0 to 23)
1, 4, 7,
// Using a range object with a “from” and “to” property
{ from: [10,30], to: [18,0] }
})
picker.set('enable', [
4,
{ from: [14,0], to: [16,30] }
])</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--disable-time-ranges class="fieldset__button button button--small">Disable times ranges</button><button id=button__api-set--enable-time-ranges class="fieldset__button button button--small">Enable times ranges</button><input id="demo__api-set--disable-enable-time-ranges" class="fieldset__input " type=text value="" placeholder="Try me&hellip;"></div></fieldset>
</li>
<li>
<p>“Flip” the enabled and disabled times:</p>
<pre class="pre--demo"><code data-language="javascript">picker.set('disable', 'flip')
picker.set('enable', 'flip')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--disable-time-flip class="fieldset__button button button--small">Flip the enabled &amp; disabled times</button><input id="demo__api-set--disable-enable-time-flip" class="fieldset__input " type=text value="" placeholder="Try me&hellip;"></div></fieldset>
</li>
<li>
<p>All the times:</p>
<pre class="pre--demo"><code data-language="javascript">// Disable all the times
picker.set('disable', true)
picker.set('enable', true)
// Enable all the dates
picker.set('enable', true)
picker.set('disable', false)</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--disable-time-all class="fieldset__button button button--small">Disable all times</button><button id=button__api-set--enable-time-all class="fieldset__button button button--small">Enable all times</button><input id="demo__api-set--disable-enable-time-all" class="fieldset__input " type=text value="" placeholder="Try me&hellip;"></div></fieldset>
</li>
</ul>
<h3 class="heading heading--divide"><span class="heading__text">Enable an element within a disabled range <a class="heading__anchor--bigger" name="method-set-enable-disable-in-range" href="#method-set-enable-disable-in-range">&sect;</a></span></h3>
<p>When a date or time you want to enable falls within a disabled range, add the <code class="string">inverted</code> property to the item:</p>
<pre class="pre--demo"><code data-language="javascript">picker.set('disable', [
// Disable all Mondays, except November 17<sup>th</sup>, 2013.
1, [2013, 10, 17, 'inverted'],
// Disable all dates from March 2<sup>nd</sup>, 2014 to March 28<sup>th</sup>, 2014
// except for March 10<sup>th</sup> and all between March 14<sup>th</sup> and March 23<sup>rd</sup>.
{ from: [2014, 2, 2], to: [2014, 2, 28] },
[2014, 2, 10, 'inverted'],
{ from: [2014, 2, 14], to: [2014, 2, 23], inverted: true }
])</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="demo__api-set--enable-disable-in-range-date" class="fieldset__input " type=text value="" placeholder="Try me&hellip;"></div></fieldset>
<pre class="pre--demo"><code data-language="javascript">picker.set('disable', [
// Disable all times from 1:00 AM to 1:59 AM, except 1:30 AM.
1, [1, 30, 'inverted'],
// Disable all times from 3:00 AM to 6:00 PM except
// for 4:30 AM and all between 7:30 AM and 11:30 AM.
{ from: [3,0], to: [18,0] },
[4, 30, 'inverted'],
{ from: [7,30], to: [11,30], inverted: true }
])</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="demo__api-set--enable-disable-in-range-time" class="fieldset__input " type=text value="" 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">Set <code class="string">interval</code><a class="heading__anchor" name="method-set-interval" href="#method-set-interval">&sect;</a></span></h2>
<p>For the time picker only, you can change the interval between each time display.</p>
<p>Setting <code class="string">interval</code> has <a href="#cascading-changes">cascading changes</a> on the <code class="string">select</code>, <code class="string">highlight</code>, and <code class="string">view</code> only when the particular <a href="#item-objects">item object</a> goes out of range.</p>
<pre class="pre--demo"><code data-language="javascript">// Using integers representing the interval length in minutes
picker.set('interval', 15)
picker.set('interval', 20)
picker.set('interval', 120)</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--interval-fifteen class="fieldset__button button button--small">Set it to 15</button><button id=button__api-set--interval-twenty class="fieldset__button button button--small">Set it to 20</button><button id=button__api-set--interval-onetwenty class="fieldset__button button button--small">Set it to 120</button><input id="demo__api-set--interval" class="fieldset__input " type=text value="" placeholder="Try me&hellip;"></div></fieldset>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h1 class="heading heading--divide-center"><span class="heading__text">The Events and Callbacks<a class="heading__anchor" name="events-callbacks" href="#events-callbacks">&sect;</a></span></h1>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Event <code class="function">on</code><a class="heading__anchor" name="method-on" href="#method-on">&sect;</a></span></h2>
<p>Bind callbacks to get fired off when the relative <a href="#api-methods">picker method</a> is called (unless if <a href="#muted-callbacks">the callback is “muted”</a>):</p>
<pre><code data-language="javascript">// One at a time
picker.on(methodName, function() { &hellip; })
// Multiple at once
picker.on({
methodName: function() { &hellip; },
methodName: function() { &hellip; },
methodName: function() { &hellip; }
})</code></pre>
<p>The <code>methodName</code> can be <code class="string">open</code>, <code class="string">close</code>, <code class="string">render</code>, <code class="string">start</code>, <code class="string">stop</code>, or <code class="string">set</code>.</p>
<p>Within scope of these callbacks, <code class="keyword">this</code> refers to <a href="#picker">the picker object</a> and for most events, no arguments are passed.</p>
<p>The only exception is the <code class="function">set</code> method, which is passed an argument that provides more context as to what is being “set”.</p>
</div> <!-- .section__block -->
<div class="section__block section__block--scoped">
<h3 class="heading heading--divide"><span class="heading__text">Event callbacks as bindings<a class="heading__anchor--bigger" name="method-on-callback-bindings" href="#method-on-callback-bindings">&sect;</a></span></h3>
<p><i>After</i> the picker has been initiated, callbacks to events can be set using the <code class="function">on</code> method:</p>
<pre class="pre--demo"><code data-language="javascript">picker.on({
open: function() {
console.log('Opened up!')
},
close: function() {
console.log('Closed now')
},
render: function() {
console.log('Just rendered anew')
},
stop: function() {
console.log('See ya')
},
set: function(thingSet) {
console.log('Set stuff:', thingSet)
}
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-callback-bindings class="fieldset__button button button--small">Stop</button><input id="demo__api-callback-bindings" class="fieldset__input " type=date value="" placeholder="Open your console and try me&hellip;"></div></fieldset>
<div class="section__block section__block--notification">
<p>Since these callbacks can only be bound <i>after</i> the picker has started, the <code class="string">'start'</code> event cannot be given a callback this way. To do that, it must be <a href="#method-on-callback-options">passed as an option</a>.</p>
</div>
</div> <!-- .section__block -->
<div class="section__block section__block--scoped">
<h3 class="heading heading--divide"><span class="heading__text">Event callbacks as options<a class="heading__anchor--bigger" name="method-on-callback-options" href="#method-on-callback-options">&sect;</a></span></h3>
<p><i>Before</i> the picker has initiated, callbacks to events can be set by passing them as options when invoking the picker:</p>
<pre class="pre--demo"><code data-language="javascript">$('.datepicker').pickadate({
onOpen: function() {
console.log('Opened up!')
},
onClose: function() {
console.log('Closed now')
},
onRender: function() {
console.log('Just rendered anew')
},
onStart: function() {
console.log('Hello there :)')
},
onStop: function() {
console.log('See ya')
},
onSet: function(thingSet) {
console.log('Set stuff:', thingSet)
}
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-callback-options class="fieldset__button button button--small">Stop</button><input id="demo__api-callback-options" class="fieldset__input " type=date value="" placeholder="Open your console and 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">Event <code class="function">off</code><a class="heading__anchor" name="method-off" href="#method-off">&sect;</a></span></h2>
<p>Unbind callbacks that are bound using <a href="#method-on">the <code class="function">on</code> method</a>:</p>
<pre><code data-language="javascript">picker.off(methodName, methodName, methodName, ...)</code></pre>
<p>The <code>methodName</code> can be <code class="string">open</code>, <code class="string">close</code>, <code class="string">render</code>, <code class="string">start</code>, <code class="string">stop</code>, or <code class="string">set</code>.</p>
<pre class="pre--demo"><code data-language="javascript">picker.on('open', function() {
console.log('Even when Im opened, Im not logged..')
})
picker.off('open')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="demo__api-method-off" class="fieldset__input " type=text value="" placeholder="Open your console and 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">Event <code class="function">trigger</code><a class="heading__anchor" name="method-trigger" href="#method-trigger">&sect;</a></span></h2>
<p>Trigger an <a href="#events-callbacks">events callbacks</a> that have been queued up:</p>
<pre class="pre--demo"><code data-language="javascript">picker.on('open', function() {
console.log('This logs without opening!')
})
picker.trigger('open')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-method-trigger--a class="fieldset__button button button--small">Trigger open callback</button><input id="demo__api-method-trigger--a" class="fieldset__input " type=text value="" placeholder="Open your console and try me&hellip;"></div></fieldset>
<div class="section__block section__block--notification">
<p>Note: this doesnt actually invoke the method; it only triggers the callback. Similar to jQuerys <code class="method">triggerHandler</code> method.</p>
</div>
<p>Optionally, you can also pass some data to the method being triggered:</p>
<pre class="pre--demo"><code data-language="javascript">picker.on('open', function(data) {
console.log('This logs without opening with this data:', data)
})
picker.trigger('open', { some: 'value' })</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-method-trigger--b class="fieldset__button button button--small">Trigger open callback with data</button><input id="demo__api-method-trigger--b" class="fieldset__input " type=text value="" placeholder="Open your console and try me&hellip;"></div></fieldset>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h1 class="heading heading--divide-center"><span class="heading__text">The Objects<a class="heading__anchor" name="objects" href="#objects">&sect;</a></span></h1>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Object <code>$node</code><a class="heading__anchor" name="object-node" href="#object-node">&sect;</a></span></h2>
<p>This is the pickers relative <code class="tag-name">input</code> element wrapped as a jQuery object.</p>
<pre class="pre--demo"><code data-language="javascript">picker.$node</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-object--node class="fieldset__button button button--small">Get the node</button><input id="demo__api-object--node" class="fieldset__input " type=text value="" placeholder="Open your console and 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">Object <code>$root</code><a class="heading__anchor" name="object-root" href="#object-root">&sect;</a></span></h2>
<p>This is the pickers relative root holder element wrapped as a jQuery object.</p>
<pre class="pre--demo"><code data-language="javascript">picker.$root</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-object--holder class="fieldset__button button button--small">Get the root</button><input id="demo__api-object--holder" class="fieldset__input " type=text value="" placeholder="Open your console and 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">Object <code>_hidden</code><a class="heading__anchor" name="object-hidden" href="#object-hidden">&sect;</a></span></h2>
<p>This is the pickers relative hidden element, which is <code class="null">undefined</code> if theres no <code>formatSubmit</code> option.</p>
<p>There should be no reason to use this its mostly for internal use. If you have a valid reason for using this, please mention it in the <a href="https://github.com/amsul/pickadate.js/issues">Issues</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">Object <code>component</code><a class="heading__anchor" name="object-component" href="#object-component">&sect;</a></span></h2>
<p>This is the pickers relative component constructor that builds the date or time picker. This API is in flux so avoid using it for now.</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>