bootstrap-datepicker-rails 1.3.0.1.rc5 → 1.3.0.1.rc6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bootstrap-datepicker-rails/version.rb +1 -1
- data/vendor/assets/javascripts/bootstrap-datepicker/core.js +285 -219
- data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.el.js +13 -13
- data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.hr.js +3 -3
- data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.nb.js +1 -1
- data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.nl-BE.js +17 -17
- data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.ro.js +1 -0
- data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.sv.js +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4848dcf43c1d2ff14c6dd969e6baa2398089bf20
|
4
|
+
data.tar.gz: d85cc2c130f7ad3ce748a3946d1ea06b813ec177
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e8dffac2f02f1a17e936db9a7d21f3a97e3e0ad78f95c1d6c70726fd95969e9d6296e4091756427c3575e2887e2845569553813b8ca7839feabbf6e4bf567ae
|
7
|
+
data.tar.gz: d5e21b96c960164e22bb48e33eadd6af185e97a5f2c2eca73254e85eaffe1d81c6aade1aee61525427923f75c4c81948fb272153a6d2480679f6b835da1a7462
|
@@ -20,7 +20,7 @@
|
|
20
20
|
* limitations under the License.
|
21
21
|
* ========================================================= */
|
22
22
|
|
23
|
-
(function($, undefined)
|
23
|
+
(function($, undefined){
|
24
24
|
|
25
25
|
var $window = $(window);
|
26
26
|
|
@@ -34,7 +34,7 @@
|
|
34
34
|
function alias(method){
|
35
35
|
return function(){
|
36
36
|
return this[method].apply(this, arguments);
|
37
|
-
}
|
37
|
+
};
|
38
38
|
}
|
39
39
|
|
40
40
|
var DateArray = (function(){
|
@@ -46,7 +46,7 @@
|
|
46
46
|
// Array.indexOf is not cross-browser;
|
47
47
|
// $.inArray doesn't work with Dates
|
48
48
|
var val = d && d.valueOf();
|
49
|
-
for (var i=0, l=this.length; i<l; i++)
|
49
|
+
for (var i=0, l=this.length; i < l; i++)
|
50
50
|
if (this[i].valueOf() === val)
|
51
51
|
return i;
|
52
52
|
return -1;
|
@@ -77,13 +77,13 @@
|
|
77
77
|
a.push.apply(a, arguments);
|
78
78
|
$.extend(a, extras);
|
79
79
|
return a;
|
80
|
-
}
|
80
|
+
};
|
81
81
|
})();
|
82
82
|
|
83
83
|
|
84
84
|
// Picker object
|
85
85
|
|
86
|
-
var Datepicker = function(element, options)
|
86
|
+
var Datepicker = function(element, options){
|
87
87
|
this.dates = new DateArray();
|
88
88
|
this.viewDate = UTCToday();
|
89
89
|
this.focusDate = null;
|
@@ -95,16 +95,17 @@
|
|
95
95
|
this.isInput = this.element.is('input');
|
96
96
|
this.component = this.element.is('.date') ? this.element.find('.add-on, .input-group-addon, .btn') : false;
|
97
97
|
this.hasInput = this.component && this.element.find('input').length;
|
98
|
-
if(this.component && this.component.length === 0)
|
98
|
+
if (this.component && this.component.length === 0)
|
99
99
|
this.component = false;
|
100
100
|
|
101
101
|
this.picker = $(DPGlobal.template);
|
102
102
|
this._buildEvents();
|
103
103
|
this._attachEvents();
|
104
104
|
|
105
|
-
if(this.isInline)
|
105
|
+
if (this.isInline){
|
106
106
|
this.picker.addClass('datepicker-inline').appendTo(this.element);
|
107
|
-
}
|
107
|
+
}
|
108
|
+
else {
|
108
109
|
this.picker.addClass('datepicker-dropdown dropdown-menu');
|
109
110
|
}
|
110
111
|
|
@@ -134,7 +135,7 @@
|
|
134
135
|
this.update();
|
135
136
|
this.showMode();
|
136
137
|
|
137
|
-
if(this.isInline)
|
138
|
+
if (this.isInline){
|
138
139
|
this.show();
|
139
140
|
}
|
140
141
|
};
|
@@ -151,14 +152,14 @@
|
|
151
152
|
// Check if "de-DE" style date is available, if not language should
|
152
153
|
// fallback to 2 letter code eg "de"
|
153
154
|
var lang = o.language;
|
154
|
-
if (!dates[lang])
|
155
|
+
if (!dates[lang]){
|
155
156
|
lang = lang.split('-')[0];
|
156
157
|
if (!dates[lang])
|
157
158
|
lang = defaults.language;
|
158
159
|
}
|
159
160
|
o.language = lang;
|
160
161
|
|
161
|
-
switch(o.startView){
|
162
|
+
switch (o.startView){
|
162
163
|
case 2:
|
163
164
|
case 'decade':
|
164
165
|
o.startView = 2;
|
@@ -171,7 +172,7 @@
|
|
171
172
|
o.startView = 0;
|
172
173
|
}
|
173
174
|
|
174
|
-
switch (o.minViewMode)
|
175
|
+
switch (o.minViewMode){
|
175
176
|
case 1:
|
176
177
|
case 'months':
|
177
178
|
o.minViewMode = 1;
|
@@ -200,23 +201,25 @@
|
|
200
201
|
o.weekEnd = ((o.weekStart + 6) % 7);
|
201
202
|
|
202
203
|
var format = DPGlobal.parseFormat(o.format);
|
203
|
-
if (o.startDate !== -Infinity)
|
204
|
-
if (!!o.startDate)
|
204
|
+
if (o.startDate !== -Infinity){
|
205
|
+
if (!!o.startDate){
|
205
206
|
if (o.startDate instanceof Date)
|
206
207
|
o.startDate = this._local_to_utc(this._zero_time(o.startDate));
|
207
208
|
else
|
208
209
|
o.startDate = DPGlobal.parseDate(o.startDate, format, o.language);
|
209
|
-
}
|
210
|
+
}
|
211
|
+
else {
|
210
212
|
o.startDate = -Infinity;
|
211
213
|
}
|
212
214
|
}
|
213
|
-
if (o.endDate !== Infinity)
|
214
|
-
if (!!o.endDate)
|
215
|
+
if (o.endDate !== Infinity){
|
216
|
+
if (!!o.endDate){
|
215
217
|
if (o.endDate instanceof Date)
|
216
218
|
o.endDate = this._local_to_utc(this._zero_time(o.endDate));
|
217
219
|
else
|
218
220
|
o.endDate = DPGlobal.parseDate(o.endDate, format, o.language);
|
219
|
-
}
|
221
|
+
}
|
222
|
+
else {
|
220
223
|
o.endDate = Infinity;
|
221
224
|
}
|
222
225
|
}
|
@@ -224,7 +227,7 @@
|
|
224
227
|
o.daysOfWeekDisabled = o.daysOfWeekDisabled||[];
|
225
228
|
if (!$.isArray(o.daysOfWeekDisabled))
|
226
229
|
o.daysOfWeekDisabled = o.daysOfWeekDisabled.split(/[,\s]*/);
|
227
|
-
o.daysOfWeekDisabled = $.map(o.daysOfWeekDisabled, function
|
230
|
+
o.daysOfWeekDisabled = $.map(o.daysOfWeekDisabled, function(d){
|
228
231
|
return parseInt(d, 10);
|
229
232
|
});
|
230
233
|
|
@@ -237,7 +240,7 @@
|
|
237
240
|
if (!_plc || _plc === 'auto')
|
238
241
|
; // no action
|
239
242
|
else if (plc.length === 1){
|
240
|
-
switch(plc[0]){
|
243
|
+
switch (plc[0]){
|
241
244
|
case 'top':
|
242
245
|
case 'bottom':
|
243
246
|
o.orientation.y = plc[0];
|
@@ -263,13 +266,13 @@
|
|
263
266
|
_events: [],
|
264
267
|
_secondaryEvents: [],
|
265
268
|
_applyEvents: function(evs){
|
266
|
-
for (var i=0, el, ch, ev; i<evs.length; i++){
|
269
|
+
for (var i=0, el, ch, ev; i < evs.length; i++){
|
267
270
|
el = evs[i][0];
|
268
|
-
if (evs[i].length
|
271
|
+
if (evs[i].length === 2){
|
269
272
|
ch = undefined;
|
270
273
|
ev = evs[i][1];
|
271
274
|
}
|
272
|
-
else if (evs[i].length
|
275
|
+
else if (evs[i].length === 3){
|
273
276
|
ch = evs[i][1];
|
274
277
|
ev = evs[i][2];
|
275
278
|
}
|
@@ -277,13 +280,13 @@
|
|
277
280
|
}
|
278
281
|
},
|
279
282
|
_unapplyEvents: function(evs){
|
280
|
-
for (var i=0, el, ev, ch; i<evs.length; i++){
|
283
|
+
for (var i=0, el, ev, ch; i < evs.length; i++){
|
281
284
|
el = evs[i][0];
|
282
|
-
if (evs[i].length
|
285
|
+
if (evs[i].length === 2){
|
283
286
|
ch = undefined;
|
284
287
|
ev = evs[i][1];
|
285
288
|
}
|
286
|
-
else if (evs[i].length
|
289
|
+
else if (evs[i].length === 3){
|
287
290
|
ch = evs[i][1];
|
288
291
|
ev = evs[i][2];
|
289
292
|
}
|
@@ -291,7 +294,7 @@
|
|
291
294
|
}
|
292
295
|
},
|
293
296
|
_buildEvents: function(){
|
294
|
-
if (this.isInput)
|
297
|
+
if (this.isInput){ // single input
|
295
298
|
this._events = [
|
296
299
|
[this.element, {
|
297
300
|
focus: $.proxy(this.show, this),
|
@@ -310,7 +313,7 @@
|
|
310
313
|
focus: $.proxy(this.show, this),
|
311
314
|
keyup: $.proxy(function(e){
|
312
315
|
if ($.inArray(e.keyCode, [27,37,39,38,40,32,13,9]) === -1)
|
313
|
-
this.update()
|
316
|
+
this.update();
|
314
317
|
}, this),
|
315
318
|
keydown: $.proxy(this.keydown, this)
|
316
319
|
}],
|
@@ -319,7 +322,7 @@
|
|
319
322
|
}]
|
320
323
|
];
|
321
324
|
}
|
322
|
-
else if (this.element.is('div'))
|
325
|
+
else if (this.element.is('div')){ // inline datepicker
|
323
326
|
this.isInline = true;
|
324
327
|
}
|
325
328
|
else {
|
@@ -352,14 +355,14 @@
|
|
352
355
|
resize: $.proxy(this.place, this)
|
353
356
|
}],
|
354
357
|
[$(document), {
|
355
|
-
'mousedown touchstart': $.proxy(function
|
358
|
+
'mousedown touchstart': $.proxy(function(e){
|
356
359
|
// Clicked outside the datepicker, hide it
|
357
360
|
if (!(
|
358
361
|
this.element.is(e.target) ||
|
359
362
|
this.element.find(e.target).length ||
|
360
363
|
this.picker.is(e.target) ||
|
361
364
|
this.picker.find(e.target).length
|
362
|
-
))
|
365
|
+
)){
|
363
366
|
this.hide();
|
364
367
|
}
|
365
368
|
}, this)
|
@@ -393,7 +396,7 @@
|
|
393
396
|
ix = this.dates.length - 1;
|
394
397
|
format = this.o.format;
|
395
398
|
}
|
396
|
-
else if (typeof ix
|
399
|
+
else if (typeof ix === 'string'){
|
397
400
|
format = ix;
|
398
401
|
ix = this.dates.length - 1;
|
399
402
|
}
|
@@ -404,19 +407,20 @@
|
|
404
407
|
});
|
405
408
|
},
|
406
409
|
|
407
|
-
show: function(
|
410
|
+
show: function(){
|
408
411
|
if (!this.isInline)
|
409
412
|
this.picker.appendTo('body');
|
410
413
|
this.picker.show();
|
411
|
-
this.height = this.component ? this.component.outerHeight() : this.element.outerHeight();
|
412
414
|
this.place();
|
413
415
|
this._attachSecondaryEvents();
|
414
416
|
this._trigger('show');
|
415
417
|
},
|
416
418
|
|
417
419
|
hide: function(){
|
418
|
-
if(this.isInline)
|
419
|
-
|
420
|
+
if (this.isInline)
|
421
|
+
return;
|
422
|
+
if (!this.picker.is(':visible'))
|
423
|
+
return;
|
420
424
|
this.focusDate = null;
|
421
425
|
this.picker.hide().detach();
|
422
426
|
this._detachSecondaryEvents();
|
@@ -434,13 +438,13 @@
|
|
434
438
|
this._trigger('hide');
|
435
439
|
},
|
436
440
|
|
437
|
-
remove: function()
|
441
|
+
remove: function(){
|
438
442
|
this.hide();
|
439
443
|
this._detachEvents();
|
440
444
|
this._detachSecondaryEvents();
|
441
445
|
this.picker.remove();
|
442
446
|
delete this.element.data().datepicker;
|
443
|
-
if (!this.isInput)
|
447
|
+
if (!this.isInput){
|
444
448
|
delete this.element.data().date;
|
445
449
|
}
|
446
450
|
},
|
@@ -463,25 +467,29 @@
|
|
463
467
|
},
|
464
468
|
|
465
469
|
getUTCDates: function(){
|
466
|
-
return $.map(this.dates, function(d){
|
470
|
+
return $.map(this.dates, function(d){
|
471
|
+
return new Date(d);
|
472
|
+
});
|
467
473
|
},
|
468
474
|
|
469
|
-
getDate: function()
|
475
|
+
getDate: function(){
|
470
476
|
return this._utc_to_local(this.getUTCDate());
|
471
477
|
},
|
472
478
|
|
473
|
-
getUTCDate: function()
|
479
|
+
getUTCDate: function(){
|
474
480
|
return new Date(this.dates.get(-1));
|
475
481
|
},
|
476
482
|
|
477
|
-
setDates: function()
|
478
|
-
|
483
|
+
setDates: function(){
|
484
|
+
var args = $.isArray(arguments[0]) ? arguments[0] : arguments;
|
485
|
+
this.update.apply(this, args);
|
479
486
|
this._trigger('changeDate');
|
480
487
|
this.setValue();
|
481
488
|
},
|
482
489
|
|
483
|
-
setUTCDates: function()
|
484
|
-
|
490
|
+
setUTCDates: function(){
|
491
|
+
var args = $.isArray(arguments[0]) ? arguments[0] : arguments;
|
492
|
+
this.update.apply(this, $.map(args, this._utc_to_local));
|
485
493
|
this._trigger('changeDate');
|
486
494
|
this.setValue();
|
487
495
|
},
|
@@ -489,18 +497,19 @@
|
|
489
497
|
setDate: alias('setDates'),
|
490
498
|
setUTCDate: alias('setUTCDates'),
|
491
499
|
|
492
|
-
setValue: function()
|
500
|
+
setValue: function(){
|
493
501
|
var formatted = this.getFormattedDate();
|
494
|
-
if (!this.isInput)
|
502
|
+
if (!this.isInput){
|
495
503
|
if (this.component){
|
496
504
|
this.element.find('input').val(formatted).change();
|
497
505
|
}
|
498
|
-
}
|
506
|
+
}
|
507
|
+
else {
|
499
508
|
this.element.val(formatted).change();
|
500
509
|
}
|
501
510
|
},
|
502
511
|
|
503
|
-
getFormattedDate: function(format)
|
512
|
+
getFormattedDate: function(format){
|
504
513
|
if (format === undefined)
|
505
514
|
format = this.o.format;
|
506
515
|
|
@@ -529,7 +538,8 @@
|
|
529
538
|
},
|
530
539
|
|
531
540
|
place: function(){
|
532
|
-
|
541
|
+
if (this.isInline)
|
542
|
+
return;
|
533
543
|
var calendarWidth = this.picker.outerWidth(),
|
534
544
|
calendarHeight = this.picker.outerHeight(),
|
535
545
|
visualPadding = 10,
|
@@ -537,9 +547,9 @@
|
|
537
547
|
windowHeight = $window.height(),
|
538
548
|
scrollTop = $window.scrollTop();
|
539
549
|
|
540
|
-
var zIndex = parseInt(this.element.parents().filter(function()
|
541
|
-
|
542
|
-
|
550
|
+
var zIndex = parseInt(this.element.parents().filter(function(){
|
551
|
+
return $(this).css('z-index') !== 'auto';
|
552
|
+
}).first().css('z-index'))+10;
|
543
553
|
var offset = this.component ? this.component.parent().offset() : this.element.offset();
|
544
554
|
var height = this.component ? this.component.outerHeight(true) : this.element.outerHeight(false);
|
545
555
|
var width = this.component ? this.component.outerWidth(true) : this.element.outerWidth(false);
|
@@ -551,7 +561,7 @@
|
|
551
561
|
'datepicker-orient-right datepicker-orient-left'
|
552
562
|
);
|
553
563
|
|
554
|
-
if (this.o.orientation.x !== 'auto')
|
564
|
+
if (this.o.orientation.x !== 'auto'){
|
555
565
|
this.picker.addClass('datepicker-orient-' + this.o.orientation.x);
|
556
566
|
if (this.o.orientation.x === 'right')
|
557
567
|
left -= calendarWidth - width;
|
@@ -571,7 +581,7 @@
|
|
571
581
|
// decision based on which shows more of the calendar
|
572
582
|
var yorient = this.o.orientation.y,
|
573
583
|
top_overflow, bottom_overflow;
|
574
|
-
if (yorient === 'auto')
|
584
|
+
if (yorient === 'auto'){
|
575
585
|
top_overflow = -scrollTop + offset.top - calendarHeight;
|
576
586
|
bottom_overflow = scrollTop + windowHeight - (offset.top + height + calendarHeight);
|
577
587
|
if (Math.max(top_overflow, bottom_overflow) === bottom_overflow)
|
@@ -594,19 +604,21 @@
|
|
594
604
|
|
595
605
|
_allow_update: true,
|
596
606
|
update: function(){
|
597
|
-
if (!this._allow_update)
|
607
|
+
if (!this._allow_update)
|
608
|
+
return;
|
598
609
|
|
599
610
|
var oldDates = this.dates.copy(),
|
600
611
|
dates = [],
|
601
612
|
fromArgs = false;
|
602
|
-
if(arguments.length)
|
613
|
+
if (arguments.length){
|
603
614
|
$.each(arguments, $.proxy(function(i, date){
|
604
615
|
if (date instanceof Date)
|
605
616
|
date = this._local_to_utc(date);
|
606
617
|
dates.push(date);
|
607
618
|
}, this));
|
608
619
|
fromArgs = true;
|
609
|
-
}
|
620
|
+
}
|
621
|
+
else {
|
610
622
|
dates = this.isInput
|
611
623
|
? this.element.val()
|
612
624
|
: this.element.data('date') || this.element.find('input').val();
|
@@ -636,10 +648,11 @@
|
|
636
648
|
else if (this.viewDate > this.o.endDate)
|
637
649
|
this.viewDate = new Date(this.o.endDate);
|
638
650
|
|
639
|
-
if (fromArgs)
|
651
|
+
if (fromArgs){
|
640
652
|
// setting date by clicking
|
641
653
|
this.setValue();
|
642
|
-
}
|
654
|
+
}
|
655
|
+
else if (dates.length){
|
643
656
|
// setting date by typing
|
644
657
|
if (String(oldDates) !== String(this.dates))
|
645
658
|
this._trigger('changeDate');
|
@@ -652,13 +665,13 @@
|
|
652
665
|
|
653
666
|
fillDow: function(){
|
654
667
|
var dowCnt = this.o.weekStart,
|
655
|
-
|
656
|
-
if(this.o.calendarWeeks){
|
668
|
+
html = '<tr>';
|
669
|
+
if (this.o.calendarWeeks){
|
657
670
|
var cell = '<th class="cw"> </th>';
|
658
671
|
html += cell;
|
659
672
|
this.picker.find('.datepicker-days thead tr:first-child').prepend(cell);
|
660
673
|
}
|
661
|
-
while (dowCnt < this.o.weekStart + 7)
|
674
|
+
while (dowCnt < this.o.weekStart + 7){
|
662
675
|
html += '<th class="dow">'+dates[this.o.language].daysMin[(dowCnt++)%7]+'</th>';
|
663
676
|
}
|
664
677
|
html += '</tr>';
|
@@ -668,7 +681,7 @@
|
|
668
681
|
fillMonths: function(){
|
669
682
|
var html = '',
|
670
683
|
i = 0;
|
671
|
-
while (i < 12)
|
684
|
+
while (i < 12){
|
672
685
|
html += '<span class="month">'+dates[this.o.language].monthsShort[i++]+'</span>';
|
673
686
|
}
|
674
687
|
this.picker.find('.datepicker-months td').html(html);
|
@@ -678,7 +691,9 @@
|
|
678
691
|
if (!range || !range.length)
|
679
692
|
delete this.range;
|
680
693
|
else
|
681
|
-
this.range = $.map(range, function(d){
|
694
|
+
this.range = $.map(range, function(d){
|
695
|
+
return d.valueOf();
|
696
|
+
});
|
682
697
|
this.fill();
|
683
698
|
},
|
684
699
|
|
@@ -687,38 +702,39 @@
|
|
687
702
|
year = this.viewDate.getUTCFullYear(),
|
688
703
|
month = this.viewDate.getUTCMonth(),
|
689
704
|
today = new Date();
|
690
|
-
if (date.getUTCFullYear() < year || (date.getUTCFullYear()
|
705
|
+
if (date.getUTCFullYear() < year || (date.getUTCFullYear() === year && date.getUTCMonth() < month)){
|
691
706
|
cls.push('old');
|
692
|
-
}
|
707
|
+
}
|
708
|
+
else if (date.getUTCFullYear() > year || (date.getUTCFullYear() === year && date.getUTCMonth() > month)){
|
693
709
|
cls.push('new');
|
694
710
|
}
|
695
711
|
if (this.focusDate && date.valueOf() === this.focusDate.valueOf())
|
696
712
|
cls.push('focused');
|
697
713
|
// Compare internal UTC date with local today, not UTC today
|
698
714
|
if (this.o.todayHighlight &&
|
699
|
-
date.getUTCFullYear()
|
700
|
-
date.getUTCMonth()
|
701
|
-
date.getUTCDate()
|
715
|
+
date.getUTCFullYear() === today.getFullYear() &&
|
716
|
+
date.getUTCMonth() === today.getMonth() &&
|
717
|
+
date.getUTCDate() === today.getDate()){
|
702
718
|
cls.push('today');
|
703
719
|
}
|
704
720
|
if (this.dates.contains(date) !== -1)
|
705
721
|
cls.push('active');
|
706
722
|
if (date.valueOf() < this.o.startDate || date.valueOf() > this.o.endDate ||
|
707
|
-
$.inArray(date.getUTCDay(), this.o.daysOfWeekDisabled) !== -1)
|
723
|
+
$.inArray(date.getUTCDay(), this.o.daysOfWeekDisabled) !== -1){
|
708
724
|
cls.push('disabled');
|
709
725
|
}
|
710
726
|
if (this.range){
|
711
727
|
if (date > this.range[0] && date < this.range[this.range.length-1]){
|
712
728
|
cls.push('range');
|
713
729
|
}
|
714
|
-
if ($.inArray(date.valueOf(), this.range)
|
730
|
+
if ($.inArray(date.valueOf(), this.range) !== -1){
|
715
731
|
cls.push('selected');
|
716
732
|
}
|
717
733
|
}
|
718
734
|
return cls;
|
719
735
|
},
|
720
736
|
|
721
|
-
fill: function()
|
737
|
+
fill: function(){
|
722
738
|
var d = new Date(this.viewDate),
|
723
739
|
year = d.getUTCFullYear(),
|
724
740
|
month = d.getUTCMonth(),
|
@@ -726,14 +742,16 @@
|
|
726
742
|
startMonth = this.o.startDate !== -Infinity ? this.o.startDate.getUTCMonth() : -Infinity,
|
727
743
|
endYear = this.o.endDate !== Infinity ? this.o.endDate.getUTCFullYear() : Infinity,
|
728
744
|
endMonth = this.o.endDate !== Infinity ? this.o.endDate.getUTCMonth() : Infinity,
|
729
|
-
|
745
|
+
todaytxt = dates[this.o.language].today || dates['en'].today || '',
|
746
|
+
cleartxt = dates[this.o.language].clear || dates['en'].clear || '',
|
747
|
+
tooltip;
|
730
748
|
this.picker.find('.datepicker-days thead th.datepicker-switch')
|
731
749
|
.text(dates[this.o.language].months[month]+' '+year);
|
732
750
|
this.picker.find('tfoot th.today')
|
733
|
-
.text(
|
751
|
+
.text(todaytxt)
|
734
752
|
.toggle(this.o.todayBtn !== false);
|
735
753
|
this.picker.find('tfoot th.clear')
|
736
|
-
.text(
|
754
|
+
.text(cleartxt)
|
737
755
|
.toggle(this.o.clearBtn !== false);
|
738
756
|
this.updateNavArrows();
|
739
757
|
this.fillMonths();
|
@@ -746,19 +764,19 @@
|
|
746
764
|
nextMonth = nextMonth.valueOf();
|
747
765
|
var html = [];
|
748
766
|
var clsName;
|
749
|
-
while(prevMonth.valueOf() < nextMonth)
|
750
|
-
if (prevMonth.getUTCDay()
|
767
|
+
while (prevMonth.valueOf() < nextMonth){
|
768
|
+
if (prevMonth.getUTCDay() === this.o.weekStart){
|
751
769
|
html.push('<tr>');
|
752
|
-
if(this.o.calendarWeeks){
|
770
|
+
if (this.o.calendarWeeks){
|
753
771
|
// ISO 8601: First week contains first thursday.
|
754
772
|
// ISO also states week starts on Monday, but we can be more abstract here.
|
755
773
|
var
|
756
774
|
// Start of current week: based on weekstart/current date
|
757
775
|
ws = new Date(+prevMonth + (this.o.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
|
758
776
|
// Thursday of this week
|
759
|
-
th = new Date(
|
777
|
+
th = new Date(Number(ws) + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
|
760
778
|
// First Thursday of year, year from thursday
|
761
|
-
yth = new Date(
|
779
|
+
yth = new Date(Number(yth = UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
|
762
780
|
// Calendar week: ms between thursdays, div ms per day, div 7 days
|
763
781
|
calWeek = (th - yth) / 864e5 / 7 + 1;
|
764
782
|
html.push('<td class="cw">'+ calWeek +'</td>');
|
@@ -786,7 +804,7 @@
|
|
786
804
|
|
787
805
|
clsName = $.unique(clsName);
|
788
806
|
html.push('<td class="'+clsName.join(' ')+'"' + (tooltip ? ' title="'+tooltip+'"' : '') + '>'+prevMonth.getUTCDate() + '</td>');
|
789
|
-
if (prevMonth.getUTCDay()
|
807
|
+
if (prevMonth.getUTCDay() === this.o.weekEnd){
|
790
808
|
html.push('</tr>');
|
791
809
|
}
|
792
810
|
prevMonth.setUTCDate(prevMonth.getUTCDate()+1);
|
@@ -800,17 +818,17 @@
|
|
800
818
|
.find('span').removeClass('active');
|
801
819
|
|
802
820
|
$.each(this.dates, function(i, d){
|
803
|
-
if (d.getUTCFullYear()
|
821
|
+
if (d.getUTCFullYear() === year)
|
804
822
|
months.eq(d.getUTCMonth()).addClass('active');
|
805
823
|
});
|
806
824
|
|
807
|
-
if (year < startYear || year > endYear)
|
825
|
+
if (year < startYear || year > endYear){
|
808
826
|
months.addClass('disabled');
|
809
827
|
}
|
810
|
-
if (year
|
828
|
+
if (year === startYear){
|
811
829
|
months.slice(0, startMonth).addClass('disabled');
|
812
830
|
}
|
813
|
-
if (year
|
831
|
+
if (year === endYear){
|
814
832
|
months.slice(endMonth+1).addClass('disabled');
|
815
833
|
}
|
816
834
|
|
@@ -822,9 +840,11 @@
|
|
822
840
|
.end()
|
823
841
|
.find('td');
|
824
842
|
year -= 1;
|
825
|
-
var years = $.map(this.dates, function(d){
|
843
|
+
var years = $.map(this.dates, function(d){
|
844
|
+
return d.getUTCFullYear();
|
845
|
+
}),
|
826
846
|
classes;
|
827
|
-
for (var i = -1; i < 11; i++)
|
847
|
+
for (var i = -1; i < 11; i++){
|
828
848
|
classes = ['year'];
|
829
849
|
if (i === -1)
|
830
850
|
classes.push('old');
|
@@ -840,56 +860,61 @@
|
|
840
860
|
yearCont.html(html);
|
841
861
|
},
|
842
862
|
|
843
|
-
updateNavArrows: function()
|
844
|
-
if (!this._allow_update)
|
863
|
+
updateNavArrows: function(){
|
864
|
+
if (!this._allow_update)
|
865
|
+
return;
|
845
866
|
|
846
867
|
var d = new Date(this.viewDate),
|
847
868
|
year = d.getUTCFullYear(),
|
848
869
|
month = d.getUTCMonth();
|
849
|
-
switch (this.viewMode)
|
870
|
+
switch (this.viewMode){
|
850
871
|
case 0:
|
851
|
-
if (this.o.startDate !== -Infinity && year <= this.o.startDate.getUTCFullYear() && month <= this.o.startDate.getUTCMonth())
|
872
|
+
if (this.o.startDate !== -Infinity && year <= this.o.startDate.getUTCFullYear() && month <= this.o.startDate.getUTCMonth()){
|
852
873
|
this.picker.find('.prev').css({visibility: 'hidden'});
|
853
|
-
}
|
874
|
+
}
|
875
|
+
else {
|
854
876
|
this.picker.find('.prev').css({visibility: 'visible'});
|
855
877
|
}
|
856
|
-
if (this.o.endDate !== Infinity && year >= this.o.endDate.getUTCFullYear() && month >= this.o.endDate.getUTCMonth())
|
878
|
+
if (this.o.endDate !== Infinity && year >= this.o.endDate.getUTCFullYear() && month >= this.o.endDate.getUTCMonth()){
|
857
879
|
this.picker.find('.next').css({visibility: 'hidden'});
|
858
|
-
}
|
880
|
+
}
|
881
|
+
else {
|
859
882
|
this.picker.find('.next').css({visibility: 'visible'});
|
860
883
|
}
|
861
884
|
break;
|
862
885
|
case 1:
|
863
886
|
case 2:
|
864
|
-
if (this.o.startDate !== -Infinity && year <= this.o.startDate.getUTCFullYear())
|
887
|
+
if (this.o.startDate !== -Infinity && year <= this.o.startDate.getUTCFullYear()){
|
865
888
|
this.picker.find('.prev').css({visibility: 'hidden'});
|
866
|
-
}
|
889
|
+
}
|
890
|
+
else {
|
867
891
|
this.picker.find('.prev').css({visibility: 'visible'});
|
868
892
|
}
|
869
|
-
if (this.o.endDate !== Infinity && year >= this.o.endDate.getUTCFullYear())
|
893
|
+
if (this.o.endDate !== Infinity && year >= this.o.endDate.getUTCFullYear()){
|
870
894
|
this.picker.find('.next').css({visibility: 'hidden'});
|
871
|
-
}
|
895
|
+
}
|
896
|
+
else {
|
872
897
|
this.picker.find('.next').css({visibility: 'visible'});
|
873
898
|
}
|
874
899
|
break;
|
875
900
|
}
|
876
901
|
},
|
877
902
|
|
878
|
-
click: function(e)
|
903
|
+
click: function(e){
|
879
904
|
e.preventDefault();
|
880
905
|
var target = $(e.target).closest('span, td, th'),
|
881
906
|
year, month, day;
|
882
|
-
if (target.length
|
883
|
-
switch(target[0].nodeName.toLowerCase())
|
907
|
+
if (target.length === 1){
|
908
|
+
switch (target[0].nodeName.toLowerCase()){
|
884
909
|
case 'th':
|
885
|
-
switch(target[0].className)
|
910
|
+
switch (target[0].className){
|
886
911
|
case 'datepicker-switch':
|
887
912
|
this.showMode(1);
|
888
913
|
break;
|
889
914
|
case 'prev':
|
890
915
|
case 'next':
|
891
|
-
var dir = DPGlobal.modes[this.viewMode].navStep * (target[0].className
|
892
|
-
switch(this.viewMode){
|
916
|
+
var dir = DPGlobal.modes[this.viewMode].navStep * (target[0].className === 'prev' ? -1 : 1);
|
917
|
+
switch (this.viewMode){
|
893
918
|
case 0:
|
894
919
|
this.viewDate = this.moveMonth(this.viewDate, dir);
|
895
920
|
this._trigger('changeMonth', this.viewDate);
|
@@ -908,7 +933,7 @@
|
|
908
933
|
date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
|
909
934
|
|
910
935
|
this.showMode(-2);
|
911
|
-
var which = this.o.todayBtn
|
936
|
+
var which = this.o.todayBtn === 'linked' ? null : 'view';
|
912
937
|
this._setDate(date, which);
|
913
938
|
break;
|
914
939
|
case 'clear':
|
@@ -927,24 +952,25 @@
|
|
927
952
|
}
|
928
953
|
break;
|
929
954
|
case 'span':
|
930
|
-
if (!target.is('.disabled'))
|
955
|
+
if (!target.is('.disabled')){
|
931
956
|
this.viewDate.setUTCDate(1);
|
932
|
-
if (target.is('.month'))
|
957
|
+
if (target.is('.month')){
|
933
958
|
day = 1;
|
934
959
|
month = target.parent().find('span').index(target);
|
935
960
|
year = this.viewDate.getUTCFullYear();
|
936
961
|
this.viewDate.setUTCMonth(month);
|
937
962
|
this._trigger('changeMonth', this.viewDate);
|
938
|
-
if (this.o.minViewMode === 1)
|
963
|
+
if (this.o.minViewMode === 1){
|
939
964
|
this._setDate(UTCDate(year, month, day));
|
940
965
|
}
|
941
|
-
}
|
966
|
+
}
|
967
|
+
else {
|
942
968
|
day = 1;
|
943
969
|
month = 0;
|
944
970
|
year = parseInt(target.text(), 10)||0;
|
945
971
|
this.viewDate.setUTCFullYear(year);
|
946
972
|
this._trigger('changeYear', this.viewDate);
|
947
|
-
if (this.o.minViewMode === 2)
|
973
|
+
if (this.o.minViewMode === 2){
|
948
974
|
this._setDate(UTCDate(year, month, day));
|
949
975
|
}
|
950
976
|
}
|
@@ -957,18 +983,21 @@
|
|
957
983
|
day = parseInt(target.text(), 10)||1;
|
958
984
|
year = this.viewDate.getUTCFullYear();
|
959
985
|
month = this.viewDate.getUTCMonth();
|
960
|
-
if (target.is('.old'))
|
961
|
-
if (month === 0)
|
986
|
+
if (target.is('.old')){
|
987
|
+
if (month === 0){
|
962
988
|
month = 11;
|
963
989
|
year -= 1;
|
964
|
-
}
|
990
|
+
}
|
991
|
+
else {
|
965
992
|
month -= 1;
|
966
993
|
}
|
967
|
-
}
|
968
|
-
|
994
|
+
}
|
995
|
+
else if (target.is('.new')){
|
996
|
+
if (month === 11){
|
969
997
|
month = 0;
|
970
998
|
year += 1;
|
971
|
-
}
|
999
|
+
}
|
1000
|
+
else {
|
972
1001
|
month += 1;
|
973
1002
|
}
|
974
1003
|
}
|
@@ -983,7 +1012,7 @@
|
|
983
1012
|
delete this._focused_from;
|
984
1013
|
},
|
985
1014
|
|
986
|
-
_toggle_multidate: function(
|
1015
|
+
_toggle_multidate: function(date){
|
987
1016
|
var ix = this.dates.contains(date);
|
988
1017
|
if (!date){
|
989
1018
|
this.dates.clear();
|
@@ -991,68 +1020,78 @@
|
|
991
1020
|
else if (ix !== -1){
|
992
1021
|
this.dates.remove(ix);
|
993
1022
|
}
|
994
|
-
else{
|
1023
|
+
else {
|
995
1024
|
this.dates.push(date);
|
996
1025
|
}
|
997
|
-
if (typeof this.o.multidate
|
1026
|
+
if (typeof this.o.multidate === 'number')
|
998
1027
|
while (this.dates.length > this.o.multidate)
|
999
1028
|
this.dates.remove(0);
|
1000
1029
|
},
|
1001
1030
|
|
1002
1031
|
_setDate: function(date, which){
|
1003
|
-
if (!which || which
|
1032
|
+
if (!which || which === 'date')
|
1004
1033
|
this._toggle_multidate(date && new Date(date));
|
1005
|
-
if (!which || which
|
1034
|
+
if (!which || which === 'view')
|
1006
1035
|
this.viewDate = date && new Date(date);
|
1007
1036
|
|
1008
1037
|
this.fill();
|
1009
1038
|
this.setValue();
|
1010
1039
|
this._trigger('changeDate');
|
1011
1040
|
var element;
|
1012
|
-
if (this.isInput)
|
1041
|
+
if (this.isInput){
|
1013
1042
|
element = this.element;
|
1014
|
-
}
|
1043
|
+
}
|
1044
|
+
else if (this.component){
|
1015
1045
|
element = this.element.find('input');
|
1016
1046
|
}
|
1017
|
-
if (element)
|
1047
|
+
if (element){
|
1018
1048
|
element.change();
|
1019
1049
|
}
|
1020
|
-
if (this.o.autoclose && (!which || which
|
1050
|
+
if (this.o.autoclose && (!which || which === 'date')){
|
1021
1051
|
this.hide();
|
1022
1052
|
}
|
1023
1053
|
},
|
1024
1054
|
|
1025
1055
|
moveMonth: function(date, dir){
|
1026
|
-
if (!date)
|
1027
|
-
|
1056
|
+
if (!date)
|
1057
|
+
return undefined;
|
1058
|
+
if (!dir)
|
1059
|
+
return date;
|
1028
1060
|
var new_date = new Date(date.valueOf()),
|
1029
1061
|
day = new_date.getUTCDate(),
|
1030
1062
|
month = new_date.getUTCMonth(),
|
1031
1063
|
mag = Math.abs(dir),
|
1032
1064
|
new_month, test;
|
1033
1065
|
dir = dir > 0 ? 1 : -1;
|
1034
|
-
if (mag
|
1035
|
-
test = dir
|
1066
|
+
if (mag === 1){
|
1067
|
+
test = dir === -1
|
1036
1068
|
// If going back one month, make sure month is not current month
|
1037
1069
|
// (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
|
1038
|
-
? function(){
|
1070
|
+
? function(){
|
1071
|
+
return new_date.getUTCMonth() === month;
|
1072
|
+
}
|
1039
1073
|
// If going forward one month, make sure month is as expected
|
1040
1074
|
// (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
|
1041
|
-
: function(){
|
1075
|
+
: function(){
|
1076
|
+
return new_date.getUTCMonth() !== new_month;
|
1077
|
+
};
|
1042
1078
|
new_month = month + dir;
|
1043
1079
|
new_date.setUTCMonth(new_month);
|
1044
1080
|
// Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
|
1045
1081
|
if (new_month < 0 || new_month > 11)
|
1046
1082
|
new_month = (new_month + 12) % 12;
|
1047
|
-
}
|
1083
|
+
}
|
1084
|
+
else {
|
1048
1085
|
// For magnitudes >1, move one month at a time...
|
1049
|
-
for (var i=0; i<mag; i++)
|
1086
|
+
for (var i=0; i < mag; i++)
|
1050
1087
|
// ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
|
1051
1088
|
new_date = this.moveMonth(new_date, dir);
|
1052
1089
|
// ...then reset the day, keeping it in the new month
|
1053
1090
|
new_month = new_date.getUTCMonth();
|
1054
1091
|
new_date.setUTCDate(day);
|
1055
|
-
test = function(){
|
1092
|
+
test = function(){
|
1093
|
+
return new_month !== new_date.getUTCMonth();
|
1094
|
+
};
|
1056
1095
|
}
|
1057
1096
|
// Common date-resetting loop -- if date is beyond end of month, make it
|
1058
1097
|
// end of month
|
@@ -1073,14 +1112,14 @@
|
|
1073
1112
|
|
1074
1113
|
keydown: function(e){
|
1075
1114
|
if (this.picker.is(':not(:visible)')){
|
1076
|
-
if (e.keyCode
|
1115
|
+
if (e.keyCode === 27) // allow escape to hide and re-show picker
|
1077
1116
|
this.show();
|
1078
1117
|
return;
|
1079
1118
|
}
|
1080
1119
|
var dateChanged = false,
|
1081
1120
|
dir, newDate, newViewDate,
|
1082
1121
|
focusDate = this.focusDate || this.viewDate;
|
1083
|
-
switch(e.keyCode){
|
1122
|
+
switch (e.keyCode){
|
1084
1123
|
case 27: // escape
|
1085
1124
|
if (this.focusDate){
|
1086
1125
|
this.focusDate = null;
|
@@ -1093,17 +1132,20 @@
|
|
1093
1132
|
break;
|
1094
1133
|
case 37: // left
|
1095
1134
|
case 39: // right
|
1096
|
-
if (!this.o.keyboardNavigation)
|
1097
|
-
|
1135
|
+
if (!this.o.keyboardNavigation)
|
1136
|
+
break;
|
1137
|
+
dir = e.keyCode === 37 ? -1 : 1;
|
1098
1138
|
if (e.ctrlKey){
|
1099
1139
|
newDate = this.moveYear(this.dates.get(-1) || UTCToday(), dir);
|
1100
1140
|
newViewDate = this.moveYear(focusDate, dir);
|
1101
1141
|
this._trigger('changeYear', this.viewDate);
|
1102
|
-
}
|
1142
|
+
}
|
1143
|
+
else if (e.shiftKey){
|
1103
1144
|
newDate = this.moveMonth(this.dates.get(-1) || UTCToday(), dir);
|
1104
1145
|
newViewDate = this.moveMonth(focusDate, dir);
|
1105
1146
|
this._trigger('changeMonth', this.viewDate);
|
1106
|
-
}
|
1147
|
+
}
|
1148
|
+
else {
|
1107
1149
|
newDate = new Date(this.dates.get(-1) || UTCToday());
|
1108
1150
|
newDate.setUTCDate(newDate.getUTCDate() + dir);
|
1109
1151
|
newViewDate = new Date(focusDate);
|
@@ -1118,17 +1160,20 @@
|
|
1118
1160
|
break;
|
1119
1161
|
case 38: // up
|
1120
1162
|
case 40: // down
|
1121
|
-
if (!this.o.keyboardNavigation)
|
1122
|
-
|
1163
|
+
if (!this.o.keyboardNavigation)
|
1164
|
+
break;
|
1165
|
+
dir = e.keyCode === 38 ? -1 : 1;
|
1123
1166
|
if (e.ctrlKey){
|
1124
1167
|
newDate = this.moveYear(this.dates.get(-1) || UTCToday(), dir);
|
1125
1168
|
newViewDate = this.moveYear(focusDate, dir);
|
1126
1169
|
this._trigger('changeYear', this.viewDate);
|
1127
|
-
}
|
1170
|
+
}
|
1171
|
+
else if (e.shiftKey){
|
1128
1172
|
newDate = this.moveMonth(this.dates.get(-1) || UTCToday(), dir);
|
1129
1173
|
newViewDate = this.moveMonth(focusDate, dir);
|
1130
1174
|
this._trigger('changeMonth', this.viewDate);
|
1131
|
-
}
|
1175
|
+
}
|
1176
|
+
else {
|
1132
1177
|
newDate = new Date(this.dates.get(-1) || UTCToday());
|
1133
1178
|
newDate.setUTCDate(newDate.getUTCDate() + dir * 7);
|
1134
1179
|
newViewDate = new Date(focusDate);
|
@@ -1172,55 +1217,58 @@
|
|
1172
1217
|
else
|
1173
1218
|
this._trigger('clearDate');
|
1174
1219
|
var element;
|
1175
|
-
if (this.isInput)
|
1220
|
+
if (this.isInput){
|
1176
1221
|
element = this.element;
|
1177
|
-
}
|
1222
|
+
}
|
1223
|
+
else if (this.component){
|
1178
1224
|
element = this.element.find('input');
|
1179
1225
|
}
|
1180
|
-
if (element)
|
1226
|
+
if (element){
|
1181
1227
|
element.change();
|
1182
1228
|
}
|
1183
1229
|
}
|
1184
1230
|
},
|
1185
1231
|
|
1186
|
-
showMode: function(dir)
|
1187
|
-
if (dir)
|
1232
|
+
showMode: function(dir){
|
1233
|
+
if (dir){
|
1188
1234
|
this.viewMode = Math.max(this.o.minViewMode, Math.min(2, this.viewMode + dir));
|
1189
1235
|
}
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
See https://github.com/vitalets/x-editable/issues/37
|
1196
|
-
|
1197
|
-
In jquery 1.7.2+ everything works fine.
|
1198
|
-
*/
|
1199
|
-
//this.picker.find('>div').hide().filter('.datepicker-'+DPGlobal.modes[this.viewMode].clsName).show();
|
1200
|
-
this.picker.find('>div').hide().filter('.datepicker-'+DPGlobal.modes[this.viewMode].clsName).css('display', 'block');
|
1236
|
+
this.picker
|
1237
|
+
.find('>div')
|
1238
|
+
.hide()
|
1239
|
+
.filter('.datepicker-'+DPGlobal.modes[this.viewMode].clsName)
|
1240
|
+
.css('display', 'block');
|
1201
1241
|
this.updateNavArrows();
|
1202
1242
|
}
|
1203
1243
|
};
|
1204
1244
|
|
1205
1245
|
var DateRangePicker = function(element, options){
|
1206
1246
|
this.element = $(element);
|
1207
|
-
this.inputs = $.map(options.inputs, function(i){
|
1247
|
+
this.inputs = $.map(options.inputs, function(i){
|
1248
|
+
return i.jquery ? i[0] : i;
|
1249
|
+
});
|
1208
1250
|
delete options.inputs;
|
1209
1251
|
|
1210
1252
|
$(this.inputs)
|
1211
1253
|
.datepicker(options)
|
1212
1254
|
.bind('changeDate', $.proxy(this.dateUpdated, this));
|
1213
1255
|
|
1214
|
-
this.pickers = $.map(this.inputs, function(i){
|
1256
|
+
this.pickers = $.map(this.inputs, function(i){
|
1257
|
+
return $(i).data('datepicker');
|
1258
|
+
});
|
1215
1259
|
this.updateDates();
|
1216
1260
|
};
|
1217
1261
|
DateRangePicker.prototype = {
|
1218
1262
|
updateDates: function(){
|
1219
|
-
this.dates = $.map(this.pickers, function(i){
|
1263
|
+
this.dates = $.map(this.pickers, function(i){
|
1264
|
+
return i.getUTCDate();
|
1265
|
+
});
|
1220
1266
|
this.updateRanges();
|
1221
1267
|
},
|
1222
1268
|
updateRanges: function(){
|
1223
|
-
var range = $.map(this.dates, function(d){
|
1269
|
+
var range = $.map(this.dates, function(d){
|
1270
|
+
return d.valueOf();
|
1271
|
+
});
|
1224
1272
|
$.each(this.pickers, function(i, p){
|
1225
1273
|
p.setRange(range);
|
1226
1274
|
});
|
@@ -1237,7 +1285,8 @@
|
|
1237
1285
|
new_date = dp.getUTCDate(),
|
1238
1286
|
i = $.inArray(e.target, this.inputs),
|
1239
1287
|
l = this.inputs.length;
|
1240
|
-
if (i
|
1288
|
+
if (i === -1)
|
1289
|
+
return;
|
1241
1290
|
|
1242
1291
|
$.each(this.pickers, function(i, p){
|
1243
1292
|
if (!p.getUTCDate())
|
@@ -1246,13 +1295,13 @@
|
|
1246
1295
|
|
1247
1296
|
if (new_date < this.dates[i]){
|
1248
1297
|
// Date being moved earlier/left
|
1249
|
-
while (i>=0 && new_date < this.dates[i]){
|
1298
|
+
while (i >= 0 && new_date < this.dates[i]){
|
1250
1299
|
this.pickers[i--].setUTCDate(new_date);
|
1251
1300
|
}
|
1252
1301
|
}
|
1253
1302
|
else if (new_date > this.dates[i]){
|
1254
1303
|
// Date being moved later/right
|
1255
|
-
while (i<l && new_date > this.dates[i]){
|
1304
|
+
while (i < l && new_date > this.dates[i]){
|
1256
1305
|
this.pickers[i++].setUTCDate(new_date);
|
1257
1306
|
}
|
1258
1307
|
}
|
@@ -1270,11 +1319,14 @@
|
|
1270
1319
|
// Derive options from element data-attrs
|
1271
1320
|
var data = $(el).data(),
|
1272
1321
|
out = {}, inkey,
|
1273
|
-
replace = new RegExp('^' + prefix.toLowerCase() + '([A-Z])')
|
1274
|
-
|
1322
|
+
replace = new RegExp('^' + prefix.toLowerCase() + '([A-Z])');
|
1323
|
+
prefix = new RegExp('^' + prefix.toLowerCase());
|
1324
|
+
function re_lower(_,a){
|
1325
|
+
return a.toLowerCase();
|
1326
|
+
}
|
1275
1327
|
for (var key in data)
|
1276
1328
|
if (prefix.test(key)){
|
1277
|
-
inkey = key.replace(replace,
|
1329
|
+
inkey = key.replace(replace, re_lower);
|
1278
1330
|
out[inkey] = data[key];
|
1279
1331
|
}
|
1280
1332
|
return out;
|
@@ -1285,7 +1337,7 @@
|
|
1285
1337
|
var out = {};
|
1286
1338
|
// Check if "de-DE" style date is available, if not language should
|
1287
1339
|
// fallback to 2 letter code eg "de"
|
1288
|
-
if (!dates[lang])
|
1340
|
+
if (!dates[lang]){
|
1289
1341
|
lang = lang.split('-')[0];
|
1290
1342
|
if (!dates[lang])
|
1291
1343
|
return;
|
@@ -1299,15 +1351,15 @@
|
|
1299
1351
|
}
|
1300
1352
|
|
1301
1353
|
var old = $.fn.datepicker;
|
1302
|
-
$.fn.datepicker = function
|
1354
|
+
$.fn.datepicker = function(option){
|
1303
1355
|
var args = Array.apply(null, arguments);
|
1304
1356
|
args.shift();
|
1305
1357
|
var internal_return;
|
1306
|
-
this.each(function
|
1358
|
+
this.each(function(){
|
1307
1359
|
var $this = $(this),
|
1308
1360
|
data = $this.data('datepicker'),
|
1309
|
-
options = typeof option
|
1310
|
-
if (!data)
|
1361
|
+
options = typeof option === 'object' && option;
|
1362
|
+
if (!data){
|
1311
1363
|
var elopts = opts_from_el(this, 'date'),
|
1312
1364
|
// Preliminary otions
|
1313
1365
|
xopts = $.extend({}, defaults, elopts, options),
|
@@ -1320,11 +1372,11 @@
|
|
1320
1372
|
};
|
1321
1373
|
$this.data('datepicker', (data = new DateRangePicker(this, $.extend(opts, ropts))));
|
1322
1374
|
}
|
1323
|
-
else{
|
1375
|
+
else {
|
1324
1376
|
$this.data('datepicker', (data = new Datepicker(this, opts)));
|
1325
1377
|
}
|
1326
1378
|
}
|
1327
|
-
if (typeof option
|
1379
|
+
if (typeof option === 'string' && typeof data[option] === 'function'){
|
1328
1380
|
internal_return = data[option].apply(data, args);
|
1329
1381
|
if (internal_return !== undefined)
|
1330
1382
|
return false;
|
@@ -1393,10 +1445,10 @@
|
|
1393
1445
|
navFnc: 'FullYear',
|
1394
1446
|
navStep: 10
|
1395
1447
|
}],
|
1396
|
-
isLeapYear: function
|
1448
|
+
isLeapYear: function(year){
|
1397
1449
|
return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0));
|
1398
1450
|
},
|
1399
|
-
getDaysInMonth: function
|
1451
|
+
getDaysInMonth: function(year, month){
|
1400
1452
|
return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
|
1401
1453
|
},
|
1402
1454
|
validParts: /dd?|DD?|mm?|MM?|yy(?:yy)?/g,
|
@@ -1411,21 +1463,22 @@
|
|
1411
1463
|
}
|
1412
1464
|
return {separators: separators, parts: parts};
|
1413
1465
|
},
|
1414
|
-
parseDate: function(date, format, language)
|
1466
|
+
parseDate: function(date, format, language){
|
1415
1467
|
if (!date)
|
1416
1468
|
return undefined;
|
1417
|
-
if (date instanceof Date)
|
1469
|
+
if (date instanceof Date)
|
1470
|
+
return date;
|
1418
1471
|
if (typeof format === 'string')
|
1419
1472
|
format = DPGlobal.parseFormat(format);
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1473
|
+
var part_re = /([\-+]\d+)([dmwy])/,
|
1474
|
+
parts = date.match(/([\-+]\d+)([dmwy])/g),
|
1475
|
+
part, dir, i;
|
1476
|
+
if (/^[\-+]\d+[dmwy]([\s,]+[\-+]\d+[dmwy])*$/.test(date)){
|
1424
1477
|
date = new Date();
|
1425
|
-
for (
|
1478
|
+
for (i=0; i < parts.length; i++){
|
1426
1479
|
part = part_re.exec(parts[i]);
|
1427
1480
|
dir = parseInt(part[1]);
|
1428
|
-
switch(part[2]){
|
1481
|
+
switch (part[2]){
|
1429
1482
|
case 'd':
|
1430
1483
|
date.setUTCDate(date.getUTCDate() + dir);
|
1431
1484
|
break;
|
@@ -1442,65 +1495,70 @@
|
|
1442
1495
|
}
|
1443
1496
|
return UTCDate(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), 0, 0, 0);
|
1444
1497
|
}
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1498
|
+
parts = date && date.match(this.nonpunctuation) || [];
|
1499
|
+
date = new Date();
|
1500
|
+
var parsed = {},
|
1448
1501
|
setters_order = ['yyyy', 'yy', 'M', 'MM', 'm', 'mm', 'd', 'dd'],
|
1449
1502
|
setters_map = {
|
1450
|
-
yyyy: function(d,v){
|
1451
|
-
|
1503
|
+
yyyy: function(d,v){
|
1504
|
+
return d.setUTCFullYear(v);
|
1505
|
+
},
|
1506
|
+
yy: function(d,v){
|
1507
|
+
return d.setUTCFullYear(2000+v);
|
1508
|
+
},
|
1452
1509
|
m: function(d,v){
|
1453
1510
|
if (isNaN(d))
|
1454
1511
|
return d;
|
1455
1512
|
v -= 1;
|
1456
|
-
while (v<0) v += 12;
|
1513
|
+
while (v < 0) v += 12;
|
1457
1514
|
v %= 12;
|
1458
1515
|
d.setUTCMonth(v);
|
1459
|
-
while (d.getUTCMonth()
|
1516
|
+
while (d.getUTCMonth() !== v)
|
1460
1517
|
d.setUTCDate(d.getUTCDate()-1);
|
1461
1518
|
return d;
|
1462
1519
|
},
|
1463
|
-
d: function(d,v){
|
1520
|
+
d: function(d,v){
|
1521
|
+
return d.setUTCDate(v);
|
1522
|
+
}
|
1464
1523
|
},
|
1465
|
-
val, filtered
|
1524
|
+
val, filtered;
|
1466
1525
|
setters_map['M'] = setters_map['MM'] = setters_map['mm'] = setters_map['m'];
|
1467
1526
|
setters_map['dd'] = setters_map['d'];
|
1468
1527
|
date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
|
1469
1528
|
var fparts = format.parts.slice();
|
1470
1529
|
// Remove noop parts
|
1471
|
-
if (parts.length
|
1530
|
+
if (parts.length !== fparts.length){
|
1472
1531
|
fparts = $(fparts).filter(function(i,p){
|
1473
1532
|
return $.inArray(p, setters_order) !== -1;
|
1474
1533
|
}).toArray();
|
1475
1534
|
}
|
1476
1535
|
// Process remainder
|
1477
|
-
|
1478
|
-
|
1536
|
+
function match_part(){
|
1537
|
+
var m = this.slice(0, parts[i].length),
|
1538
|
+
p = parts[i].slice(0, m.length);
|
1539
|
+
return m === p;
|
1540
|
+
}
|
1541
|
+
if (parts.length === fparts.length){
|
1542
|
+
var cnt;
|
1543
|
+
for (i=0, cnt = fparts.length; i < cnt; i++){
|
1479
1544
|
val = parseInt(parts[i], 10);
|
1480
1545
|
part = fparts[i];
|
1481
|
-
if (isNaN(val))
|
1482
|
-
switch(part)
|
1546
|
+
if (isNaN(val)){
|
1547
|
+
switch (part){
|
1483
1548
|
case 'MM':
|
1484
|
-
filtered = $(dates[language].months).filter(
|
1485
|
-
var m = this.slice(0, parts[i].length),
|
1486
|
-
p = parts[i].slice(0, m.length);
|
1487
|
-
return m == p;
|
1488
|
-
});
|
1549
|
+
filtered = $(dates[language].months).filter(match_part);
|
1489
1550
|
val = $.inArray(filtered[0], dates[language].months) + 1;
|
1490
1551
|
break;
|
1491
1552
|
case 'M':
|
1492
|
-
filtered = $(dates[language].monthsShort).filter(
|
1493
|
-
var m = this.slice(0, parts[i].length),
|
1494
|
-
p = parts[i].slice(0, m.length);
|
1495
|
-
return m == p;
|
1496
|
-
});
|
1553
|
+
filtered = $(dates[language].monthsShort).filter(match_part);
|
1497
1554
|
val = $.inArray(filtered[0], dates[language].monthsShort) + 1;
|
1498
1555
|
break;
|
1499
1556
|
}
|
1500
1557
|
}
|
1501
1558
|
parsed[part] = val;
|
1502
1559
|
}
|
1503
|
-
|
1560
|
+
var _date, s;
|
1561
|
+
for (i=0; i < setters_order.length; i++){
|
1504
1562
|
s = setters_order[i];
|
1505
1563
|
if (s in parsed && !isNaN(parsed[s])){
|
1506
1564
|
_date = new Date(date);
|
@@ -1529,9 +1587,9 @@
|
|
1529
1587
|
};
|
1530
1588
|
val.dd = (val.d < 10 ? '0' : '') + val.d;
|
1531
1589
|
val.mm = (val.m < 10 ? '0' : '') + val.m;
|
1532
|
-
|
1533
|
-
|
1534
|
-
for (var i=0, cnt = format.parts.length; i <= cnt; i++)
|
1590
|
+
date = [];
|
1591
|
+
var seps = $.extend([], format.separators);
|
1592
|
+
for (var i=0, cnt = format.parts.length; i <= cnt; i++){
|
1535
1593
|
if (seps.length)
|
1536
1594
|
date.push(seps.shift());
|
1537
1595
|
date.push(val[format.parts[i]]);
|
@@ -1546,7 +1604,14 @@
|
|
1546
1604
|
'</tr>'+
|
1547
1605
|
'</thead>',
|
1548
1606
|
contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>',
|
1549
|
-
footTemplate: '<tfoot
|
1607
|
+
footTemplate: '<tfoot>'+
|
1608
|
+
'<tr>'+
|
1609
|
+
'<th colspan="7" class="today"></th>'+
|
1610
|
+
'</tr>'+
|
1611
|
+
'<tr>'+
|
1612
|
+
'<th colspan="7" class="clear"></th>'+
|
1613
|
+
'</tr>'+
|
1614
|
+
'</tfoot>'
|
1550
1615
|
};
|
1551
1616
|
DPGlobal.template = '<div class="datepicker">'+
|
1552
1617
|
'<div class="datepicker-days">'+
|
@@ -1592,7 +1657,8 @@
|
|
1592
1657
|
'[data-provide="datepicker"]',
|
1593
1658
|
function(e){
|
1594
1659
|
var $this = $(this);
|
1595
|
-
if ($this.data('datepicker'))
|
1660
|
+
if ($this.data('datepicker'))
|
1661
|
+
return;
|
1596
1662
|
e.preventDefault();
|
1597
1663
|
// component click requires us to explicitly show it
|
1598
1664
|
$this.datepicker('show');
|
@@ -1602,4 +1668,4 @@
|
|
1602
1668
|
$('[data-provide="datepicker-inline"]').datepicker();
|
1603
1669
|
});
|
1604
1670
|
|
1605
|
-
}(
|
1671
|
+
}(window.jQuery));
|