]> git.mxchange.org Git - friendica.git/blob - library/datetimepicker/jquery.datetimepicker.js
Fix generated po headers
[friendica.git] / library / datetimepicker / jquery.datetimepicker.js
1 /**
2  * @preserve jQuery DateTimePicker plugin v2.4.0
3  * @homepage http://xdsoft.net/jqplugins/datetimepicker/
4  * (c) 2014, Chupurnov Valeriy.
5  */
6 /*global document,window,jQuery,setTimeout,clearTimeout*/
7 (function ($) {
8         'use strict';
9         var default_options  = {
10                 i18n: {
11                         ar: { // Arabic
12                                 months: [
13                                         "كانون الثاني", "شباط", "آذار", "نيسان", "مايو", "حزيران", "تموز", "آب", "أيلول", "تشرين الأول", "تشرين الثاني", "كانون الأول"
14                                 ],
15                                 dayOfWeek: [
16                                         "ن", "ث", "ع", "خ", "ج", "س", "ح"
17                                 ]
18                         },
19                         ro: { // Romanian
20                                 months: [
21                                         "ianuarie", "februarie", "martie", "aprilie", "mai", "iunie", "iulie", "august", "septembrie", "octombrie", "noiembrie", "decembrie"
22                                 ],
23                                 dayOfWeek: [
24                                         "l", "ma", "mi", "j", "v", "s", "d"
25                                 ]
26                         },
27                         id: { // Indonesian
28                                 months: [
29                                         "Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"
30                                 ],
31                                 dayOfWeek: [
32                                         "Sen", "Sel", "Rab", "Kam", "Jum", "Sab", "Min"
33                                 ]
34                         },
35                         bg: { // Bulgarian
36                                 months: [
37                                         "Януари", "Февруари", "Март", "Април", "Май", "Юни", "Юли", "Август", "Септември", "Октомври", "Ноември", "Декември"
38                                 ],
39                                 dayOfWeek: [
40                                         "Нд", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"
41                                 ]
42                         },
43                         fa: { // Persian/Farsi
44                                 months: [
45                                         'فروردین', 'اردیبهشت', 'خرداد', 'تیر', 'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند'
46                                 ],
47                                 dayOfWeek: [
48                                         'یکشنبه', 'دوشنبه', 'سه شنبه', 'چهارشنبه', 'پنجشنبه', 'جمعه', 'شنبه'
49                                 ]
50                         },
51                         ru: { // Russian
52                                 months: [
53                                         'Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'
54                                 ],
55                                 dayOfWeek: [
56                                         "Вск", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"
57                                 ]
58                         },
59                         uk: { // Ukrainian
60                                 months: [
61                                         'Січень', 'Лютий', 'Березень', 'Квітень', 'Травень', 'Червень', 'Липень', 'Серпень', 'Вересень', 'Жовтень', 'Листопад', 'Грудень'
62                                 ],
63                                 dayOfWeek: [
64                                         "Ндл", "Пнд", "Втр", "Срд", "Чтв", "Птн", "Сбт"
65                                 ]
66                         },
67                         en: { // English
68                                 months: [
69                                         "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
70                                 ],
71                                 dayOfWeek: [
72                                         "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
73                                 ]
74                         },
75                         el: { // Ελληνικά
76                                 months: [
77                                         "Ιανουάριος", "Φεβρουάριος", "Μάρτιος", "Απρίλιος", "Μάιος", "Ιούνιος", "Ιούλιος", "Αύγουστος", "Σεπτέμβριος", "Οκτώβριος", "Νοέμβριος", "Δεκέμβριος"
78                                 ],
79                                 dayOfWeek: [
80                                         "Κυρ", "Δευ", "Τρι", "Τετ", "Πεμ", "Παρ", "Σαβ"
81                                 ]
82                         },
83                         de: { // German
84                                 months: [
85                                         'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'
86                                 ],
87                                 dayOfWeek: [
88                                         "So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"
89                                 ]
90                         },
91                         nl: { // Dutch
92                                 months: [
93                                         "januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"
94                                 ],
95                                 dayOfWeek: [
96                                         "zo", "ma", "di", "wo", "do", "vr", "za"
97                                 ]
98                         },
99                         tr: { // Turkish
100                                 months: [
101                                         "Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"
102                                 ],
103                                 dayOfWeek: [
104                                         "Paz", "Pts", "Sal", "Çar", "Per", "Cum", "Cts"
105                                 ]
106                         },
107                         fr: { //French
108                                 months: [
109                                         "Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"
110                                 ],
111                                 dayOfWeek: [
112                                         "Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam"
113                                 ]
114                         },
115                         es: { // Spanish
116                                 months: [
117                                         "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"
118                                 ],
119                                 dayOfWeek: [
120                                         "Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb"
121                                 ]
122                         },
123                         th: { // Thai
124                                 months: [
125                                         'มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'พฤษภาคม', 'มิถุนายน', 'กรกฎาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม'
126                                 ],
127                                 dayOfWeek: [
128                                         'อา.', 'จ.', 'อ.', 'พ.', 'พฤ.', 'ศ.', 'ส.'
129                                 ]
130                         },
131                         pl: { // Polish
132                                 months: [
133                                         "styczeń", "luty", "marzec", "kwiecień", "maj", "czerwiec", "lipiec", "sierpień", "wrzesień", "październik", "listopad", "grudzień"
134                                 ],
135                                 dayOfWeek: [
136                                         "nd", "pn", "wt", "śr", "cz", "pt", "sb"
137                                 ]
138                         },
139                         pt: { // Portuguese
140                                 months: [
141                                         "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"
142                                 ],
143                                 dayOfWeek: [
144                                         "Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab"
145                                 ]
146                         },
147                         ch: { // Simplified Chinese
148                                 months: [
149                                         "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
150                                 ],
151                                 dayOfWeek: [
152                                         "日", "一", "二", "三", "四", "五", "六"
153                                 ]
154                         },
155                         se: { // Swedish
156                                 months: [
157                                         "Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September",  "Oktober", "November", "December"
158                                 ],
159                                 dayOfWeek: [
160                                         "Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör"
161                                 ]
162                         },
163                         kr: { // Korean
164                                 months: [
165                                         "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"
166                                 ],
167                                 dayOfWeek: [
168                                         "일", "월", "화", "수", "목", "금", "토"
169                                 ]
170                         },
171                         it: { // Italian
172                                 months: [
173                                         "Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"
174                                 ],
175                                 dayOfWeek: [
176                                         "Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab"
177                                 ]
178                         },
179                         da: { // Dansk
180                                 months: [
181                                         "January", "Februar", "Marts", "April", "Maj", "Juni", "July", "August", "September", "Oktober", "November", "December"
182                                 ],
183                                 dayOfWeek: [
184                                         "Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør"
185                                 ]
186                         },
187                         no: { // Norwegian
188                                 months: [
189                                         "Januar", "Februar", "Mars", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Desember"
190                                 ],
191                                 dayOfWeek: [
192                                         "Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør"
193                                 ]
194                         },
195                         ja: { // Japanese
196                                 months: [
197                                         "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"
198                                 ],
199                                 dayOfWeek: [
200                                         "日", "月", "火", "水", "木", "金", "土"
201                                 ]
202                         },
203                         vi: { // Vietnamese
204                                 months: [
205                                         "Tháng 1", "Tháng 2", "Tháng 3", "Tháng 4", "Tháng 5", "Tháng 6", "Tháng 7", "Tháng 8", "Tháng 9", "Tháng 10", "Tháng 11", "Tháng 12"
206                                 ],
207                                 dayOfWeek: [
208                                         "CN", "T2", "T3", "T4", "T5", "T6", "T7"
209                                 ]
210                         },
211                         sl: { // Slovenščina
212                                 months: [
213                                         "Januar", "Februar", "Marec", "April", "Maj", "Junij", "Julij", "Avgust", "September", "Oktober", "November", "December"
214                                 ],
215                                 dayOfWeek: [
216                                         "Ned", "Pon", "Tor", "Sre", "Čet", "Pet", "Sob"
217                                 ]
218                         },
219                         cs: { // Čeština
220                                 months: [
221                                         "Leden", "Únor", "Březen", "Duben", "Květen", "Červen", "Červenec", "Srpen", "Září", "Říjen", "Listopad", "Prosinec"
222                                 ],
223                                 dayOfWeek: [
224                                         "Ne", "Po", "Út", "St", "Čt", "Pá", "So"
225                                 ]
226                         },
227                         hu: { // Hungarian
228                                 months: [
229                                         "Január", "Február", "Március", "Április", "Május", "Június", "Július", "Augusztus", "Szeptember", "Október", "November", "December"
230                                 ],
231                                 dayOfWeek: [
232                                         "Va", "Hé", "Ke", "Sze", "Cs", "Pé", "Szo"
233                                 ]
234                         }
235                 },
236                 value: '',
237                 lang: 'en',
238
239                 format: 'Y/m/d H:i',
240                 formatTime:     'H:i',
241                 formatDate:     'Y/m/d',
242
243                 startDate:      false, // new Date(), '1986/12/08', '-1970/01/05','-1970/01/05',
244                 step: 60,
245                 monthChangeSpinner: true,
246
247                 closeOnDateSelect: false,
248                 closeOnWithoutClick: true,
249                 closeOnInputClick: true,
250
251                 timepicker: true,
252                 datepicker: true,
253                 weeks: false,
254
255                 defaultTime: false,     // use formatTime format (ex. '10:00' for formatTime:   'H:i')
256                 defaultDate: false,     // use formatDate format (ex new Date() or '1986/12/08' or '-1970/01/05' or '-1970/01/05')
257
258                 minDate: false,
259                 maxDate: false,
260                 minTime: false,
261                 maxTime: false,
262
263                 allowTimes: [],
264                 opened: false,
265                 initTime: true,
266                 inline: false,
267                 theme: '',
268
269                 onSelectDate: function () {},
270                 onSelectTime: function () {},
271                 onChangeMonth: function () {},
272                 onChangeYear: function () {},
273                 onChangeDateTime: function () {},
274                 onShow: function () {},
275                 onClose: function () {},
276                 onGenerate: function () {},
277
278                 withoutCopyright: true,
279                 inverseButton: false,
280                 hours12: false,
281                 next:   'xdsoft_next',
282                 prev : 'xdsoft_prev',
283                 dayOfWeekStart: 0,
284                 parentID: 'body',
285                 timeHeightInTimePicker: 25,
286                 timepickerScrollbar: true,
287                 todayButton: true,
288                 defaultSelect: true,
289
290                 scrollMonth: true,
291                 scrollTime: true,
292                 scrollInput: true,
293
294                 lazyInit: false,
295                 mask: false,
296                 validateOnBlur: true,
297                 allowBlank: true,
298                 yearStart: 1950,
299                 yearEnd: 2050,
300                 style: '',
301                 id: '',
302                 fixed: false,
303                 roundTime: 'round', // ceil, floor
304                 className: '',
305                 weekends: [],
306                 disabledDates : [],
307                 yearOffset: 0,
308                 beforeShowDay: null,
309
310                 enterLikeTab: true
311         };
312         // fix for ie8
313         if (!Array.prototype.indexOf) {
314                 Array.prototype.indexOf = function (obj, start) {
315                         var i, j;
316                         for (i = (start || 0), j = this.length; i < j; i += 1) {
317                                 if (this[i] === obj) { return i; }
318                         }
319                         return -1;
320                 };
321         }
322         Date.prototype.countDaysInMonth = function () {
323                 return new Date(this.getFullYear(), this.getMonth() + 1, 0).getDate();
324         };
325         $.fn.xdsoftScroller = function (percent) {
326                 return this.each(function () {
327                         var timeboxparent = $(this),
328                                 pointerEventToXY = function (e) {
329                                         var out = {x: 0, y: 0},
330                                                 touch;
331                                         if (e.type === 'touchstart' || e.type === 'touchmove' || e.type === 'touchend' || e.type === 'touchcancel') {
332                                                 touch  = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
333                                                 out.x = touch.clientX;
334                                                 out.y = touch.clientY;
335                                         } else if (e.type === 'mousedown' || e.type === 'mouseup' || e.type === 'mousemove' || e.type === 'mouseover' || e.type === 'mouseout' || e.type === 'mouseenter' || e.type === 'mouseleave') {
336                                                 out.x = e.clientX;
337                                                 out.y = e.clientY;
338                                         }
339                                         return out;
340                                 },
341                                 move = 0,
342                                 timebox,
343                                 parentHeight,
344                                 height,
345                                 scrollbar,
346                                 scroller,
347                                 maximumOffset = 100,
348                                 start = false,
349                                 startY = 0,
350                                 startTop = 0,
351                                 h1 = 0,
352                                 touchStart = false,
353                                 startTopScroll = 0,
354                                 calcOffset = function () {};
355                         if (percent === 'hide') {
356                                 timeboxparent.find('.xdsoft_scrollbar').hide();
357                                 return;
358                         }
359                         if (!$(this).hasClass('xdsoft_scroller_box')) {
360                                 timebox = timeboxparent.children().eq(0);
361                                 parentHeight = timeboxparent[0].clientHeight;
362                                 height = timebox[0].offsetHeight;
363                                 scrollbar = $('<div class="xdsoft_scrollbar"></div>');
364                                 scroller = $('<div class="xdsoft_scroller"></div>');
365                                 scrollbar.append(scroller);
366
367                                 timeboxparent.addClass('xdsoft_scroller_box').append(scrollbar);
368                                 calcOffset = function calcOffset(event) {
369                                         var offset = pointerEventToXY(event).y - startY + startTopScroll;
370                                         if (offset < 0) {
371                                                 offset = 0;
372                                         }
373                                         if (offset + scroller[0].offsetHeight > h1) {
374                                                 offset = h1 - scroller[0].offsetHeight;
375                                         }
376                                         timeboxparent.trigger('scroll_element.xdsoft_scroller', [maximumOffset ? offset / maximumOffset : 0]);
377                                 };
378
379                                 scroller
380                                         .on('touchstart.xdsoft_scroller mousedown.xdsoft_scroller', function (event) {
381                                                 if (!parentHeight) {
382                                                         timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percent]);
383                                                 }
384
385                                                 startY = pointerEventToXY(event).y;
386                                                 startTopScroll = parseInt(scroller.css('margin-top'), 10);
387                                                 h1 = scrollbar[0].offsetHeight;
388
389                                                 if (event.type === 'mousedown') {
390                                                         if (document) {
391                                                                 $(document.body).addClass('xdsoft_noselect');
392                                                         }
393                                                         $([document.body, window]).on('mouseup.xdsoft_scroller', function arguments_callee() {
394                                                                 $([document.body, window]).off('mouseup.xdsoft_scroller', arguments_callee)
395                                                                         .off('mousemove.xdsoft_scroller', calcOffset)
396                                                                         .removeClass('xdsoft_noselect');
397                                                         });
398                                                         $(document.body).on('mousemove.xdsoft_scroller', calcOffset);
399                                                 } else {
400                                                         touchStart = true;
401                                                         event.stopPropagation();
402                                                         event.preventDefault();
403                                                 }
404                                         })
405                                         .on('touchmove', function (event) {
406                                                 if (touchStart) {
407                                                         event.preventDefault();
408                                                         calcOffset(event);
409                                                 }
410                                         })
411                                         .on('touchend touchcancel', function (event) {
412                                                 touchStart =  false;
413                                                 startTopScroll = 0;
414                                         });
415
416                                 timeboxparent
417                                         .on('scroll_element.xdsoft_scroller', function (event, percentage) {
418                                                 if (!parentHeight) {
419                                                         timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percentage, true]);
420                                                 }
421                                                 percentage = percentage > 1 ? 1 : (percentage < 0 || isNaN(percentage)) ? 0 : percentage;
422
423                                                 scroller.css('margin-top', maximumOffset * percentage);
424
425                                                 setTimeout(function () {
426                                                         timebox.css('marginTop', -parseInt((timebox[0].offsetHeight - parentHeight) * percentage, 10));
427                                                 }, 10);
428                                         })
429                                         .on('resize_scroll.xdsoft_scroller', function (event, percentage, noTriggerScroll) {
430                                                 var percent, sh;
431                                                 parentHeight = timeboxparent[0].clientHeight;
432                                                 height = timebox[0].offsetHeight;
433                                                 percent = parentHeight / height;
434                                                 sh = percent * scrollbar[0].offsetHeight;
435                                                 if (percent > 1) {
436                                                         scroller.hide();
437                                                 } else {
438                                                         scroller.show();
439                                                         scroller.css('height', parseInt(sh > 10 ? sh : 10, 10));
440                                                         maximumOffset = scrollbar[0].offsetHeight - scroller[0].offsetHeight;
441                                                         if (noTriggerScroll !== true) {
442                                                                 timeboxparent.trigger('scroll_element.xdsoft_scroller', [percentage || Math.abs(parseInt(timebox.css('marginTop'), 10)) / (height - parentHeight)]);
443                                                         }
444                                                 }
445                                         });
446
447                                 timeboxparent.on('mousewheel', function (event) {
448                                         var top = Math.abs(parseInt(timebox.css('marginTop'), 10));
449
450                                         top = top - (event.deltaY * 20);
451                                         if (top < 0) {
452                                                 top = 0;
453                                         }
454
455                                         timeboxparent.trigger('scroll_element.xdsoft_scroller', [top / (height - parentHeight)]);
456                                         event.stopPropagation();
457                                         return false;
458                                 });
459
460                                 timeboxparent.on('touchstart', function (event) {
461                                         start = pointerEventToXY(event);
462                                         startTop = Math.abs(parseInt(timebox.css('marginTop'), 10));
463                                 });
464
465                                 timeboxparent.on('touchmove', function (event) {
466                                         if (start) {
467                                                 event.preventDefault();
468                                                 var coord = pointerEventToXY(event);
469                                                 timeboxparent.trigger('scroll_element.xdsoft_scroller', [(startTop - (coord.y - start.y)) / (height - parentHeight)]);
470                                         }
471                                 });
472
473                                 timeboxparent.on('touchend touchcancel', function (event) {
474                                         start = false;
475                                         startTop = 0;
476                                 });
477                         }
478                         timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percent]);
479                 });
480         };
481
482         $.fn.datetimepicker = function (opt) {
483                 var KEY0 = 48,
484                         KEY9 = 57,
485                         _KEY0 = 96,
486                         _KEY9 = 105,
487                         CTRLKEY = 17,
488                         DEL = 46,
489                         ENTER = 13,
490                         ESC = 27,
491                         BACKSPACE = 8,
492                         ARROWLEFT = 37,
493                         ARROWUP = 38,
494                         ARROWRIGHT = 39,
495                         ARROWDOWN = 40,
496                         TAB = 9,
497                         F5 = 116,
498                         AKEY = 65,
499                         CKEY = 67,
500                         VKEY = 86,
501                         ZKEY = 90,
502                         YKEY = 89,
503                         ctrlDown        =       false,
504                         options = ($.isPlainObject(opt) || !opt) ? $.extend(true, {}, default_options, opt) : $.extend(true, {}, default_options),
505
506                         lazyInitTimer = 0,
507                         createDateTimePicker,
508                         destroyDateTimePicker,
509                         _xdsoft_datetime,
510
511                         lazyInit = function (input) {
512                                 input
513                                         .on('open.xdsoft focusin.xdsoft mousedown.xdsoft', function initOnActionCallback(event) {
514                                                 if (input.is(':disabled') || input.is(':hidden') || !input.is(':visible') || input.data('xdsoft_datetimepicker')) {
515                                                         return;
516                                                 }
517                                                 clearTimeout(lazyInitTimer);
518                                                 lazyInitTimer = setTimeout(function () {
519
520                                                         if (!input.data('xdsoft_datetimepicker')) {
521                                                                 createDateTimePicker(input);
522                                                         }
523                                                         input
524                                                                 .off('open.xdsoft focusin.xdsoft mousedown.xdsoft', initOnActionCallback)
525                                                                 .trigger('open.xdsoft');
526                                                 }, 100);
527                                         });
528                         };
529
530                 createDateTimePicker = function (input) {
531                         var datetimepicker = $('<div ' + (options.id ? 'id="' + options.id + '"' : '') + ' ' + (options.style ? 'style="' + options.style + '"' : '') + ' class="xdsoft_datetimepicker xdsoft_' + options.theme + ' xdsoft_noselect ' + (options.weeks ? ' xdsoft_showweeks' : '') + options.className + '"></div>'),
532                                 xdsoft_copyright = $('<div class="xdsoft_copyright"><a target="_blank" href="http://xdsoft.net/jqplugins/datetimepicker/">xdsoft.net</a></div>'),
533                                 datepicker = $('<div class="xdsoft_datepicker active"></div>'),
534                                 mounth_picker = $('<div class="xdsoft_mounthpicker"><button type="button" class="xdsoft_prev"></button><button type="button" class="xdsoft_today_button"></button>' +
535                                         '<div class="xdsoft_label xdsoft_month"><span></span><i></i></div>' +
536                                         '<div class="xdsoft_label xdsoft_year"><span></span><i></i></div>' +
537                                         '<button type="button" class="xdsoft_next"></button></div>'),
538                                 calendar = $('<div class="xdsoft_calendar"></div>'),
539                                 timepicker = $('<div class="xdsoft_timepicker active"><button type="button" class="xdsoft_prev"></button><div class="xdsoft_time_box"></div><button type="button" class="xdsoft_next"></button></div>'),
540                                 timeboxparent = timepicker.find('.xdsoft_time_box').eq(0),
541                                 timebox = $('<div class="xdsoft_time_variant"></div>'),
542                                 /*scrollbar = $('<div class="xdsoft_scrollbar"></div>'),
543                                 scroller = $('<div class="xdsoft_scroller"></div>'),*/
544                                 monthselect = $('<div class="xdsoft_select xdsoft_monthselect"><div></div></div>'),
545                                 yearselect = $('<div class="xdsoft_select xdsoft_yearselect"><div></div></div>'),
546                                 triggerAfterOpen = false,
547                                 XDSoft_datetime,
548                                 //scroll_element,
549                                 xchangeTimer,
550                                 timerclick,
551                                 current_time_index,
552                                 setPos,
553                                 timer = 0,
554                                 timer1 = 0;
555
556                         mounth_picker
557                                 .find('.xdsoft_month span')
558                                         .after(monthselect);
559                         mounth_picker
560                                 .find('.xdsoft_year span')
561                                         .after(yearselect);
562
563                         mounth_picker
564                                 .find('.xdsoft_month,.xdsoft_year')
565                                         .on('mousedown.xdsoft', function (event) {
566                                         var select = $(this).find('.xdsoft_select').eq(0),
567                                                 val = 0,
568                                                 top = 0,
569                                                 visible = select.is(':visible'),
570                                                 items,
571                                                 i;
572
573                                         mounth_picker
574                                                 .find('.xdsoft_select')
575                                                         .hide();
576                                         if (_xdsoft_datetime.currentTime) {
577                                                 val = _xdsoft_datetime.currentTime[$(this).hasClass('xdsoft_month') ? 'getMonth' : 'getFullYear']();
578                                         }
579
580                                         select[visible ? 'hide' : 'show']();
581                                         for (items = select.find('div.xdsoft_option'), i = 0; i < items.length; i += 1) {
582                                                 if (items.eq(i).data('value') === val) {
583                                                         break;
584                                                 } else {
585                                                         top += items[0].offsetHeight;
586                                                 }
587                                         }
588
589                                         select.xdsoftScroller(top / (select.children()[0].offsetHeight - (select[0].clientHeight)));
590                                         event.stopPropagation();
591                                         return false;
592                                 });
593
594                         mounth_picker
595                                 .find('.xdsoft_select')
596                                         .xdsoftScroller()
597                                 .on('mousedown.xdsoft', function (event) {
598                                         event.stopPropagation();
599                                         event.preventDefault();
600                                 })
601                                 .on('mousedown.xdsoft', '.xdsoft_option', function (event) {
602                                         var year = _xdsoft_datetime.currentTime.getFullYear();
603                                         if (_xdsoft_datetime && _xdsoft_datetime.currentTime) {
604                                                 _xdsoft_datetime.currentTime[$(this).parent().parent().hasClass('xdsoft_monthselect') ? 'setMonth' : 'setFullYear']($(this).data('value'));
605                                         }
606
607                                         $(this).parent().parent().hide();
608
609                                         datetimepicker.trigger('xchange.xdsoft');
610                                         if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
611                                                 options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
612                                         }
613
614                                         if (year !== _xdsoft_datetime.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) {
615                                                 options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
616                                         }
617                                 });
618
619                         datetimepicker.setOptions = function (_options) {
620                                 options = $.extend(true, {}, options, _options);
621
622                                 if (_options.allowTimes && $.isArray(_options.allowTimes) && _options.allowTimes.length) {
623                                         options.allowTimes = $.extend(true, [], _options.allowTimes);
624                                 }
625
626                                 if (_options.weekends && $.isArray(_options.weekends) && _options.weekends.length) {
627                                         options.weekends = $.extend(true, [], _options.weekends);
628                                 }
629
630                                 if (_options.disabledDates && $.isArray(_options.disabledDates) && _options.disabledDates.length) {
631                     options.disabledDates = $.extend(true, [], _options.disabledDates);
632                 }
633
634                                 if ((options.open || options.opened) && (!options.inline)) {
635                                         input.trigger('open.xdsoft');
636                                 }
637
638                                 if (options.inline) {
639                                         triggerAfterOpen = true;
640                                         datetimepicker.addClass('xdsoft_inline');
641                                         input.after(datetimepicker).hide();
642                                 }
643
644                                 if (options.inverseButton) {
645                                         options.next = 'xdsoft_prev';
646                                         options.prev = 'xdsoft_next';
647                                 }
648
649                                 if (options.datepicker) {
650                                         datepicker.addClass('active');
651                                 } else {
652                                         datepicker.removeClass('active');
653                                 }
654
655                                 if (options.timepicker) {
656                                         timepicker.addClass('active');
657                                 } else {
658                                         timepicker.removeClass('active');
659                                 }
660
661                                 if (options.value) {
662                                         if (input && input.val) {
663                                                 input.val(options.value);
664                                         }
665                                         _xdsoft_datetime.setCurrentTime(options.value);
666                                 }
667
668                                 if (isNaN(options.dayOfWeekStart)) {
669                                         options.dayOfWeekStart = 0;
670                                 } else {
671                                         options.dayOfWeekStart = parseInt(options.dayOfWeekStart, 10) % 7;
672                                 }
673
674                                 if (!options.timepickerScrollbar) {
675                                         timeboxparent.xdsoftScroller('hide');
676                                 }
677
678                                 if (options.minDate && /^-(.*)$/.test(options.minDate)) {
679                                         options.minDate = _xdsoft_datetime.strToDateTime(options.minDate).dateFormat(options.formatDate);
680                                 }
681
682                                 if (options.maxDate &&  /^\+(.*)$/.test(options.maxDate)) {
683                                         options.maxDate = _xdsoft_datetime.strToDateTime(options.maxDate).dateFormat(options.formatDate);
684                                 }
685
686                                 mounth_picker
687                                         .find('.xdsoft_today_button')
688                                                 .css('visibility', !options.todayButton ? 'hidden' : 'visible');
689
690                                 if (options.mask) {
691                                         var e,
692                                                 getCaretPos = function (input) {
693                                                         try {
694                                                                 if (document.selection && document.selection.createRange) {
695                                                                         var range = document.selection.createRange();
696                                                                         return range.getBookmark().charCodeAt(2) - 2;
697                                                                 }
698                                                                 if (input.setSelectionRange) {
699                                                                         return input.selectionStart;
700                                                                 }
701                                                         } catch (e) {
702                                                                 return 0;
703                                                         }
704                                                 },
705                                                 setCaretPos = function (node, pos) {
706                                                         node = (typeof node === "string" || node instanceof String) ? document.getElementById(node) : node;
707                                                         if (!node) {
708                                                                 return false;
709                                                         }
710                                                         if (node.createTextRange) {
711                                                                 var textRange = node.createTextRange();
712                                                                 textRange.collapse(true);
713                                                                 textRange.moveEnd('character', pos);
714                                                                 textRange.moveStart('character', pos);
715                                                                 textRange.select();
716                                                                 return true;
717                                                         }
718                                                         if (node.setSelectionRange) {
719                                                                 node.setSelectionRange(pos, pos);
720                                                                 return true;
721                                                         }
722                                                         return false;
723                                                 },
724                                                 isValidValue = function (mask, value) {
725                                                         var reg = mask
726                                                                 .replace(/([\[\]\/\{\}\(\)\-\.\+]{1})/g, '\\$1')
727                                                                 .replace(/_/g, '{digit+}')
728                                                                 .replace(/([0-9]{1})/g, '{digit$1}')
729                                                                 .replace(/\{digit([0-9]{1})\}/g, '[0-$1_]{1}')
730                                                                 .replace(/\{digit[\+]\}/g, '[0-9_]{1}');
731                                                         return (new RegExp(reg)).test(value);
732                                                 };
733                                         input.off('keydown.xdsoft');
734
735                                         if (options.mask === true) {
736                                                 options.mask = options.format
737                                                         .replace(/Y/g, '9999')
738                                                         .replace(/F/g, '9999')
739                                                         .replace(/m/g, '19')
740                                                         .replace(/d/g, '39')
741                                                         .replace(/H/g, '29')
742                                                         .replace(/i/g, '59')
743                                                         .replace(/s/g, '59');
744                                         }
745
746                                         if ($.type(options.mask) === 'string') {
747                                                 if (!isValidValue(options.mask, input.val())) {
748                                                         input.val(options.mask.replace(/[0-9]/g, '_'));
749                                                 }
750
751                                                 input.on('keydown.xdsoft', function (event) {
752                                                         var val = this.value,
753                                                                 key = event.which,
754                                                                 pos,
755                                                                 digit;
756
757                                                         if (((key >= KEY0 && key <= KEY9) || (key >= _KEY0 && key <= _KEY9)) || (key === BACKSPACE || key === DEL)) {
758                                                                 pos = getCaretPos(this);
759                                                                 digit = (key !== BACKSPACE && key !== DEL) ? String.fromCharCode((_KEY0 <= key && key <= _KEY9) ? key - KEY0 : key) : '_';
760
761                                                                 if ((key === BACKSPACE || key === DEL) && pos) {
762                                                                         pos -= 1;
763                                                                         digit = '_';
764                                                                 }
765
766                                                                 while (/[^0-9_]/.test(options.mask.substr(pos, 1)) && pos < options.mask.length && pos > 0) {
767                                                                         pos += (key === BACKSPACE || key === DEL) ? -1 : 1;
768                                                                 }
769
770                                                                 val = val.substr(0, pos) + digit + val.substr(pos + 1);
771                                                                 if ($.trim(val) === '') {
772                                                                         val = options.mask.replace(/[0-9]/g, '_');
773                                                                 } else {
774                                                                         if (pos === options.mask.length) {
775                                                                                 event.preventDefault();
776                                                                                 return false;
777                                                                         }
778                                                                 }
779
780                                                                 pos += (key === BACKSPACE || key === DEL) ? 0 : 1;
781                                                                 while (/[^0-9_]/.test(options.mask.substr(pos, 1)) && pos < options.mask.length && pos > 0) {
782                                                                         pos += (key === BACKSPACE || key === DEL) ? -1 : 1;
783                                                                 }
784
785                                                                 if (isValidValue(options.mask, val)) {
786                                                                         this.value = val;
787                                                                         setCaretPos(this, pos);
788                                                                 } else if ($.trim(val) === '') {
789                                                                         this.value = options.mask.replace(/[0-9]/g, '_');
790                                                                 } else {
791                                                                         input.trigger('error_input.xdsoft');
792                                                                 }
793                                                         } else {
794                                                                 if (([AKEY, CKEY, VKEY, ZKEY, YKEY].indexOf(key) !== -1 && ctrlDown) || [ESC, ARROWUP, ARROWDOWN, ARROWLEFT, ARROWRIGHT, F5, CTRLKEY, TAB, ENTER].indexOf(key) !== -1) {
795                                                                         return true;
796                                                                 }
797                                                         }
798
799                                                         event.preventDefault();
800                                                         return false;
801                                                 });
802                                         }
803                                 }
804                                 if (options.validateOnBlur) {
805                                         input
806                                                 .off('blur.xdsoft')
807                                                 .on('blur.xdsoft', function () {
808                                                         if (options.allowBlank && !$.trim($(this).val()).length) {
809                                                                 $(this).val(null);
810                                                                 datetimepicker.data('xdsoft_datetime').empty();
811                                                         } else if (!Date.parseDate($(this).val(), options.format)) {
812                                                                 $(this).val((_xdsoft_datetime.now()).dateFormat(options.format));
813                                                                 datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
814                                                         } else {
815                                                                 datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
816                                                         }
817                                                         datetimepicker.trigger('changedatetime.xdsoft');
818                                                 });
819                                 }
820                                 options.dayOfWeekStartPrev = (options.dayOfWeekStart === 0) ? 6 : options.dayOfWeekStart - 1;
821
822                                 datetimepicker
823                                         .trigger('xchange.xdsoft')
824                                         .trigger('afterOpen.xdsoft');
825                         };
826
827                         datetimepicker
828                                 .data('options', options)
829                                 .on('mousedown.xdsoft', function (event) {
830                                         event.stopPropagation();
831                                         event.preventDefault();
832                                         yearselect.hide();
833                                         monthselect.hide();
834                                         return false;
835                                 });
836
837                         //scroll_element = timepicker.find('.xdsoft_time_box');
838                         timeboxparent.append(timebox);
839                         timeboxparent.xdsoftScroller();
840
841                         datetimepicker.on('afterOpen.xdsoft', function () {
842                                 timeboxparent.xdsoftScroller();
843                         });
844
845                         datetimepicker
846                                 .append(datepicker)
847                                 .append(timepicker);
848
849                         if (options.withoutCopyright !== true) {
850                                 datetimepicker
851                                         .append(xdsoft_copyright);
852                         }
853
854                         datepicker
855                                 .append(mounth_picker)
856                                 .append(calendar);
857
858                         $(options.parentID)
859                                 .append(datetimepicker);
860
861                         XDSoft_datetime = function () {
862                                 var _this = this;
863                                 _this.now = function (norecursion) {
864                                         var d = new Date(),
865                                                 date,
866                                                 time;
867
868                                         if (!norecursion && options.defaultDate) {
869                                                 date = _this.strToDate(options.defaultDate);
870                                                 d.setFullYear(date.getFullYear());
871                                                 d.setMonth(date.getMonth());
872                                                 d.setDate(date.getDate());
873                                         }
874
875                                         if (options.yearOffset) {
876                                                 d.setFullYear(d.getFullYear() + options.yearOffset);
877                                         }
878
879                                         if (!norecursion && options.defaultTime) {
880                                                 time = _this.strtotime(options.defaultTime);
881                                                 d.setHours(time.getHours());
882                                                 d.setMinutes(time.getMinutes());
883                                         }
884
885                                         return d;
886                                 };
887
888                                 _this.isValidDate = function (d) {
889                                         if (Object.prototype.toString.call(d) !== "[object Date]") {
890                                                 return false;
891                                         }
892                                         return !isNaN(d.getTime());
893                                 };
894
895                                 _this.setCurrentTime = function (dTime) {
896                                         _this.currentTime = (typeof dTime === 'string') ? _this.strToDateTime(dTime) : _this.isValidDate(dTime) ? dTime : _this.now();
897                                         datetimepicker.trigger('xchange.xdsoft');
898                                 };
899
900                                 _this.empty = function () {
901                                         _this.currentTime = null;
902                                 };
903
904                                 _this.getCurrentTime = function (dTime) {
905                                         return _this.currentTime;
906                                 };
907
908                                 _this.nextMonth = function () {
909                                         var month = _this.currentTime.getMonth() + 1,
910                                                 year;
911                                         if (month === 12) {
912                                                 _this.currentTime.setFullYear(_this.currentTime.getFullYear() + 1);
913                                                 month = 0;
914                                         }
915
916                                         year = _this.currentTime.getFullYear();
917
918                                         _this.currentTime.setDate(
919                                                 Math.min(
920                                                         new Date(_this.currentTime.getFullYear(), month + 1, 0).getDate(),
921                                                         _this.currentTime.getDate()
922                                                 )
923                                         );
924                                         _this.currentTime.setMonth(month);
925
926                                         if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
927                                                 options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
928                                         }
929
930                                         if (year !== _this.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) {
931                                                 options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
932                                         }
933
934                                         datetimepicker.trigger('xchange.xdsoft');
935                                         return month;
936                                 };
937
938                                 _this.prevMonth = function () {
939                                         var month = _this.currentTime.getMonth() - 1;
940                                         if (month === -1) {
941                                                 _this.currentTime.setFullYear(_this.currentTime.getFullYear() - 1);
942                                                 month = 11;
943                                         }
944                                         _this.currentTime.setDate(
945                                                 Math.min(
946                                                         new Date(_this.currentTime.getFullYear(), month + 1, 0).getDate(),
947                                                         _this.currentTime.getDate()
948                                                 )
949                                         );
950                                         _this.currentTime.setMonth(month);
951                                         if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
952                                                 options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
953                                         }
954                                         datetimepicker.trigger('xchange.xdsoft');
955                                         return month;
956                                 };
957
958                                 _this.getWeekOfYear = function (datetime) {
959                                         var onejan = new Date(datetime.getFullYear(), 0, 1);
960                                         return Math.ceil((((datetime - onejan) / 86400000) + onejan.getDay() + 1) / 7);
961                                 };
962
963                                 _this.strToDateTime = function (sDateTime) {
964                                         var tmpDate = [], timeOffset, currentTime;
965
966                                         if (sDateTime && sDateTime instanceof Date && _this.isValidDate(sDateTime)) {
967                                                 return sDateTime;
968                                         }
969
970                                         tmpDate = /^(\+|\-)(.*)$/.exec(sDateTime);
971                                         if (tmpDate) {
972                                                 tmpDate[2] = Date.parseDate(tmpDate[2], options.formatDate);
973                                         }
974                                         if (tmpDate  && tmpDate[2]) {
975                                                 timeOffset = tmpDate[2].getTime() - (tmpDate[2].getTimezoneOffset()) * 60000;
976                                                 currentTime = new Date((_xdsoft_datetime.now()).getTime() + parseInt(tmpDate[1] + '1', 10) * timeOffset);
977                                         } else {
978                                                 currentTime = sDateTime ? Date.parseDate(sDateTime, options.format) : _this.now();
979                                         }
980
981                                         if (!_this.isValidDate(currentTime)) {
982                                                 currentTime = _this.now();
983                                         }
984
985                                         return currentTime;
986                                 };
987
988                                 _this.strToDate = function (sDate) {
989                                         if (sDate && sDate instanceof Date && _this.isValidDate(sDate)) {
990                                                 return sDate;
991                                         }
992
993                                         var currentTime = sDate ? Date.parseDate(sDate, options.formatDate) : _this.now(true);
994                                         if (!_this.isValidDate(currentTime)) {
995                                                 currentTime = _this.now(true);
996                                         }
997                                         return currentTime;
998                                 };
999
1000                                 _this.strtotime = function (sTime) {
1001                                         if (sTime && sTime instanceof Date && _this.isValidDate(sTime)) {
1002                                                 return sTime;
1003                                         }
1004                                         var currentTime = sTime ? Date.parseDate(sTime, options.formatTime) : _this.now(true);
1005                                         if (!_this.isValidDate(currentTime)) {
1006                                                 currentTime = _this.now(true);
1007                                         }
1008                                         return currentTime;
1009                                 };
1010
1011                                 _this.str = function () {
1012                                         return _this.currentTime.dateFormat(options.format);
1013                                 };
1014                                 _this.currentTime = this.now();
1015                         };
1016
1017                         _xdsoft_datetime = new XDSoft_datetime();
1018
1019                         mounth_picker
1020                                 .find('.xdsoft_today_button')
1021                                 .on('mousedown.xdsoft', function () {
1022                                         datetimepicker.data('changed', true);
1023                                         _xdsoft_datetime.setCurrentTime(0);
1024                                         datetimepicker.trigger('afterOpen.xdsoft');
1025                                 }).on('dblclick.xdsoft', function () {
1026                                         input.val(_xdsoft_datetime.str());
1027                                         datetimepicker.trigger('close.xdsoft');
1028                                 });
1029                         mounth_picker
1030                                 .find('.xdsoft_prev,.xdsoft_next')
1031                                 .on('mousedown.xdsoft', function () {
1032                                         var $this = $(this),
1033                                                 timer = 0,
1034                                                 stop = false;
1035
1036                                         (function arguments_callee1(v) {
1037                                                 var month =  _xdsoft_datetime.currentTime.getMonth();
1038                                                 if ($this.hasClass(options.next)) {
1039                                                         _xdsoft_datetime.nextMonth();
1040                                                 } else if ($this.hasClass(options.prev)) {
1041                                                         _xdsoft_datetime.prevMonth();
1042                                                 }
1043                                                 if (options.monthChangeSpinner) {
1044                                                         if (!stop) {
1045                                                                 timer = setTimeout(arguments_callee1, v || 100);
1046                                                         }
1047                                                 }
1048                                         }(500));
1049
1050                                         $([document.body, window]).on('mouseup.xdsoft', function arguments_callee2() {
1051                                                 clearTimeout(timer);
1052                                                 stop = true;
1053                                                 $([document.body, window]).off('mouseup.xdsoft', arguments_callee2);
1054                                         });
1055                                 });
1056
1057                         timepicker
1058                                 .find('.xdsoft_prev,.xdsoft_next')
1059                                 .on('mousedown.xdsoft', function () {
1060                                         var $this = $(this),
1061                                                 timer = 0,
1062                                                 stop = false,
1063                                                 period = 110;
1064                                         (function arguments_callee4(v) {
1065                                                 var pheight = timeboxparent[0].clientHeight,
1066                                                         height = timebox[0].offsetHeight,
1067                                                         top = Math.abs(parseInt(timebox.css('marginTop'), 10));
1068                                                 if ($this.hasClass(options.next) && (height - pheight) - options.timeHeightInTimePicker >= top) {
1069                                                         timebox.css('marginTop', '-' + (top + options.timeHeightInTimePicker) + 'px');
1070                                                 } else if ($this.hasClass(options.prev) && top - options.timeHeightInTimePicker >= 0) {
1071                                                         timebox.css('marginTop', '-' + (top - options.timeHeightInTimePicker) + 'px');
1072                                                 }
1073                                                 timeboxparent.trigger('scroll_element.xdsoft_scroller', [Math.abs(parseInt(timebox.css('marginTop'), 10) / (height - pheight))]);
1074                                                 period = (period > 10) ? 10 : period - 10;
1075                                                 if (!stop) {
1076                                                         timer = setTimeout(arguments_callee4, v || period);
1077                                                 }
1078                                         }(500));
1079                                         $([document.body, window]).on('mouseup.xdsoft', function arguments_callee5() {
1080                                                 clearTimeout(timer);
1081                                                 stop = true;
1082                                                 $([document.body, window])
1083                                                         .off('mouseup.xdsoft', arguments_callee5);
1084                                         });
1085                                 });
1086
1087                         xchangeTimer = 0;
1088                         // base handler - generating a calendar and timepicker
1089                         datetimepicker
1090                                 .on('xchange.xdsoft', function (event) {
1091                                         clearTimeout(xchangeTimer);
1092                                         xchangeTimer = setTimeout(function () {
1093                                                 var table =     '',
1094                                                         start = new Date(_xdsoft_datetime.currentTime.getFullYear(), _xdsoft_datetime.currentTime.getMonth(), 1, 12, 0, 0),
1095                                                         i = 0,
1096                                                         j,
1097                                                         today = _xdsoft_datetime.now(),
1098                                                         maxDate = false,
1099                                                         minDate = false,
1100                                                         d,
1101                                                         y,
1102                                                         m,
1103                                                         w,
1104                                                         classes = [],
1105                                                         customDateSettings,
1106                                                         newRow = true,
1107                                                         time = '',
1108                                                         h = '',
1109                                                         line_time;
1110
1111                                                 while (start.getDay() !== options.dayOfWeekStart) {
1112                                                         start.setDate(start.getDate() - 1);
1113                                                 }
1114
1115                                                 table += '<table><thead><tr>';
1116
1117                                                 if (options.weeks) {
1118                                                         table += '<th></th>';
1119                                                 }
1120
1121                                                 for (j = 0; j < 7; j += 1) {
1122                                                         table += '<th>' + options.i18n[options.lang].dayOfWeek[(j + options.dayOfWeekStart) % 7] + '</th>';
1123                                                 }
1124
1125                                                 table += '</tr></thead>';
1126                                                 table += '<tbody>';
1127
1128                                                 if (options.maxDate !== false) {
1129                                                         maxDate = _xdsoft_datetime.strToDate(options.maxDate);
1130                                                         maxDate = new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate(), 23, 59, 59, 999);
1131                                                 }
1132
1133                                                 if (options.minDate !== false) {
1134                                                         minDate = _xdsoft_datetime.strToDate(options.minDate);
1135                                                         minDate = new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate());
1136                                                 }
1137
1138                                                 while (i < _xdsoft_datetime.currentTime.countDaysInMonth() || start.getDay() !== options.dayOfWeekStart || _xdsoft_datetime.currentTime.getMonth() === start.getMonth()) {
1139                                                         classes = [];
1140                                                         i += 1;
1141
1142                                                         d = start.getDate();
1143                                                         y = start.getFullYear();
1144                                                         m = start.getMonth();
1145                                                         w = _xdsoft_datetime.getWeekOfYear(start);
1146
1147                                                         classes.push('xdsoft_date');
1148
1149                                                         if (options.beforeShowDay && $.isFunction(options.beforeShowDay.call)) {
1150                                                                 customDateSettings = options.beforeShowDay.call(datetimepicker, start);
1151                                                         } else {
1152                                                                 customDateSettings = null;
1153                                                         }
1154
1155                                                         if ((maxDate !== false && start > maxDate) || (minDate !== false && start < minDate) || (customDateSettings && customDateSettings[0] === false)) {
1156                                                                 classes.push('xdsoft_disabled');
1157                                                         } else if (options.disabledDates.indexOf(start.dateFormat(options.formatDate)) !== -1) {
1158                                                                 classes.push('xdsoft_disabled');
1159                                                         }
1160
1161                                                         if (customDateSettings && customDateSettings[1] !== "") {
1162                                                                 classes.push(customDateSettings[1]);
1163                                                         }
1164
1165                                                         if (_xdsoft_datetime.currentTime.getMonth() !== m) {
1166                                                                 classes.push('xdsoft_other_month');
1167                                                         }
1168
1169                                                         if ((options.defaultSelect || datetimepicker.data('changed')) && _xdsoft_datetime.currentTime.dateFormat(options.formatDate) === start.dateFormat(options.formatDate)) {
1170                                                                 classes.push('xdsoft_current');
1171                                                         }
1172
1173                                                         if (today.dateFormat(options.formatDate) === start.dateFormat(options.formatDate)) {
1174                                                                 classes.push('xdsoft_today');
1175                                                         }
1176
1177                                                         if (start.getDay() === 0 || start.getDay() === 6 || options.weekends.indexOf(start.dateFormat(options.formatDate)) === -1) {
1178                                                                 classes.push('xdsoft_weekend');
1179                                                         }
1180
1181                                                         if (options.beforeShowDay && $.isFunction(options.beforeShowDay)) {
1182                                                                 classes.push(options.beforeShowDay(start));
1183                                                         }
1184
1185                                                         if (newRow) {
1186                                                                 table += '<tr>';
1187                                                                 newRow = false;
1188                                                                 if (options.weeks) {
1189                                                                         table += '<th>' + w + '</th>';
1190                                                                 }
1191                                                         }
1192
1193                                                         table += '<td data-date="' + d + '" data-month="' + m + '" data-year="' + y + '"' + ' class="xdsoft_date xdsoft_day_of_week' + start.getDay() + ' ' + classes.join(' ') + '">' +
1194                                                                                 '<div>' + d + '</div>' +
1195                                                                         '</td>';
1196
1197                                                         if (start.getDay() === options.dayOfWeekStartPrev) {
1198                                                                 table += '</tr>';
1199                                                                 newRow = true;
1200                                                         }
1201
1202                                                         start.setDate(d + 1);
1203                                                 }
1204                                                 table += '</tbody></table>';
1205
1206                                                 calendar.html(table);
1207
1208                                                 mounth_picker.find('.xdsoft_label span').eq(0).text(options.i18n[options.lang].months[_xdsoft_datetime.currentTime.getMonth()]);
1209                                                 mounth_picker.find('.xdsoft_label span').eq(1).text(_xdsoft_datetime.currentTime.getFullYear());
1210
1211                                                 // generate timebox
1212                                                 time = '';
1213                                                 h = '';
1214                                                 m = '';
1215                                                 line_time = function line_time(h, m) {
1216                                                         var now = _xdsoft_datetime.now();
1217                                                         now.setHours(h);
1218                                                         h = parseInt(now.getHours(), 10);
1219                                                         now.setMinutes(m);
1220                                                         m = parseInt(now.getMinutes(), 10);
1221
1222                                                         classes = [];
1223                                                         if ((options.maxTime !== false && _xdsoft_datetime.strtotime(options.maxTime).getTime() < now.getTime()) || (options.minTime !== false && _xdsoft_datetime.strtotime(options.minTime).getTime() > now.getTime())) {
1224                                                                 classes.push('xdsoft_disabled');
1225                                                         }
1226                                                         if ((options.initTime || options.defaultSelect || datetimepicker.data('changed')) && parseInt(_xdsoft_datetime.currentTime.getHours(), 10) === parseInt(h, 10) && (options.step > 59 || Math[options.roundTime](_xdsoft_datetime.currentTime.getMinutes() / options.step) * options.step === parseInt(m, 10))) {
1227                                                                 if (options.defaultSelect || datetimepicker.data('changed')) {
1228                                                                         classes.push('xdsoft_current');
1229                                                                 } else if (options.initTime) {
1230                                                                         classes.push('xdsoft_init_time');
1231                                                                 }
1232                                                         }
1233                                                         if (parseInt(today.getHours(), 10) === parseInt(h, 10) && parseInt(today.getMinutes(), 10) === parseInt(m, 10)) {
1234                                                                 classes.push('xdsoft_today');
1235                                                         }
1236                                                         time += '<div class="xdsoft_time ' + classes.join(' ') + '" data-hour="' + h + '" data-minute="' + m + '">' + now.dateFormat(options.formatTime) + '</div>';
1237                                                 };
1238
1239                                                 if (!options.allowTimes || !$.isArray(options.allowTimes) || !options.allowTimes.length) {
1240                                                         for (i = 0, j = 0; i < (options.hours12 ? 12 : 24); i += 1) {
1241                                                                 for (j = 0; j < 60; j += options.step) {
1242                                                                         h = (i < 10 ? '0' : '') + i;
1243                                                                         m = (j < 10 ? '0' : '') + j;
1244                                                                         line_time(h, m);
1245                                                                 }
1246                                                         }
1247                                                 } else {
1248                                                         for (i = 0; i < options.allowTimes.length; i += 1) {
1249                                                                 h = _xdsoft_datetime.strtotime(options.allowTimes[i]).getHours();
1250                                                                 m = _xdsoft_datetime.strtotime(options.allowTimes[i]).getMinutes();
1251                                                                 line_time(h, m);
1252                                                         }
1253                                                 }
1254
1255                                                 timebox.html(time);
1256
1257                                                 opt = '';
1258                                                 i = 0;
1259
1260                                                 for (i = parseInt(options.yearStart, 10) + options.yearOffset; i <= parseInt(options.yearEnd, 10) + options.yearOffset; i += 1) {
1261                                                         opt += '<div class="xdsoft_option ' + (_xdsoft_datetime.currentTime.getFullYear() === i ? 'xdsoft_current' : '') + '" data-value="' + i + '">' + i + '</div>';
1262                                                 }
1263                                                 yearselect.children().eq(0)
1264                                                                                                 .html(opt);
1265
1266                                                 for (i = 0, opt = ''; i <= 11; i += 1) {
1267                                                         opt += '<div class="xdsoft_option ' + (_xdsoft_datetime.currentTime.getMonth() === i ? 'xdsoft_current' : '') + '" data-value="' + i + '">' + options.i18n[options.lang].months[i] + '</div>';
1268                                                 }
1269                                                 monthselect.children().eq(0).html(opt);
1270                                                 $(datetimepicker)
1271                                                         .trigger('generate.xdsoft');
1272                                         }, 10);
1273                                         event.stopPropagation();
1274                                 })
1275                                 .on('afterOpen.xdsoft', function () {
1276                                         if (options.timepicker) {
1277                                                 var classType, pheight, height, top;
1278                                                 if (timebox.find('.xdsoft_current').length) {
1279                                                         classType = '.xdsoft_current';
1280                                                 } else if (timebox.find('.xdsoft_init_time').length) {
1281                                                         classType = '.xdsoft_init_time';
1282                                                 }
1283                                                 if (classType) {
1284                                                         pheight = timeboxparent[0].clientHeight;
1285                                                         height = timebox[0].offsetHeight;
1286                                                         top = timebox.find(classType).index() * options.timeHeightInTimePicker + 1;
1287                                                         if ((height - pheight) < top) {
1288                                                                 top = height - pheight;
1289                                                         }
1290                                                         timeboxparent.trigger('scroll_element.xdsoft_scroller', [parseInt(top, 10) / (height - pheight)]);
1291                                                 } else {
1292                                                         timeboxparent.trigger('scroll_element.xdsoft_scroller', [0]);
1293                                                 }
1294                                         }
1295                                 });
1296
1297                         timerclick = 0;
1298                         calendar
1299                                 .on('click.xdsoft', 'td', function (xdevent) {
1300                                         xdevent.stopPropagation();  // Prevents closing of Pop-ups, Modals and Flyouts in Bootstrap
1301                                         timerclick += 1;
1302                                         var $this = $(this),
1303                                                 currentTime = _xdsoft_datetime.currentTime;
1304
1305                                         if (currentTime === undefined || currentTime === null) {
1306                                                 _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
1307                                                 currentTime = _xdsoft_datetime.currentTime;
1308                                         }
1309
1310                                         if ($this.hasClass('xdsoft_disabled')) {
1311                                                 return false;
1312                                         }
1313
1314                                         currentTime.setDate(1);
1315                                         currentTime.setFullYear($this.data('year'));
1316                                         currentTime.setMonth($this.data('month'));
1317                                         currentTime.setDate($this.data('date'));
1318
1319                                         datetimepicker.trigger('select.xdsoft', [currentTime]);
1320
1321                                         input.val(_xdsoft_datetime.str());
1322                                         if ((timerclick > 1 || (options.closeOnDateSelect === true || (options.closeOnDateSelect === 0 && !options.timepicker))) && !options.inline) {
1323                                                 datetimepicker.trigger('close.xdsoft');
1324                                         }
1325
1326                                         if (options.onSelectDate &&     $.isFunction(options.onSelectDate)) {
1327                                                 options.onSelectDate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
1328                                         }
1329
1330                                         datetimepicker.data('changed', true);
1331                                         datetimepicker.trigger('xchange.xdsoft');
1332                                         datetimepicker.trigger('changedatetime.xdsoft');
1333                                         setTimeout(function () {
1334                                                 timerclick = 0;
1335                                         }, 200);
1336                                 });
1337
1338                         timebox
1339                                 .on('click.xdsoft', 'div', function (xdevent) {
1340                                         xdevent.stopPropagation();
1341                                         var $this = $(this),
1342                                                 currentTime = _xdsoft_datetime.currentTime;
1343
1344                                         if (currentTime === undefined || currentTime === null) {
1345                                                 _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
1346                                                 currentTime = _xdsoft_datetime.currentTime;
1347                                         }
1348
1349                                         if ($this.hasClass('xdsoft_disabled')) {
1350                                                 return false;
1351                                         }
1352                                         currentTime.setHours($this.data('hour'));
1353                                         currentTime.setMinutes($this.data('minute'));
1354                                         datetimepicker.trigger('select.xdsoft', [currentTime]);
1355
1356                                         datetimepicker.data('input').val(_xdsoft_datetime.str());
1357                                         if (!options.inline) {
1358                                                 datetimepicker.trigger('close.xdsoft');
1359                                         }
1360
1361                                         if (options.onSelectTime && $.isFunction(options.onSelectTime)) {
1362                                                 options.onSelectTime.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
1363                                         }
1364                                         datetimepicker.data('changed', true);
1365                                         datetimepicker.trigger('xchange.xdsoft');
1366                                         datetimepicker.trigger('changedatetime.xdsoft');
1367                                 });
1368
1369
1370                         datepicker
1371                                 .on('mousewheel.xdsoft', function (event) {
1372                                         if (!options.scrollMonth) {
1373                                                 return true;
1374                                         }
1375                                         if (event.deltaY < 0) {
1376                                                 _xdsoft_datetime.nextMonth();
1377                                         } else {
1378                                                 _xdsoft_datetime.prevMonth();
1379                                         }
1380                                         return false;
1381                                 });
1382
1383                         input
1384                                 .on('mousewheel.xdsoft', function (event) {
1385                                         if (!options.scrollInput) {
1386                                                 return true;
1387                                         }
1388                                         if (!options.datepicker && options.timepicker) {
1389                                                 current_time_index = timebox.find('.xdsoft_current').length ? timebox.find('.xdsoft_current').eq(0).index() : 0;
1390                                                 if (current_time_index + event.deltaY >= 0 && current_time_index + event.deltaY < timebox.children().length) {
1391                                                         current_time_index += event.deltaY;
1392                                                 }
1393                                                 if (timebox.children().eq(current_time_index).length) {
1394                                                         timebox.children().eq(current_time_index).trigger('mousedown');
1395                                                 }
1396                                                 return false;
1397                                         }
1398                                         if (options.datepicker && !options.timepicker) {
1399                                                 datepicker.trigger(event, [event.deltaY, event.deltaX, event.deltaY]);
1400                                                 if (input.val) {
1401                                                         input.val(_xdsoft_datetime.str());
1402                                                 }
1403                                                 datetimepicker.trigger('changedatetime.xdsoft');
1404                                                 return false;
1405                                         }
1406                                 });
1407
1408                         datetimepicker
1409                                 .on('changedatetime.xdsoft', function (event) {
1410                                         if (options.onChangeDateTime && $.isFunction(options.onChangeDateTime)) {
1411                                                 var $input = datetimepicker.data('input');
1412                                                 options.onChangeDateTime.call(datetimepicker, _xdsoft_datetime.currentTime, $input, event);
1413                                                 delete options.value;
1414                                                 $input.trigger('change');
1415                                         }
1416                                 })
1417                                 .on('generate.xdsoft', function () {
1418                                         if (options.onGenerate && $.isFunction(options.onGenerate)) {
1419                                                 options.onGenerate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
1420                                         }
1421                                         if (triggerAfterOpen) {
1422                                                 datetimepicker.trigger('afterOpen.xdsoft');
1423                                                 triggerAfterOpen = false;
1424                                         }
1425                                 })
1426                                 .on('click.xdsoft', function (xdevent) {
1427                                         xdevent.stopPropagation();
1428                                 });
1429
1430                         current_time_index = 0;
1431
1432                         setPos = function () {
1433                                 var offset = datetimepicker.data('input').offset(), top = offset.top + datetimepicker.data('input')[0].offsetHeight - 1, left = offset.left, position = "absolute";
1434                                 if (options.fixed) {
1435                                         top -= $(window).scrollTop();
1436                                         left -= $(window).scrollLeft();
1437                                         position = "fixed";
1438                                 } else {
1439                                         if (top + datetimepicker[0].offsetHeight > $(window).height() + $(window).scrollTop()) {
1440                                                 top = offset.top - datetimepicker[0].offsetHeight + 1;
1441                                         }
1442                                         if (top < 0) {
1443                                                 top = 0;
1444                                         }
1445                                         if (left + datetimepicker[0].offsetWidth > $(window).width()) {
1446                                                 left = $(window).width() - datetimepicker[0].offsetWidth;
1447                                         }
1448                                 }
1449                                 datetimepicker.css({
1450                                         left: left,
1451                                         top: top,
1452                                         position: position
1453                                 });
1454                         };
1455                         datetimepicker
1456                                 .on('open.xdsoft', function (event) {
1457                                         var onShow = true;
1458                                         if (options.onShow && $.isFunction(options.onShow)) {
1459                                                 onShow = options.onShow.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
1460                                         }
1461                                         if (onShow !== false) {
1462                                                 datetimepicker.show();
1463                                                 setPos();
1464                                                 $(window)
1465                                                         .off('resize.xdsoft', setPos)
1466                                                         .on('resize.xdsoft', setPos);
1467
1468                                                 if (options.closeOnWithoutClick) {
1469                                                         $([document.body, window]).on('mousedown.xdsoft', function arguments_callee6() {
1470                                                                 datetimepicker.trigger('close.xdsoft');
1471                                                                 $([document.body, window]).off('mousedown.xdsoft', arguments_callee6);
1472                                                         });
1473                                                 }
1474                                         }
1475                                 })
1476                                 .on('close.xdsoft', function (event) {
1477                                         var onClose = true;
1478                                         mounth_picker
1479                                                 .find('.xdsoft_month,.xdsoft_year')
1480                                                         .find('.xdsoft_select')
1481                                                                 .hide();
1482                                         if (options.onClose && $.isFunction(options.onClose)) {
1483                                                 onClose = options.onClose.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
1484                                         }
1485                                         if (onClose !== false && !options.opened && !options.inline) {
1486                                                 datetimepicker.hide();
1487                                         }
1488                                         event.stopPropagation();
1489                                 })
1490                                 .on('toggle.xdsoft', function (event) {
1491                                         datetimepicker.is(':visible') ? datetimepicker.trigger('close.xdsoft') : datetimepicker.trigger('open.xdsoft');
1492                                 })
1493                                 .data('input', input);
1494
1495                         timer = 0;
1496                         timer1 = 0;
1497
1498                         datetimepicker.data('xdsoft_datetime', _xdsoft_datetime);
1499                         datetimepicker.setOptions(options);
1500
1501                         function getCurrentValue() {
1502
1503                                 var ct = false, time;
1504
1505                                 if (options.startDate) {
1506                                         ct = _xdsoft_datetime.strToDate(options.startDate);
1507                                 } else {
1508                                         ct = options.value || ((input && input.val && input.val()) ? input.val() : '');
1509                                         if (ct) {
1510                                                 ct = _xdsoft_datetime.strToDateTime(ct);
1511                                         } else if (options.defaultDate) {
1512                                                 ct = _xdsoft_datetime.strToDate(options.defaultDate);
1513                                                 if (options.defaultTime) {
1514                                                         time = _xdsoft_datetime.strtotime(options.defaultTime);
1515                                                         ct.setHours(time.getHours());
1516                                                         ct.setMinutes(time.getMinutes());
1517                                                 }
1518                                         }
1519                                 }
1520
1521                                 if (ct && _xdsoft_datetime.isValidDate(ct)) {
1522                                         datetimepicker.data('changed', true);
1523                                 } else {
1524                                         ct = '';
1525                                 }
1526
1527                                 return ct || 0;
1528                         }
1529
1530                         _xdsoft_datetime.setCurrentTime(getCurrentValue());
1531
1532                         input
1533                                 .data('xdsoft_datetimepicker', datetimepicker)
1534                                 .on('open.xdsoft focusin.xdsoft mousedown.xdsoft', function (event) {
1535                                         if (input.is(':disabled') || input.is(':hidden') || !input.is(':visible') || (input.data('xdsoft_datetimepicker').is(':visible') && options.closeOnInputClick)) {
1536                                                 return;
1537                                         }
1538                                         clearTimeout(timer);
1539                                         timer = setTimeout(function () {
1540                                                 if (input.is(':disabled') || input.is(':hidden') || !input.is(':visible')) {
1541                                                         return;
1542                                                 }
1543
1544                                                 triggerAfterOpen = true;
1545                                                 _xdsoft_datetime.setCurrentTime(getCurrentValue());
1546
1547                                                 datetimepicker.trigger('open.xdsoft');
1548                                         }, 100);
1549                                 })
1550                                 .on('keydown.xdsoft', function (event) {
1551                                         var val = this.value, elementSelector,
1552                                                 key = event.which;
1553                                         if ([ENTER].indexOf(key) !== -1 && options.enterLikeTab) {
1554                                                 elementSelector = $("input:visible,textarea:visible");
1555                                                 datetimepicker.trigger('close.xdsoft');
1556                                                 elementSelector.eq(elementSelector.index(this) + 1).focus();
1557                                                 return false;
1558                                         }
1559                                         if ([TAB].indexOf(key) !== -1) {
1560                                                 datetimepicker.trigger('close.xdsoft');
1561                                                 return true;
1562                                         }
1563                                 });
1564                 };
1565                 destroyDateTimePicker = function (input) {
1566                         var datetimepicker = input.data('xdsoft_datetimepicker');
1567                         if (datetimepicker) {
1568                                 datetimepicker.data('xdsoft_datetime', null);
1569                                 datetimepicker.remove();
1570                                 input
1571                                         .data('xdsoft_datetimepicker', null)
1572                                         .off('.xdsoft');
1573                                 $(window).off('resize.xdsoft');
1574                                 $([window, document.body]).off('mousedown.xdsoft');
1575                                 if (input.unmousewheel) {
1576                                         input.unmousewheel();
1577                                 }
1578                         }
1579                 };
1580                 $(document)
1581                         .off('keydown.xdsoftctrl keyup.xdsoftctrl')
1582                         .on('keydown.xdsoftctrl', function (e) {
1583                                 if (e.keyCode === CTRLKEY) {
1584                                         ctrlDown = true;
1585                                 }
1586                         })
1587                         .on('keyup.xdsoftctrl', function (e) {
1588                                 if (e.keyCode === CTRLKEY) {
1589                                         ctrlDown = false;
1590                                 }
1591                         });
1592                 return this.each(function () {
1593                         var datetimepicker = $(this).data('xdsoft_datetimepicker');
1594                         if (datetimepicker) {
1595                                 if ($.type(opt) === 'string') {
1596                                         switch (opt) {
1597                                         case 'show':
1598                                                 $(this).select().focus();
1599                                                 datetimepicker.trigger('open.xdsoft');
1600                                                 break;
1601                                         case 'hide':
1602                                                 datetimepicker.trigger('close.xdsoft');
1603                                                 break;
1604                                         case 'toggle':
1605                                                 datetimepicker.trigger('toggle.xdsoft');
1606                                                 break;
1607                                         case 'destroy':
1608                                                 destroyDateTimePicker($(this));
1609                                                 break;
1610                                         case 'reset':
1611                                                 this.value = this.defaultValue;
1612                                                 if (!this.value || !datetimepicker.data('xdsoft_datetime').isValidDate(Date.parseDate(this.value, options.format))) {
1613                                                         datetimepicker.data('changed', false);
1614                                                 }
1615                                                 datetimepicker.data('xdsoft_datetime').setCurrentTime(this.value);
1616                                                 break;
1617                                         }
1618                                 } else {
1619                                         datetimepicker
1620                                                 .setOptions(opt);
1621                                 }
1622                                 return 0;
1623                         }
1624                         if ($.type(opt) !== 'string') {
1625                                 if (!options.lazyInit || options.open || options.inline) {
1626                                         createDateTimePicker($(this));
1627                                 } else {
1628                                         lazyInit($(this));
1629                                 }
1630                         }
1631                 });
1632         };
1633         $.fn.datetimepicker.defaults = default_options;
1634 }(jQuery));
1635 (function () {
1636
1637 /*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh)
1638  * Licensed under the MIT License (LICENSE.txt).
1639  *
1640  * Version: 3.1.12
1641  *
1642  * Requires: jQuery 1.2.2+
1643  */
1644 !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b),d=c["offsetParent"in a.fn?"offsetParent":"parent"]();return d.length||(d=a("body")),parseInt(d.css("fontSize"),10)||parseInt(c.css("fontSize"),10)||16},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})});
1645
1646 // Parse and Format Library
1647 //http://www.xaprb.com/blog/2005/12/12/javascript-closures-for-runtime-efficiency/
1648 /*
1649  * Copyright (C) 2004 Baron Schwartz <baron at sequent dot org>
1650  *
1651  * This program is free software; you can redistribute it and/or modify it
1652  * under the terms of the GNU Lesser General Public License as published by the
1653  * Free Software Foundation, version 2.1.
1654  *
1655  * This program is distributed in the hope that it will be useful, but WITHOUT
1656  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1657  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
1658  * details.
1659  */
1660 Date.parseFunctions={count:0};Date.parseRegexes=[];Date.formatFunctions={count:0};Date.prototype.dateFormat=function(b){if(b=="unixtime"){return parseInt(this.getTime()/1000);}if(Date.formatFunctions[b]==null){Date.createNewFormat(b);}var a=Date.formatFunctions[b];return this[a]();};Date.createNewFormat=function(format){var funcName="format"+Date.formatFunctions.count++;Date.formatFunctions[format]=funcName;var code="Date.prototype."+funcName+" = function() {return ";var special=false;var ch="";for(var i=0;i<format.length;++i){ch=format.charAt(i);if(!special&&ch=="\\"){special=true;}else{if(special){special=false;code+="'"+String.escape(ch)+"' + ";}else{code+=Date.getFormatCode(ch);}}}eval(code.substring(0,code.length-3)+";}");};Date.getFormatCode=function(a){switch(a){case"d":return"String.leftPad(this.getDate(), 2, '0') + ";case"D":return"Date.dayNames[this.getDay()].substring(0, 3) + ";case"j":return"this.getDate() + ";case"l":return"Date.dayNames[this.getDay()] + ";case"S":return"this.getSuffix() + ";case"w":return"this.getDay() + ";case"z":return"this.getDayOfYear() + ";case"W":return"this.getWeekOfYear() + ";case"F":return"Date.monthNames[this.getMonth()] + ";case"m":return"String.leftPad(this.getMonth() + 1, 2, '0') + ";case"M":return"Date.monthNames[this.getMonth()].substring(0, 3) + ";case"n":return"(this.getMonth() + 1) + ";case"t":return"this.getDaysInMonth() + ";case"L":return"(this.isLeapYear() ? 1 : 0) + ";case"Y":return"this.getFullYear() + ";case"y":return"('' + this.getFullYear()).substring(2, 4) + ";case"a":return"(this.getHours() < 12 ? 'am' : 'pm') + ";case"A":return"(this.getHours() < 12 ? 'AM' : 'PM') + ";case"g":return"((this.getHours() %12) ? this.getHours() % 12 : 12) + ";case"G":return"this.getHours() + ";case"h":return"String.leftPad((this.getHours() %12) ? this.getHours() % 12 : 12, 2, '0') + ";case"H":return"String.leftPad(this.getHours(), 2, '0') + ";case"i":return"String.leftPad(this.getMinutes(), 2, '0') + ";case"s":return"String.leftPad(this.getSeconds(), 2, '0') + ";case"O":return"this.getGMTOffset() + ";case"T":return"this.getTimezone() + ";case"Z":return"(this.getTimezoneOffset() * -60) + ";default:return"'"+String.escape(a)+"' + ";}};Date.parseDate=function(a,c){if(c=="unixtime"){return new Date(!isNaN(parseInt(a))?parseInt(a)*1000:0);}if(Date.parseFunctions[c]==null){Date.createParser(c);}var b=Date.parseFunctions[c];return Date[b](a);};Date.createParser=function(format){var funcName="parse"+Date.parseFunctions.count++;var regexNum=Date.parseRegexes.length;var currentGroup=1;Date.parseFunctions[format]=funcName;var code="Date."+funcName+" = function(input) {\nvar y = -1, m = -1, d = -1, h = -1, i = -1, s = -1, z = -1;\nvar d = new Date();\ny = d.getFullYear();\nm = d.getMonth();\nd = d.getDate();\nvar results = input.match(Date.parseRegexes["+regexNum+"]);\nif (results && results.length > 0) {";var regex="";var special=false;var ch="";for(var i=0;i<format.length;++i){ch=format.charAt(i);if(!special&&ch=="\\"){special=true;}else{if(special){special=false;regex+=String.escape(ch);}else{obj=Date.formatCodeToRegex(ch,currentGroup);currentGroup+=obj.g;regex+=obj.s;if(obj.g&&obj.c){code+=obj.c;}}}}code+="if (y > 0 && z > 0){\nvar doyDate = new Date(y,0);\ndoyDate.setDate(z);\nm = doyDate.getMonth();\nd = doyDate.getDate();\n}";code+="if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n{return new Date(y, m, d, h, i, s);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n{return new Date(y, m, d, h, i);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0)\n{return new Date(y, m, d, h);}\nelse if (y > 0 && m >= 0 && d > 0)\n{return new Date(y, m, d);}\nelse if (y > 0 && m >= 0)\n{return new Date(y, m);}\nelse if (y > 0)\n{return new Date(y);}\n}return null;}";Date.parseRegexes[regexNum]=new RegExp("^"+regex+"$");eval(code);};Date.formatCodeToRegex=function(b,a){switch(b){case"D":return{g:0,c:null,s:"(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)"};case"j":case"d":return{g:1,c:"d = parseInt(results["+a+"], 10);\n",s:"(\\d{1,2})"};case"l":return{g:0,c:null,s:"(?:"+Date.dayNames.join("|")+")"};case"S":return{g:0,c:null,s:"(?:st|nd|rd|th)"};case"w":return{g:0,c:null,s:"\\d"};case"z":return{g:1,c:"z = parseInt(results["+a+"], 10);\n",s:"(\\d{1,3})"};case"W":return{g:0,c:null,s:"(?:\\d{2})"};case"F":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+a+"].substring(0, 3)], 10);\n",s:"("+Date.monthNames.join("|")+")"};case"M":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+a+"]], 10);\n",s:"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"};case"n":case"m":return{g:1,c:"m = parseInt(results["+a+"], 10) - 1;\n",s:"(\\d{1,2})"};case"t":return{g:0,c:null,s:"\\d{1,2}"};case"L":return{g:0,c:null,s:"(?:1|0)"};case"Y":return{g:1,c:"y = parseInt(results["+a+"], 10);\n",s:"(\\d{4})"};case"y":return{g:1,c:"var ty = parseInt(results["+a+"], 10);\ny = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",s:"(\\d{1,2})"};case"a":return{g:1,c:"if (results["+a+"] == 'am') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",s:"(am|pm)"};case"A":return{g:1,c:"if (results["+a+"] == 'AM') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",s:"(AM|PM)"};case"g":case"G":case"h":case"H":return{g:1,c:"h = parseInt(results["+a+"], 10);\n",s:"(\\d{1,2})"};case"i":return{g:1,c:"i = parseInt(results["+a+"], 10);\n",s:"(\\d{2})"};case"s":return{g:1,c:"s = parseInt(results["+a+"], 10);\n",s:"(\\d{2})"};case"O":return{g:0,c:null,s:"[+-]\\d{4}"};case"T":return{g:0,c:null,s:"[A-Z]{3}"};case"Z":return{g:0,c:null,s:"[+-]\\d{1,5}"};default:return{g:0,c:null,s:String.escape(b)};}};Date.prototype.getTimezone=function(){return this.toString().replace(/^.*? ([A-Z]{3}) [0-9]{4}.*$/,"$1").replace(/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/,"$1$2$3");};Date.prototype.getGMTOffset=function(){return(this.getTimezoneOffset()>0?"-":"+")+String.leftPad(Math.floor(Math.abs(this.getTimezoneOffset())/60),2,"0")+String.leftPad(Math.abs(this.getTimezoneOffset())%60,2,"0");};Date.prototype.getDayOfYear=function(){var a=0;Date.daysInMonth[1]=this.isLeapYear()?29:28;for(var b=0;b<this.getMonth();++b){a+=Date.daysInMonth[b];}return a+this.getDate();};Date.prototype.getWeekOfYear=function(){var b=this.getDayOfYear()+(4-this.getDay());var a=new Date(this.getFullYear(),0,1);var c=(7-a.getDay()+4);return String.leftPad(Math.ceil((b-c)/7)+1,2,"0");};Date.prototype.isLeapYear=function(){var a=this.getFullYear();return((a&3)==0&&(a%100||(a%400==0&&a)));};Date.prototype.getFirstDayOfMonth=function(){var a=(this.getDay()-(this.getDate()-1))%7;return(a<0)?(a+7):a;};Date.prototype.getLastDayOfMonth=function(){var a=(this.getDay()+(Date.daysInMonth[this.getMonth()]-this.getDate()))%7;return(a<0)?(a+7):a;};Date.prototype.getDaysInMonth=function(){Date.daysInMonth[1]=this.isLeapYear()?29:28;return Date.daysInMonth[this.getMonth()];};Date.prototype.getSuffix=function(){switch(this.getDate()){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th";}};String.escape=function(a){return a.replace(/('|\\)/g,"\\$1");};String.leftPad=function(d,b,c){var a=new String(d);if(c==null){c=" ";}while(a.length<b){a=c+a;}return a;};Date.daysInMonth=[31,28,31,30,31,30,31,31,30,31,30,31];Date.monthNames=["January","February","March","April","May","June","July","August","September","October","November","December"];Date.dayNames=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];Date.y2kYear=50;Date.monthNumbers={Jan:0,Feb:1,Mar:2,Apr:3,May:4,Jun:5,Jul:6,Aug:7,Sep:8,Oct:9,Nov:10,Dec:11};Date.patterns={ISO8601LongPattern:"Y-m-d H:i:s",ISO8601ShortPattern:"Y-m-d",ShortDatePattern:"n/j/Y",LongDatePattern:"l, F d, Y",FullDateTimePattern:"l, F d, Y g:i:s A",MonthDayPattern:"F d",ShortTimePattern:"g:i A",LongTimePattern:"g:i:s A",SortableDateTimePattern:"Y-m-d\\TH:i:s",UniversalSortableDateTimePattern:"Y-m-d H:i:sO",YearMonthPattern:"F, Y"};
1661 }());