forked from amsul/pickadate.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtime.htm
459 lines (324 loc) · 18.1 KB
/
time.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
<!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 / time</title>
<link rel="shortcut icon" href="demo/images/favicon.ico">
<link rel="stylesheet" href="demo/styles/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 menu__link--active" 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/index.htm">v2.1.8</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" for="show_theme_default">default</label> and <input class="theme-toggle__input" type="radio" id="show_theme_classic" name="show_theme" value="classic" hidden><label class="theme-toggle__label" 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 Time Picker<a class="heading__anchor" name="picker" href="#picker">§</a></span></h1>
<h3 class="heading heading--thin">The basic setup requires targetting an <code class="tag-name">input</code> element and invoking the picker:</h3>
<pre class="pre--demo"><code data-language="javascript">$('.timepicker').pickatime()</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="" class="fieldset__input js__timepicker" type=text placeholder="Try me…"></div></fieldset>
</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">§</a></span></h2>
<p>With the basic invocation above, these are the default settings:</p>
<pre><code data-language="javascript">// <a href="#translations">Translations</a> and <a href="#buttons">clear button</a>
clear: 'Clear',
// <a href="#formats">Formats</a>
format: 'h:i A',
formatLabel: undefined,
formatSubmit: undefined,
hiddenSuffix: '_submit',
// <a href="#intervals">Time intervals</a>
interval: 30,
// <a href="#limits">Time limits</a>
min: undefined,
max: undefined,
// <a href="#disable-times">Disable times</a>
disable: 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 picker--time',
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',
// List of times
list: 'picker__list',
listItem: 'picker__list-item',
// Time states
disabled: 'picker__list-item--disabled',
selected: 'picker__list-item--selected',
highlighted: 'picker__list-item--highlighted',
viewset: 'picker__list-item--viewset',
now: 'picker__list-item--now',
// Clear button
buttonClear: 'picker__button--clear',
}</code></pre>
<div class="section__block section__block--notification">
<p><b>*</b> It is important to not add any stylings to the picker’s 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">Translations<a class="heading__anchor" name="translations" href="#translations">§</a></span></h2>
<p>Coming soon...</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">Clear Button<a class="heading__anchor" name="buttons" href="#buttons">§</a></span></h2>
<p>Change the text or hide the button completely by passing a false-y value:</p>
<pre class="pre--demo"><code data-language="javascript">$('.timepicker').pickatime({
clear: ''
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="time_demo__buttons" class="fieldset__input " type=text placeholder="Try me…"></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">§</a></span></h2>
<p>Display a human-friendly label and input format and use an alternate one to submit.</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 and a suffix:</p>
<pre class="pre--demo"><code data-language="javascript">$('.timepicker').pickatime({
// Escape any “<a href="#formatting-rules">rule</a>” characters with an exclamation mark (!).
format: 'T!ime selected: h:i a',
formatLabel: '<b>h</b>:i <!i>a</!i>',
formatSubmit: 'HH:i',
hiddenSuffix: '--submit'
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="time_demo__formats--a" class="fieldset__input " name=time_demo__formats type=text placeholder="Try me…"></div></fieldset>
<p><code>formatLabel</code> is unique. It can contain HTML and it can also be a function if you want to create the label during run-time:</p>
<style>
.picker__list small {
color: #999;
float: right;
line-height: 1.5;
}
.picker__list .picker__list-item--highlighted small {
color: #fff;
}
</style>
<pre class="pre--demo"><code data-language="javascript">$('.timepicker').pickatime({
formatLabel: function(time) {
var hours = ( time.pick - this.get('now').pick ) / 60,
label = hours < 0 ? ' !hours to now' : hours > 0 ? ' !hours from now' : 'now'
return 'h:i a <sm!all>' + ( hours ? Math.abs(hours) : '' ) + label + '</sm!all>'
}
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="time_demo__formats--b" class="fieldset__input " name=time_demo__formats type=text placeholder="Try me…"></div></fieldset>
</div> <!-- .section__block -->
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Formatting Rules<a class="heading__anchor" name="formatting-rules" href="#formatting-rules">§</a></span></h2>
<p>The following rules can be used to format any time:</p>
<table class="table">
<thead>
<tr>
<th>Rule</th>
<th>Description</th>
<th>Result</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>h</code></td>
<td>Hour in 12-hour format</td>
<td>1 – 12</td>
</tr>
<tr>
<td><code>hh</code></td>
<td>Hour in 12-hour format with a leading zero</td>
<td>01 – 12</td>
</tr>
<tr>
<td><code>H</code></td>
<td>Hour in 24-hour format</td>
<td>0 – 23</td>
</tr>
<tr>
<td><code>HH</code></td>
<td>Hour in 24-hour format with a leading zero</td>
<td>00 – 23</td>
</tr>
</tbody>
<tbody>
<tr>
<td><code>i</code></td>
<td>Minutes</td>
<td>00 – 59</td>
</tr>
</tbody>
<tbody>
<tr>
<td><code>a</code></td>
<td>Day time period</td>
<td>a.m. / p.m.</td>
</tr>
<tr>
<td><code>A</code></td>
<td>Day time period in uppercase</td>
<td>AM / PM</td>
</tr>
</tbody>
</table>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Intervals<a class="heading__anchor" name="intervals" href="#intervals">§</a></span></h2>
<p>Choose the minutes interval between each time in the list:</p>
<pre class="pre--demo"><code data-language="javascript">$('.datepicker').pickadate({
interval: 150
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="time_demo__interval" class="fieldset__input " type=text placeholder="Try me…"></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">Time Limits<a class="heading__anchor" name="limits" href="#limits">§</a></span></h2>
<p>Set the minimum and maximum selectable times on the picker.</p>
<p><b>1)</b> Using arrays formatted as <code>[HOUR,MINUTE]</code>:</p>
<pre class="pre--demo"><code data-language="javascript">$('.timepicker').pickatime({
min: [7,30],
max: [14,0]
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="time_demo__limits--a" class="fieldset__input " type=text placeholder="Try me…"></div></fieldset>
<p><b>2)</b> As times relative to now using integers or a boolean:</p>
<pre class="pre--demo"><code data-language="javascript">$('.timepicker').pickatime({
// An integer (positive/negative) sets it as intervals relative from now.
min: -5,
// `true` sets it to now. `false` removes any limits.
max: true
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="time_demo__limits--b" class="fieldset__input " type=text placeholder="Try me…"></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 Times<a class="heading__anchor" name="disable-times" href="#disable-times">§</a></span></h2>
<p>Disable a specific or arbitrary set of times selectable on the picker.</p>
<p><b>1)</b> Using arrays formatted as <code>[HOUR,MINUTE]</code>:</p>
<pre class="pre--demo"><code data-language="javascript">$('.timepicker').pickatime({
disable: [
[0,30],
[2,0],
[8,30],
[9,0]
]
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="time_demo__disable-times--a" class="fieldset__input " type=text placeholder="Try me…"></div></fieldset>
<p><b>2)</b> Using integers representing hours (from 0 to 23):</p>
<pre class="pre--demo"><code data-language="javascript">$('.timepicker').pickatime({
disable: [
3, 5, 7
]
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="time_demo__disable-times--b" class="fieldset__input " type=text placeholder="Try me…"></div></fieldset>
<p><b>3)</b> <i><u>Disabling all</u></i> except a specific or arbitrary set of times by setting <code class="constant">true</code> as the first item in the collection:</p>
<pre class="pre--demo"><code data-language="javascript">$('.timepicker').pickatime({
disable: [
true,
3, 5, 7,
[0,30],
[2,0],
[8,30],
[9,0]
]
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="time_demo__disable-times--c" class="fieldset__input " type=text placeholder="Try me…"></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">events<a class="heading__anchor" name="events" href="#events">§</a></span></h2>
<p>Fire off events as the user interacts with the picker:</p>
<pre class="pre--demo"><code data-language="javascript">$('.timepicker').pickatime({
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(event) {
console.log('Just set stuff:', event)
}
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="time_demo__events" class="fieldset__input " type=text placeholder="Open your console and try me…"></div></fieldset>
<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>The <code class="function">onSet</code> event is the only callback that is passed an <code>event</code> argument that provides a bit of context as to which properties are being “set”.</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">✌</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> <!-- .section__block -->
</footer> <!-- .section -->
<script src="http://code.jquery.com/jquery-1.10.0.min.js"></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/main.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>