xdan-datetimepicker-rails 2.1.9 → 2.2.5

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: aaf6cad5e688683672d3abca3e58770c388a50d6
4
- data.tar.gz: ae36d36f213ce8c0dae5c622fbf4284d1bd236f3
3
+ metadata.gz: b3749340fc68f467cf181d96a09e15a84b643018
4
+ data.tar.gz: 3618731ed9568522a117fb0c48371c223739b4bf
5
5
  SHA512:
6
- metadata.gz: d70510b01d80ce8f3990c4bfaad7231285b6fe72686efa0b6436cbdf7be736911731343d0f63b8088bad31d81dccb005da3721a22c404c96b11b8eb2fb37414c
7
- data.tar.gz: f6972b1944a27a35b4f01b31d812fcd6a0b7d6f65e096eedff88044ac5c6bc1cb30ead49311723c8a3523d63c9e3af43dedca77e60b48d893bd4e1a59be65139
6
+ metadata.gz: 910f4a7850a5981f872d5fa19af085063257ee19b7b3e82c89a66224f790391fd33d64ec2fe89c49f8952735deb6ceb10dc0f9ab20376c3acd27ff10ce8cafe6
7
+ data.tar.gz: 32e22ff9f1a95a94af42f9f86c5949a40c8814b2e5bb9a6953646e75e9e944da80693c05dd84dc0f7853cc07e5fc8f8eb2fce4e3e17f2b8571f4ffeefce1c02c
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Xdan Datetimepicker Rails
2
2
 
3
- This gem adds @xdan's [datetimepicker] to the Rails asset pipeline.
3
+ This gem adds @xdan's [datetimepicker](https://github.com/xdan/datetimepicker) to the Rails asset pipeline.
4
4
 
5
5
  ## Installation
6
6
 
@@ -37,6 +37,12 @@ $ ->
37
37
  $(".datetimepicker").datetimepicker()
38
38
  ```
39
39
 
40
+ See the [detailed documentation](http://xdsoft.net/jqplugins/datetimepicker/) for more options. When the site is back up I'll try to port some of them into this README or move them to the official repo of [datetimepicker](https://github.com/xdan/datetimepicker).
41
+
42
+ ## Versioning
43
+
44
+ This gem will attempt to maintain the same version as the `datetimepicker` library.
45
+
40
46
  ## Contributing
41
47
 
42
48
  1. Fork it ( http://github.com/<my-github-username>/xdan-datetimepicker-rails/fork )
data/Rakefile CHANGED
@@ -6,21 +6,16 @@ require 'open-uri'
6
6
  namespace :source do
7
7
  desc "update the source file"
8
8
  task :update do
9
+ version = ENV['version'] || 'master'
9
10
  puts "Downloading jquery.datetimepicker.js..."
10
- download "https://raw.github.com/xdan/datetimepicker/master/jquery.datetimepicker.js", "app/assets/javascripts/jquery.xdan.datetimepicker.js"
11
+ download "https://raw.github.com/xdan/datetimepicker/#{version}/jquery.datetimepicker.js", "app/assets/javascripts/jquery.xdan.datetimepicker.js"
11
12
 
12
13
  puts "Downloading jquery.datetimepicker.css..."
13
- download "https://raw.github.com/xdan/datetimepicker/master/jquery.datetimepicker.css", "app/assets/stylesheets/jquery.xdan.datetimepicker.css"
14
+ download "https://raw.github.com/xdan/datetimepicker/#{version}/jquery.datetimepicker.css", "app/assets/stylesheets/jquery.xdan.datetimepicker.css"
14
15
  end
15
16
  end
16
17
 
17
18
 
18
19
  def download remote_path, local_path
19
20
  `wget -O #{local_path} #{remote_path}`
20
- # File.open(local_path, "wb") do |saved_file|
21
- # # the following "open" is provided by open-uri
22
- # open(remote_path, "rb") do |read_file|
23
- # saved_file.write(read_file.read)
24
- # end
25
- # end
26
21
  end
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @preserve jQuery DateTimePicker plugin v2.1.9
2
+ * @preserve jQuery DateTimePicker plugin v2.2.5
3
3
  * @homepage http://xdsoft.net/jqplugins/datetimepicker/
4
4
  * (c) 2014, Chupurnov Valeriy.
5
5
  */
@@ -102,25 +102,69 @@
102
102
  dayOfWeek: [
103
103
  "Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör"
104
104
  ]
105
+ },
106
+ kr:{ // Korean
107
+ months: [
108
+ "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"
109
+ ],
110
+ dayOfWeek: [
111
+ "일", "월", "화", "수", "목", "금", "토"
112
+ ]
113
+ },
114
+ it:{ // Italian
115
+ months: [
116
+ "Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"
117
+ ],
118
+ dayOfWeek: [
119
+ "Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab"
120
+ ]
121
+ },
122
+ da:{ // Dansk
123
+ months: [
124
+ "January", "Februar", "Marts", "April", "Maj", "Juni", "July", "August", "September", "Oktober", "November", "December"
125
+ ],
126
+ dayOfWeek: [
127
+ "Søn", "Man", "Tir", "ons", "Tor", "Fre", "lør"
128
+ ]
129
+ },
130
+ ja:{ // Japanese
131
+ months: [
132
+ "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"
133
+ ],
134
+ dayOfWeek: [
135
+ "日", "月", "火", "水", "木", "金", "土"
136
+ ]
105
137
  }
106
138
  },
107
139
  value:'',
108
- lang:'en',
109
- format:'Y/m/d H:i',
110
- formatTime:'H:i',
111
- formatDate:'Y/m/d',
140
+ lang: 'en',
141
+
142
+ format: 'Y/m/d H:i',
143
+ formatTime: 'H:i',
144
+ formatDate: 'Y/m/d',
145
+
146
+ startDate: false, // new Date(), '1986/12/08', '-1970/01/05','-1970/01/05',
147
+
148
+ //fromUnixtime: false,
149
+
112
150
  step:60,
113
- closeOnDateSelect:0,
151
+
152
+ closeOnDateSelect:false,
114
153
  closeOnWithoutClick:true,
