xdan-datetimepicker-rails 2.3.6 → 2.3.7

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