jquery-datetimepicker-rails 2.3.0.0 → 2.3.7.0

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