154
+
115
155
  timepicker:true,
116
156
  datepicker:true,
157
+
117
158
  minDate:false,
118
159
  maxDate:false,
119
160
  minTime:false,
120
161
  maxTime:false,
162
+
121
163
  allowTimes:[],
122
164
  opened:false,
165
+ initTime:true,
123
166
  inline:false,
167
+
124
168
  onSelectDate:function() {},
125
169
  onSelectTime:function() {},
126
170
  onChangeMonth:function() {},
@@ -128,31 +172,44 @@
128
172
  onShow:function() {},
129
173
  onClose:function() {},
130
174
  onGenerate:function() {},
175
+
131
176
  withoutCopyright:true,
177
+
132
178
  inverseButton:false,
133
179
  hours12:false,
134
180
  next: 'xdsoft_next',
135
181
  prev : 'xdsoft_prev',
136
182
  dayOfWeekStart:0,
183
+
137
184
  timeHeightInTimePicker:25,
138
185
  timepickerScrollbar:true,
186
+
139
187
  todayButton:true, // 2.1.0
140
188
  defaultSelect:true, // 2.1.0
189
+
141
190
  scrollMonth:true,
142
191
  scrollTime:true,
143
192
  scrollInput:true,
193
+
194
+ lazyInit:false,
195
+
144
196
  mask:false,
145
197
  validateOnBlur:true,
146
- allowBlank:false,
198
+ allowBlank:true,
199
+
147
200
  yearStart:1950,
148
201
  yearEnd:2050,
202
+
149
203
  style:'',
150
204
  id:'',
205
+
151
206
  roundTime:'round', // ceil, floor
152
207
  className:'',
208
+
153
209
  weekends : [],
154
210
  yearOffset:0
155
211
  };
212
+
156
213
  // fix for ie8
157
214
  if ( !Array.prototype.indexOf ) {
158
215
  Array.prototype.indexOf = function(obj, start) {
@@ -162,6 +219,7 @@
162
219
  return -1;
163
220
  }
164
221
  };
