simple_form_extension 1.0.2 → 1.0.3

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