Debian Codegraph @

dist/index.html

raw
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2 <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
5 <title>Adding a Timepicker to jQuery UI Datepicker</title>
6 <meta name="Description" content="jQuery Timepicker Addon. Add a timepicker to your jQuery UI Datepicker. With options to show only time, format time, and much more." />
7 <meta name="Keywords" content="jQuery, UI, datepicker, timepicker, datetime, time, format" />
8
9 <style type="text/css">
10 body,img,p,h1,h2,h3,h4,h5,h6,form,table,td,ul,ol,li,dl,dt,dd,pre,blockquote,fieldset,label{
11 margin:0;
12 padding:0;
13 border:0;
14 }
15 body{ background-color: #777; border-top: solid 10px #7b94b2; font: 90% Arial, Helvetica, sans-serif; padding: 20px; }
16 h1,h2,h3{ margin: 10px 0; }
17 h1{}
18 h2{ color: #f66; }
19 h3{ color: #6b84a2; }
20 p{ margin: 10px 0; }
21 a{ color: #7b94b2; }
22 ul,ol{ margin: 10px 0 10px 40px; }
23 li{ margin: 4px 0; }
24 dl.defs{ margin: 10px 0 10px 40px; }
25 dl.defs dt{ font-weight: bold; line-height: 20px; margin: 10px 0 0 0; }
26 dl.defs dd{ margin: -20px 0 10px 160px; padding-bottom: 10px; border-bottom: solid 1px #eee;}
27 pre{ font-size: 12px; line-height: 16px; padding: 5px 5px 5px 10px; margin: 10px 0; background-color: #e4f4d4; border-left: solid 5px #9EC45F; overflow: auto; tab-size: 4; -moz-tab-size: 4; -o-tab-size: 4; -webkit-tab-size: 4; }
28
29 .wrapper{ background-color: #ffffff; width: 800px; border: solid 1px #eeeeee; padding: 20px; margin: 0 auto; }
30 #tabs{ margin: 20px -20px; border: none; }
31 #tabs, #ui-datepicker-div, .ui-datepicker{ font-size: 85%; }
32 .clear{ clear: both; }
33
34 .example-container{ background-color: #f4f4f4; border-bottom: solid 2px #777777; margin: 0 0 20px 40px; padding: 20px; }
35 .example-container input{ border: solid 1px #aaa; padding: 4px; width: 175px; }
36 .ebook{}
37 .ebook img.ebookimg{ float: left; margin: 0 15px 15px 0; width: 100px; }
38 .ebook .buyp a iframe{ margin-bottom: -5px; }
39 </style>
40
41 <link rel="stylesheet" media="all" type="text/css" href="http://code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css" />
42 <link rel="stylesheet" media="all" type="text/css" href="jquery-ui-timepicker-addon.css" />
43
44 </head>
45 <body>
46 <div class="wrapper">
47 <h1>Adding a Timepicker to jQuery UI Datepicker</h1>
48
49 <p>The timepicker addon adds a timepicker to jQuery UI Datepicker, thus the datepicker and slider components (jQueryUI) are required for using any of these. In addition all datepicker options are still available through the timepicker addon.</p>
50
51 <p>If you are interested in contributing to Timepicker Addon please <a href="http://github.com/trentrichardson/jQuery-Timepicker-Addon" title="Check out Timepicker on GitHub">check it out on GitHub</a>. If you do make additions please keep in mind I enjoy tabs over spaces,.. But contributions are welcome in any form.</p>
52
53 <p><a href="http://trentrichardson.com" title="Back to Blog">Back to Blog</a> or <a href="http://twitter.com/practicalweb" title="Follow Me on Twitter">Follow on Twitter</a></p>
54
55 <h2>Donation</h2>
56 <p>Has this Timepicker Addon been helpful to you?</p>
57 <div class="donation">
58 <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
59 <input type="hidden" name="cmd" value="_s-xclick">
60 <input type="hidden" name="hosted_button_id" value="C2QQHR7JQGD28">
61 <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
62 <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
63 </form>
64 </div>
65
66 <div id="tabs">
67 <ul>
68 <li><a href="#tp-getting-started" title="Getting Started">Getting Started</a></li>
69 <li><a href="#tp-options" title="Options">Options</a></li>
70 <li><a href="#tp-formatting" title="Examples">Formatting</a></li>
71 <li><a href="#tp-localization" title="Examples">Localization</a></li>
72 <li><a href="#tp-examples" title="Examples">Examples</a></li>
73 </ul>
74
75 <!-- ############################################################################# -->
76 <!-- Getting Started
77 <!-- ############################################################################# -->
78 <div id="tp-getting-started">
79 <h2>Getting Started</h2>
80
81 <h3>Highly Recommended</h3>
82
83 <h4>Handling Time eBook</h4>
84 <div class="ebook">
85 <p>Check out the <a href="http://trentrichardson.com/ebooks/handling-time/" title="Handling Time eBook">Handling Time eBook</a> to learn from the basic setup to advanced i18n usage, and from client's javascript to the server's database.</p>
86 <a href="http://trentrichardson.com/ebooks/handling-time/" title="Handling Time eBook"><img src="http://trentrichardson.com/wp-content/uploads/2013/04/time-book-titlepage.jpg" alt="Handling Time eBook" style="float:left;width:100px;margin:0 15px 15px 0;" /></a>
87 <p class="buyp"><a href="https://sellfy.com/p/8gxZ" id="8gxZ" class="sellfy-buy-button">buy</a> eBook + Example code</p>
88 <p class="buyp"><a href="https://sellfy.com/p/LvAG" id="LvAG" class="sellfy-buy-button">buy</a> eBook</p>
89 <div class="clear"></div>
90 </div>
91
92 <h4>Subscribe to Blog and Twitter</h4>
93 <p><a href="http://trentrichardson.com" title="Subscribe to TrentRichardson.com via email">Subscribe to my blog via email</a> and follow <a href="http://twitter.com/practicalweb" title="Follow Me on Twitter">@PracticalWeb</a> on Twitter. I post for nearly every new version, so you know about updates.</p>
94 <div class="clear"></div>
95 <br />
96
97 <h3>Download</h3>
98 <p><a href="jquery-ui-timepicker-addon.js" title="Download Timepicker Addon">Download Timepicker Addon</a> and the <a href="jquery-ui-timepicker-addon.css" title="Download CSS">required CSS</a>.</p>
99
100 <p><a href="http://github.com/trentrichardson/jQuery-Timepicker-Addon" title="Check out Timepicker on GitHub">Download/Contribute on GitHub</a> (Need the entire repo? Find a bug? See if its fixed here)</p>
101
102 <p>If you prefer a hosted CDN there are a couple available: <a href="http://cdnjs.com/libraries/jquery-ui-timepicker-addon" title="Timepicker on CDNJS">CDNJS</a>, <a href="http://www.jsdelivr.com/#!jquery.ui.timepicker.addon" title="Timepicker on jsDelivr">jsDelivr</a>.</p>
103 <br />
104
105 <h3>Requirements</h3>
106 <p>You also need to include jQuery and jQuery UI with datepicker and slider wigits. You should include them in your page in the following order:</p>
107 <ol>
108 <li>jQuery</li>
109 <li>jQueryUI (with datepicker and slider wigits)</li>
110 <li>Timepicker</li>
111 </ol>
112
113 <br />
114 <h3>Version</h3>
115 <p>Version 1.6.3</p>
116
117 <p>Last updated on 2016-04-20</p>
118 <p>jQuery Timepicker Addon is currently available for use in all personal or commercial projects under the MIT license.</p>
119 <p><a href="http://trentrichardson.com/Impromptu/MIT-LICENSE.txt" title="MIT License">MIT License</a></p>
120
121 </div>
122
123 <!-- ############################################################################# -->
124 <!-- Options
125 <!-- ############################################################################# -->
126 <div id="tp-options">
127 <h2>Options</h2>
128
129 <p>The timepicker does inherit all options from datepicker. However, there are many options that are shared by them both, and many timepicker only options:</p>
130
131 <h3>Localization Options</h3>
132 <dl class="defs">
133 <dt>currentText</dt>
134 <dd><em>Default: "Now", A Localization Setting</em> - Text for the Now button.</dd>
135
136 <dt>closeText</dt>
137 <dd><em>Default: "Done", A Localization Setting</em> - Text for the Close button.</dd>
138
139 <dt>amNames</dt>
140 <dd><em>Default: ['AM', 'A'], A Localization Setting</em> - Array of strings to try and parse against to determine AM.</dd>
141
142 <dt>pmNames</dt>
143 <dd><em>Default: ['PM', 'P'], A Localization Setting</em> - Array of strings to try and parse against to determine PM.</dd>
144
145 <dt>timeFormat</dt>
146 <dd><em>Default: "HH:mm", A Localization Setting</em> - String of format tokens to be replaced with the time. <a href="#tp-formatting" title="Formatting" onclick="$('#tabs').tabs('select',2);">See Formatting</a>.</dd>
147
148 <dt>timeSuffix</dt>
149 <dd><em>Default: "", A Localization Setting</em> - String to place after the formatted time.</dd>
150
151 <dt>timeOnlyTitle</dt>
152 <dd><em>Default: "Choose Time", A Localization Setting</em> - Title of the wigit when using only timepicker.</dd>
153
154 <dt>timeText</dt>
155 <dd><em>Default: "Time", A Localization Setting</em> - Label used within timepicker for the formatted time.</dd>
156
157 <dt>hourText</dt>
158 <dd><em>Default: "Hour", A Localization Setting</em> - Label used to identify the hour slider.</dd>
159
160 <dt>minuteText</dt>
161 <dd><em>Default: "Minute", A Localization Setting</em> - Label used to identify the minute slider.</dd>
162
163 <dt>secondText</dt>
164 <dd><em>Default: "Second", A Localization Setting</em> - Label used to identify the second slider.</dd>
165
166 <dt>millisecText</dt>
167 <dd><em>Default: "Millisecond", A Localization Setting</em> - Label used to identify the millisecond slider.</dd>
168
169 <dt>microsecText</dt>
170 <dd><em>Default: "Microsecond", A Localization Setting</em> - Label used to identify the microsecond slider.</dd>
171
172 <dt>timezoneText</dt>
173 <dd><em>Default: "Timezone", A Localization Setting</em> - Label used to identify the timezone slider.</dd>
174
175 <dt>isRTL</dt>
176 <dd><em>Default: false, A Localization Setting</em> - Right to Left support.</dd>
177 </dl>
178
179 <h3>Alt Field Options</h3>
180 <dl class="defs">
181
182 <dt>altFieldTimeOnly</dt>
183 <dd><em>Default: true</em> - When altField is used from datepicker altField will only receive the formatted time and the original field only receives date.</dd>
184
185 <dt>altSeparator</dt>
186 <dd><em>Default: (separator option)</em> - String placed between formatted date and formatted time in the altField.</dd>
187
188 <dt>altTimeSuffix</dt>
189 <dd><em>Default: (timeSuffix option)</em> - String always placed after the formatted time in the altField.</dd>
190
191 <dt>altTimeFormat</dt>
192 <dd><em>Default: (timeFormat option)</em> - The time format to use with the altField.</dd>
193
194 <dt>altRedirectFocus</dt>
195 <dd><em>Default: true</em> - Whether to immediately focus the main field whenever the altField receives focus. Effective at construction time only, changing it later has no effect.</dd>
196 </dl>
197
198 <h3>Timezone Options</h3>
199 <dl class="defs">
200
201 <dt>timezoneList</dt>
202 <dd><em>Default: [generated timezones]</em> - An array of timezones used to populate the timezone select. Can be an array of values or an array of objects: { label: "EDT", value: -240 }. The value should be the offset number in minutes. So "-0400" which is the format "-hhmm", would equate to -240 minutes.</dd>
203 </dl>
204
205 <h3>Time Field Options</h3>
206 <dl class="defs">
207
208 <dt>controlType</dt>
209 <dd><em>Default: 'slider'</em> - Whether to use 'slider' or 'select'. If 'slider' is unavailable through jQueryUI, 'select' will be used. For advanced usage you may pass an object which implements "create", "options", "value" methods to use controls other than sliders or selects. See the _controls property in the source code for more details.
210 <pre>{
211 create: function(tp_inst, obj, unit, val, min, max, step){
212 // generate whatever controls you want here, just return obj
213 },
214 options: function(tp_inst, obj, unit, opts, val){
215 // if val==undefined return the value, else return obj
216 },
217 value: function(tp_inst, obj, unit, val){
218 // if val==undefined return the value, else return obj
219 }
220 }</pre>
221 </dd>
222
223 <dt>showHour</dt>
224 <dd><em>Default: null</em> - Whether to show the hour control. The default of null will use detection from timeFormat.</dd>
225
226 <dt>showMinute</dt>
227 <dd><em>Default: null</em> - Whether to show the minute control. The default of null will use detection from timeFormat.</dd>
228
229 <dt>showSecond</dt>
230 <dd><em>Default: null</em> - Whether to show the second control. The default of null will use detection from timeFormat.</dd>
231
232 <dt>showMillisec</dt>
233 <dd><em>Default: null</em> - Whether to show the millisecond control. The default of null will use detection from timeFormat.</dd>
234
235 <dt>showMicrosec</dt>
236 <dd><em>Default: null</em> - Whether to show the microsecond control. The default of null will use detection from timeFormat.</dd>
237
238 <dt>showTimezone</dt>
239 <dd><em>Default: null</em> - Whether to show the timezone select.</dd>
240
241 <dt>showTime</dt>
242 <dd><em>Default: true</em> - Whether to show the time selected within the datetimepicker.</dd>
243
244 <dt>stepHour</dt>
245 <dd><em>Default: 1</em> - Hours per step the slider makes.</dd>
246
247 <dt>stepMinute</dt>
248 <dd><em>Default: 1</em> - Minutes per step the slider makes.</dd>
249
250 <dt>stepSecond</dt>
251 <dd><em>Default: 1</em> - Seconds per step the slider makes.</dd>
252
253 <dt>stepMillisec</dt>
254 <dd><em>Default: 1</em> - Milliseconds per step the slider makes.</dd>
255
256 <dt>stepMicrosec</dt>
257 <dd><em>Default: 1</em> - Microseconds per step the slider makes.</dd>
258
259 <dt>hour</dt>
260 <dd><em>Default: 0</em> - Initial hour set.</dd>
261
262 <dt>minute</dt>
263 <dd><em>Default: 0</em> - Initial minute set.</dd>
264
265 <dt>second</dt>
266 <dd><em>Default: 0</em> - Initial second set.</dd>
267
268 <dt>millisec</dt>
269 <dd><em>Default: 0</em> - Initial millisecond set.</dd>
270
271 <dt>microsec</dt>
272 <dd><em>Default: 0</em> - Initial microsecond set. Note: Javascript's native Date object does not natively support microseconds. Timepicker adds ability to simply Date.setMicroseconds(m) and Date.getMicroseconds(). Date comparisons will not acknowledge microseconds. Use this only for display purposes.</dd>
273
274 <dt>timezone</dt>
275 <dd><em>Default: null</em> - Initial timezone set. This is the offset in minutes. If null the browser's local timezone will be used. If you're timezone is "-0400" you would use -240. For backwards compatibility you may pass "-0400", however the timezone is stored in minutes and more reliable.</dd>
276
277 <dt>hourMin</dt>
278 <dd><em>Default: 0</em> - The minimum hour allowed for all dates.</dd>
279
280 <dt>minuteMin</dt>
281 <dd><em>Default: 0</em> - The minimum minute allowed for all dates.</dd>
282
283 <dt>secondMin</dt>
284 <dd><em>Default: 0</em> - The minimum second allowed for all dates.</dd>
285
286 <dt>millisecMin</dt>
287 <dd><em>Default: 0</em> - The minimum millisecond allowed for all dates.</dd>
288
289 <dt>microsecMin</dt>
290 <dd><em>Default: 0</em> - The minimum microsecond allowed for all dates.</dd>
291
292 <dt>hourMax</dt>
293 <dd><em>Default: 23</em> - The maximum hour allowed for all dates.</dd>
294
295 <dt>minuteMax</dt>
296 <dd><em>Default: 59</em> - The maximum minute allowed for all dates.</dd>
297
298 <dt>secondMax</dt>
299 <dd><em>Default: 59</em> - The maximum second allowed for all dates.</dd>
300
301 <dt>millisecMax</dt>
302 <dd><em>Default: 999</em> - The maximum millisecond allowed for all dates.</dd>
303
304 <dt>microsecMax</dt>
305 <dd><em>Default: 999</em> - The maximum microsecond allowed for all dates.</dd>
306
307 <dt>hourGrid</dt>
308 <dd><em>Default: 0</em> - When greater than 0 a label grid will be generated under the slider. This number represents the units (in hours) between labels.</dd>
309
310 <dt>minuteGrid</dt>
311 <dd><em>Default: 0</em> - When greater than 0 a label grid will be generated under the slider. This number represents the units (in minutes) between labels.</dd>
312
313 <dt>secondGrid</dt>
314 <dd><em>Default: 0</em> - When greater than 0 a label grid will be genereated under the slider. This number represents the units (in seconds) between labels.</dd>
315
316 <dt>millisecGrid</dt>
317 <dd><em>Default: 0</em> - When greater than 0 a label grid will be genereated under the slider. This number represents the units (in milliseconds) between labels.</dd>
318
319 <dt>microsecGrid</dt>
320 <dd><em>Default: 0</em> - When greater than 0 a label grid will be genereated under the slider. This number represents the units (in microseconds) between labels.</dd>
321 </dl>
322
323 <h3>Other Options</h3>
324 <dl class="defs">
325 <dt>showButtonPanel</dt>
326 <dd><em>Default: true</em> - Whether to show the button panel at the bottom. This is generally needed.</dd>
327
328 <dt>timeInput</dt>
329 <dd><em>Default: false</em> - Allows direct input in time field</dd>
330
331 <dt>timeOnly</dt>
332 <dd><em>Default: false</em> - Hide the datepicker and only provide a time interface.</dd>
333
334 <dt>timeOnlyShowDate</dt>
335 <dd><em>Default: false</em> - Show the date and time in the input, but only allow the timepicker.</dd>
336
337 <dt>afterInject</dt>
338 <dd><em>Default: null</em> - Function to be called when the timepicker or selection control is injected or re-rendered. Called in the context of the timepicker instance.</dd>
339
340 <dt>onSelect</dt>
341 <dd><em>Default: null</em> - Function to be called when a date is chosen or time has changed (parameters: datetimeText, datepickerInstance).</dd>
342
343 <dt>alwaysSetTime</dt>
344 <dd><em>Default: true</em> - Always have a time set internally, even before user has chosen one.</dd>
345
346 <dt>separator</dt>
347 <dd><em>Default: " "</em> - When formatting the time this string is placed between the formatted date and formatted time.</dd>
348
349 <dt>pickerTimeFormat</dt>
350 <dd><em>Default: (timeFormat option)</em> - How to format the time displayed within the timepicker.</dd>
351
352 <dt>pickerTimeSuffix</dt>
353 <dd><em>Default: (timeSuffix option)</em> - String to place after the formatted time within the timepicker.</dd>
354
355 <dt>showTimepicker</dt>
356 <dd><em>Default: true</em> - Whether to show the timepicker within the datepicker.</dd>
357
358 <dt>oneLine</dt>
359 <dd><em>Default: false</em> - Try to show the time dropdowns all on one line. This should be used with controlType 'select' and as few units as possible.</dd>
360
361 <dt>addSliderAccess</dt>
362 <dd><em>Default: false</em> - Adds the <a href="http://trentrichardson.com/examples/jQuery-SliderAccess/" title="jQueryUI Slider Access Plugin">sliderAccess plugin</a> to sliders within timepicker</dd>
363
364 <dt>sliderAccessArgs</dt>
365 <dd><em>Default: null</em> - Object to pass to sliderAccess when used.</dd>
366
367 <dt>defaultValue</dt>
368 <dd><em>Default: null</em> - String of the default time value placed in the input on focus when the input is empty.</dd>
369
370 <dt>minDateTime</dt>
371 <dd><em>Default: null</em> - Date object of the minimum datetime allowed. Also available as minDate.</dd>
372
373 <dt>maxDateTime</dt>
374 <dd><em>Default: null</em> - Date object of the maximum datetime allowed. Also Available as maxDate.</dd>
375
376 <dt>minTime</dt>
377 <dd><em>Default: null</em> - String of the minimum time allowed. '8:00 am' will restrict to times after 8am</dd>
378
379 <dt>maxTime</dt>
380 <dd><em>Default: null</em> - String of the maximum time allowed. '8:00 pm' will restrict to times before 8pm</dd>
381
382 <dt>parse</dt>
383 <dd><em>Default: 'strict'</em> - How to parse the time string. Two methods are provided: 'strict' which must match the timeFormat exactly, and 'loose' which uses javascript's new Date(timeString) to guess the time. You may also pass in a function(timeFormat, timeString, options) to handle the parsing yourself, returning a simple object:
384 <pre>{
385 hour: 19,
386 minute: 10,
387 second: 23,
388 millisec: 45,
389 microsec: 23,
390 timezone: '-0400'
391 }</pre>
392 </dd>
393 </dl>
394
395 </div>
396
397 <!-- ############################################################################# -->
398 <!-- Formatting
399 <!-- ############################################################################# -->
400 <div id="tp-formatting">
401
402 <h2>Formatting Your Time</h2>
403
404 <p>The default format is "HH:mm". To use 12 hour time use something similar to: "hh:mm tt". When both "t" and lower case "h" are present in the timeFormat, 12 hour time will be used.</p>
405
406 <dl class="defs">
407 <dt>H</dt><dd>Hour with no leading 0 (24 hour)</dd>
408 <dt>HH</dt><dd>Hour with leading 0 (24 hour)</dd>
409 <dt>h</dt><dd>Hour with no leading 0 (12 hour)</dd>
410 <dt>hh</dt><dd>Hour with leading 0 (12 hour)</dd>
411 <dt>m</dt><dd>Minute with no leading 0</dd>
412 <dt>mm</dt><dd>Minute with leading 0</dd>
413 <dt>s</dt><dd>Second with no leading 0</dd>
414 <dt>ss</dt><dd>Second with leading 0</dd>
415 <dt>l</dt><dd>Milliseconds always with leading 0</dd>
416 <dt>c</dt><dd>Microseconds always with leading 0</dd>
417 <dt>t</dt><dd>a or p for AM/PM</dd>
418 <dt>T</dt><dd>A or P for AM/PM</dd>
419 <dt>tt</dt><dd>am or pm for AM/PM</dd>
420 <dt>TT</dt><dd>AM or PM for AM/PM</dd>
421 <dt>z</dt><dd>Timezone as defined by timezoneList</dd>
422 <dt>Z</dt><dd>Timezone in Iso 8601 format (+04:45)</dd>
423 <dt>'...'</dt><dd>Literal text (Uses single quotes)</dd>
424 </dl>
425
426 <p>Formats are used in the following ways:</p>
427 <ul>
428 <li>timeFormat option</li>
429 <li>altTimeFormat option</li>
430 <li>pickerTimeFormat option</li>
431 <li>$.datepicker.formatTime(format, timeObj, options) utility method</li>
432 <li>$.datepicker.parseTime(format, timeStr, options) utility method</li>
433 </ul>
434
435 <p>For help with formatting the date portion, visit the datepicker documentation for <a href="http://docs.jquery.com/UI/Datepicker/formatDate" title="jQuery UI Datepicker Formatting">formatting dates</a>.</p>
436 </div>
437
438 <!-- ############################################################################# -->
439 <!-- Localization
440 <!-- ############################################################################# -->
441 <div id="tp-localization">
442
443 <h2>Working with Localizations</h2>
444
445 <p>Timepicker comes with many translations and localizations, thanks to all the contributors. They can be found in the i18n folder in the git repo.</p>
446
447 <p>The quick and cheap way to use localizations is to pass in options to a timepicker instance:</p>
448
449 <pre>$('#example123').timepicker({
450 timeOnlyTitle: 'Выберите время',
451 timeText: 'Время',
452 hourText: 'Часы',
453 minuteText: 'Минуты',
454 secondText: 'Секунды',
455 currentText: 'Сейчас',
456 closeText: 'Закрыть'
457 });
458 </pre>
459 <p>However, if you plan to use timepicker extensively you will need to include (build your own) localization. It is simply assigning those same variables to an object.</p>
460 <p>As you see in the example below we maintain a separate object for timepicker. This way we aren't bound to any future changes within datepicker.</p>
461
462 <pre>$.datepicker.regional['ru'] = {
463 closeText: 'Закрыть',
464 prevText: '&#x3c;Пред',
465 nextText: 'След&#x3e;',
466 currentText: 'Сегодня',
467 monthNames: ['Январь','Февраль','Март','Апрель','Май','Июнь',
468 'Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь'],
469 monthNamesShort: ['Янв','Фев','Мар','Апр','Май','Июн',
470 'Июл','Авг','Сен','Окт','Ноя','Дек'],
471 dayNames: ['воскресенье','понедельник','вторник','среда','четверг','пятница','суббота'],
472 dayNamesShort: ['вск','пнд','втр','срд','чтв','птн','сбт'],
473 dayNamesMin: ['Вс','Пн','Вт','Ср','Чт','Пт','Сб'],
474 weekHeader: 'Не',
475 dateFormat: 'dd.mm.yy',
476 firstDay: 1,
477 isRTL: false,
478 showMonthAfterYear: false,
479 yearSuffix: ''
480 };
481 $.datepicker.setDefaults($.datepicker.regional['ru']);
482
483
484 $.timepicker.regional['ru'] = {
485 timeOnlyTitle: 'Выберите время',
486 timeText: 'Время',
487 hourText: 'Часы',
488 minuteText: 'Минуты',
489 secondText: 'Секунды',
490 millisecText: 'Миллисекунды',
491 timezoneText: 'Часовой пояс',
492 currentText: 'Сейчас',
493 closeText: 'Закрыть',
494 timeFormat: 'HH:mm',
495 amNames: ['AM', 'A'],
496 pmNames: ['PM', 'P'],
497 isRTL: false
498 };
499 $.timepicker.setDefaults($.timepicker.regional['ru']);
500 </pre>
501
502 <p>Now all you have to do is call timepicker and the Russian localization is used. Generally you only need to include the localization file, it will setDefaults() for you.</p>
503 <p>As of version 1.4.5 a combined file of all localizations available is included. This file DOES NOT call setDefaults(), so you will need to pass, or merge with your options.</p>
504
505 <pre>$('#example123').timepicker($.timepicker.regional['ru']);
506 </pre>
507
508 <p>Localization files for datepicker are typically available in your jQueryUI downloads.</p>
509 </div>
510
511 <!-- ############################################################################# -->
512 <!-- Examples
513 <!-- ############################################################################# -->
514 <div id="tp-examples">
515 <h2>Examples</h2>
516
517 <ul>
518 <li><a href="#basic_examples" title="Basic Initializations">Basic Initializations</a></li>
519 <li><a href="#timezone_examples" title="Using Timezones">Using Timezones</a></li>
520 <li><a href="#slider_examples" title="Slider Modifications">Slider Modifications</a></li>
521 <li><a href="#alt_examples" title="Alternate Field">Alternate Fields</a></li>
522 <li><a href="#input_examples" title="Time Input">Time Input</a></li>
523 <li><a href="#rest_examples" title="Time Restraints">Time Restraints</a></li>
524 <li><a href="#range_examples" title="Time Ranges">Time Ranges</a></li>
525 <li><a href="#utility_examples" title="Utilities">Utilities</a></li>
526 </ul>
527
528 <h3 id="basic_examples">Basic Initializations</h3>
529
530 <!-- ============= example -->
531 <div class="example-container">
532 <p>Add a simple datetimepicker to jQuery UI's datepicker</p>
533 <div>
534 <input type="text" name="basic_example_1" id="basic_example_1" value="" />
535 </div>
536 <pre>
537 $('#basic_example_1').datetimepicker();
538 </pre>
539 </div>
540
541
542 <!-- ============= example -->
543 <div class="example-container">
544 <p>Add only a timepicker:</p>
545 <div>
546 <input type="text" name="basic_example_2" id="basic_example_2" value="" />
547 </div>
548 <pre>
549 $('#basic_example_2').timepicker();
550 </pre>
551 </div>
552
553 <!-- ============= example -->
554 <div class="example-container">
555 <p>Format the time:</p>
556 <div>
557 <input type="text" name="basic_example_3" id="basic_example_3" value="" />
558 </div>
559 <pre>
560 $('#basic_example_3').datetimepicker({
561 timeFormat: "hh:mm tt"
562 });
563 </pre>
564 </div>
565
566
567 <!-- ============= example -->
568 <div class="example-container">
569 <p>Timepicker comes with a collection of localization files and one combined file with all available localizations. $.timepicker.regional["your localization code here"] is a simple object with preset options:</p>
570 <div>
571 <input type="text" name="basic_example_4" id="basic_example_4" value="" />
572 </div>
573 <pre>
574 $('#basic_example_4').timepicker(
575 $.timepicker.regional['es']
576 );
577 </pre>
578 </div>
579
580 <h3 id="timezone_examples">Using Timezones</h3>
581
582 <!-- ============= example -->
583 <div class="example-container">
584 <p>Simplest timezone usage:</p>
585 <div>
586 <input type="text" name="timezone_example_1" id="timezone_example_1" value="" />
587 </div>
588 <pre>
589 $('#timezone_example_1').datetimepicker({
590 timeFormat: 'hh:mm tt z'
591 });
592 </pre>
593 </div>
594
595 <!-- ============= example -->
596 <div class="example-container">
597 <p>Define your own timezone options:</p>
598 <div>
599 <input type="text" name="timezone_example_2" id="timezone_example_2" value="" />
600 </div>
601 <pre>
602 $('#timezone_example_2').datetimepicker({
603 timeFormat: 'HH:mm z',
604 timezoneList: [
605 { value: -300, label: 'Eastern'},
606 { value: -360, label: 'Central' },
607 { value: -420, label: 'Mountain' },
608 { value: -480, label: 'Pacific' }
609 ]
610 });
611 </pre>
612 </div>
613
614 <h3 id="slider_examples">Slider Modifications</h3>
615
616 <!-- ============= example -->
617 <div class="example-container">
618 <p>Add a grid to each slider:</p>
619 <div>
620 <input type="text" name="slider_example_1" id="slider_example_1" value="" />
621 </div>
622 <pre>
623 $('#slider_example_1').timepicker({
624 hourGrid: 4,
625 minuteGrid: 10,
626 timeFormat: 'hh:mm tt'
627 });
628 </pre>
629 </div>
630
631 <!-- ============= example -->
632 <div class="example-container">
633 <p>Set the interval step of sliders:</p>
634 <div>
635 <input type="text" name="slider_example_2" id="slider_example_2" value="" />
636 </div>
637 <pre>
638 $('#slider_example_2').datetimepicker({
639 timeFormat: 'HH:mm:ss',
640 stepHour: 2,
641 stepMinute: 10,
642 stepSecond: 10
643 });
644 </pre>
645 </div>
646
647 <!-- ============= example -->
648 <div class="example-container">
649 <p>Add sliderAccess plugin for touch devices:</p>
650 <div>
651 <input type="text" name="slider_example_3" id="slider_example_3" value="" />
652 </div>
653 <pre>
654 $('#slider_example_3').datetimepicker({
655 addSliderAccess: true,
656 sliderAccessArgs: { touchonly: false }
657 });</pre>
658 </div>
659
660 <!-- ============= example -->
661 <div class="example-container">
662 <p>Use dropdowns instead of sliders. By default if slider is not available dropdowns will be used.</p>
663 <div>
664 <input type="text" name="slider_example_4" id="slider_example_4" value="" />
665 </div>
666 <pre>
667 $('#slider_example_4').datetimepicker({
668 controlType: 'select',
669 timeFormat: 'hh:mm tt'
670 });</pre>
671 </div>
672
673 <!-- ============= example -->
674 <div class="example-container">
675 <p>Uses one line dropdowns instead of sliders.</p>
676 <div>
677 <input type="text" name="slider_example_4andHalf" id="slider_example_4andHalf" value="" />
678 </div>
679 <pre>
680 $('#slider_example_4andHalf').datetimepicker({
681 controlType: 'select',
682 oneLine: true,
683 timeFormat: 'hh:mm tt'
684 });</pre>
685 </div>
686
687 <!-- ============= example -->
688 <div class="example-container">
689 <p>Create your own control by implementing the create, options, and value methods. If you want to use your new control for all instances use the $.timepicker.setDefaults({controlType:myControl}). Here we implement jQueryUI's spinner control (jQueryUI 1.9+).</p>
690 <div>
691 <input type="text" name="slider_example_5" id="slider_example_5" value="" />
692 </div>
693 <pre>var myControl= {
694 create: function(tp_inst, obj, unit, val, min, max, step){
695 $('&lt;input class="ui-timepicker-input" value="'+val+'" style="width:50%"&gt;')
696 .appendTo(obj)
697 .spinner({
698 min: min,
699 max: max,
700 step: step,
701 change: function(e,ui){ // key events
702 // don't call if api was used and not key press
703 if(e.originalEvent !== undefined)
704 tp_inst._onTimeChange();
705 tp_inst._onSelectHandler();
706 },
707 spin: function(e,ui){ // spin events
708 tp_inst.control.value(tp_inst, obj, unit, ui.value);
709 tp_inst._onTimeChange();
710 tp_inst._onSelectHandler();
711 }
712 });
713 return obj;
714 },
715 options: function(tp_inst, obj, unit, opts, val){
716 if(typeof(opts) == 'string' && val !== undefined)
717 return obj.find('.ui-timepicker-input').spinner(opts, val);
718 return obj.find('.ui-timepicker-input').spinner(opts);
719 },
720 value: function(tp_inst, obj, unit, val){
721 if(val !== undefined)
722 return obj.find('.ui-timepicker-input').spinner('value', val);
723 return obj.find('.ui-timepicker-input').spinner('value');
724 }
725 };
726
727 $('#slider_example_5').datetimepicker({
728 controlType: myControl
729 });</pre>
730 </div>
731
732 <h3 id="alt_examples">Alternate Fields</h3>
733
734 <!-- ============= example -->
735 <div class="example-container">
736 <p>Alt field in the simplest form:</p>
737 <div>
738 <input type="text" name="alt_example_1" id="alt_example_1" value="09/15/2012" />
739 <input type="text" name="alt_example_1_alt" id="alt_example_1_alt" value="10:15" />
740 </div>
741 <pre>
742 $('#alt_example_1').datetimepicker({
743 altField: "#alt_example_1_alt"
744 });
745 </pre>
746 </div>
747
748 <!-- ============= example -->
749 <div class="example-container">
750 <p>With datetime in both:</p>
751 <div>
752 <input type="text" name="alt_example_2" id="alt_example_2" value="" />
753 <input type="text" name="alt_example_2_alt" id="alt_example_2_alt" value="" />
754 </div>
755 <pre>
756 $('#alt_example_2').datetimepicker({
757 altField: "#alt_example_2_alt",
758 altFieldTimeOnly: false
759 });
760 </pre>
761 </div>
762
763 <!-- ============= example -->
764 <div class="example-container">
765 <p>Format the altField differently:</p>
766 <div>
767 <input type="text" name="alt_example_3" id="alt_example_3" value="" />
768 <input type="text" name="alt_example_3_alt" id="alt_example_3_alt" value="" />
769 </div>
770 <pre>
771 $('#alt_example_3').datetimepicker({
772 altField: "#alt_example_3_alt",
773 altFieldTimeOnly: false,
774 altFormat: "yy-mm-dd",
775 altTimeFormat: "h:m t",
776 altSeparator: " @ "
777 });
778 </pre>
779 </div>
780
781 <!-- ============= example -->
782 <div class="example-container">
783 <p>With inline mode using altField:</p>
784 <div>
785 <input type="text" name="alt_example_4_alt" id="alt_example_4_alt" value="" />
786 <span id="alt_example_4" ></span>
787 </div>
788 <pre>
789 $('#alt_example_4').datetimepicker({
790 altField: "#alt_example_4_alt",
791 altFieldTimeOnly: false
792 });
793 </pre>
794 </div>
795
796 <h3 id="input_examples">Time Input</h3>
797
798 <!-- ============= example -->
799 <div class="example-container">
800 <p>Allows time displayed inside the picker to allow being typed in.</p>
801 <div>
802 <input type="text" name="input_example_1" id="input_example_1" value="08/20/2014 01:22 pm" />
803 </div>
804 <pre>
805 $('#input_example_1').datetimepicker({
806 timeInput: true,
807 timeFormat: "hh:mm tt"
808 });
809 </pre>
810 </div>
811
812 <!-- ============= example -->
813 <div class="example-container">
814 <p>Don't show any sliders, only the time input.</p>
815 <div>
816 <input type="text" name="input_example_1" id="input_example_2" value="08/20/2014 01:22 pm" />
817 </div>
818 <pre>
819 $('#input_example_2').datetimepicker({
820 timeInput: true,
821 timeFormat: "hh:mm tt",
822 showHour: false,
823 showMinute: false
824 });
825 </pre>
826 </div>
827
828 <h3 id="rest_examples">Time Restraints</h3>
829
830 <!-- ============= example -->
831 <div class="example-container">
832 <p>Set the min/max hour of every date:</p>
833 <div>
834 <input type="text" name="rest_example_1" id="rest_example_1" value="" />
835 </div>
836 <pre>
837 $('#rest_example_1').timepicker({
838 hourMin: 8,
839 hourMax: 16
840 });
841 </pre>
842 </div>
843
844 <!-- ============= example -->
845 <div class="example-container">
846 <p>Set the min/max date numerically:</p>
847 <div>
848 <input type="text" name="rest_example_2" id="rest_example_2" value="" />
849 </div>
850 <pre>
851 $('#rest_example_2').datetimepicker({
852 numberOfMonths: 2,
853 minDate: 0,
854 maxDate: 30
855 });
856 </pre>
857 </div>
858
859 <!-- ============= example -->
860 <div class="example-container">
861 <p>Set the min/max date and time with a Date object:</p>
862 <div>
863 <input type="text" name="rest_example_3" id="rest_example_3" value="" />
864 </div>
865 <pre>
866 $('#rest_example_3').datetimepicker({
867 minDate: new Date(2010, 11, 20, 8, 30),
868 maxDate: new Date(2010, 11, 31, 17, 30)
869 });
870 </pre>
871 </div>
872
873
874 <h3 id="range_examples">Time Ranges</h3>
875
876 <!-- ============= example -->
877 <div class="example-container">
878 <p>Restrict a start and end date by using onSelect and onClose events for more control over functionality:</p>
879 <p>For more examples and advanced usage grab the <a href="http://trentrichardson.com/ebooks/handling-time/" title="Handling Time eBook">Handling Time eBook</a>.</p>
880 <div>
881 <input type="text" name="range_example_1_start" id="range_example_1_start" value="08/20/2014 09:22 -0400" />
882 <input type="text" name="range_example_1_end" id="range_example_1_end" value="08/21/2014 08:00 -0400" />
883 </div>
884 <pre>
885 var startDateTextBox = $('#range_example_1_start');
886 var endDateTextBox = $('#range_example_1_end');
887
888 startDateTextBox.datetimepicker({
889 timeFormat: 'HH:mm z',
890 onClose: function(dateText, inst) {
891 if (endDateTextBox.val() != '') {
892 var testStartDate = startDateTextBox.datetimepicker('getDate');
893 var testEndDate = endDateTextBox.datetimepicker('getDate');
894 if (testStartDate > testEndDate)
895 endDateTextBox.datetimepicker('setDate', testStartDate);
896 }
897 else {
898 endDateTextBox.val(dateText);
899 }
900 },
901 onSelect: function (selectedDateTime){
902 endDateTextBox.datetimepicker('option', 'minDate', startDateTextBox.datetimepicker('getDate') );
903 }
904 });
905 endDateTextBox.datetimepicker({
906 timeFormat: 'HH:mm z',
907 onClose: function(dateText, inst) {
908 if (startDateTextBox.val() != '') {
909 var testStartDate = startDateTextBox.datetimepicker('getDate');
910 var testEndDate = endDateTextBox.datetimepicker('getDate');
911 if (testStartDate > testEndDate)
912 startDateTextBox.datetimepicker('setDate', testEndDate);
913 }
914 else {
915 startDateTextBox.val(dateText);
916 }
917 },
918 onSelect: function (selectedDateTime){
919 startDateTextBox.datetimepicker('option', 'maxDate', endDateTextBox.datetimepicker('getDate') );
920 }
921 });
922 </pre>
923 </div>
924
925 <!-- ============= example -->
926 <div class="example-container">
927 <p>Timepicker also includes some shortcut methods for ranges:</p>
928 <div>
929 <input type="text" name="range_example_2_start" id="range_example_2_start" value="" />
930 <input type="text" name="range_example_2_end" id="range_example_2_end" value="" />
931 </div>
932 <pre>
933 var startDateTextBox = $('#range_example_2_start');
934 var endDateTextBox = $('#range_example_2_end');
935
936 $.timepicker.datetimeRange(
937 startDateTextBox,
938 endDateTextBox,
939 {
940 minInterval: (1000*60*60), // 1hr
941 dateFormat: 'dd M yy',
942 timeFormat: 'HH:mm',
943 start: {}, // start picker options
944 end: {} // end picker options
945 }
946 );
947 </pre>
948 </div>
949
950 <!-- ============= example -->
951 <div class="example-container">
952 <p>To use only times for a time range use $.timepicker.timeRange():</p>
953 <div>
954 <input type="text" name="range_example_3_start" id="range_example_3_start" value="09:16" />
955 <input type="text" name="range_example_3_end" id="range_example_3_end" value="10:16" />
956 </div>
957 <pre>
958 var startTimeTextBox = $('#range_example_3_start');
959 var endTimeTextBox = $('#range_example_3_end');
960
961 $.timepicker.timeRange(
962 startTimeTextBox,
963 endTimeTextBox,
964 {
965 minInterval: (1000*60*60), // 1hr
966 timeFormat: 'HH:mm',
967 start: {}, // start picker options
968 end: {} // end picker options
969 }
970 );
971 </pre>
972 </div>
973
974 <!-- ============= example -->
975 <div class="example-container">
976 <p>Even though this plugin focuses on datetime, it also provides a dateRange function:</p>
977 <div>
978 <input type="text" name="range_example_4_start" id="range_example_4_start" value="" />
979 <input type="text" name="range_example_4_end" id="range_example_4_end" value="" />
980 </div>
981 <pre>
982 var startDateTextBox = $('#range_example_4_start');
983 var endDateTextBox = $('#range_example_4_end');
984
985 $.timepicker.dateRange(
986 startDateTextBox,
987 endDateTextBox,
988 {
989 minInterval: (1000*60*60*24*4), // 4 days
990 maxInterval: (1000*60*60*24*8), // 8 days
991 start: {}, // start picker options
992 end: {} // end picker options
993 }
994 );
995 </pre>
996 </div>
997
998 <h3 id="utility_examples">Utilities</h3>
999
1000 <!-- ============= example -->
1001 <div class="example-container">
1002 <p>Get and Set Datetime with the getDate and setDate methods. This example uses timezone to demonstrate the timepicker regonizes the timezones and computes the offsets when getting and setting.</p>
1003 <div>
1004 <input type="text" name="utility_example_1" id="utility_example_1" value="" />
1005 <button id="utility_example_1_setdt" value="1">Set Datetime</button>
1006 <button id="utility_example_1_getdt" value="1">Get Datetime</button>
1007 </div>
1008
1009 <pre>
1010 var ex13 = $('#utility_example_1');
1011
1012 ex13.datetimepicker({
1013 timeFormat: 'hh:mm tt z',
1014 separator: ' @ ',
1015 showTimezone: true
1016 });
1017
1018 $('#utility_example_1_setdt').click(function(){
1019 ex13.datetimepicker('setDate', (new Date()) );
1020 });
1021
1022 $('#utility_example_1_getdt').click(function(){
1023 alert(ex13.datetimepicker('getDate'));
1024 });
1025 </pre>
1026 </div>
1027
1028 <!-- ============= example -->
1029 <div class="example-container">
1030 <p>Use the utility function to format your own time. $.datepicker.formatTime(format, time, options)</p>
1031 <dl class="defs">
1032 <dt>format</dt><dd>required - string represenation of the time format to use</dd>
1033 <dt>time</dt><dd>required - hash: { hour, minute, second, millisecond, timezone }</dd>
1034 <dt>options</dt><dd>optional - hash of any options in regional translation (ampm, amNames, pmNames..)</dd>
1035 </dl>
1036 <p>Returns a time string in the specified format.</p>
1037 <div>
1038 <div id="utility_example_2"></div>
1039 </div>
1040
1041 <pre>
1042 $('#utility_example_2').text(
1043 $.datepicker.formatTime('HH:mm z', { hour: 14, minute: 36, timezone: '+2000' }, {})
1044 );
1045 </pre>
1046 </div>
1047
1048 <!-- ============= example -->
1049 <div class="example-container">
1050 <p>Use the utility function to parses a formatted time. $.datepicker.parseTime(format, timeString, options)</p>
1051 <dl class="defs">
1052 <dt>format</dt><dd>required - string represenation of the time format to use</dd>
1053 <dt>time</dt><dd>required - time string matching the format given in parameter 1</dd>
1054 <dt>options</dt><dd>optional - hash of any options in regional translation (ampm, amNames, pmNames..)</dd>
1055 </dl>
1056 <p>Returns an object with hours, minutes, seconds, milliseconds, timezone.</p>
1057 <div>
1058 <div id="utility_example_3"></div>
1059 </div>
1060
1061 <pre>
1062 $('#utility_example_3').text(JSON.stringify(
1063 $.datepicker.parseTime('HH:mm:ss:l z', "14:36:21:765 +2000", {})
1064 ));
1065 </pre>
1066 </div>
1067
1068 </div>
1069
1070
1071 </div>
1072
1073
1074 <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
1075 <script type="text/javascript" src="http://code.jquery.com/ui/1.11.0/jquery-ui.min.js"></script>
1076 <script type="text/javascript" src="jquery-ui-timepicker-addon.js"></script>
1077 <script type="text/javascript" src="i18n/jquery-ui-timepicker-addon-i18n.min.js"></script>
1078 <script type="text/javascript" src="jquery-ui-sliderAccess.js"></script>
1079
1080 <script type="text/javascript">
1081
1082 $(function(){
1083 $('#tabs').tabs();
1084
1085 $('.example-container > pre').each(function(i){
1086 eval($(this).text());
1087 });
1088 });
1089
1090 </script>
1091
1092 <script type="text/javascript" src="https://sellfy.com/js/api_buttons.js"></script>
1093 <!--
1094 <script type="text/javascript">
1095 var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
1096 document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
1097 </script>
1098 <script type="text/javascript">
1099 try {
1100 var pageTracker = _gat._getTracker("UA-7602218-1");
1101 pageTracker._trackPageview();
1102 } catch(err) {}</script>
1103 -->
1104 </body>
1105 </html>