222
+
165
223
  $.fn.xdsoftScroller = function( _percent ) {
166
224
  return this.each(function() {
167
225
  var timeboxparent = $(this);
@@ -282,7 +340,32 @@
282
340
  YKEY = 89,
283
341
  ctrlDown = false,
284
342
  options = ($.isPlainObject(opt)||!opt)?$.extend(true,{},default_options,opt):$.extend({},default_options),
343
+
344
+ lazyInitTimer = 0,
345
+
346
+ lazyInit = function( input ){
347
+ input
348
+ .on('open.xdsoft focusin.xdsoft mousedown.xdsoft',function initOnActionCallback(event) {
349
+ if( input.is(':disabled')||input.is(':hidden')||!input.is(':visible')||input.data( 'xdsoft_datetimepicker') )
350
+ return;
351
+
352
+ clearTimeout(lazyInitTimer);
353
+
354
+ lazyInitTimer = setTimeout(function() {
355
+
356
+ if( !input.data( 'xdsoft_datetimepicker') )
357
+ createDateTimePicker(input);
358
+
359
+ input
360
+ .off('open.xdsoft focusin.xdsoft mousedown.xdsoft',initOnActionCallback)
361
+ .trigger('open.xdsoft');
362
+ },100);
363
+
364
+ });
365
+ },
366
+
285
367
  createDateTimePicker = function( input ) {
368
+
286
369
  var datetimepicker = $('<div '+(options.id?'id="'+options.id+'"':'')+' '+(options.style?'style="'+options.style+'"':'')+' class="xdsoft_datetimepicker xdsoft_noselect '+options.className+'"></div>'),
287
370
  xdsoft_copyright = $('<div class="xdsoft_copyright"><a target="_blank" href="http://xdsoft.net/jqplugins/datetimepicker/">xdsoft.net</a></div>'),
288
371
  datepicker = $('<div class="xdsoft_datepicker active"></div>'),
@@ -310,6 +393,7 @@
310
393
  mounth_picker
311
394
  .find('.xdsoft_select')
312
395
  .hide();
396
+
313
397
  var select = $(this).find('.xdsoft_select').eq(0),
314
398
  val = 0,
315
399
  top = 0;
@@ -318,6 +402,7 @@
318
402
  val = _xdsoft_datetime.currentTime[$(this).hasClass('xdsoft_month')?'getMonth':'getFullYear']();
319
403
 
320
404
  select.show();
405
+
321
406
  for(var items = select.find('div.xdsoft_option'),i = 0;i<items.length;i++) {
322
407
  if( items.eq(i).data('value')==val ) {
323
408
  break;
@@ -326,6 +411,7 @@
326
411
 
327
412
  select.xdsoftScroller(top/(select.children()[0].offsetHeight-(select[0].clientHeight)));
328
413
  event.stopPropagation();
414
+
329
415
  return false;
330
416
  });
331
417
 
@@ -339,7 +425,9 @@
339
425
  .on('mousedown.xdsoft','.xdsoft_option',function( event ) {
340
426
  if( _xdsoft_datetime&&_xdsoft_datetime.currentTime )
341
427
  _xdsoft_datetime.currentTime[$(this).parent().parent().hasClass('xdsoft_monthselect')?'setMonth':'setFullYear']($(this).data('value'));
428
+
342
429
  $(this).parent().parent().hide();
430
+
343
431
  datetimepicker.trigger('xchange.xdsoft');
344
432
  options.onChangeMonth&&options.onChangeMonth.call&&options.onChangeMonth.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input'));
345
433
  });
@@ -348,6 +436,15 @@
348
436
  // set options
349
437
  datetimepicker.setOptions = function( _options ) {
350
438
  options = $.extend(true,{},options,_options);
439
+
440
+ if( _options.allowTimes && $.isArray(_options.allowTimes) && _options.allowTimes.length ){
441
+ options['allowTimes'] = $.extend(true,[],_options.allowTimes);
442
+ }
443
+
444
+ if( _options.weekends && $.isArray(_options.weekends) && _options.weekends.length ){
445
+ options['weekends'] = $.extend(true,[],_options.weekends);
446
+ }
447
+
351
448
  if( (options.open||options.opened)&&(!options.inline) ) {
352
449
  input.trigger('open.xdsoft');
353
450
  }
@@ -363,10 +460,14 @@
363
460
  options.prev = 'xdsoft_next';
364
461
  }
365
462
 
366
- if( !options.datepicker && options.timepicker )
463
+ if( options.datepicker )
464
+ datepicker.addClass('active');
465
+ else
367
466
  datepicker.removeClass('active');
368
-
369
- if( options.datepicker && !options.timepicker )
467
+
468
+ if( options.timepicker )
469
+ timepicker.addClass('active');
470
+ else
370
471
  timepicker.removeClass('active');
371
472
 
372
473
  if( options.value ){
@@ -381,17 +482,15 @@
381
482
 
382
483
  if( !options.timepickerScrollbar )
383
484
  scrollbar.hide();
384
-
385
- var tmpDate = [],timeOffset;
386
- if( options.minDate && ( tmpDate = /^-(.*)$/.exec(options.minDate) ) && (tmpDate=Date.parseDate(tmpDate[1], options.formatDate)) ) {
387
- timeOffset = tmpDate.getTime()+-1*(tmpDate.getTimezoneOffset())*60000;
388
- options.minDate = new Date((_xdsoft_datetime.now()).getTime()-timeOffset).dateFormat( options.formatDate );
485
+
486
+ if( options.minDate && /^-(.*)$/.test(options.minDate) ){
487
+ options.minDate = _xdsoft_datetime.strToDateTime(options.minDate).dateFormat( options.formatDate );
389
488
  }
390
- if( options.maxDate && ( tmpDate = /^\+(.*)$/.exec(options.maxDate) ) && (tmpDate=Date.parseDate(tmpDate[1], options.formatDate)) ) {
391
- timeOffset = tmpDate.getTime()+-1*(tmpDate.getTimezoneOffset())*60000;
392
- options.maxDate = new Date((_xdsoft_datetime.now()).getTime()+timeOffset).dateFormat( options.formatDate );
489
+
490
+ if( options.maxDate && /^\+(.*)$/.test(options.maxDate) ) {
491
+ options.maxDate = _xdsoft_datetime.strToDateTime(options.maxDate).dateFormat( options.formatDate );
393
492
  }
394
-
493
+
395
494
  mounth_picker
396
495
  .find('.xdsoft_today_button')
397
496
  .css('visibility',!options.todayButton?'hidden':'visible');
@@ -439,8 +538,7 @@
439
538
  input.off('keydown.xdsoft');
440
539
  switch(true) {
441
540
  case ( options.mask===true ):
442
- //options.mask = (new Date()).dateFormat( options.format );
443
- //options.mask = options.mask.replace(/[0-9]/g,'_');
541
+
444
542
  options.mask = options.format
445
543
  .replace(/Y/g,'9999')
446
544
  .replace(/F/g,'9999')
@@ -449,34 +547,41 @@
449
547
  .replace(/H/g,'29')
450
548
  .replace(/i/g,'59')
451
549
  .replace(/s/g,'59');
550
+
452
551
  case ( $.type(options.mask) == 'string' ):
552
+
453
553
  if( !isValidValue( options.mask,input.val() ) )
454
554
  input.val(options.mask.replace(/[0-9]/g,'_'));
455
555
 
456
556
  input.on('keydown.xdsoft',function( event ) {
457
557
  var val = this.value,
458
558
  key = event.which;
559
+
459
560
  switch(true) {
460
561
  case (( key>=KEY0&&key<=KEY9 )||( key>=_KEY0&&key<=_KEY9 ))||(key==BACKSPACE||key==DEL):
461
562
  var pos = getCaretPos(this),
462
563
  digit = ( key!=BACKSPACE&&key!=DEL )?String.fromCharCode((_KEY0 <= key && key <= _KEY9)? key-KEY0 : key):'_';
564
+
463
565
  if( (key==BACKSPACE||key==DEL)&&pos ) {
464
566
  pos--;
465
567
  digit='_';
466
568
  }
569
+
467
570
  while( /[^0-9_]/.test(options.mask.substr(pos,1))&&pos<options.mask.length&&pos>0 )
468
571
  pos+=( key==BACKSPACE||key==DEL )?-1:1;
469
572
 
470
573
  val = val.substr(0,pos)+digit+val.substr(pos+1);
471
- if( $.trim(val)=='' )
574
+ if( $.trim(val)=='' ){
472
575
  val = options.mask.replace(/[0-9]/g,'_');
473
- else
576
+ }else{
474
577
  if( pos==options.mask.length )
475
578
  break;
476
-
579
+ }
580
+
477
581
  pos+=(key==BACKSPACE||key==DEL)?0:1;
478
582
  while( /[^0-9_]/.test(options.mask.substr(pos,1))&&pos<options.mask.length&&pos>0 )
479
583
  pos+=(key==BACKSPACE||key==DEL)?-1:1;
584
+
480
585
  if( isValidValue( options.mask,val ) ) {
481
586
  this.value = val;
482
587
  setCaretPos(this,pos);
@@ -566,7 +671,7 @@
566
671
  };
567
672
 
568
673
  _this.setCurrentTime = function( dTime) {
569
- _this.currentTime = (typeof dTime == 'string')? _this.strtodatetime(dTime) : _this.isValidDate(dTime) ? dTime: _this.now();
674
+ _this.currentTime = (typeof dTime == 'string')? _this.strToDateTime(dTime) : _this.isValidDate(dTime) ? dTime: _this.now();
570
675
  datetimepicker.trigger('xchange.xdsoft');
571
676
  };
572
677
 
@@ -614,10 +719,18 @@
614
719
  return month;
615
720
  };
616
721
 
617
- _this.strtodatetime = function( sDateTime ) {
618
- var currentTime = sDateTime?Date.parseDate(sDateTime, options.format):_this.now();
722
+ _this.strToDateTime = function( sDateTime ) {
723
+ var tmpDate = [],timeOffset,currentTime;
724
+
725
+ if( ( tmpDate = /^(\+|\-)(.*)$/.exec(sDateTime) ) && ( tmpDate[2]=Date.parseDate(tmpDate[2], options.formatDate) ) ) {
726
+ timeOffset = tmpDate[2].getTime()-1*(tmpDate[2].getTimezoneOffset())*60000;
727
+ currentTime = new Date((_xdsoft_datetime.now()).getTime()+parseInt(tmpDate[1]+'1')*timeOffset);
728
+ }else
729
+ currentTime = sDateTime?Date.parseDate(sDateTime, options.format):_this.now();
730
+
619
731
  if( !_this.isValidDate(currentTime) )
620
732
  currentTime = _this.now();
733
+
621
734
  return currentTime;
622
735
  };
623
736
 
@@ -701,157 +814,188 @@
701
814
  });
702
815
  });
703
816
 
817
+ var xchangeTimer = 0;
704
818
  // base handler - generating a calendar and timepicker
705
819
  datetimepicker
706
820
  .on('xchange.xdsoft',function( event ) {
707
- var table = '',
708
- start = new Date(_xdsoft_datetime.currentTime.getFullYear(),_xdsoft_datetime.currentTime.getMonth(),1),
709
- i = 0,
710
- today = _xdsoft_datetime.now();
711
- while( start.getDay()!=options.dayOfWeekStart )
712
- start.setDate(start.getDate()-1);
713
-
714
- //generate calendar
715
- table+='<table><thead><tr>';
716
-
717
- // days
718
- for(var j = 0; j<7; j++) {
719
- table+='<th>'+options.i18n[options.lang].dayOfWeek[(j+options.dayOfWeekStart)>6?0:j+options.dayOfWeekStart]+'</th>';
720
- }
721
-
722
- table+='</tr></thead>';
723
- table+='<tbody><tr>';
724
- var maxDate = false, minDate = false;
725
- if( options.maxDate!==false ) {
726
- maxDate = _xdsoft_datetime.strtodate(options.maxDate);
727
- maxDate = new Date(maxDate.getFullYear(),maxDate.getMonth(),maxDate.getDate(),23,59,59,999);
728
- }
729
- if( options.minDate!==false ) {
730
- minDate = _xdsoft_datetime.strtodate(options.minDate);
731
- minDate = new Date(minDate.getFullYear(),minDate.getMonth(),minDate.getDate());
732
- }
733
- var d,y,m,classes = [];
734
- while( i<_xdsoft_datetime.currentTime.getDaysInMonth()||start.getDay()!=options.dayOfWeekStart||_xdsoft_datetime.currentTime.getMonth()==start.getMonth() ) {
735
- classes = [];
736
- i++;
821
+ clearTimeout(xchangeTimer);
822
+ xchangeTimer = setTimeout(function(){
823
+ var table = '',
824
+ start = new Date(_xdsoft_datetime.currentTime.getFullYear(),_xdsoft_datetime.currentTime.getMonth(),1, 12, 0, 0),
825
+ i = 0,
826
+ today = _xdsoft_datetime.now();
827
+
828
+ console.log('fire xchange.xdsoft',_xdsoft_datetime.currentTime); // remove
829
+
830
+ while( start.getDay()!=options.dayOfWeekStart )
831
+ start.setDate(start.getDate()-1);
832
+
833
+ //generate calendar
834
+ table+='<table><thead><tr>';
835
+
836
+ // days
837
+ for(var j = 0; j<7; j++) {
838
+ table+='<th>'+options.i18n[options.lang].dayOfWeek[(j+options.dayOfWeekStart)>6?0:j+options.dayOfWeekStart]+'</th>';
839
+ }
737
840
 
738
- d = start.getDate(); y = start.getFullYear(); m = start.getMonth();
841
+ table+='</tr></thead>';
842
+ table+='<tbody><tr>';
843
+ var maxDate = false, minDate = false;
844
+
845
+ if( options.maxDate!==false ) {
846
+ maxDate = _xdsoft_datetime.strtodate(options.maxDate);
847
+ maxDate = new Date(maxDate.getFullYear(),maxDate.getMonth(),maxDate.getDate(),23,59,59,999);
848
+ }
849
+
850
+ if( options.minDate!==false ) {
851
+ minDate = _xdsoft_datetime.strtodate(options.minDate);
852
+ minDate = new Date(minDate.getFullYear(),minDate.getMonth(),minDate.getDate());
853
+ }
854
+
855
+ var d,y,m,classes = [];
856
+
857
+ while( i<_xdsoft_datetime.currentTime.getDaysInMonth()||start.getDay()!=options.dayOfWeekStart||_xdsoft_datetime.currentTime.getMonth()==start.getMonth() ) {
858
+ classes = [];
859
+ i++;
739
860
 
740
- classes.push('xdsoft_date');
861
+ d = start.getDate(); y = start.getFullYear(); m = start.getMonth();
741
862
 
742
- if( ( maxDate!==false && start > maxDate )||( minDate!==false && start < minDate ) ){
743
- classes.push('xdsoft_disabled');
744
- }
863
+ classes.push('xdsoft_date');
745
864
 
746
- if( _xdsoft_datetime.currentTime.getMonth()!=m ) classes.push('xdsoft_other_month');
865
+ if( ( maxDate!==false && start > maxDate )||( minDate!==false && start < minDate ) ){
866
+ classes.push('xdsoft_disabled');
867
+ }
747
868
 
748
- if( (options.defaultSelect||datetimepicker.data('changed')) && _xdsoft_datetime.currentTime.dateFormat('d.m.Y')==start.dateFormat('d.m.Y') ) {
749
- classes.push('xdsoft_current');
750
- }
869
+ if( _xdsoft_datetime.currentTime.getMonth()!=m ){
870
+ classes.push('xdsoft_other_month');
871
+ }
751
872
 
752
- if( today.dateFormat('d.m.Y')==start.dateFormat('d.m.Y') ) {
753
- classes.push('xdsoft_today');
754
- }
873
+ if( (options.defaultSelect||datetimepicker.data('changed')) && _xdsoft_datetime.currentTime.dateFormat('d.m.Y')==start.dateFormat('d.m.Y') ) {
874
+ classes.push('xdsoft_current');
875
+ }
755
876
 
756
- if( start.getDay()==0||start.getDay()==6||~options.weekends.indexOf(start.dateFormat('d.m.Y')) ) {
757
- classes.push('xdsoft_weekend');
758
- }
877
+ if( today.dateFormat('d.m.Y')==start.dateFormat('d.m.Y') ) {
878
+ classes.push('xdsoft_today');
879
+ }
759
880
 
760
- table+='<td data-date="'+d+'" data-month="'+m+'" data-year="'+y+'"'+' class="xdsoft_date xdsoft_day_of_week'+start.getDay()+' '+ classes.join(' ')+'">'+
761
- '<div>'+d+'</div>'+
762
- '</td>';
881
+ if( start.getDay()==0||start.getDay()==6||~options.weekends.indexOf(start.dateFormat('d.m.Y')) ) {
882
+ classes.push('xdsoft_weekend');
883
+ }
763
884
 
764
- if( start.getDay()==options.dayOfWeekStartPrev ) {
765
- table+='</tr>';
766
- }
885
+ table+='<td data-date="'+d+'" data-month="'+m+'" data-year="'+y+'"'+' class="xdsoft_date xdsoft_day_of_week'+start.getDay()+' '+ classes.join(' ')+'">'+
886
+ '<div>'+d+'</div>'+
887
+ '</td>';
767
888
 
768
- start.setDate(d+1);
769
- }
770
- table+='</tbody></table>';
771
-
772
- calendar.html(table);
773
-
774
- mounth_picker.find('.xdsoft_label span').eq(0).text(options.i18n[options.lang].months[_xdsoft_datetime.currentTime.getMonth()]);
775
- mounth_picker.find('.xdsoft_label span').eq(1).text(_xdsoft_datetime.currentTime.getFullYear());
776
-
777
- // generate timebox
778
- var time = '',
779
- h = '',
780
- m ='',
781
- line_time = function line_time( h,m ) {
782
- var now = _xdsoft_datetime.now();
783
- now.setHours(h);
784
- h = parseInt(now.getHours());
785
- now.setMinutes(m);
786
- m = parseInt(now.getMinutes());
787
-
788
- classes = [];
789
- if( (options.maxTime!==false&&_xdsoft_datetime.strtotime(options.maxTime).getTime()<now.getTime())||(options.minTime!==false&&_xdsoft_datetime.strtotime(options.minTime).getTime()>now.getTime()))
790
- classes.push('xdsoft_disabled');
791
- if( (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)))
792
- classes.push('xdsoft_current');
793
- if( parseInt(today.getHours())==parseInt(h)&&parseInt(today.getMinutes())==parseInt(m))
794
- classes.push('xdsoft_today');
795
- time+= '<div class="xdsoft_time '+classes.join(' ')+'" data-hour="'+h+'" data-minute="'+m+'">'+now.dateFormat(options.formatTime)+'</div>';
796
- };
889
+ if( start.getDay()==options.dayOfWeekStartPrev ) {
890
+ table+='</tr>';
891
+ }
797
892
 
798
- if( !options.allowTimes || !$.isArray(options.allowTimes) || !options.allowTimes.length ) {
799
- for( var i=0,j=0;i<(options.hours12?12:24);i++ ) {
800
- for( j=0;j<60;j+=options.step ) {
801
- h = (i<10?'0':'')+i;
802
- m = (j<10?'0':'')+j;
803
- line_time( h,m );
893
+ start.setDate(d+1);
894
+ }
895
+ table+='</tbody></table>';
896
+
897
+ calendar.html(table);
898
+
899
+ mounth_picker.find('.xdsoft_label span').eq(0).text(options.i18n[options.lang].months[_xdsoft_datetime.currentTime.getMonth()]);
900
+ mounth_picker.find('.xdsoft_label span').eq(1).text(_xdsoft_datetime.currentTime.getFullYear());
901
+
902
+ // generate timebox
903
+ var time = '',
904
+ h = '',
905
+ m ='',
906
+ line_time = function line_time( h,m ) {
907
+ var now = _xdsoft_datetime.now();
908
+ now.setHours(h);
909
+ h = parseInt(now.getHours());
910
+ now.setMinutes(m);
911
+ m = parseInt(now.getMinutes());
912
+
913
+ classes = [];
914
+ if( (options.maxTime!==false&&_xdsoft_datetime.strtotime(options.maxTime).getTime()<now.getTime())||(options.minTime!==false&&_xdsoft_datetime.strtotime(options.minTime).getTime()>now.getTime()))
915
+ classes.push('xdsoft_disabled');
916
+ 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))) {
917
+ if( options.defaultSelect||datetimepicker.data('changed')) {
918
+ classes.push('xdsoft_current');
919
+ } else if( options.initTime ) {
920
+ classes.push('xdsoft_init_time');
921
+ }
922
+ }
923
+ if( parseInt(today.getHours())==parseInt(h)&&parseInt(today.getMinutes())==parseInt(m))
924
+ classes.push('xdsoft_today');
925
+ time+= '<div class="xdsoft_time '+classes.join(' ')+'" data-hour="'+h+'" data-minute="'+m+'">'+now.dateFormat(options.formatTime)+'</div>';
926
+ };
927
+
928
+ if( !options.allowTimes || !$.isArray(options.allowTimes) || !options.allowTimes.length ) {
929
+ for( var i=0,j=0;i<(options.hours12?12:24);i++ ) {
930
+ for( j=0;j<60;j+=options.step ) {
931
+ h = (i<10?'0':'')+i;
932
+ m = (j<10?'0':'')+j;
933
+ line_time( h,m );
934
+ }
935
+ }
936
+ }else{
937
+ for( var i=0;i<options.allowTimes.length;i++ ) {
938
+ h = _xdsoft_datetime.strtotime(options.allowTimes[i]).getHours();
939
+ m = _xdsoft_datetime.strtotime(options.allowTimes[i]).getMinutes();
940
+ line_time( h,m );
941
+ }
804
942
  }
805
- }
806
- }else{
807
- for( var i=0;i<options.allowTimes.length;i++ ) {
808
- h = _xdsoft_datetime.strtotime(options.allowTimes[i]).getHours();
809
- m = _xdsoft_datetime.strtotime(options.allowTimes[i]).getMinutes();
810
- line_time( h,m );
811
- }
812
- }
813
943
 
814
- timebox.html(time);
944
+ timebox.html(time);
815
945
 
816
- var opt = '',
817
- i = 0;
946
+ var opt = '',
947
+ i = 0;
818
948
 
819
- for( i = parseInt(options.yearStart,10)+options.yearOffset;i<= parseInt(options.yearEnd,10)+options.yearOffset;i++ ) {
820
- opt+='<div class="xdsoft_option '+(_xdsoft_datetime.currentTime.getFullYear()==i?'xdsoft_current':'')+'" data-value="'+i+'">'+i+'</div>';
821
- }
822
- yearselect.children().eq(0)
823
- .html(opt);
949
+ for( i = parseInt(options.yearStart,10)+options.yearOffset;i<= parseInt(options.yearEnd,10)+options.yearOffset;i++ ) {
950
+ opt+='<div class="xdsoft_option '+(_xdsoft_datetime.currentTime.getFullYear()==i?'xdsoft_current':'')+'" data-value="'+i+'">'+i+'</div>';
951
+ }
952
+ yearselect.children().eq(0)
953
+ .html(opt);
824
954
 
825
- for( i = 0,opt = '';i<= 11;i++ ) {
826
- opt+='<div class="xdsoft_option '+(_xdsoft_datetime.currentTime.getMonth()==i?'xdsoft_current':'')+'" data-value="'+i+'">'+options.i18n[options.lang].months[i]+'</div>';
827
- }
828
- monthselect.children().eq(0).html(opt);
829
- $(this).trigger('generate.xdsoft');
955
+ for( i = 0,opt = '';i<= 11;i++ ) {
956
+ opt+='<div class="xdsoft_option '+(_xdsoft_datetime.currentTime.getMonth()==i?'xdsoft_current':'')+'" data-value="'+i+'">'+options.i18n[options.lang].months[i]+'</div>';
957
+ }
958
+ monthselect.children().eq(0).html(opt);
959
+ $(this).trigger('generate.xdsoft');
960
+ },10);
830
961
  event.stopPropagation();
831
962
  })
832
963
  .on('afterOpen.xdsoft',function() {
833
- if( options.timepicker && timebox.find('.xdsoft_current').length ) {
834
- var pheight = timeboxparent[0].clientHeight,
835
- height = timebox[0].offsetHeight,
836
- top = timebox.find('.xdsoft_current').index()*options.timeHeightInTimePicker+1;
837
- if( (height-pheight)<top )
838
- top = height-pheight;
839
- timebox.css('marginTop','-'+parseInt(top)+'px');
840
- timeboxparent.trigger('scroll_element.xdsoft_scroller',[parseInt(top)/(height-pheight)]);
964
+ if( options.timepicker ) {
965
+ var classType;
966
+ if( timebox.find('.xdsoft_current').length ) {
967
+ classType = '.xdsoft_current';
968
+ } else if( timebox.find('.xdsoft_init_time').length ) {
969
+ classType = '.xdsoft_init_time';
970
+ }
971
+
972
+ if( classType ) {
973
+ var pheight = timeboxparent[0].clientHeight,
974
+ height = timebox[0].offsetHeight,
975
+ top = timebox.find(classType).index()*options.timeHeightInTimePicker+1;
976
+ if( (height-pheight)<top )
977
+ top = height-pheight;
978
+ timebox.css('marginTop','-'+parseInt(top)+'px');
979
+ timeboxparent.trigger('scroll_element.xdsoft_scroller',[parseInt(top)/(height-pheight)]);
980
+ }
841
981
  }
842
982
  });
983
+
843
984
  var timerclick = 0;
985
+
844
986
  calendar
845
- .on('click.xdsoft','td',function() {
987
+ .on('click.xdsoft', 'td', function (xdevent) {
988
+ xdevent.stopPropagation(); // Prevents closing of Pop-ups, Modals and Flyouts in Bootstrap
846
989
  timerclick++;
847
990
  var $this = $(this),
848
991
  currentTime = _xdsoft_datetime.currentTime;
849
992
  if( $this.hasClass('xdsoft_disabled') )
850
993
  return false;
851
994
 
852
- currentTime.setFullYear( $this.data('year') );
853
995
  currentTime.setDate( $this.data('date') );
854
996
  currentTime.setMonth( $this.data('month') );
997
+ currentTime.setFullYear( $this.data('year') );
998
+
855
999
  datetimepicker.trigger('select.xdsoft',[currentTime]);
856
1000
 
857
1001
  input.val( _xdsoft_datetime.str() );
@@ -872,7 +1016,8 @@
872
1016
  });
873
1017
 
874
1018
  timebox
875
- .on('click.xdsoft','div',function() {
1019
+ .on('click.xdsoft', 'div', function (xdevent) {
1020
+ xdevent.stopPropagation(); // NAJ: Prevents closing of Pop-ups, Modals and Flyouts
876
1021
  var $this = $(this),
877
1022
  currentTime = _xdsoft_datetime.currentTime;
878
1023
  if( $this.hasClass('xdsoft_disabled') )
@@ -924,8 +1069,11 @@
924
1069
 
925
1070
  datetimepicker
926
1071
  .on('changedatetime.xdsoft',function() {
927
- if( options.onChangeDateTime&&options.onChangeDateTime.call )
928
- options.onChangeDateTime.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input'));
1072
+ if( options.onChangeDateTime&&options.onChangeDateTime.call ) {
1073
+ var $input = datetimepicker.data('input');
1074
+ options.onChangeDateTime.call(datetimepicker, _xdsoft_datetime.currentTime, $input);
1075
+ $input.trigger('change');
1076
+ }
929
1077
  })
930
1078
  .on('generate.xdsoft',function() {
931
1079
  if( options.onGenerate&&options.onGenerate.call )
@@ -953,6 +1101,8 @@
953
1101
  var offset = datetimepicker.data('input').offset(), top = offset.top+datetimepicker.data('input')[0].offsetHeight-1, left = offset.left;
954
1102
  if( top+datetimepicker[0].offsetHeight>$(window).height()+$(window).scrollTop() )
955
1103
  top = offset.top-datetimepicker[0].offsetHeight+1;
1104
+ if (top < 0)
1105
+ top = 0;
956
1106
  if( left+datetimepicker[0].offsetWidth>$(window).width() )
957
1107
  left = offset.left-datetimepicker[0].offsetWidth+datetimepicker.data('input')[0].offsetWidth;
958
1108
  datetimepicker.css({
@@ -999,14 +1149,23 @@
999
1149
 
1000
1150
  datetimepicker.data('xdsoft_datetime',_xdsoft_datetime);
1001
1151
  datetimepicker.setOptions(options);
1002
-
1003
- var ct = options.value?options.value:(input&&input.val&&input.val())?input.val():'';
1004
- if( ct && _xdsoft_datetime.isValidDate(ct = Date.parseDate(ct, options.format)) ) {
1005
- datetimepicker.data('changed',true);
1006
- }else
1007
- ct = '';
1008
-
1009
- _xdsoft_datetime.setCurrentTime( ct?ct:0 );
1152
+
1153
+ function getCurrentValue(){
1154
+ var ct = options.value?options.value:(input&&input.val&&input.val())?input.val():'';
1155
+
1156
+ if( ct && _xdsoft_datetime.isValidDate(ct = Date.parseDate(ct, options.format)) ) {
1157
+ datetimepicker.data('changed',true);
1158
+ }else
1159
+ ct = '';
1160
+
1161
+ if( !ct && options.startDate!==false ){
1162
+ ct = _xdsoft_datetime.strToDateTime(options.startDate);
1163
+ }
1164
+
1165
+ return ct?ct:0;
1166
+ }
1167
+
1168
+ _xdsoft_datetime.setCurrentTime( getCurrentValue() );
1010
1169
 
1011
1170
  datetimepicker.trigger('afterOpen.xdsoft');
1012
1171
 
@@ -1019,7 +1178,8 @@
1019
1178
  timer = setTimeout(function() {
1020
1179
  if( input.is(':disabled')||input.is(':hidden')||!input.is(':visible') )
1021
1180
  return;
1022
- _xdsoft_datetime.setCurrentTime((input&&input.val&&input.val())?input.val():0);
1181
+ _xdsoft_datetime.setCurrentTime(getCurrentValue());
1182
+
1023
1183
  datetimepicker.trigger('open.xdsoft');
1024
1184
  },100);
1025
1185
  })
@@ -1089,7 +1249,12 @@
1089
1249
  }
1090
1250
  return 0;
1091
1251
  }else
1092
- ($.type(opt) !== 'string')&&createDateTimePicker($(this));
1252
+ if( ($.type(opt) !== 'string') ){
1253
+ if( !options.lazyInit||options.open||options.inline ){
1254
+ createDateTimePicker($(this));
1255
+ }else
1256
+ lazyInit($(this));
1257
+ }
1093
1258
  });
1094
1259
  };
1095
1260
  })( jQuery );
@@ -1107,9 +1272,7 @@
1107
1272
  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
1108
1273
  * details.
1109
1274
  */
1110
- Date.parseFunctions={count:0};Date.parseRegexes=[];Date.formatFunctions={count:0};Date.prototype.dateFormat=function(format) {if(Date.formatFunctions[format]==null) {Date.createNewFormat(format)}var func=Date.formatFunctions[format];return this[func]()};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(character) {switch(character) {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(character)+"' + "}};Date.parseDate=function(input,format) {if(Date.parseFunctions[format]==null) {Date.createParser(format)}var func=Date.parseFunctions[format];return Date[func](input)};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) {\n"+"var y = -1, m = -1, d = -1, h = -1, i = -1, s = -1;\n"+"var d = new Date();\n"+"y = d.getFullYear();\n"+"m = d.getMonth();\n"+"d = d.getDate();\n"+"var results = input.match(Date.parseRegexes["+regexNum+"]);\n"+"if (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 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n"+"{return new Date(y, m, d, h, i, s);}\n"+"else if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n"+"{return new Date(y, m, d, h, i);}\n"+"else if (y > 0 && m >= 0 && d > 0 && h >= 0)\n"+"{return new Date(y, m, d, h);}\n"+"else if (y > 0 && m >= 0 && d > 0)\n"+"{return new Date(y, m, d);}\n"+"else if (y > 0 && m >= 0)\n"+"{return new Date(y, m);}\n"+"else if (y > 0)\n"+"{return new Date(y);}\n"+"}return null;}";Date.parseRegexes[regexNum]=new RegExp("^"+regex+"$");eval(code)};Date.formatCodeToRegex=function(character,currentGroup) {switch(character) {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["+currentGroup+"], 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:0,c:null,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["+currentGroup+"].substring(0, 3)], 10);\n",s:"("+Date.monthNames.join("|")+")"};case"M":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+currentGroup+"]], 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["+currentGroup+"], 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["+currentGroup+"], 10);\n",s:"(\\d{4})"};case"y":return{g:1,c:"var ty = parseInt(results["+currentGroup+"], 10);\n"+"y = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",s:"(\\d{1,2})"};case"a":return{g:1,c:"if (results["+currentGroup+"] == 'am') {\n"+"if (h == 12) { h = 0; }\n"+"} else { if (h < 12) { h += 12; }}",s:"(am|pm)"};case"A":return{g:1,c:"if (results["+currentGroup+"] == 'AM') {\n"+"if (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["+currentGroup+"], 10);\n",s:"(\\d{1,2})"};case"i":return{g:1,c:"i = parseInt(results["+currentGroup+"], 10);\n",s:"(\\d{2})"};case"s":return{g:1,c:"s = parseInt(results["+currentGroup+"], 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(character)}}};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 num=0;Date.daysInMonth[1]=this.isLeapYear()?29:28;for(var i=0;i<this.getMonth();++i) {num+=Date.daysInMonth[i]}return num+this.getDate()-1};Date.prototype.getWeekOfYear=function() {var now=this.getDayOfYear()+(4-this.getDay());var jan1=new Date(this.getFullYear(),0,1);var then=(7-jan1.getDay()+4);document.write(then);return String.leftPad(((now-then)/7)+1,2,"0")};Date.prototype.isLeapYear=function() {var year=this.getFullYear();return((year&3)==0&&(year%100||(year%400==0&&year)))};Date.prototype.getFirstDayOfMonth=function() {var day=(this.getDay()-(this.getDate()-1))%7;return(day<0)?(day+7):day};Date.prototype.getLastDayOfMonth=function() {var day=(this.getDay()+(Date.daysInMonth[this.getMonth()]-this.getDate()))%7;return(day<0)?(day+7):day};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(string) {return string.replace(/('|\\)/g,"\\$1")};String.leftPad=function(val,size,ch) {var result=new String(val);if(ch==null) {ch=" "}while(result.length<size) {result=ch+result}return result};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"};
1111
-
1112
- //https://github.com/brandonaaron/jquery-mousewheel/blob/master/jquery.mousewheel.js
1275
+ Date.parseFunctions={count:0};Date.parseRegexes=[];Date.formatFunctions={count:0};Date.prototype.dateFormat=function(a){if(a=='unixtime')return parseInt(this.getTime()/1000);if(Date.formatFunctions[a]==null){Date.createNewFormat(a)}var b=Date.formatFunctions[a];return this[b]()};Date.createNewFormat=function(a){var b="format"+Date.formatFunctions.count++;Date.formatFunctions[a]=b;var c="Date.prototype."+b+" = function() {return ";var d=false;var e='';for(var i=0;i<a.length;++i){e=a.charAt(i);if(!d&&e=="\\"){d=true}else if(d){d=false;c+="'"+String.escape(e)+"' + "}else{c+=Date.getFormatCode(e)}}eval(c.substring(0,c.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,b){if(b=='unixtime')return new Date(!isNaN(parseInt(a))?parseInt(a)*1000:0);if(Date.parseFunctions[b]==null){Date.createParser(b)}var c=Date.parseFunctions[b];return Date[c](a)};Date.createParser=function(a){var b="parse"+Date.parseFunctions.count++;var c=Date.parseRegexes.length;var d=1;Date.parseFunctions[a]=b;var e="Date."+b+" = function(input) {\n"+"var y = -1, m = -1, d = -1, h = -1, i = -1, s = -1;\n"+"var d = new Date();\n"+"y = d.getFullYear();\n"+"m = d.getMonth();\n"+"d = d.getDate();\n"+"var results = input.match(Date.parseRegexes["+c+"]);\n"+"if (results && results.length > 0) {";var f="";var g=false;var h='';for(var i=0;i<a.length;++i){h=a.charAt(i);if(!g&&h=="\\"){g=true}else if(g){g=false;f+=String.escape(h)}else{obj=Date.formatCodeToRegex(h,d);d+=obj.g;f+=obj.s;if(obj.g&&obj.c){e+=obj.c}}}e+="if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n"+"{return new Date(y, m, d, h, i, s);}\n"+"else if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n"+"{return new Date(y, m, d, h, i);}\n"+"else if (y > 0 && m >= 0 && d > 0 && h >= 0)\n"+"{return new Date(y, m, d, h);}\n"+"else if (y > 0 && m >= 0 && d > 0)\n"+"{return new Date(y, m, d);}\n"+"else if (y > 0 && m >= 0)\n"+"{return new Date(y, m);}\n"+"else if (y > 0)\n"+"{return new Date(y);}\n"+"}return null;}";Date.parseRegexes[c]=new RegExp("^"+f+"$");eval(e)};Date.formatCodeToRegex=function(a,b){switch(a){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["+b+"], 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:0,c:null,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["+b+"].substring(0, 3)], 10);\n",s:"("+Date.monthNames.join("|")+")"};case"M":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+b+"]], 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["+b+"], 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["+b+"], 10);\n",s:"(\\d{4})"};case"y":return{g:1,c:"var ty = parseInt(results["+b+"], 10);\n"+"y = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",s:"(\\d{1,2})"};case"a":return{g:1,c:"if (results["+b+"] == 'am') {\n"+"if (h == 12) { h = 0; }\n"+"} else { if (h < 12) { h += 12; }}",s:"(am|pm)"};case"A":return{g:1,c:"if (results["+b+"] == 'AM') {\n"+"if (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["+b+"], 10);\n",s:"(\\d{1,2})"};case"i":return{g:1,c:"i = parseInt(results["+b+"], 10);\n",s:"(\\d{2})"};case"s":return{g:1,c:"s = parseInt(results["+b+"], 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(a)}}};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 i=0;i<this.getMonth();++i){a+=Date.daysInMonth[i]}return a+this.getDate()};Date.prototype.getWeekOfYear=function(){var a=this.getDayOfYear()+(4-this.getDay());var b=new Date(this.getFullYear(),0,1);var c=(7-b.getDay()+4);return String.leftPad(Math.ceil((a-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(a,b,c){var d=new String(a);if(c==null){c=" "}while(d.length<b){d=c+d}return d};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"};//https://github.com/brandonaaron/jquery-mousewheel/blob/master/jquery.mousewheel.js
1113
1276
  /*
1114
1277
  * Copyright (c) 2013 Brandon Aaron (http://brandonaaron.net)
1115
1278
  *
@@ -1,3 +1,3 @@
1
1
  module XdanDatetimepickerRails
2
- VERSION = "2.1.9"
2
+ VERSION = "2.2.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xdan-datetimepicker-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.9
4
+ version: 2.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Kovach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-18 00:00:00.000000000 Z
11
+ date: 2014-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  version: '0'
102
102
  requirements: []
103
103
  rubyforge_project:
104
- rubygems_version: 2.2.0
104
+ rubygems_version: 2.2.2
105
105
  signing_key:
106
106
  specification_version: 4
107
107
  summary: XDan's jQuery DateTimePicker packaged for the Rails Asset Pipeline