jquery-ui-timepicker-addon.js 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755
  1. /*
  2. * jQuery timepicker addon
  3. * By: Trent Richardson [http://trentrichardson.com]
  4. * Version 1.0.4
  5. * Last Modified: 09/29/2012
  6. *
  7. * Copyright 2012 Trent Richardson
  8. * You may use this project under MIT or GPL licenses.
  9. * http://trentrichardson.com/Impromptu/GPL-LICENSE.txt
  10. * http://trentrichardson.com/Impromptu/MIT-LICENSE.txt
  11. *
  12. * HERES THE CSS:
  13. * .ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
  14. * .ui-timepicker-div dl { text-align: left; }
  15. * .ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; }
  16. * .ui-timepicker-div dl dd { margin: 0 10px 10px 65px; }
  17. * .ui-timepicker-div td { font-size: 90%; }
  18. * .ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
  19. */
  20. /*jslint evil: true, white: false, undef: false, nomen: false */
  21. (function($) {
  22. /*
  23. * Lets not redefine timepicker, Prevent "Uncaught RangeError: Maximum call stack size exceeded"
  24. */
  25. $.ui.timepicker = $.ui.timepicker || {};
  26. if ($.ui.timepicker.version) {
  27. return;
  28. }
  29. /*
  30. * Extend jQueryUI, get it started with our version number
  31. */
  32. $.extend($.ui, {
  33. timepicker: {
  34. version: "1.0.4"
  35. }
  36. });
  37. /*
  38. * Timepicker manager.
  39. * Use the singleton instance of this class, $.timepicker, to interact with the time picker.
  40. * Settings for (groups of) time pickers are maintained in an instance object,
  41. * allowing multiple different settings on the same page.
  42. */
  43. function Timepicker() {
  44. this.regional = []; // Available regional settings, indexed by language code
  45. this.regional[''] = { // Default regional settings
  46. currentText: 'Now',
  47. closeText: 'Done',
  48. ampm: false,
  49. amNames: ['AM', 'A'],
  50. pmNames: ['PM', 'P'],
  51. timeFormat: 'hh:mm tt',
  52. timeSuffix: '',
  53. timeOnlyTitle: 'Choose Time',
  54. timeText: 'Time',
  55. hourText: 'Hour',
  56. minuteText: 'Minute',
  57. secondText: 'Second',
  58. millisecText: 'Millisecond',
  59. timezoneText: 'Time Zone'
  60. };
  61. this._defaults = { // Global defaults for all the datetime picker instances
  62. showButtonPanel: true,
  63. timeOnly: false,
  64. showHour: true,
  65. showMinute: true,
  66. showSecond: false,
  67. showMillisec: false,
  68. showTimezone: false,
  69. showTime: true,
  70. stepHour: 1,
  71. stepMinute: 1,
  72. stepSecond: 1,
  73. stepMillisec: 1,
  74. hour: 0,
  75. minute: 0,
  76. second: 0,
  77. millisec: 0,
  78. timezone: null,
  79. useLocalTimezone: false,
  80. defaultTimezone: "+0000",
  81. hourMin: 0,
  82. minuteMin: 0,
  83. secondMin: 0,
  84. millisecMin: 0,
  85. hourMax: 23,
  86. minuteMax: 59,
  87. secondMax: 59,
  88. millisecMax: 999,
  89. minDateTime: null,
  90. maxDateTime: null,
  91. onSelect: null,
  92. hourGrid: 0,
  93. minuteGrid: 0,
  94. secondGrid: 0,
  95. millisecGrid: 0,
  96. alwaysSetTime: true,
  97. separator: ' ',
  98. altFieldTimeOnly: true,
  99. altSeparator: null,
  100. altTimeSuffix: null,
  101. showTimepicker: true,
  102. timezoneIso8601: false,
  103. timezoneList: null,
  104. addSliderAccess: false,
  105. sliderAccessArgs: null,
  106. defaultValue: null
  107. };
  108. $.extend(this._defaults, this.regional['']);
  109. }
  110. $.extend(Timepicker.prototype, {
  111. $input: null,
  112. $altInput: null,
  113. $timeObj: null,
  114. inst: null,
  115. hour_slider: null,
  116. minute_slider: null,
  117. second_slider: null,
  118. millisec_slider: null,
  119. timezone_select: null,
  120. hour: 0,
  121. minute: 0,
  122. second: 0,
  123. millisec: 0,
  124. timezone: null,
  125. defaultTimezone: "+0000",
  126. hourMinOriginal: null,
  127. minuteMinOriginal: null,
  128. secondMinOriginal: null,
  129. millisecMinOriginal: null,
  130. hourMaxOriginal: null,
  131. minuteMaxOriginal: null,
  132. secondMaxOriginal: null,
  133. millisecMaxOriginal: null,
  134. ampm: '',
  135. formattedDate: '',
  136. formattedTime: '',
  137. formattedDateTime: '',
  138. timezoneList: null,
  139. units: ['hour','minute','second','millisec'],
  140. /*
  141. * Override the default settings for all instances of the time picker.
  142. * @param settings object - the new settings to use as defaults (anonymous object)
  143. * @return the manager object
  144. */
  145. setDefaults: function(settings) {
  146. extendRemove(this._defaults, settings || {});
  147. return this;
  148. },
  149. /*
  150. * Create a new Timepicker instance
  151. */
  152. _newInst: function($input, o) {
  153. var tp_inst = new Timepicker(),
  154. inlineSettings = {};
  155. for (var attrName in this._defaults) {
  156. if(this._defaults.hasOwnProperty(attrName)){
  157. var attrValue = $input.attr('time:' + attrName);
  158. if (attrValue) {
  159. try {
  160. inlineSettings[attrName] = eval(attrValue);
  161. } catch (err) {
  162. inlineSettings[attrName] = attrValue;
  163. }
  164. }
  165. }
  166. }
  167. tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, o, {
  168. beforeShow: function(input, dp_inst) {
  169. if ($.isFunction(o.beforeShow)) {
  170. return o.beforeShow(input, dp_inst, tp_inst);
  171. }
  172. },
  173. onChangeMonthYear: function(year, month, dp_inst) {
  174. // Update the time as well : this prevents the time from disappearing from the $input field.
  175. tp_inst._updateDateTime(dp_inst);
  176. if ($.isFunction(o.onChangeMonthYear)) {
  177. o.onChangeMonthYear.call($input[0], year, month, dp_inst, tp_inst);
  178. }
  179. },
  180. onClose: function(dateText, dp_inst) {
  181. if (tp_inst.timeDefined === true && $input.val() !== '') {
  182. tp_inst._updateDateTime(dp_inst);
  183. }
  184. if ($.isFunction(o.onClose)) {
  185. o.onClose.call($input[0], dateText, dp_inst, tp_inst);
  186. }
  187. },
  188. timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker');
  189. });
  190. tp_inst.amNames = $.map(tp_inst._defaults.amNames, function(val) {
  191. return val.toUpperCase();
  192. });
  193. tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function(val) {
  194. return val.toUpperCase();
  195. });
  196. if (tp_inst._defaults.timezoneList === null) {
  197. var timezoneList = ['-1200', '-1100', '-1000', '-0930', '-0900', '-0800', '-0700', '-0600', '-0500', '-0430', '-0400', '-0330', '-0300', '-0200', '-0100', '+0000',
  198. '+0100', '+0200', '+0300', '+0330', '+0400', '+0430', '+0500', '+0530', '+0545', '+0600', '+0630', '+0700', '+0800', '+0845', '+0900', '+0930',
  199. '+1000', '+1030', '+1100', '+1130', '+1200', '+1245', '+1300', '+1400'];
  200. if (tp_inst._defaults.timezoneIso8601) {
  201. timezoneList = $.map(timezoneList, function(val) {
  202. return val == '+0000' ? 'Z' : (val.substring(0, 3) + ':' + val.substring(3));
  203. });
  204. }
  205. tp_inst._defaults.timezoneList = timezoneList;
  206. }
  207. tp_inst.timezone = tp_inst._defaults.timezone;
  208. tp_inst.hour = tp_inst._defaults.hour;
  209. tp_inst.minute = tp_inst._defaults.minute;
  210. tp_inst.second = tp_inst._defaults.second;
  211. tp_inst.millisec = tp_inst._defaults.millisec;
  212. tp_inst.ampm = '';
  213. tp_inst.$input = $input;
  214. if (o.altField) {
  215. tp_inst.$altInput = $(o.altField).css({
  216. cursor: 'pointer'
  217. }).focus(function() {
  218. $input.trigger("focus");
  219. });
  220. }
  221. if (tp_inst._defaults.minDate === 0 || tp_inst._defaults.minDateTime === 0) {
  222. tp_inst._defaults.minDate = new Date();
  223. }
  224. if (tp_inst._defaults.maxDate === 0 || tp_inst._defaults.maxDateTime === 0) {
  225. tp_inst._defaults.maxDate = new Date();
  226. }
  227. // datepicker needs minDate/maxDate, timepicker needs minDateTime/maxDateTime..
  228. if (tp_inst._defaults.minDate !== undefined && tp_inst._defaults.minDate instanceof Date) {
  229. tp_inst._defaults.minDateTime = new Date(tp_inst._defaults.minDate.getTime());
  230. }
  231. if (tp_inst._defaults.minDateTime !== undefined && tp_inst._defaults.minDateTime instanceof Date) {
  232. tp_inst._defaults.minDate = new Date(tp_inst._defaults.minDateTime.getTime());
  233. }
  234. if (tp_inst._defaults.maxDate !== undefined && tp_inst._defaults.maxDate instanceof Date) {
  235. tp_inst._defaults.maxDateTime = new Date(tp_inst._defaults.maxDate.getTime());
  236. }
  237. if (tp_inst._defaults.maxDateTime !== undefined && tp_inst._defaults.maxDateTime instanceof Date) {
  238. tp_inst._defaults.maxDate = new Date(tp_inst._defaults.maxDateTime.getTime());
  239. }
  240. tp_inst.$input.bind('focus', function() {
  241. tp_inst._onFocus();
  242. });
  243. return tp_inst;
  244. },
  245. /*
  246. * add our sliders to the calendar
  247. */
  248. _addTimePicker: function(dp_inst) {
  249. var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ? this.$input.val() + ' ' + this.$altInput.val() : this.$input.val();
  250. this.timeDefined = this._parseTime(currDT);
  251. this._limitMinMaxDateTime(dp_inst, false);
  252. this._injectTimePicker();
  253. },
  254. /*
  255. * parse the time string from input value or _setTime
  256. */
  257. _parseTime: function(timeString, withDate) {
  258. if (!this.inst) {
  259. this.inst = $.datepicker._getInst(this.$input[0]);
  260. }
  261. if (withDate || !this._defaults.timeOnly) {
  262. var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat');
  263. try {
  264. var parseRes = parseDateTimeInternal(dp_dateFormat, this._defaults.timeFormat, timeString, $.datepicker._getFormatConfig(this.inst), this._defaults);
  265. if (!parseRes.timeObj) {
  266. return false;
  267. }
  268. $.extend(this, parseRes.timeObj);
  269. } catch (err) {
  270. return false;
  271. }
  272. return true;
  273. } else {
  274. var timeObj = $.datepicker.parseTime(this._defaults.timeFormat, timeString, this._defaults);
  275. if (!timeObj) {
  276. return false;
  277. }
  278. $.extend(this, timeObj);
  279. return true;
  280. }
  281. },
  282. /*
  283. * generate and inject html for timepicker into ui datepicker
  284. */
  285. _injectTimePicker: function() {
  286. var $dp = this.inst.dpDiv,
  287. o = this.inst.settings,
  288. tp_inst = this,
  289. litem = '',
  290. uitem = '',
  291. max = {},
  292. gridSize = {},
  293. size = null;
  294. // Prevent displaying twice
  295. if ($dp.find("div.ui-timepicker-div").length === 0 && o.showTimepicker) {
  296. var noDisplay = ' style="display:none;"',
  297. html = '<div class="ui-timepicker-div"><dl>' + '<dt class="ui_tpicker_time_label"' + ((o.showTime) ? '' : noDisplay) + '>' + o.timeText + '</dt>' +
  298. '<dd class="ui_tpicker_time"' + ((o.showTime) ? '' : noDisplay) + '></dd>';
  299. // Create the markup
  300. for(var i=0,l=this.units.length; i<l; i++){
  301. litem = this.units[i];
  302. uitem = litem.substr(0,1).toUpperCase() + litem.substr(1);
  303. // Added by Peter Medeiros:
  304. // - Figure out what the hour/minute/second max should be based on the step values.
  305. // - Example: if stepMinute is 15, then minMax is 45.
  306. max[litem] = parseInt((o[litem+'Max'] - ((o[litem+'Max'] - o[litem+'Min']) % o['step'+uitem])), 10);
  307. gridSize[litem] = 0;
  308. html += '<dt class="ui_tpicker_'+ litem +'_label"' + ((o['show'+uitem]) ? '' : noDisplay) + '>' + o[litem +'Text'] + '</dt>' +
  309. '<dd class="ui_tpicker_'+ litem +'"><div class="ui_tpicker_'+ litem +'_slider"' + ((o['show'+uitem]) ? '' : noDisplay) + '></div>';
  310. if (o['show'+uitem] && o[litem+'Grid'] > 0) {
  311. html += '<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';
  312. if(litem == 'hour'){
  313. for (var h = o[litem+'Min']; h <= max[litem]; h += parseInt(o[litem+'Grid'], 10)) {
  314. gridSize[litem]++;
  315. var tmph = (o.ampm && h > 12) ? h - 12 : h;
  316. if (tmph < 10) {
  317. tmph = '0' + tmph;
  318. }
  319. if (o.ampm) {
  320. if (h === 0) {
  321. tmph = 12 + 'a';
  322. } else {
  323. if (h < 12) {
  324. tmph += 'a';
  325. } else {
  326. tmph += 'p';
  327. }
  328. }
  329. }
  330. html += '<td data-for="'+litem+'">' + tmph + '</td>';
  331. }
  332. }
  333. else{
  334. for (var m = o[litem+'Min']; m <= max[litem]; m += parseInt(o[litem+'Grid'], 10)) {
  335. gridSize[litem]++;
  336. html += '<td data-for="'+litem+'">' + ((m < 10) ? '0' : '') + m + '</td>';
  337. }
  338. }
  339. html += '</tr></table></div>';
  340. }
  341. html += '</dd>';
  342. }
  343. // Timezone
  344. html += '<dt class="ui_tpicker_timezone_label"' + ((o.showTimezone) ? '' : noDisplay) + '>' + o.timezoneText + '</dt>';
  345. html += '<dd class="ui_tpicker_timezone" ' + ((o.showTimezone) ? '' : noDisplay) + '></dd>';
  346. // Create the elements from string
  347. html += '</dl></div>';
  348. var $tp = $(html);
  349. // if we only want time picker...
  350. if (o.timeOnly === true) {
  351. $tp.prepend('<div class="ui-widget-header ui-helper-clearfix ui-corner-all">' + '<div class="ui-datepicker-title">' + o.timeOnlyTitle + '</div>' + '</div>');
  352. $dp.find('.ui-datepicker-header, .ui-datepicker-calendar').hide();
  353. }
  354. // Updated by Peter Medeiros:
  355. // - Pass in Event and UI instance into slide function
  356. this.hour_slider = $tp.find('.ui_tpicker_hour_slider').prop('slide', null).slider({
  357. orientation: "horizontal",
  358. value: this.hour,
  359. min: o.hourMin,
  360. max: max.hour,
  361. step: o.stepHour,
  362. slide: function(event, ui) {
  363. tp_inst.hour_slider.slider("option", "value", ui.value);
  364. tp_inst._onTimeChange();
  365. },
  366. stop: function(event, ui) {
  367. tp_inst._onSelectHandler();
  368. }
  369. });
  370. this.minute_slider = $tp.find('.ui_tpicker_minute_slider').prop('slide', null).slider({
  371. orientation: "horizontal",
  372. value: this.minute,
  373. min: o.minuteMin,
  374. max: max.minute,
  375. step: o.stepMinute,
  376. slide: function(event, ui) {
  377. tp_inst.minute_slider.slider("option", "value", ui.value);
  378. tp_inst._onTimeChange();
  379. },
  380. stop: function(event, ui) {
  381. tp_inst._onSelectHandler();
  382. }
  383. });
  384. this.second_slider = $tp.find('.ui_tpicker_second_slider').prop('slide', null).slider({
  385. orientation: "horizontal",
  386. value: this.second,
  387. min: o.secondMin,
  388. max: max.second,
  389. step: o.stepSecond,
  390. slide: function(event, ui) {
  391. tp_inst.second_slider.slider("option", "value", ui.value);
  392. tp_inst._onTimeChange();
  393. },
  394. stop: function(event, ui) {
  395. tp_inst._onSelectHandler();
  396. }
  397. });
  398. this.millisec_slider = $tp.find('.ui_tpicker_millisec_slider').prop('slide', null).slider({
  399. orientation: "horizontal",
  400. value: this.millisec,
  401. min: o.millisecMin,
  402. max: max.millisec,
  403. step: o.stepMillisec,
  404. slide: function(event, ui) {
  405. tp_inst.millisec_slider.slider("option", "value", ui.value);
  406. tp_inst._onTimeChange();
  407. },
  408. stop: function(event, ui) {
  409. tp_inst._onSelectHandler();
  410. }
  411. });
  412. // add sliders, adjust grids, add events
  413. for(var i=0,l=tp_inst.units.length; i<l; i++){
  414. litem = tp_inst.units[i];
  415. uitem = litem.substr(0,1).toUpperCase() + litem.substr(1);
  416. /*
  417. Something fishy happens when assigning to tp_inst['hour_slider'] instead of tp_inst.hour_slider, I think
  418. it is because it is assigned as a prototype. Clicking the slider will always change to the previous value
  419. not the new one clicked. Ideally this works and reduces the 80+ lines of code above
  420. // add the slider
  421. tp_inst[litem+'_slider'] = $tp.find('.ui_tpicker_'+litem+'_slider').prop('slide', null).slider({
  422. orientation: "horizontal",
  423. value: tp_inst[litem],
  424. min: o[litem+'Min'],
  425. max: max[litem],
  426. step: o['step'+uitem],
  427. slide: function(event, ui) {
  428. tp_inst[litem+'_slider'].slider("option", "value", ui.value);
  429. tp_inst._onTimeChange();
  430. },
  431. stop: function(event, ui) {
  432. //Emulate datepicker onSelect behavior. Call on slidestop.
  433. tp_inst._onSelectHandler();
  434. }
  435. });
  436. */
  437. // adjust the grid and add click event
  438. if (o['show'+uitem] && o[litem+'Grid'] > 0) {
  439. size = 100 * gridSize[litem] * o[litem+'Grid'] / (max[litem] - o[litem+'Min']);
  440. $tp.find('.ui_tpicker_'+litem+' table').css({
  441. width: size + "%",
  442. marginLeft: (size / (-2 * gridSize[litem])) + "%",
  443. borderCollapse: 'collapse'
  444. }).find("td").click(function(e){
  445. var $t = $(this),
  446. h = $t.html(),
  447. f = $t.data('for'); // loses scope, so we use data-for
  448. if (f == 'hour' && o.ampm) {
  449. var ap = h.substring(2).toLowerCase(),
  450. aph = parseInt(h.substring(0, 2), 10);
  451. if (ap == 'a') {
  452. if (aph == 12) {
  453. h = 0;
  454. } else {
  455. h = aph;
  456. }
  457. } else if (aph == 12) {
  458. h = 12;
  459. } else {
  460. h = aph + 12;
  461. }
  462. }
  463. tp_inst[f+'_slider'].slider("option", "value", parseInt(h,10));
  464. tp_inst._onTimeChange();
  465. tp_inst._onSelectHandler();
  466. })
  467. .css({
  468. cursor: 'pointer',
  469. width: (100 / gridSize[litem]) + '%',
  470. textAlign: 'center',
  471. overflow: 'hidden'
  472. });
  473. } // end if grid > 0
  474. } // end for loop
  475. // Add timezone options
  476. this.timezone_select = $tp.find('.ui_tpicker_timezone').append('<select></select>').find("select");
  477. $.fn.append.apply(this.timezone_select,
  478. $.map(o.timezoneList, function(val, idx) {
  479. return $("<option />").val(typeof val == "object" ? val.value : val).text(typeof val == "object" ? val.label : val);
  480. }));
  481. if (typeof(this.timezone) != "undefined" && this.timezone !== null && this.timezone !== "") {
  482. var local_date = new Date(this.inst.selectedYear, this.inst.selectedMonth, this.inst.selectedDay, 12);
  483. var local_timezone = $.timepicker.timeZoneOffsetString(local_date);
  484. if (local_timezone == this.timezone) {
  485. selectLocalTimeZone(tp_inst);
  486. } else {
  487. this.timezone_select.val(this.timezone);
  488. }
  489. } else {
  490. if (typeof(this.hour) != "undefined" && this.hour !== null && this.hour !== "") {
  491. this.timezone_select.val(o.defaultTimezone);
  492. } else {
  493. selectLocalTimeZone(tp_inst);
  494. }
  495. }
  496. this.timezone_select.change(function() {
  497. tp_inst._defaults.useLocalTimezone = false;
  498. tp_inst._onTimeChange();
  499. });
  500. // End timezone options
  501. // inject timepicker into datepicker
  502. var $buttonPanel = $dp.find('.ui-datepicker-buttonpane');
  503. if ($buttonPanel.length) {
  504. $buttonPanel.before($tp);
  505. } else {
  506. $dp.append($tp);
  507. }
  508. this.$timeObj = $tp.find('.ui_tpicker_time');
  509. if (this.inst !== null) {
  510. var timeDefined = this.timeDefined;
  511. this._onTimeChange();
  512. this.timeDefined = timeDefined;
  513. }
  514. // slideAccess integration: http://trentrichardson.com/2011/11/11/jquery-ui-sliders-and-touch-accessibility/
  515. if (this._defaults.addSliderAccess) {
  516. var sliderAccessArgs = this._defaults.sliderAccessArgs;
  517. setTimeout(function() { // fix for inline mode
  518. if ($tp.find('.ui-slider-access').length === 0) {
  519. $tp.find('.ui-slider:visible').sliderAccess(sliderAccessArgs);
  520. // fix any grids since sliders are shorter
  521. var sliderAccessWidth = $tp.find('.ui-slider-access:eq(0)').outerWidth(true);
  522. if (sliderAccessWidth) {
  523. $tp.find('table:visible').each(function() {
  524. var $g = $(this),
  525. oldWidth = $g.outerWidth(),
  526. oldMarginLeft = $g.css('marginLeft').toString().replace('%', ''),
  527. newWidth = oldWidth - sliderAccessWidth,
  528. newMarginLeft = ((oldMarginLeft * newWidth) / oldWidth) + '%';
  529. $g.css({
  530. width: newWidth,
  531. marginLeft: newMarginLeft
  532. });
  533. });
  534. }
  535. }
  536. }, 10);
  537. }
  538. // end slideAccess integration
  539. }
  540. },
  541. /*
  542. * This function tries to limit the ability to go outside the
  543. * min/max date range
  544. */
  545. _limitMinMaxDateTime: function(dp_inst, adjustSliders) {
  546. var o = this._defaults,
  547. dp_date = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay);
  548. if (!this._defaults.showTimepicker) {
  549. return;
  550. } // No time so nothing to check here
  551. if ($.datepicker._get(dp_inst, 'minDateTime') !== null && $.datepicker._get(dp_inst, 'minDateTime') !== undefined && dp_date) {
  552. var minDateTime = $.datepicker._get(dp_inst, 'minDateTime'),
  553. minDateTimeDate = new Date(minDateTime.getFullYear(), minDateTime.getMonth(), minDateTime.getDate(), 0, 0, 0, 0);
  554. if (this.hourMinOriginal === null || this.minuteMinOriginal === null || this.secondMinOriginal === null || this.millisecMinOriginal === null) {
  555. this.hourMinOriginal = o.hourMin;
  556. this.minuteMinOriginal = o.minuteMin;
  557. this.secondMinOriginal = o.secondMin;
  558. this.millisecMinOriginal = o.millisecMin;
  559. }
  560. if (dp_inst.settings.timeOnly || minDateTimeDate.getTime() == dp_date.getTime()) {
  561. this._defaults.hourMin = minDateTime.getHours();
  562. if (this.hour <= this._defaults.hourMin) {
  563. this.hour = this._defaults.hourMin;
  564. this._defaults.minuteMin = minDateTime.getMinutes();
  565. if (this.minute <= this._defaults.minuteMin) {
  566. this.minute = this._defaults.minuteMin;
  567. this._defaults.secondMin = minDateTime.getSeconds();
  568. if (this.second <= this._defaults.secondMin) {
  569. this.second = this._defaults.secondMin;
  570. this._defaults.millisecMin = minDateTime.getMilliseconds();
  571. } else {
  572. if (this.millisec < this._defaults.millisecMin) {
  573. this.millisec = this._defaults.millisecMin;
  574. }
  575. this._defaults.millisecMin = this.millisecMinOriginal;
  576. }
  577. } else {
  578. this._defaults.secondMin = this.secondMinOriginal;
  579. this._defaults.millisecMin = this.millisecMinOriginal;
  580. }
  581. } else {
  582. this._defaults.minuteMin = this.minuteMinOriginal;
  583. this._defaults.secondMin = this.secondMinOriginal;
  584. this._defaults.millisecMin = this.millisecMinOriginal;
  585. }
  586. } else {
  587. this._defaults.hourMin = this.hourMinOriginal;
  588. this._defaults.minuteMin = this.minuteMinOriginal;
  589. this._defaults.secondMin = this.secondMinOriginal;
  590. this._defaults.millisecMin = this.millisecMinOriginal;
  591. }
  592. }
  593. if ($.datepicker._get(dp_inst, 'maxDateTime') !== null && $.datepicker._get(dp_inst, 'maxDateTime') !== undefined && dp_date) {
  594. var maxDateTime = $.datepicker._get(dp_inst, 'maxDateTime'),
  595. maxDateTimeDate = new Date(maxDateTime.getFullYear(), maxDateTime.getMonth(), maxDateTime.getDate(), 0, 0, 0, 0);
  596. if (this.hourMaxOriginal === null || this.minuteMaxOriginal === null || this.secondMaxOriginal === null) {
  597. this.hourMaxOriginal = o.hourMax;
  598. this.minuteMaxOriginal = o.minuteMax;
  599. this.secondMaxOriginal = o.secondMax;
  600. this.millisecMaxOriginal = o.millisecMax;
  601. }
  602. if (dp_inst.settings.timeOnly || maxDateTimeDate.getTime() == dp_date.getTime()) {
  603. this._defaults.hourMax = maxDateTime.getHours();
  604. if (this.hour >= this._defaults.hourMax) {
  605. this.hour = this._defaults.hourMax;
  606. this._defaults.minuteMax = maxDateTime.getMinutes();
  607. if (this.minute >= this._defaults.minuteMax) {
  608. this.minute = this._defaults.minuteMax;
  609. this._defaults.secondMax = maxDateTime.getSeconds();
  610. } else if (this.second >= this._defaults.secondMax) {
  611. this.second = this._defaults.secondMax;
  612. this._defaults.millisecMax = maxDateTime.getMilliseconds();
  613. } else {
  614. if (this.millisec > this._defaults.millisecMax) {
  615. this.millisec = this._defaults.millisecMax;
  616. }
  617. this._defaults.millisecMax = this.millisecMaxOriginal;
  618. }
  619. } else {
  620. this._defaults.minuteMax = this.minuteMaxOriginal;
  621. this._defaults.secondMax = this.secondMaxOriginal;
  622. this._defaults.millisecMax = this.millisecMaxOriginal;
  623. }
  624. } else {
  625. this._defaults.hourMax = this.hourMaxOriginal;
  626. this._defaults.minuteMax = this.minuteMaxOriginal;
  627. this._defaults.secondMax = this.secondMaxOriginal;
  628. this._defaults.millisecMax = this.millisecMaxOriginal;
  629. }
  630. }
  631. if (adjustSliders !== undefined && adjustSliders === true) {
  632. var hourMax = parseInt((this._defaults.hourMax - ((this._defaults.hourMax - this._defaults.hourMin) % this._defaults.stepHour)), 10),
  633. minMax = parseInt((this._defaults.minuteMax - ((this._defaults.minuteMax - this._defaults.minuteMin) % this._defaults.stepMinute)), 10),
  634. secMax = parseInt((this._defaults.secondMax - ((this._defaults.secondMax - this._defaults.secondMin) % this._defaults.stepSecond)), 10),
  635. millisecMax = parseInt((this._defaults.millisecMax - ((this._defaults.millisecMax - this._defaults.millisecMin) % this._defaults.stepMillisec)), 10);
  636. if (this.hour_slider) {
  637. this.hour_slider.slider("option", {
  638. min: this._defaults.hourMin,
  639. max: hourMax
  640. }).slider('value', this.hour);
  641. }
  642. if (this.minute_slider) {
  643. this.minute_slider.slider("option", {
  644. min: this._defaults.minuteMin,
  645. max: minMax
  646. }).slider('value', this.minute);
  647. }
  648. if (this.second_slider) {
  649. this.second_slider.slider("option", {
  650. min: this._defaults.secondMin,
  651. max: secMax
  652. }).slider('value', this.second);
  653. }
  654. if (this.millisec_slider) {
  655. this.millisec_slider.slider("option", {
  656. min: this._defaults.millisecMin,
  657. max: millisecMax
  658. }).slider('value', this.millisec);
  659. }
  660. }
  661. },
  662. /*
  663. * when a slider moves, set the internal time...
  664. * on time change is also called when the time is updated in the text field
  665. */
  666. _onTimeChange: function() {
  667. var hour = (this.hour_slider) ? this.hour_slider.slider('value') : false,
  668. minute = (this.minute_slider) ? this.minute_slider.slider('value') : false,
  669. second = (this.second_slider) ? this.second_slider.slider('value') : false,
  670. millisec = (this.millisec_slider) ? this.millisec_slider.slider('value') : false,
  671. timezone = (this.timezone_select) ? this.timezone_select.val() : false,
  672. o = this._defaults;
  673. if (typeof(hour) == 'object') {
  674. hour = false;
  675. }
  676. if (typeof(minute) == 'object') {
  677. minute = false;
  678. }
  679. if (typeof(second) == 'object') {
  680. second = false;
  681. }
  682. if (typeof(millisec) == 'object') {
  683. millisec = false;
  684. }
  685. if (typeof(timezone) == 'object') {
  686. timezone = false;
  687. }
  688. if (hour !== false) {
  689. hour = parseInt(hour, 10);
  690. }
  691. if (minute !== false) {
  692. minute = parseInt(minute, 10);
  693. }
  694. if (second !== false) {
  695. second = parseInt(second, 10);
  696. }
  697. if (millisec !== false) {
  698. millisec = parseInt(millisec, 10);
  699. }
  700. var ampm = o[hour < 12 ? 'amNames' : 'pmNames'][0];
  701. // If the update was done in the input field, the input field should not be updated.
  702. // If the update was done using the sliders, update the input field.
  703. var hasChanged = (hour != this.hour || minute != this.minute || second != this.second || millisec != this.millisec
  704. || (this.ampm.length > 0 && (hour < 12) != ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1))
  705. || ((this.timezone === null && timezone != this.defaultTimezone) || (this.timezone !== null && timezone != this.timezone)));
  706. if (hasChanged) {
  707. if (hour !== false) {
  708. this.hour = hour;
  709. }
  710. if (minute !== false) {
  711. this.minute = minute;
  712. }
  713. if (second !== false) {
  714. this.second = second;
  715. }
  716. if (millisec !== false) {
  717. this.millisec = millisec;
  718. }
  719. if (timezone !== false) {
  720. this.timezone = timezone;
  721. }
  722. if (!this.inst) {
  723. this.inst = $.datepicker._getInst(this.$input[0]);
  724. }
  725. this._limitMinMaxDateTime(this.inst, true);
  726. }
  727. if (o.ampm) {
  728. this.ampm = ampm;
  729. }
  730. //this._formatTime();
  731. this.formattedTime = $.datepicker.formatTime(this._defaults.timeFormat, this, this._defaults);
  732. if (this.$timeObj) {
  733. this.$timeObj.text(this.formattedTime + o.timeSuffix);
  734. }
  735. this.timeDefined = true;
  736. if (hasChanged) {
  737. this._updateDateTime();
  738. }
  739. },
  740. /*
  741. * call custom onSelect.
  742. * bind to sliders slidestop, and grid click.
  743. */
  744. _onSelectHandler: function() {
  745. var onSelect = this._defaults.onSelect || this.inst.settings.onSelect;
  746. var inputEl = this.$input ? this.$input[0] : null;
  747. if (onSelect && inputEl) {
  748. onSelect.apply(inputEl, [this.formattedDateTime, this]);
  749. }
  750. },
  751. /*
  752. * left for any backwards compatibility
  753. */
  754. _formatTime: function(time, format) {
  755. time = time || {
  756. hour: this.hour,
  757. minute: this.minute,
  758. second: this.second,
  759. millisec: this.millisec,
  760. ampm: this.ampm,
  761. timezone: this.timezone
  762. };
  763. var tmptime = (format || this._defaults.timeFormat).toString();
  764. tmptime = $.datepicker.formatTime(tmptime, time, this._defaults);
  765. if (arguments.length) {
  766. return tmptime;
  767. } else {
  768. this.formattedTime = tmptime;
  769. }
  770. },
  771. /*
  772. * update our input with the new date time..
  773. */
  774. _updateDateTime: function(dp_inst) {
  775. dp_inst = this.inst || dp_inst;
  776. var dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
  777. dateFmt = $.datepicker._get(dp_inst, 'dateFormat'),
  778. formatCfg = $.datepicker._getFormatConfig(dp_inst),
  779. timeAvailable = dt !== null && this.timeDefined;
  780. this.formattedDate = $.datepicker.formatDate(dateFmt, (dt === null ? new Date() : dt), formatCfg);
  781. var formattedDateTime = this.formattedDate;
  782. /*
  783. * remove following lines to force every changes in date picker to change the input value
  784. * Bug descriptions: when an input field has a default value, and click on the field to pop up the date picker.
  785. * If the user manually empty the value in the input field, the date picker will never change selected value.
  786. */
  787. //if (dp_inst.lastVal !== undefined && (dp_inst.lastVal.length > 0 && this.$input.val().length === 0)) {
  788. // return;
  789. //}
  790. if (this._defaults.timeOnly === true) {
  791. formattedDateTime = this.formattedTime;
  792. } else if (this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) {
  793. formattedDateTime += this._defaults.separator + this.formattedTime + this._defaults.timeSuffix;
  794. }
  795. this.formattedDateTime = formattedDateTime;
  796. if (!this._defaults.showTimepicker) {
  797. this.$input.val(this.formattedDate);
  798. } else if (this.$altInput && this._defaults.altFieldTimeOnly === true) {
  799. this.$altInput.val(this.formattedTime);
  800. this.$input.val(this.formattedDate);
  801. } else if (this.$altInput) {
  802. this.$input.val(formattedDateTime);
  803. var altFormattedDateTime = '',
  804. altSeparator = this._defaults.altSeparator ? this._defaults.altSeparator : this._defaults.separator,
  805. altTimeSuffix = this._defaults.altTimeSuffix ? this._defaults.altTimeSuffix : this._defaults.timeSuffix;
  806. if (this._defaults.altFormat) altFormattedDateTime = $.datepicker.formatDate(this._defaults.altFormat, (dt === null ? new Date() : dt), formatCfg);
  807. else altFormattedDateTime = this.formattedDate;
  808. if (altFormattedDateTime) altFormattedDateTime += altSeparator;
  809. if (this._defaults.altTimeFormat) altFormattedDateTime += $.datepicker.formatTime(this._defaults.altTimeFormat, this, this._defaults) + altTimeSuffix;
  810. else altFormattedDateTime += this.formattedTime + altTimeSuffix;
  811. this.$altInput.val(altFormattedDateTime);
  812. } else {
  813. this.$input.val(formattedDateTime);
  814. }
  815. this.$input.trigger("change");
  816. },
  817. _onFocus: function() {
  818. if (!this.$input.val() && this._defaults.defaultValue) {
  819. this.$input.val(this._defaults.defaultValue);
  820. var inst = $.datepicker._getInst(this.$input.get(0)),
  821. tp_inst = $.datepicker._get(inst, 'timepicker');
  822. if (tp_inst) {
  823. if (tp_inst._defaults.timeOnly && (inst.input.val() != inst.lastVal)) {
  824. try {
  825. $.datepicker._updateDatepicker(inst);
  826. } catch (err) {
  827. $.datepicker.log(err);
  828. }
  829. }
  830. }
  831. }
  832. }
  833. });
  834. $.fn.extend({
  835. /*
  836. * shorthand just to use timepicker..
  837. */
  838. timepicker: function(o) {
  839. o = o || {};
  840. var tmp_args = Array.prototype.slice.call(arguments);
  841. if (typeof o == 'object') {
  842. tmp_args[0] = $.extend(o, {
  843. timeOnly: true
  844. });
  845. }
  846. return $(this).each(function() {
  847. $.fn.datetimepicker.apply($(this), tmp_args);
  848. });
  849. },
  850. /*
  851. * extend timepicker to datepicker
  852. */
  853. datetimepicker: function(o) {
  854. o = o || {};
  855. var tmp_args = arguments;
  856. if (typeof(o) == 'string') {
  857. if (o == 'getDate') {
  858. return $.fn.datepicker.apply($(this[0]), tmp_args);
  859. } else {
  860. return this.each(function() {
  861. var $t = $(this);
  862. $t.datepicker.apply($t, tmp_args);
  863. });
  864. }
  865. } else {
  866. return this.each(function() {
  867. var $t = $(this);
  868. $t.datepicker($.timepicker._newInst($t, o)._defaults);
  869. });
  870. }
  871. }
  872. });
  873. /*
  874. * Public Utility to parse date and time
  875. */
  876. $.datepicker.parseDateTime = function(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings) {
  877. var parseRes = parseDateTimeInternal(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings);
  878. if (parseRes.timeObj) {
  879. var t = parseRes.timeObj;
  880. parseRes.date.setHours(t.hour, t.minute, t.second, t.millisec);
  881. }
  882. return parseRes.date;
  883. };
  884. /*
  885. * Public utility to parse time
  886. */
  887. $.datepicker.parseTime = function(timeFormat, timeString, options) {
  888. // pattern for standard and localized AM/PM markers
  889. var getPatternAmpm = function(amNames, pmNames) {
  890. var markers = [];
  891. if (amNames) {
  892. $.merge(markers, amNames);
  893. }
  894. if (pmNames) {
  895. $.merge(markers, pmNames);
  896. }
  897. markers = $.map(markers, function(val) {
  898. return val.replace(/[.*+?|()\[\]{}\\]/g, '\\$&');
  899. });
  900. return '(' + markers.join('|') + ')?';
  901. };
  902. // figure out position of time elements.. cause js cant do named captures
  903. var getFormatPositions = function(timeFormat) {
  904. var finds = timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|l{1}|t{1,2}|z)/g),
  905. orders = {
  906. h: -1,
  907. m: -1,
  908. s: -1,
  909. l: -1,
  910. t: -1,
  911. z: -1
  912. };
  913. if (finds) {
  914. for (var i = 0; i < finds.length; i++) {
  915. if (orders[finds[i].toString().charAt(0)] == -1) {
  916. orders[finds[i].toString().charAt(0)] = i + 1;
  917. }
  918. }
  919. }
  920. return orders;
  921. };
  922. var o = extendRemove(extendRemove({}, $.timepicker._defaults), options || {});
  923. var regstr = '^' + timeFormat.toString()
  924. .replace(/h{1,2}/ig, '(\\d?\\d)')
  925. .replace(/m{1,2}/ig, '(\\d?\\d)')
  926. .replace(/s{1,2}/ig, '(\\d?\\d)')
  927. .replace(/l{1}/ig, '(\\d?\\d?\\d)')
  928. .replace(/t{1,2}/ig, getPatternAmpm(o.amNames, o.pmNames))
  929. .replace(/z{1}/ig, '(z|[-+]\\d\\d:?\\d\\d|\\S+)?')
  930. .replace(/\s/g, '\\s?') +
  931. o.timeSuffix + '$',
  932. order = getFormatPositions(timeFormat),
  933. ampm = '',
  934. treg;
  935. treg = timeString.match(new RegExp(regstr, 'i'));
  936. var resTime = {
  937. hour: 0,
  938. minute: 0,
  939. second: 0,
  940. millisec: 0
  941. };
  942. if (treg) {
  943. if (order.t !== -1) {
  944. if (treg[order.t] === undefined || treg[order.t].length === 0) {
  945. ampm = '';
  946. resTime.ampm = '';
  947. } else {
  948. ampm = $.inArray(treg[order.t].toUpperCase(), o.amNames) !== -1 ? 'AM' : 'PM';
  949. resTime.ampm = o[ampm == 'AM' ? 'amNames' : 'pmNames'][0];
  950. }
  951. }
  952. if (order.h !== -1) {
  953. if (ampm == 'AM' && treg[order.h] == '12') {
  954. resTime.hour = 0; // 12am = 0 hour
  955. } else {
  956. if (ampm == 'PM' && treg[order.h] != '12') {
  957. resTime.hour = parseInt(treg[order.h], 10) + 12; // 12pm = 12 hour, any other pm = hour + 12
  958. } else {
  959. resTime.hour = Number(treg[order.h]);
  960. }
  961. }
  962. }
  963. if (order.m !== -1) {
  964. resTime.minute = Number(treg[order.m]);
  965. }
  966. if (order.s !== -1) {
  967. resTime.second = Number(treg[order.s]);
  968. }
  969. if (order.l !== -1) {
  970. resTime.millisec = Number(treg[order.l]);
  971. }
  972. if (order.z !== -1 && treg[order.z] !== undefined) {
  973. var tz = treg[order.z].toUpperCase();
  974. switch (tz.length) {
  975. case 1:
  976. // Z
  977. tz = o.timezoneIso8601 ? 'Z' : '+0000';
  978. break;
  979. case 5:
  980. // +hhmm
  981. if (o.timezoneIso8601) {
  982. tz = tz.substring(1) == '0000' ? 'Z' : tz.substring(0, 3) + ':' + tz.substring(3);
  983. }
  984. break;
  985. case 6:
  986. // +hh:mm
  987. if (!o.timezoneIso8601) {
  988. tz = tz == 'Z' || tz.substring(1) == '00:00' ? '+0000' : tz.replace(/:/, '');
  989. } else {
  990. if (tz.substring(1) == '00:00') {
  991. tz = 'Z';
  992. }
  993. }
  994. break;
  995. }
  996. resTime.timezone = tz;
  997. }
  998. return resTime;
  999. }
  1000. return false;
  1001. };
  1002. /*
  1003. * Public utility to format the time
  1004. * format = string format of the time
  1005. * time = a {}, not a Date() for timezones
  1006. * options = essentially the regional[].. amNames, pmNames, ampm
  1007. */
  1008. $.datepicker.formatTime = function(format, time, options) {
  1009. options = options || {};
  1010. options = $.extend({}, $.timepicker._defaults, options);
  1011. time = $.extend({
  1012. hour: 0,
  1013. minute: 0,
  1014. second: 0,
  1015. millisec: 0,
  1016. timezone: '+0000'
  1017. }, time);
  1018. var tmptime = format;
  1019. var ampmName = options.amNames[0];
  1020. var hour = parseInt(time.hour, 10);
  1021. if (options.ampm) {
  1022. if (hour > 11) {
  1023. ampmName = options.pmNames[0];
  1024. if (hour > 12) {
  1025. hour = hour % 12;
  1026. }
  1027. }
  1028. if (hour === 0) {
  1029. hour = 12;
  1030. }
  1031. }
  1032. tmptime = tmptime.replace(/(?:hh?|mm?|ss?|[tT]{1,2}|[lz]|('.*?'|".*?"))/g, function(match) {
  1033. switch (match.toLowerCase()) {
  1034. case 'hh':
  1035. return ('0' + hour).slice(-2);
  1036. case 'h':
  1037. return hour;
  1038. case 'mm':
  1039. return ('0' + time.minute).slice(-2);
  1040. case 'm':
  1041. return time.minute;
  1042. case 'ss':
  1043. return ('0' + time.second).slice(-2);
  1044. case 's':
  1045. return time.second;
  1046. case 'l':
  1047. return ('00' + time.millisec).slice(-3);
  1048. case 'z':
  1049. return time.timezone === null? options.defaultTimezone : time.timezone;
  1050. case 't':
  1051. case 'tt':
  1052. if (options.ampm) {
  1053. if (match.length == 1) {
  1054. ampmName = ampmName.charAt(0);
  1055. }
  1056. return match.charAt(0) === 'T' ? ampmName.toUpperCase() : ampmName.toLowerCase();
  1057. }
  1058. return '';
  1059. default:
  1060. return match.replace(/\'/g, "") || "'";
  1061. }
  1062. });
  1063. tmptime = $.trim(tmptime);
  1064. return tmptime;
  1065. };
  1066. /*
  1067. * the bad hack :/ override datepicker so it doesnt close on select
  1068. // inspired: http://stackoverflow.com/questions/1252512/jquery-datepicker-prevent-closing-picker-when-clicking-a-date/1762378#1762378
  1069. */
  1070. $.datepicker._base_selectDate = $.datepicker._selectDate;
  1071. $.datepicker._selectDate = function(id, dateStr) {
  1072. var inst = this._getInst($(id)[0]),
  1073. tp_inst = this._get(inst, 'timepicker');
  1074. if (tp_inst) {
  1075. tp_inst._limitMinMaxDateTime(inst, true);
  1076. inst.inline = inst.stay_open = true;
  1077. //This way the onSelect handler called from calendarpicker get the full dateTime
  1078. this._base_selectDate(id, dateStr);
  1079. inst.inline = inst.stay_open = false;
  1080. this._notifyChange(inst);
  1081. this._updateDatepicker(inst);
  1082. } else {
  1083. this._base_selectDate(id, dateStr);
  1084. }
  1085. };
  1086. /*
  1087. * second bad hack :/ override datepicker so it triggers an event when changing the input field
  1088. * and does not redraw the datepicker on every selectDate event
  1089. */
  1090. $.datepicker._base_updateDatepicker = $.datepicker._updateDatepicker;
  1091. $.datepicker._updateDatepicker = function(inst) {
  1092. // don't popup the datepicker if there is another instance already opened
  1093. var input = inst.input[0];
  1094. if ($.datepicker._curInst && $.datepicker._curInst != inst && $.datepicker._datepickerShowing && $.datepicker._lastInput != input) {
  1095. return;
  1096. }
  1097. if (typeof(inst.stay_open) !== 'boolean' || inst.stay_open === false) {
  1098. this._base_updateDatepicker(inst);
  1099. // Reload the time control when changing something in the input text field.
  1100. var tp_inst = this._get(inst, 'timepicker');
  1101. if (tp_inst) {
  1102. tp_inst._addTimePicker(inst);
  1103. if (tp_inst._defaults.useLocalTimezone) { //checks daylight saving with the new date.
  1104. var date = new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay, 12);
  1105. selectLocalTimeZone(tp_inst, date);
  1106. tp_inst._onTimeChange();
  1107. }
  1108. }
  1109. }
  1110. };
  1111. /*
  1112. * third bad hack :/ override datepicker so it allows spaces and colon in the input field
  1113. */
  1114. $.datepicker._base_doKeyPress = $.datepicker._doKeyPress;
  1115. $.datepicker._doKeyPress = function(event) {
  1116. var inst = $.datepicker._getInst(event.target),
  1117. tp_inst = $.datepicker._get(inst, 'timepicker');
  1118. if (tp_inst) {
  1119. if ($.datepicker._get(inst, 'constrainInput')) {
  1120. var ampm = tp_inst._defaults.ampm,
  1121. dateChars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')),
  1122. datetimeChars = tp_inst._defaults.timeFormat.toString()
  1123. .replace(/[hms]/g, '')
  1124. .replace(/TT/g, ampm ? 'APM' : '')
  1125. .replace(/Tt/g, ampm ? 'AaPpMm' : '')
  1126. .replace(/tT/g, ampm ? 'AaPpMm' : '')
  1127. .replace(/T/g, ampm ? 'AP' : '')
  1128. .replace(/tt/g, ampm ? 'apm' : '')
  1129. .replace(/t/g, ampm ? 'ap' : '') +
  1130. " " + tp_inst._defaults.separator +
  1131. tp_inst._defaults.timeSuffix +
  1132. (tp_inst._defaults.showTimezone ? tp_inst._defaults.timezoneList.join('') : '') +
  1133. (tp_inst._defaults.amNames.join('')) + (tp_inst._defaults.pmNames.join('')) +
  1134. dateChars,
  1135. chr = String.fromCharCode(event.charCode === undefined ? event.keyCode : event.charCode);
  1136. return event.ctrlKey || (chr < ' ' || !dateChars || datetimeChars.indexOf(chr) > -1);
  1137. }
  1138. }
  1139. return $.datepicker._base_doKeyPress(event);
  1140. };
  1141. /*
  1142. * Override key up event to sync manual input changes.
  1143. */
  1144. $.datepicker._base_doKeyUp = $.datepicker._doKeyUp;
  1145. $.datepicker._doKeyUp = function(event) {
  1146. var inst = $.datepicker._getInst(event.target),
  1147. tp_inst = $.datepicker._get(inst, 'timepicker');
  1148. if (tp_inst) {
  1149. if (tp_inst._defaults.timeOnly && (inst.input.val() != inst.lastVal)) {
  1150. try {
  1151. $.datepicker._updateDatepicker(inst);
  1152. } catch (err) {
  1153. $.datepicker.log(err);
  1154. }
  1155. }
  1156. }
  1157. return $.datepicker._base_doKeyUp(event);
  1158. };
  1159. /*
  1160. * override "Today" button to also grab the time.
  1161. */
  1162. $.datepicker._base_gotoToday = $.datepicker._gotoToday;
  1163. $.datepicker._gotoToday = function(id) {
  1164. var inst = this._getInst($(id)[0]),
  1165. $dp = inst.dpDiv;
  1166. this._base_gotoToday(id);
  1167. var tp_inst = this._get(inst, 'timepicker');
  1168. selectLocalTimeZone(tp_inst);
  1169. var now = new Date();
  1170. this._setTime(inst, now);
  1171. $('.ui-datepicker-today', $dp).click();
  1172. };
  1173. /*
  1174. * Disable & enable the Time in the datetimepicker
  1175. */
  1176. $.datepicker._disableTimepickerDatepicker = function(target) {
  1177. var inst = this._getInst(target);
  1178. if (!inst) {
  1179. return;
  1180. }
  1181. var tp_inst = this._get(inst, 'timepicker');
  1182. $(target).datepicker('getDate'); // Init selected[Year|Month|Day]
  1183. if (tp_inst) {
  1184. tp_inst._defaults.showTimepicker = false;
  1185. tp_inst._updateDateTime(inst);
  1186. }
  1187. };
  1188. $.datepicker._enableTimepickerDatepicker = function(target) {
  1189. var inst = this._getInst(target);
  1190. if (!inst) {
  1191. return;
  1192. }
  1193. var tp_inst = this._get(inst, 'timepicker');
  1194. $(target).datepicker('getDate'); // Init selected[Year|Month|Day]
  1195. if (tp_inst) {
  1196. tp_inst._defaults.showTimepicker = true;
  1197. tp_inst._addTimePicker(inst); // Could be disabled on page load
  1198. tp_inst._updateDateTime(inst);
  1199. }
  1200. };
  1201. /*
  1202. * Create our own set time function
  1203. */
  1204. $.datepicker._setTime = function(inst, date) {
  1205. var tp_inst = this._get(inst, 'timepicker');
  1206. if (tp_inst) {
  1207. var defaults = tp_inst._defaults;
  1208. // calling _setTime with no date sets time to defaults
  1209. tp_inst.hour = date ? date.getHours() : defaults.hour;
  1210. tp_inst.minute = date ? date.getMinutes() : defaults.minute;
  1211. tp_inst.second = date ? date.getSeconds() : defaults.second;
  1212. tp_inst.millisec = date ? date.getMilliseconds() : defaults.millisec;
  1213. //check if within min/max times..
  1214. tp_inst._limitMinMaxDateTime(inst, true);
  1215. tp_inst._onTimeChange();
  1216. tp_inst._updateDateTime(inst);
  1217. }
  1218. };
  1219. /*
  1220. * Create new public method to set only time, callable as $().datepicker('setTime', date)
  1221. */
  1222. $.datepicker._setTimeDatepicker = function(target, date, withDate) {
  1223. var inst = this._getInst(target);
  1224. if (!inst) {
  1225. return;
  1226. }
  1227. var tp_inst = this._get(inst, 'timepicker');
  1228. if (tp_inst) {
  1229. this._setDateFromField(inst);
  1230. var tp_date;
  1231. if (date) {
  1232. if (typeof date == "string") {
  1233. tp_inst._parseTime(date, withDate);
  1234. tp_date = new Date();
  1235. tp_date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
  1236. } else {
  1237. tp_date = new Date(date.getTime());
  1238. }
  1239. if (tp_date.toString() == 'Invalid Date') {
  1240. tp_date = undefined;
  1241. }
  1242. this._setTime(inst, tp_date);
  1243. }
  1244. }
  1245. };
  1246. /*
  1247. * override setDate() to allow setting time too within Date object
  1248. */
  1249. $.datepicker._base_setDateDatepicker = $.datepicker._setDateDatepicker;
  1250. $.datepicker._setDateDatepicker = function(target, date) {
  1251. var inst = this._getInst(target);
  1252. if (!inst) {
  1253. return;
  1254. }
  1255. var tp_date = (date instanceof Date) ? new Date(date.getTime()) : date;
  1256. this._updateDatepicker(inst);
  1257. this._base_setDateDatepicker.apply(this, arguments);
  1258. this._setTimeDatepicker(target, tp_date, true);
  1259. };
  1260. /*
  1261. * override getDate() to allow getting time too within Date object
  1262. */
  1263. $.datepicker._base_getDateDatepicker = $.datepicker._getDateDatepicker;
  1264. $.datepicker._getDateDatepicker = function(target, noDefault) {
  1265. var inst = this._getInst(target);
  1266. if (!inst) {
  1267. return;
  1268. }
  1269. var tp_inst = this._get(inst, 'timepicker');
  1270. if (tp_inst) {
  1271. // if it hasn't yet been defined, grab from field
  1272. if(inst.lastVal === undefined){
  1273. this._setDateFromField(inst, noDefault);
  1274. }
  1275. var date = this._getDate(inst);
  1276. if (date && tp_inst._parseTime($(target).val(), tp_inst.timeOnly)) {
  1277. date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
  1278. }
  1279. return date;
  1280. }
  1281. return this._base_getDateDatepicker(target, noDefault);
  1282. };
  1283. /*
  1284. * override parseDate() because UI 1.8.14 throws an error about "Extra characters"
  1285. * An option in datapicker to ignore extra format characters would be nicer.
  1286. */
  1287. $.datepicker._base_parseDate = $.datepicker.parseDate;
  1288. $.datepicker.parseDate = function(format, value, settings) {
  1289. var date;
  1290. try {
  1291. date = this._base_parseDate(format, value, settings);
  1292. } catch (err) {
  1293. // Hack! The error message ends with a colon, a space, and
  1294. // the "extra" characters. We rely on that instead of
  1295. // attempting to perfectly reproduce the parsing algorithm.
  1296. date = this._base_parseDate(format, value.substring(0,value.length-(err.length-err.indexOf(':')-2)), settings);
  1297. }
  1298. return date;
  1299. };
  1300. /*
  1301. * override formatDate to set date with time to the input
  1302. */
  1303. $.datepicker._base_formatDate = $.datepicker._formatDate;
  1304. $.datepicker._formatDate = function(inst, day, month, year) {
  1305. var tp_inst = this._get(inst, 'timepicker');
  1306. if (tp_inst) {
  1307. tp_inst._updateDateTime(inst);
  1308. return tp_inst.$input.val();
  1309. }
  1310. return this._base_formatDate(inst);
  1311. };
  1312. /*
  1313. * override options setter to add time to maxDate(Time) and minDate(Time). MaxDate
  1314. */
  1315. $.datepicker._base_optionDatepicker = $.datepicker._optionDatepicker;
  1316. $.datepicker._optionDatepicker = function(target, name, value) {
  1317. var inst = this._getInst(target);
  1318. if (!inst) {
  1319. return null;
  1320. }
  1321. var tp_inst = this._get(inst, 'timepicker');
  1322. if (tp_inst) {
  1323. var min = null,
  1324. max = null,
  1325. onselect = null;
  1326. if (typeof name == 'string') { // if min/max was set with the string
  1327. if (name === 'minDate' || name === 'minDateTime') {
  1328. min = value;
  1329. } else {
  1330. if (name === 'maxDate' || name === 'maxDateTime') {
  1331. max = value;
  1332. } else {
  1333. if (name === 'onSelect') {
  1334. onselect = value;
  1335. }
  1336. }
  1337. }
  1338. } else {
  1339. if (typeof name == 'object') { //if min/max was set with the JSON
  1340. if (name.minDate) {
  1341. min = name.minDate;
  1342. } else {
  1343. if (name.minDateTime) {
  1344. min = name.minDateTime;
  1345. } else {
  1346. if (name.maxDate) {
  1347. max = name.maxDate;
  1348. } else {
  1349. if (name.maxDateTime) {
  1350. max = name.maxDateTime;
  1351. }
  1352. }
  1353. }
  1354. }
  1355. }
  1356. }
  1357. if (min) { //if min was set
  1358. if (min === 0) {
  1359. min = new Date();
  1360. } else {
  1361. min = new Date(min);
  1362. }
  1363. tp_inst._defaults.minDate = min;
  1364. tp_inst._defaults.minDateTime = min;
  1365. } else if (max) { //if max was set
  1366. if (max === 0) {
  1367. max = new Date();
  1368. } else {
  1369. max = new Date(max);
  1370. }
  1371. tp_inst._defaults.maxDate = max;
  1372. tp_inst._defaults.maxDateTime = max;
  1373. } else if (onselect) {
  1374. tp_inst._defaults.onSelect = onselect;
  1375. }
  1376. }
  1377. if (value === undefined) {
  1378. return this._base_optionDatepicker(target, name);
  1379. }
  1380. return this._base_optionDatepicker(target, name, value);
  1381. };
  1382. /*
  1383. * jQuery extend now ignores nulls!
  1384. */
  1385. function extendRemove(target, props) {
  1386. $.extend(target, props);
  1387. for (var name in props) {
  1388. if (props[name] === null || props[name] === undefined) {
  1389. target[name] = props[name];
  1390. }
  1391. }
  1392. return target;
  1393. }
  1394. /*
  1395. * Splits datetime string into date ans time substrings.
  1396. * Throws exception when date can't be parsed
  1397. * Returns [dateString, timeString]
  1398. */
  1399. var splitDateTime = function(dateFormat, dateTimeString, dateSettings, timeSettings) {
  1400. try {
  1401. // The idea is to get the number separator occurances in datetime and the time format requested (since time has
  1402. // fewer unknowns, mostly numbers and am/pm). We will use the time pattern to split.
  1403. var separator = timeSettings && timeSettings.separator ? timeSettings.separator : $.timepicker._defaults.separator,
  1404. format = timeSettings && timeSettings.timeFormat ? timeSettings.timeFormat : $.timepicker._defaults.timeFormat,
  1405. ampm = timeSettings && timeSettings.ampm ? timeSettings.ampm : $.timepicker._defaults.ampm,
  1406. timeParts = format.split(separator), // how many occurances of separator may be in our format?
  1407. timePartsLen = timeParts.length,
  1408. allParts = dateTimeString.split(separator),
  1409. allPartsLen = allParts.length;
  1410. // because our default ampm=false, but our default format has tt, we need to filter this out
  1411. if(!ampm){
  1412. timeParts = $.trim(format.replace(/t/gi,'')).split(separator);
  1413. timePartsLen = timeParts.length;
  1414. }
  1415. if (allPartsLen > 1) {
  1416. return [
  1417. allParts.splice(0,allPartsLen-timePartsLen).join(separator),
  1418. allParts.splice(0,timePartsLen).join(separator)
  1419. ];
  1420. }
  1421. } catch (err) {
  1422. if (err.indexOf(":") >= 0) {
  1423. // Hack! The error message ends with a colon, a space, and
  1424. // the "extra" characters. We rely on that instead of
  1425. // attempting to perfectly reproduce the parsing algorithm.
  1426. var dateStringLength = dateTimeString.length - (err.length - err.indexOf(':') - 2),
  1427. timeString = dateTimeString.substring(dateStringLength);
  1428. return [$.trim(dateTimeString.substring(0, dateStringLength)), $.trim(dateTimeString.substring(dateStringLength))];
  1429. } else {
  1430. throw err;
  1431. }
  1432. }
  1433. return [dateTimeString, ''];
  1434. };
  1435. /*
  1436. * Internal function to parse datetime interval
  1437. * Returns: {date: Date, timeObj: Object}, where
  1438. * date - parsed date without time (type Date)
  1439. * timeObj = {hour: , minute: , second: , millisec: } - parsed time. Optional
  1440. */
  1441. var parseDateTimeInternal = function(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings) {
  1442. var date;
  1443. var splitRes = splitDateTime(dateFormat, dateTimeString, dateSettings, timeSettings);
  1444. date = $.datepicker._base_parseDate(dateFormat, splitRes[0], dateSettings);
  1445. if (splitRes[1] !== '') {
  1446. var timeString = splitRes[1],
  1447. parsedTime = $.datepicker.parseTime(timeFormat, timeString, timeSettings);
  1448. if (parsedTime === null) {
  1449. throw 'Wrong time format';
  1450. }
  1451. return {
  1452. date: date,
  1453. timeObj: parsedTime
  1454. };
  1455. } else {
  1456. return {
  1457. date: date
  1458. };
  1459. }
  1460. };
  1461. /*
  1462. * Internal function to set timezone_select to the local timezone
  1463. */
  1464. var selectLocalTimeZone = function(tp_inst, date) {
  1465. if (tp_inst && tp_inst.timezone_select) {
  1466. tp_inst._defaults.useLocalTimezone = true;
  1467. var now = typeof date !== 'undefined' ? date : new Date();
  1468. var tzoffset = $.timepicker.timeZoneOffsetString(now);
  1469. if (tp_inst._defaults.timezoneIso8601) {
  1470. tzoffset = tzoffset.substring(0, 3) + ':' + tzoffset.substring(3);
  1471. }
  1472. tp_inst.timezone_select.val(tzoffset);
  1473. }
  1474. };
  1475. /*
  1476. * Create a Singleton Insance
  1477. */
  1478. $.timepicker = new Timepicker();
  1479. /**
  1480. * Get the timezone offset as string from a date object (eg '+0530' for UTC+5.5)
  1481. * @param date
  1482. * @return string
  1483. */
  1484. $.timepicker.timeZoneOffsetString = function(date) {
  1485. var off = date.getTimezoneOffset() * -1,
  1486. minutes = off % 60,
  1487. hours = (off - minutes) / 60;
  1488. return (off >= 0 ? '+' : '-') + ('0' + (hours * 101).toString()).substr(-2) + ('0' + (minutes * 101).toString()).substr(-2);
  1489. };
  1490. /**
  1491. * Calls `timepicker()` on the `startTime` and `endTime` elements, and configures them to
  1492. * enforce date range limits.
  1493. * n.b. The input value must be correctly formatted (reformatting is not supported)
  1494. * @param Element startTime
  1495. * @param Element endTime
  1496. * @param obj options Options for the timepicker() call
  1497. * @return jQuery
  1498. */
  1499. $.timepicker.timeRange = function(startTime, endTime, options) {
  1500. return $.timepicker.handleRange('timepicker', startTime, endTime, options);
  1501. };
  1502. /**
  1503. * Calls `datetimepicker` on the `startTime` and `endTime` elements, and configures them to
  1504. * enforce date range limits.
  1505. * @param Element startTime
  1506. * @param Element endTime
  1507. * @param obj options Options for the `timepicker()` call. Also supports `reformat`,
  1508. * a boolean value that can be used to reformat the input values to the `dateFormat`.
  1509. * @param string method Can be used to specify the type of picker to be added
  1510. * @return jQuery
  1511. */
  1512. $.timepicker.dateTimeRange = function(startTime, endTime, options) {
  1513. $.timepicker.dateRange(startTime, endTime, options, 'datetimepicker');
  1514. };
  1515. /**
  1516. * Calls `method` on the `startTime` and `endTime` elements, and configures them to
  1517. * enforce date range limits.
  1518. * @param Element startTime
  1519. * @param Element endTime
  1520. * @param obj options Options for the `timepicker()` call. Also supports `reformat`,
  1521. * a boolean value that can be used to reformat the input values to the `dateFormat`.
  1522. * @param string method Can be used to specify the type of picker to be added
  1523. * @return jQuery
  1524. */
  1525. $.timepicker.dateRange = function(startTime, endTime, options, method) {
  1526. method = method || 'datepicker';
  1527. $.timepicker.handleRange(method, startTime, endTime, options);
  1528. };
  1529. /**
  1530. * Calls `method` on the `startTime` and `endTime` elements, and configures them to
  1531. * enforce date range limits.
  1532. * @param string method Can be used to specify the type of picker to be added
  1533. * @param Element startTime
  1534. * @param Element endTime
  1535. * @param obj options Options for the `timepicker()` call. Also supports `reformat`,
  1536. * a boolean value that can be used to reformat the input values to the `dateFormat`.
  1537. * @return jQuery
  1538. */
  1539. $.timepicker.handleRange = function(method, startTime, endTime, options) {
  1540. $.fn[method].call(startTime, $.extend({
  1541. onClose: function(dateText, inst) {
  1542. checkDates(this, endTime, dateText);
  1543. },
  1544. onSelect: function(selectedDateTime) {
  1545. selected(this, endTime, 'minDate');
  1546. }
  1547. }, options, options.start));
  1548. $.fn[method].call(endTime, $.extend({
  1549. onClose: function(dateText, inst) {
  1550. checkDates(this, startTime, dateText);
  1551. },
  1552. onSelect: function(selectedDateTime) {
  1553. selected(this, startTime, 'maxDate');
  1554. }
  1555. }, options, options.end));
  1556. // timepicker doesn't provide access to its 'timeFormat' option,
  1557. // nor could I get datepicker.formatTime() to behave with times, so I
  1558. // have disabled reformatting for timepicker
  1559. if (method != 'timepicker' && options.reformat) {
  1560. $([startTime, endTime]).each(function() {
  1561. var format = $(this)[method].call($(this), 'option', 'dateFormat'),
  1562. date = new Date($(this).val());
  1563. if ($(this).val() && date) {
  1564. $(this).val($.datepicker.formatDate(format, date));
  1565. }
  1566. });
  1567. }
  1568. checkDates(startTime, endTime, startTime.val());
  1569. function checkDates(changed, other, dateText) {
  1570. if (other.val() && (new Date(startTime.val()) > new Date(endTime.val()))) {
  1571. other.val(dateText);
  1572. }
  1573. }
  1574. selected(startTime, endTime, 'minDate');
  1575. selected(endTime, startTime, 'maxDate');
  1576. function selected(changed, other, option) {
  1577. if (!$(changed).val()) {
  1578. return;
  1579. }
  1580. var date = $(changed)[method].call($(changed), 'getDate');
  1581. // timepicker doesn't implement 'getDate' and returns a jQuery
  1582. if (date.getTime) {
  1583. $(other)[method].call($(other), 'option', option, date);
  1584. }
  1585. }
  1586. return $([startTime.get(0), endTime.get(0)]);
  1587. };
  1588. /*
  1589. * Keep up with the version
  1590. */
  1591. $.timepicker.version = "1.0.4";
  1592. })(jQuery);