bootstrap3-datetimepicker-rails 4.7.14 → 4.14.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/bootstrap3-datetimepicker-rails/version.rb +1 -1
- data/vendor/assets/javascripts/bootstrap-datetimepicker.js +461 -68
- data/vendor/assets/javascripts/bootstrap-datetimepicker.min.js +3 -2
- data/vendor/assets/stylesheets/bootstrap-datetimepicker.css +7 -1
- data/vendor/assets/stylesheets/bootstrap-datetimepicker.min.css +2 -363
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf1eb41e131ed226e4ef6045cd53ff75f198a04e
|
4
|
+
data.tar.gz: 7551237d8b71261ed2c40dfc2beabc64bc676b44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79bd1d4b59da62b10534b371fec88cd60dceda47217ca9756378bbb50f4f5f2b62985c887ac86e0486cb148fd6727d95b908ebb6bd4cee2baa8e6b9909199da6
|
7
|
+
data.tar.gz: 3f059eaceb88571250f776f66f18a9d83a631b864ec4ab2ed5d854e574bea4de90c0c50419e1fc9d911377009668433b941725b80c61676af2ac9df28a5005e0
|
data/README.md
CHANGED
@@ -14,7 +14,7 @@ actively maintained and works with [Bootstrap3](http://getbootstrap.com).
|
|
14
14
|
Add these lines to your application's Gemfile:
|
15
15
|
```ruby
|
16
16
|
gem 'momentjs-rails', '>= 2.9.0'
|
17
|
-
gem 'bootstrap3-datetimepicker-rails', '~> 4.
|
17
|
+
gem 'bootstrap3-datetimepicker-rails', '~> 4.14.30'
|
18
18
|
```
|
19
19
|
|
20
20
|
And then execute:
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/*! version : 4.
|
1
|
+
/*! version : 4.14.30
|
2
2
|
=========================================================
|
3
3
|
bootstrap-datetimejs
|
4
4
|
https://github.com/Eonasdan/bootstrap-datetimepicker
|
@@ -84,9 +84,14 @@
|
|
84
84
|
clsName: 'years',
|
85
85
|
navFnc: 'y',
|
86
86
|
navStep: 10
|
87
|
+
},
|
88
|
+
{
|
89
|
+
clsName: 'decades',
|
90
|
+
navFnc: 'y',
|
91
|
+
navStep: 100
|
87
92
|
}
|
88
93
|
],
|
89
|
-
viewModes = ['days', 'months', 'years'],
|
94
|
+
viewModes = ['days', 'months', 'years', 'decades'],
|
90
95
|
verticalModes = ['top', 'bottom', 'auto'],
|
91
96
|
horizontalModes = ['left', 'right', 'auto'],
|
92
97
|
toolbarPlacements = ['default', 'top', 'bottom'],
|
@@ -149,7 +154,6 @@
|
|
149
154
|
return false;
|
150
155
|
}
|
151
156
|
},
|
152
|
-
|
153
157
|
hasTime = function () {
|
154
158
|
return (isEnabled('h') || isEnabled('m') || isEnabled('s'));
|
155
159
|
},
|
@@ -186,6 +190,11 @@
|
|
186
190
|
.append(contTemplate.clone())
|
187
191
|
),
|
188
192
|
$('<div>').addClass('datepicker-years')
|
193
|
+
.append($('<table>').addClass('table-condensed')
|
194
|
+
.append(headTemplate.clone())
|
195
|
+
.append(contTemplate.clone())
|
196
|
+
),
|
197
|
+
$('<div>').addClass('datepicker-decades')
|
189
198
|
.append($('<table>').addClass('table-condensed')
|
190
199
|
.append(headTemplate.clone())
|
191
200
|
.append(contTemplate.clone())
|
@@ -200,12 +209,12 @@
|
|
200
209
|
|
201
210
|
if (isEnabled('h')) {
|
202
211
|
topRow.append($('<td>')
|
203
|
-
.append($('<a>').attr({href: '#', tabindex: '-1'}).addClass('btn').attr('data-action', 'incrementHours')
|
212
|
+
.append($('<a>').attr({href: '#', tabindex: '-1', 'title':'Increment Hour'}).addClass('btn').attr('data-action', 'incrementHours')
|
204
213
|
.append($('<span>').addClass(options.icons.up))));
|
205
214
|
middleRow.append($('<td>')
|
206
|
-
.append($('<span>').addClass('timepicker-hour').attr('data-time-component', '
|
215
|
+
.append($('<span>').addClass('timepicker-hour').attr({'data-time-component':'hours', 'title':'Pick Hour'}).attr('data-action', 'showHours')));
|
207
216
|
bottomRow.append($('<td>')
|
208
|
-
.append($('<a>').attr({href: '#', tabindex: '-1'}).addClass('btn').attr('data-action', 'decrementHours')
|
217
|
+
.append($('<a>').attr({href: '#', tabindex: '-1', 'title':'Decrement Hour'}).addClass('btn').attr('data-action', 'decrementHours')
|
209
218
|
.append($('<span>').addClass(options.icons.down))));
|
210
219
|
}
|
211
220
|
if (isEnabled('m')) {
|
@@ -215,12 +224,12 @@
|
|
215
224
|
bottomRow.append($('<td>').addClass('separator'));
|
216
225
|
}
|
217
226
|
topRow.append($('<td>')
|
218
|
-
.append($('<a>').attr({href: '#', tabindex: '-1'}).addClass('btn').attr('data-action', 'incrementMinutes')
|
227
|
+
.append($('<a>').attr({href: '#', tabindex: '-1', 'title':'Increment Minute'}).addClass('btn').attr('data-action', 'incrementMinutes')
|
219
228
|
.append($('<span>').addClass(options.icons.up))));
|
220
229
|
middleRow.append($('<td>')
|
221
|
-
.append($('<span>').addClass('timepicker-minute').attr('data-time-component'
|
230
|
+
.append($('<span>').addClass('timepicker-minute').attr({'data-time-component': 'minutes', 'title':'Pick Minute'}).attr('data-action', 'showMinutes')));
|
222
231
|
bottomRow.append($('<td>')
|
223
|
-
.append($('<a>').attr({href: '#', tabindex: '-1'}).addClass('btn').attr('data-action', 'decrementMinutes')
|
232
|
+
.append($('<a>').attr({href: '#', tabindex: '-1', 'title':'Decrement Minute'}).addClass('btn').attr('data-action', 'decrementMinutes')
|
224
233
|
.append($('<span>').addClass(options.icons.down))));
|
225
234
|
}
|
226
235
|
if (isEnabled('s')) {
|
@@ -230,19 +239,19 @@
|
|
230
239
|
bottomRow.append($('<td>').addClass('separator'));
|
231
240
|
}
|
232
241
|
topRow.append($('<td>')
|
233
|
-
.append($('<a>').attr({href: '#', tabindex: '-1'}).addClass('btn').attr('data-action', 'incrementSeconds')
|
242
|
+
.append($('<a>').attr({href: '#', tabindex: '-1', 'title':'Increment Second'}).addClass('btn').attr('data-action', 'incrementSeconds')
|
234
243
|
.append($('<span>').addClass(options.icons.up))));
|
235
244
|
middleRow.append($('<td>')
|
236
|
-
.append($('<span>').addClass('timepicker-second').attr('data-time-component'
|
245
|
+
.append($('<span>').addClass('timepicker-second').attr({'data-time-component': 'seconds', 'title':'Pick Second'}).attr('data-action', 'showSeconds')));
|
237
246
|
bottomRow.append($('<td>')
|
238
|
-
.append($('<a>').attr({href: '#', tabindex: '-1'}).addClass('btn').attr('data-action', 'decrementSeconds')
|
247
|
+
.append($('<a>').attr({href: '#', tabindex: '-1', 'title':'Decrement Second'}).addClass('btn').attr('data-action', 'decrementSeconds')
|
239
248
|
.append($('<span>').addClass(options.icons.down))));
|
240
249
|
}
|
241
250
|
|
242
251
|
if (!use24Hours) {
|
243
252
|
topRow.append($('<td>').addClass('separator'));
|
244
253
|
middleRow.append($('<td>')
|
245
|
-
.append($('<button>').addClass('btn btn-primary').attr('data-action'
|
254
|
+
.append($('<button>').addClass('btn btn-primary').attr({'data-action': 'togglePeriod', tabindex: '-1', 'title':'Toggle Period'})));
|
246
255
|
bottomRow.append($('<td>').addClass('separator'));
|
247
256
|
}
|
248
257
|
|
@@ -276,16 +285,16 @@
|
|
276
285
|
getToolbar = function () {
|
277
286
|
var row = [];
|
278
287
|
if (options.showTodayButton) {
|
279
|
-
row.push($('<td>').append($('<a>').attr('data-action', 'today').append($('<span>').addClass(options.icons.today))));
|
288
|
+
row.push($('<td>').append($('<a>').attr({'data-action':'today', 'title':'Go to today'}).append($('<span>').addClass(options.icons.today))));
|
280
289
|
}
|
281
290
|
if (!options.sideBySide && hasDate() && hasTime()) {
|
282
|
-
row.push($('<td>').append($('<a>').attr('data-action', '
|
291
|
+
row.push($('<td>').append($('<a>').attr({'data-action':'togglePicker', 'title':'Select Time'}).append($('<span>').addClass(options.icons.time))));
|
283
292
|
}
|
284
293
|
if (options.showClear) {
|
285
|
-
row.push($('<td>').append($('<a>').attr('data-action', '
|
294
|
+
row.push($('<td>').append($('<a>').attr({'data-action':'clear', 'title':'Clear selection'}).append($('<span>').addClass(options.icons.clear))));
|
286
295
|
}
|
287
296
|
if (options.showClose) {
|
288
|
-
row.push($('<td>').append($('<a>').attr('data-action', '
|
297
|
+
row.push($('<td>').append($('<a>').attr({'data-action':'close', 'title':'Close the picker'}).append($('<span>').addClass(options.icons.close))));
|
289
298
|
}
|
290
299
|
return $('<table>').addClass('table-condensed').append($('<tbody>').append($('<tr>').append(row)));
|
291
300
|
},
|
@@ -304,6 +313,9 @@
|
|
304
313
|
if (use24Hours) {
|
305
314
|
template.addClass('usetwentyfour');
|
306
315
|
}
|
316
|
+
if (isEnabled('s') && !use24Hours) {
|
317
|
+
template.addClass('wider');
|
318
|
+
}
|
307
319
|
if (options.sideBySide && hasDate() && hasTime()) {
|
308
320
|
template.addClass('timepicker-sbs');
|
309
321
|
template.append(
|
@@ -366,7 +378,7 @@
|
|
366
378
|
if (options.widgetParent) {
|
367
379
|
parent = options.widgetParent.append(widget);
|
368
380
|
} else if (element.is('input')) {
|
369
|
-
parent = element.
|
381
|
+
parent = element.after(widget).parent();
|
370
382
|
} else if (options.inline) {
|
371
383
|
parent = element.append(widget);
|
372
384
|
return;
|
@@ -421,8 +433,8 @@
|
|
421
433
|
widget.css({
|
422
434
|
top: vertical === 'top' ? 'auto' : position.top + element.outerHeight(),
|
423
435
|
bottom: vertical === 'top' ? position.top + element.outerHeight() : 'auto',
|
424
|
-
left: horizontal === 'left' ? parent.
|
425
|
-
right: horizontal === 'left' ? 'auto' : parent.
|
436
|
+
left: horizontal === 'left' ? (parent === element ? 0 : position.left) : 'auto',
|
437
|
+
right: horizontal === 'left' ? 'auto' : parent.outerWidth() - element.outerWidth() - (parent === element ? 0 : position.left)
|
426
438
|
});
|
427
439
|
},
|
428
440
|
|
@@ -433,19 +445,30 @@
|
|
433
445
|
element.trigger(e);
|
434
446
|
},
|
435
447
|
|
448
|
+
viewUpdate = function (e) {
|
449
|
+
if (e === 'y') {
|
450
|
+
e = 'YYYY';
|
451
|
+
}
|
452
|
+
notifyEvent({
|
453
|
+
type: 'dp.update',
|
454
|
+
change: e,
|
455
|
+
viewDate: viewDate.clone()
|
456
|
+
});
|
457
|
+
},
|
458
|
+
|
436
459
|
showMode = function (dir) {
|
437
460
|
if (!widget) {
|
438
461
|
return;
|
439
462
|
}
|
440
463
|
if (dir) {
|
441
|
-
currentViewMode = Math.max(minViewModeNumber, Math.min(
|
464
|
+
currentViewMode = Math.max(minViewModeNumber, Math.min(3, currentViewMode + dir));
|
442
465
|
}
|
443
466
|
widget.find('.datepicker > div').hide().filter('.datepicker-' + datePickerModes[currentViewMode].clsName).show();
|
444
467
|
},
|
445
468
|
|
446
469
|
fillDow = function () {
|
447
470
|
var row = $('<tr>'),
|
448
|
-
currentDate = viewDate.clone().startOf('w');
|
471
|
+
currentDate = viewDate.clone().startOf('w').startOf('d');
|
449
472
|
|
450
473
|
if (options.calendarWeeks === true) {
|
451
474
|
row.append($('<th>').addClass('cw').text('#'));
|
@@ -466,14 +489,22 @@
|
|
466
489
|
return options.enabledDates[testDate.format('YYYY-MM-DD')] === true;
|
467
490
|
},
|
468
491
|
|
492
|
+
isInDisabledHours = function (testDate) {
|
493
|
+
return options.disabledHours[testDate.format('H')] === true;
|
494
|
+
},
|
495
|
+
|
496
|
+
isInEnabledHours = function (testDate) {
|
497
|
+
return options.enabledHours[testDate.format('H')] === true;
|
498
|
+
},
|
499
|
+
|
469
500
|
isValid = function (targetMoment, granularity) {
|
470
501
|
if (!targetMoment.isValid()) {
|
471
502
|
return false;
|
472
503
|
}
|
473
|
-
if (options.disabledDates &&
|
504
|
+
if (options.disabledDates && granularity === 'd' && isInDisabledDates(targetMoment)) {
|
474
505
|
return false;
|
475
506
|
}
|
476
|
-
if (options.enabledDates &&
|
507
|
+
if (options.enabledDates && granularity === 'd' && !isInEnabledDates(targetMoment)) {
|
477
508
|
return false;
|
478
509
|
}
|
479
510
|
if (options.minDate && targetMoment.isBefore(options.minDate, granularity)) {
|
@@ -482,15 +513,33 @@
|
|
482
513
|
if (options.maxDate && targetMoment.isAfter(options.maxDate, granularity)) {
|
483
514
|
return false;
|
484
515
|
}
|
485
|
-
if (granularity === 'd' && options.daysOfWeekDisabled.indexOf(targetMoment.day()) !== -1) {
|
516
|
+
if (options.daysOfWeekDisabled && granularity === 'd' && options.daysOfWeekDisabled.indexOf(targetMoment.day()) !== -1) {
|
517
|
+
return false;
|
518
|
+
}
|
519
|
+
if (options.disabledHours && (granularity === 'h' || granularity === 'm' || granularity === 's') && isInDisabledHours(targetMoment)) {
|
486
520
|
return false;
|
487
521
|
}
|
522
|
+
if (options.enabledHours && (granularity === 'h' || granularity === 'm' || granularity === 's') && !isInEnabledHours(targetMoment)) {
|
523
|
+
return false;
|
524
|
+
}
|
525
|
+
if (options.disabledTimeIntervals && (granularity === 'h' || granularity === 'm' || granularity === 's')) {
|
526
|
+
var found = false;
|
527
|
+
$.each(options.disabledTimeIntervals, function () {
|
528
|
+
if (targetMoment.isBetween(this[0], this[1])) {
|
529
|
+
found = true;
|
530
|
+
return false;
|
531
|
+
}
|
532
|
+
});
|
533
|
+
if (found) {
|
534
|
+
return false;
|
535
|
+
}
|
536
|
+
}
|
488
537
|
return true;
|
489
538
|
},
|
490
539
|
|
491
540
|
fillMonths = function () {
|
492
541
|
var spans = [],
|
493
|
-
monthsShort = viewDate.clone().startOf('y').
|
542
|
+
monthsShort = viewDate.clone().startOf('y').startOf('d');
|
494
543
|
while (monthsShort.isSame(viewDate, 'y')) {
|
495
544
|
spans.push($('<span>').attr('data-action', 'selectMonth').addClass('month').text(monthsShort.format('MMM')));
|
496
545
|
monthsShort.add(1, 'M');
|
@@ -503,6 +552,10 @@
|
|
503
552
|
monthsViewHeader = monthsView.find('th'),
|
504
553
|
months = monthsView.find('tbody').find('span');
|
505
554
|
|
555
|
+
monthsViewHeader.eq(0).find('span').attr('title', 'Previous Year');
|
556
|
+
monthsViewHeader.eq(1).attr('title', 'Select Year');
|
557
|
+
monthsViewHeader.eq(2).find('span').attr('title', 'Next Year');
|
558
|
+
|
506
559
|
monthsView.find('.disabled').removeClass('disabled');
|
507
560
|
|
508
561
|
if (!isValid(viewDate.clone().subtract(1, 'y'), 'y')) {
|
@@ -516,7 +569,7 @@
|
|
516
569
|
}
|
517
570
|
|
518
571
|
months.removeClass('active');
|
519
|
-
if (date.isSame(viewDate, 'y')) {
|
572
|
+
if (date.isSame(viewDate, 'y') && !unset) {
|
520
573
|
months.eq(date.month()).addClass('active');
|
521
574
|
}
|
522
575
|
|
@@ -534,6 +587,10 @@
|
|
534
587
|
endYear = viewDate.clone().add(6, 'y'),
|
535
588
|
html = '';
|
536
589
|
|
590
|
+
yearsViewHeader.eq(0).find('span').attr('title', 'Previous Decade');
|
591
|
+
yearsViewHeader.eq(1).attr('title', 'Select Decade');
|
592
|
+
yearsViewHeader.eq(2).find('span').attr('title', 'Next Decade');
|
593
|
+
|
537
594
|
yearsView.find('.disabled').removeClass('disabled');
|
538
595
|
|
539
596
|
if (options.minDate && options.minDate.isAfter(startYear, 'y')) {
|
@@ -547,25 +604,62 @@
|
|
547
604
|
}
|
548
605
|
|
549
606
|
while (!startYear.isAfter(endYear, 'y')) {
|
550
|
-
html += '<span data-action="selectYear" class="year' + (startYear.isSame(date, 'y') ? ' active' : '') + (!isValid(startYear, 'y') ? ' disabled' : '') + '">' + startYear.year() + '</span>';
|
607
|
+
html += '<span data-action="selectYear" class="year' + (startYear.isSame(date, 'y') && !unset ? ' active' : '') + (!isValid(startYear, 'y') ? ' disabled' : '') + '">' + startYear.year() + '</span>';
|
551
608
|
startYear.add(1, 'y');
|
552
609
|
}
|
553
610
|
|
554
611
|
yearsView.find('td').html(html);
|
555
612
|
},
|
556
613
|
|
614
|
+
updateDecades = function () {
|
615
|
+
var decadesView = widget.find('.datepicker-decades'),
|
616
|
+
decadesViewHeader = decadesView.find('th'),
|
617
|
+
startDecade = viewDate.isBefore(moment({y: 1999})) ? moment({y: 1899}) : moment({y: 1999}),
|
618
|
+
endDecade = startDecade.clone().add(100, 'y'),
|
619
|
+
html = '';
|
620
|
+
|
621
|
+
decadesViewHeader.eq(0).find('span').attr('title', 'Previous Century');
|
622
|
+
decadesViewHeader.eq(2).find('span').attr('title', 'Next Century');
|
623
|
+
|
624
|
+
decadesView.find('.disabled').removeClass('disabled');
|
625
|
+
|
626
|
+
if (startDecade.isSame(moment({y: 1900})) || (options.minDate && options.minDate.isAfter(startDecade, 'y'))) {
|
627
|
+
decadesViewHeader.eq(0).addClass('disabled');
|
628
|
+
}
|
629
|
+
|
630
|
+
decadesViewHeader.eq(1).text(startDecade.year() + '-' + endDecade.year());
|
631
|
+
|
632
|
+
if (startDecade.isSame(moment({y: 2000})) || (options.maxDate && options.maxDate.isBefore(endDecade, 'y'))) {
|
633
|
+
decadesViewHeader.eq(2).addClass('disabled');
|
634
|
+
}
|
635
|
+
|
636
|
+
while (!startDecade.isAfter(endDecade, 'y')) {
|
637
|
+
html += '<span data-action="selectDecade" class="decade' + (startDecade.isSame(date, 'y') ? ' active' : '') +
|
638
|
+
(!isValid(startDecade, 'y') ? ' disabled' : '') + '" data-selection="' + (startDecade.year() + 6) + '">' + (startDecade.year() + 1) + ' - ' + (startDecade.year() + 12) + '</span>';
|
639
|
+
startDecade.add(12, 'y');
|
640
|
+
}
|
641
|
+
html += '<span></span><span></span><span></span>'; //push the dangling block over, at least this way it's even
|
642
|
+
|
643
|
+
decadesView.find('td').html(html);
|
644
|
+
},
|
645
|
+
|
557
646
|
fillDate = function () {
|
558
647
|
var daysView = widget.find('.datepicker-days'),
|
559
648
|
daysViewHeader = daysView.find('th'),
|
560
649
|
currentDate,
|
561
650
|
html = [],
|
562
651
|
row,
|
563
|
-
clsName
|
652
|
+
clsName,
|
653
|
+
i;
|
564
654
|
|
565
655
|
if (!hasDate()) {
|
566
656
|
return;
|
567
657
|
}
|
568
658
|
|
659
|
+
daysViewHeader.eq(0).find('span').attr('title', 'Previous Month');
|
660
|
+
daysViewHeader.eq(1).attr('title', 'Select Month');
|
661
|
+
daysViewHeader.eq(2).find('span').attr('title', 'Next Month');
|
662
|
+
|
569
663
|
daysView.find('.disabled').removeClass('disabled');
|
570
664
|
daysViewHeader.eq(1).text(viewDate.format(options.dayViewHeaderFormat));
|
571
665
|
|
@@ -576,9 +670,9 @@
|
|
576
670
|
daysViewHeader.eq(2).addClass('disabled');
|
577
671
|
}
|
578
672
|
|
579
|
-
currentDate = viewDate.clone().startOf('M').startOf('
|
673
|
+
currentDate = viewDate.clone().startOf('M').startOf('w').startOf('d');
|
580
674
|
|
581
|
-
|
675
|
+
for (i = 0; i < 42; i++) { //always display 42 days (should show 6 weeks)
|
582
676
|
if (currentDate.weekday() === 0) {
|
583
677
|
row = $('<tr>');
|
584
678
|
if (options.calendarWeeks) {
|
@@ -605,7 +699,7 @@
|
|
605
699
|
if (currentDate.day() === 0 || currentDate.day() === 6) {
|
606
700
|
clsName += ' weekend';
|
607
701
|
}
|
608
|
-
row.append('<td data-action="selectDay" class="day' + clsName + '">' + currentDate.date() + '</td>');
|
702
|
+
row.append('<td data-action="selectDay" data-day="' + currentDate.format('L') + '" class="day' + clsName + '">' + currentDate.date() + '</td>');
|
609
703
|
currentDate.add(1, 'd');
|
610
704
|
}
|
611
705
|
|
@@ -614,6 +708,8 @@
|
|
614
708
|
updateMonths();
|
615
709
|
|
616
710
|
updateYears();
|
711
|
+
|
712
|
+
updateDecades();
|
617
713
|
},
|
618
714
|
|
619
715
|
fillHours = function () {
|
@@ -673,9 +769,19 @@
|
|
673
769
|
},
|
674
770
|
|
675
771
|
fillTime = function () {
|
676
|
-
var timeComponents = widget.find('.timepicker span[data-time-component]');
|
772
|
+
var toggle, newDate, timeComponents = widget.find('.timepicker span[data-time-component]');
|
773
|
+
|
677
774
|
if (!use24Hours) {
|
678
|
-
widget.find('.timepicker [data-action=togglePeriod]')
|
775
|
+
toggle = widget.find('.timepicker [data-action=togglePeriod]');
|
776
|
+
newDate = date.clone().add((date.hours() >= 12) ? -12 : 12, 'h');
|
777
|
+
|
778
|
+
toggle.text(date.format('A'));
|
779
|
+
|
780
|
+
if (isValid(newDate, 'h')) {
|
781
|
+
toggle.removeClass('disabled');
|
782
|
+
} else {
|
783
|
+
toggle.addClass('disabled');
|
784
|
+
}
|
679
785
|
}
|
680
786
|
timeComponents.filter('[data-time-component=hours]').text(date.format(use24Hours ? 'HH' : 'hh'));
|
681
787
|
timeComponents.filter('[data-time-component=minutes]').text(date.format('mm'));
|
@@ -704,7 +810,7 @@
|
|
704
810
|
element.data('date', '');
|
705
811
|
notifyEvent({
|
706
812
|
type: 'dp.change',
|
707
|
-
date:
|
813
|
+
date: false,
|
708
814
|
oldDate: oldDate
|
709
815
|
});
|
710
816
|
update();
|
@@ -722,8 +828,8 @@
|
|
722
828
|
viewDate = date.clone();
|
723
829
|
input.val(date.format(actualFormat));
|
724
830
|
element.data('date', date.format(actualFormat));
|
725
|
-
update();
|
726
831
|
unset = false;
|
832
|
+
update();
|
727
833
|
notifyEvent({
|
728
834
|
type: 'dp.change',
|
729
835
|
date: date.clone(),
|
@@ -741,6 +847,7 @@
|
|
741
847
|
},
|
742
848
|
|
743
849
|
hide = function () {
|
850
|
+
///<summary>Hides the widget. Possibly will emit dp.hide</summary>
|
744
851
|
var transitioning = false;
|
745
852
|
if (!widget) {
|
746
853
|
return picker;
|
@@ -787,13 +894,17 @@
|
|
787
894
|
********************************************************************************/
|
788
895
|
actions = {
|
789
896
|
next: function () {
|
790
|
-
|
897
|
+
var navFnc = datePickerModes[currentViewMode].navFnc;
|
898
|
+
viewDate.add(datePickerModes[currentViewMode].navStep, navFnc);
|
791
899
|
fillDate();
|
900
|
+
viewUpdate(navFnc);
|
792
901
|
},
|
793
902
|
|
794
903
|
previous: function () {
|
795
|
-
|
904
|
+
var navFnc = datePickerModes[currentViewMode].navFnc;
|
905
|
+
viewDate.subtract(datePickerModes[currentViewMode].navStep, navFnc);
|
796
906
|
fillDate();
|
907
|
+
viewUpdate(navFnc);
|
797
908
|
},
|
798
909
|
|
799
910
|
pickerSwitch: function () {
|
@@ -812,6 +923,7 @@
|
|
812
923
|
showMode(-1);
|
813
924
|
fillDate();
|
814
925
|
}
|
926
|
+
viewUpdate('M');
|
815
927
|
},
|
816
928
|
|
817
929
|
selectYear: function (e) {
|
@@ -826,6 +938,22 @@
|
|
826
938
|
showMode(-1);
|
827
939
|
fillDate();
|
828
940
|
}
|
941
|
+
viewUpdate('YYYY');
|
942
|
+
},
|
943
|
+
|
944
|
+
selectDecade: function (e) {
|
945
|
+
var year = parseInt($(e.target).data('selection'), 10) || 0;
|
946
|
+
viewDate.year(year);
|
947
|
+
if (currentViewMode === minViewModeNumber) {
|
948
|
+
setValue(date.clone().year(viewDate.year()));
|
949
|
+
if (!options.inline) {
|
950
|
+
hide();
|
951
|
+
}
|
952
|
+
} else {
|
953
|
+
showMode(-1);
|
954
|
+
fillDate();
|
955
|
+
}
|
956
|
+
viewUpdate('YYYY');
|
829
957
|
},
|
830
958
|
|
831
959
|
selectDay: function (e) {
|
@@ -843,27 +971,45 @@
|
|
843
971
|
},
|
844
972
|
|
845
973
|
incrementHours: function () {
|
846
|
-
|
974
|
+
var newDate = date.clone().add(1, 'h');
|
975
|
+
if (isValid(newDate, 'h')) {
|
976
|
+
setValue(newDate);
|
977
|
+
}
|
847
978
|
},
|
848
979
|
|
849
980
|
incrementMinutes: function () {
|
850
|
-
|
981
|
+
var newDate = date.clone().add(options.stepping, 'm');
|
982
|
+
if (isValid(newDate, 'm')) {
|
983
|
+
setValue(newDate);
|
984
|
+
}
|
851
985
|
},
|
852
986
|
|
853
987
|
incrementSeconds: function () {
|
854
|
-
|
988
|
+
var newDate = date.clone().add(1, 's');
|
989
|
+
if (isValid(newDate, 's')) {
|
990
|
+
setValue(newDate);
|
991
|
+
}
|
855
992
|
},
|
856
993
|
|
857
994
|
decrementHours: function () {
|
858
|
-
|
995
|
+
var newDate = date.clone().subtract(1, 'h');
|
996
|
+
if (isValid(newDate, 'h')) {
|
997
|
+
setValue(newDate);
|
998
|
+
}
|
859
999
|
},
|
860
1000
|
|
861
1001
|
decrementMinutes: function () {
|
862
|
-
|
1002
|
+
var newDate = date.clone().subtract(options.stepping, 'm');
|
1003
|
+
if (isValid(newDate, 'm')) {
|
1004
|
+
setValue(newDate);
|
1005
|
+
}
|
863
1006
|
},
|
864
1007
|
|
865
1008
|
decrementSeconds: function () {
|
866
|
-
|
1009
|
+
var newDate = date.clone().subtract(1, 's');
|
1010
|
+
if (isValid(newDate, 's')) {
|
1011
|
+
setValue(newDate);
|
1012
|
+
}
|
867
1013
|
},
|
868
1014
|
|
869
1015
|
togglePeriod: function () {
|
@@ -953,7 +1099,9 @@
|
|
953
1099
|
clear: clear,
|
954
1100
|
|
955
1101
|
today: function () {
|
956
|
-
|
1102
|
+
if (isValid(moment(), 'd')) {
|
1103
|
+
setValue(moment());
|
1104
|
+
}
|
957
1105
|
},
|
958
1106
|
|
959
1107
|
close: hide
|
@@ -968,6 +1116,7 @@
|
|
968
1116
|
},
|
969
1117
|
|
970
1118
|
show = function () {
|
1119
|
+
///<summary>Shows the widget. Possibly will emit dp.show and dp.change</summary>
|
971
1120
|
var currentMoment,
|
972
1121
|
useCurrentGranularity = {
|
973
1122
|
'year': function (m) {
|
@@ -990,7 +1139,9 @@
|
|
990
1139
|
if (input.prop('disabled') || (!options.ignoreReadonly && input.prop('readonly')) || widget) {
|
991
1140
|
return picker;
|
992
1141
|
}
|
993
|
-
if (
|
1142
|
+
if (input.val() !== undefined && input.val().trim().length !== 0) {
|
1143
|
+
setValue(parseInputDate(input.val().trim()));
|
1144
|
+
} else if (options.useCurrent && unset && ((input.is('input') && input.val().trim().length === 0) || options.inline)) {
|
994
1145
|
currentMoment = moment();
|
995
1146
|
if (typeof options.useCurrent === 'string') {
|
996
1147
|
currentMoment = useCurrentGranularity[options.useCurrent](currentMoment);
|
@@ -1020,7 +1171,7 @@
|
|
1020
1171
|
widget.show();
|
1021
1172
|
place();
|
1022
1173
|
|
1023
|
-
if (!input.is(':focus')) {
|
1174
|
+
if (options.focusOnShow && !input.is(':focus')) {
|
1024
1175
|
input.focus();
|
1025
1176
|
}
|
1026
1177
|
|
@@ -1031,30 +1182,25 @@
|
|
1031
1182
|
},
|
1032
1183
|
|
1033
1184
|
toggle = function () {
|
1185
|
+
/// <summary>Shows or hides the widget</summary>
|
1034
1186
|
return (widget ? hide() : show());
|
1035
1187
|
},
|
1036
1188
|
|
1037
1189
|
parseInputDate = function (inputDate) {
|
1038
|
-
if (
|
1039
|
-
|
1190
|
+
if (options.parseInputDate === undefined) {
|
1191
|
+
if (moment.isMoment(inputDate) || inputDate instanceof Date) {
|
1192
|
+
inputDate = moment(inputDate);
|
1193
|
+
} else {
|
1194
|
+
inputDate = moment(inputDate, parseFormats, options.useStrict);
|
1195
|
+
}
|
1040
1196
|
} else {
|
1041
|
-
inputDate =
|
1197
|
+
inputDate = options.parseInputDate(inputDate);
|
1042
1198
|
}
|
1043
1199
|
inputDate.locale(options.locale);
|
1044
1200
|
return inputDate;
|
1045
1201
|
},
|
1046
1202
|
|
1047
1203
|
keydown = function (e) {
|
1048
|
-
//if (e.keyCode === 27 && widget) { // allow escape to hide picker
|
1049
|
-
// hide();
|
1050
|
-
// return false;
|
1051
|
-
//}
|
1052
|
-
//if (e.keyCode === 40 && !widget) { // allow down to show picker
|
1053
|
-
// show();
|
1054
|
-
// e.preventDefault();
|
1055
|
-
//}
|
1056
|
-
//return true;
|
1057
|
-
|
1058
1204
|
var handler = null,
|
1059
1205
|
index,
|
1060
1206
|
index2,
|
@@ -1121,7 +1267,8 @@
|
|
1121
1267
|
'change': change,
|
1122
1268
|
'blur': options.debug ? '' : hide,
|
1123
1269
|
'keydown': keydown,
|
1124
|
-
'keyup': keyup
|
1270
|
+
'keyup': keyup,
|
1271
|
+
'focus': options.allowInputToggle ? show : ''
|
1125
1272
|
});
|
1126
1273
|
|
1127
1274
|
if (element.is('input')) {
|
@@ -1139,7 +1286,8 @@
|
|
1139
1286
|
'change': change,
|
1140
1287
|
'blur': hide,
|
1141
1288
|
'keydown': keydown,
|
1142
|
-
'keyup': keyup
|
1289
|
+
'keyup': keyup,
|
1290
|
+
'focus': options.allowInputToggle ? hide : ''
|
1143
1291
|
});
|
1144
1292
|
|
1145
1293
|
if (element.is('input')) {
|
@@ -1166,6 +1314,17 @@
|
|
1166
1314
|
return (Object.keys(givenDatesIndexed).length) ? givenDatesIndexed : false;
|
1167
1315
|
},
|
1168
1316
|
|
1317
|
+
indexGivenHours = function (givenHoursArray) {
|
1318
|
+
// Store given enabledHours and disabledHours as keys.
|
1319
|
+
// This way we can check their existence in O(1) time instead of looping through whole array.
|
1320
|
+
// (for example: options.enabledHours['2014-02-27'] === true)
|
1321
|
+
var givenHoursIndexed = {};
|
1322
|
+
$.each(givenHoursArray, function () {
|
1323
|
+
givenHoursIndexed[this] = true;
|
1324
|
+
});
|
1325
|
+
return (Object.keys(givenHoursIndexed).length) ? givenHoursIndexed : false;
|
1326
|
+
},
|
1327
|
+
|
1169
1328
|
initFormatting = function () {
|
1170
1329
|
var format = options.format || 'L LT';
|
1171
1330
|
|
@@ -1182,7 +1341,7 @@
|
|
1182
1341
|
parseFormats.push(actualFormat);
|
1183
1342
|
}
|
1184
1343
|
|
1185
|
-
use24Hours = (actualFormat.toLowerCase().indexOf('a') < 1 && actualFormat.indexOf('h') < 1);
|
1344
|
+
use24Hours = (actualFormat.toLowerCase().indexOf('a') < 1 && actualFormat.replace(/\[.*?\]/g, '').indexOf('h') < 1);
|
1186
1345
|
|
1187
1346
|
if (isEnabled('y')) {
|
1188
1347
|
minViewModeNumber = 2;
|
@@ -1212,6 +1371,7 @@
|
|
1212
1371
|
*
|
1213
1372
|
********************************************************************************/
|
1214
1373
|
picker.destroy = function () {
|
1374
|
+
///<summary>Destroys the widget and removes all attached event listeners</summary>
|
1215
1375
|
hide();
|
1216
1376
|
detachDatePickerElementEvents();
|
1217
1377
|
element.removeData('DateTimePicker');
|
@@ -1225,6 +1385,8 @@
|
|
1225
1385
|
picker.hide = hide;
|
1226
1386
|
|
1227
1387
|
picker.disable = function () {
|
1388
|
+
///<summary>Disables the input element, the component is attached to, by adding a disabled="true" attribute to it.
|
1389
|
+
///If the widget was visible before that call it is hidden. Possibly emits dp.hide</summary>
|
1228
1390
|
hide();
|
1229
1391
|
if (component && component.hasClass('btn')) {
|
1230
1392
|
component.addClass('disabled');
|
@@ -1234,6 +1396,7 @@
|
|
1234
1396
|
};
|
1235
1397
|
|
1236
1398
|
picker.enable = function () {
|
1399
|
+
///<summary>Enables the input element, the component is attached to, by removing disabled attribute from it.</summary>
|
1237
1400
|
if (component && component.hasClass('btn')) {
|
1238
1401
|
component.removeClass('disabled');
|
1239
1402
|
}
|
@@ -1272,6 +1435,14 @@
|
|
1272
1435
|
};
|
1273
1436
|
|
1274
1437
|
picker.date = function (newDate) {
|
1438
|
+
///<signature helpKeyword="$.fn.datetimepicker.date">
|
1439
|
+
///<summary>Returns the component's model current date, a moment object or null if not set.</summary>
|
1440
|
+
///<returns type="Moment">date.clone()</returns>
|
1441
|
+
///</signature>
|
1442
|
+
///<signature>
|
1443
|
+
///<summary>Sets the components model current moment to it. Passing a null value unsets the components model current moment. Parsing of the newDate parameter is made using moment library with the options.format and options.useStrict components configuration.</summary>
|
1444
|
+
///<param name="newDate" locid="$.fn.datetimepicker.date_p:newDate">Takes string, Date, moment, null parameter.</param>
|
1445
|
+
///</signature>
|
1275
1446
|
if (arguments.length === 0) {
|
1276
1447
|
if (unset) {
|
1277
1448
|
return null;
|
@@ -1288,6 +1459,9 @@
|
|
1288
1459
|
};
|
1289
1460
|
|
1290
1461
|
picker.format = function (newFormat) {
|
1462
|
+
///<summary>test su</summary>
|
1463
|
+
///<param name="newFormat">info about para</param>
|
1464
|
+
///<returns type="string|boolean">returns foo</returns>
|
1291
1465
|
if (arguments.length === 0) {
|
1292
1466
|
return options.format;
|
1293
1467
|
}
|
@@ -1333,6 +1507,15 @@
|
|
1333
1507
|
};
|
1334
1508
|
|
1335
1509
|
picker.disabledDates = function (dates) {
|
1510
|
+
///<signature helpKeyword="$.fn.datetimepicker.disabledDates">
|
1511
|
+
///<summary>Returns an array with the currently set disabled dates on the component.</summary>
|
1512
|
+
///<returns type="array">options.disabledDates</returns>
|
1513
|
+
///</signature>
|
1514
|
+
///<signature>
|
1515
|
+
///<summary>Setting this takes precedence over options.minDate, options.maxDate configuration. Also calling this function removes the configuration of
|
1516
|
+
///options.enabledDates if such exist.</summary>
|
1517
|
+
///<param name="dates" locid="$.fn.datetimepicker.disabledDates_p:dates">Takes an [ string or Date or moment ] of values and allows the user to select only from those days.</param>
|
1518
|
+
///</signature>
|
1336
1519
|
if (arguments.length === 0) {
|
1337
1520
|
return (options.disabledDates ? $.extend({}, options.disabledDates) : options.disabledDates);
|
1338
1521
|
}
|
@@ -1352,6 +1535,14 @@
|
|
1352
1535
|
};
|
1353
1536
|
|
1354
1537
|
picker.enabledDates = function (dates) {
|
1538
|
+
///<signature helpKeyword="$.fn.datetimepicker.enabledDates">
|
1539
|
+
///<summary>Returns an array with the currently set enabled dates on the component.</summary>
|
1540
|
+
///<returns type="array">options.enabledDates</returns>
|
1541
|
+
///</signature>
|
1542
|
+
///<signature>
|
1543
|
+
///<summary>Setting this takes precedence over options.minDate, options.maxDate configuration. Also calling this function removes the configuration of options.disabledDates if such exist.</summary>
|
1544
|
+
///<param name="dates" locid="$.fn.datetimepicker.enabledDates_p:dates">Takes an [ string or Date or moment ] of values and allows the user to select only from those days.</param>
|
1545
|
+
///</signature>
|
1355
1546
|
if (arguments.length === 0) {
|
1356
1547
|
return (options.enabledDates ? $.extend({}, options.enabledDates) : options.enabledDates);
|
1357
1548
|
}
|
@@ -1375,6 +1566,12 @@
|
|
1375
1566
|
return options.daysOfWeekDisabled.splice(0);
|
1376
1567
|
}
|
1377
1568
|
|
1569
|
+
if ((typeof daysOfWeekDisabled === 'boolean') && !daysOfWeekDisabled) {
|
1570
|
+
options.daysOfWeekDisabled = false;
|
1571
|
+
update();
|
1572
|
+
return picker;
|
1573
|
+
}
|
1574
|
+
|
1378
1575
|
if (!(daysOfWeekDisabled instanceof Array)) {
|
1379
1576
|
throw new TypeError('daysOfWeekDisabled() expects an array parameter');
|
1380
1577
|
}
|
@@ -1388,6 +1585,17 @@
|
|
1388
1585
|
}
|
1389
1586
|
return previousValue;
|
1390
1587
|
}, []).sort();
|
1588
|
+
if (options.useCurrent && !options.keepInvalid) {
|
1589
|
+
var tries = 0;
|
1590
|
+
while (!isValid(date, 'd')) {
|
1591
|
+
date.add(1, 'd');
|
1592
|
+
if (tries === 7) {
|
1593
|
+
throw 'Tried 7 times to find a valid date';
|
1594
|
+
}
|
1595
|
+
tries++;
|
1596
|
+
}
|
1597
|
+
setValue(date);
|
1598
|
+
}
|
1391
1599
|
update();
|
1392
1600
|
return picker;
|
1393
1601
|
};
|
@@ -1418,7 +1626,7 @@
|
|
1418
1626
|
throw new TypeError('maxDate() date parameter is before options.minDate: ' + parsedDate.format(actualFormat));
|
1419
1627
|
}
|
1420
1628
|
options.maxDate = parsedDate;
|
1421
|
-
if (options.
|
1629
|
+
if (options.useCurrent && !options.keepInvalid && date.isAfter(maxDate)) {
|
1422
1630
|
setValue(options.maxDate);
|
1423
1631
|
}
|
1424
1632
|
if (viewDate.isAfter(parsedDate)) {
|
@@ -1454,7 +1662,7 @@
|
|
1454
1662
|
throw new TypeError('minDate() date parameter is after options.maxDate: ' + parsedDate.format(actualFormat));
|
1455
1663
|
}
|
1456
1664
|
options.minDate = parsedDate;
|
1457
|
-
if (options.
|
1665
|
+
if (options.useCurrent && !options.keepInvalid && date.isBefore(minDate)) {
|
1458
1666
|
setValue(options.minDate);
|
1459
1667
|
}
|
1460
1668
|
if (viewDate.isBefore(parsedDate)) {
|
@@ -1465,6 +1673,14 @@
|
|
1465
1673
|
};
|
1466
1674
|
|
1467
1675
|
picker.defaultDate = function (defaultDate) {
|
1676
|
+
///<signature helpKeyword="$.fn.datetimepicker.defaultDate">
|
1677
|
+
///<summary>Returns a moment with the options.defaultDate option configuration or false if not set</summary>
|
1678
|
+
///<returns type="Moment">date.clone()</returns>
|
1679
|
+
///</signature>
|
1680
|
+
///<signature>
|
1681
|
+
///<summary>Will set the picker's inital date. If a boolean:false value is passed the options.defaultDate parameter is cleared.</summary>
|
1682
|
+
///<param name="defaultDate" locid="$.fn.datetimepicker.defaultDate_p:defaultDate">Takes a string, Date, moment, boolean:false</param>
|
1683
|
+
///</signature>
|
1468
1684
|
if (arguments.length === 0) {
|
1469
1685
|
return options.defaultDate ? options.defaultDate.clone() : options.defaultDate;
|
1470
1686
|
}
|
@@ -1489,7 +1705,7 @@
|
|
1489
1705
|
|
1490
1706
|
options.defaultDate = parsedDate;
|
1491
1707
|
|
1492
|
-
if (options.defaultDate && input.val().trim() === '' && input.attr('placeholder') === undefined) {
|
1708
|
+
if (options.defaultDate && options.inline || (input.val().trim() === '' && input.attr('placeholder') === undefined)) {
|
1493
1709
|
setValue(options.defaultDate);
|
1494
1710
|
}
|
1495
1711
|
return picker;
|
@@ -1764,6 +1980,19 @@
|
|
1764
1980
|
return picker;
|
1765
1981
|
};
|
1766
1982
|
|
1983
|
+
picker.focusOnShow = function (focusOnShow) {
|
1984
|
+
if (arguments.length === 0) {
|
1985
|
+
return options.focusOnShow;
|
1986
|
+
}
|
1987
|
+
|
1988
|
+
if (typeof focusOnShow !== 'boolean') {
|
1989
|
+
throw new TypeError('focusOnShow() expects a boolean parameter');
|
1990
|
+
}
|
1991
|
+
|
1992
|
+
options.focusOnShow = focusOnShow;
|
1993
|
+
return picker;
|
1994
|
+
};
|
1995
|
+
|
1767
1996
|
picker.inline = function (inline) {
|
1768
1997
|
if (arguments.length === 0) {
|
1769
1998
|
return options.inline;
|
@@ -1796,6 +2025,19 @@
|
|
1796
2025
|
return picker;
|
1797
2026
|
};
|
1798
2027
|
|
2028
|
+
picker.allowInputToggle = function (allowInputToggle) {
|
2029
|
+
if (arguments.length === 0) {
|
2030
|
+
return options.allowInputToggle;
|
2031
|
+
}
|
2032
|
+
|
2033
|
+
if (typeof allowInputToggle !== 'boolean') {
|
2034
|
+
throw new TypeError('allowInputToggle() expects a boolean parameter');
|
2035
|
+
}
|
2036
|
+
|
2037
|
+
options.allowInputToggle = allowInputToggle;
|
2038
|
+
return picker;
|
2039
|
+
};
|
2040
|
+
|
1799
2041
|
picker.showClose = function (showClose) {
|
1800
2042
|
if (arguments.length === 0) {
|
1801
2043
|
return options.showClose;
|
@@ -1834,6 +2076,151 @@
|
|
1834
2076
|
return picker;
|
1835
2077
|
};
|
1836
2078
|
|
2079
|
+
picker.parseInputDate = function (parseInputDate) {
|
2080
|
+
if (arguments.length === 0) {
|
2081
|
+
return options.parseInputDate;
|
2082
|
+
}
|
2083
|
+
|
2084
|
+
if (typeof parseInputDate !== 'function') {
|
2085
|
+
throw new TypeError('parseInputDate() sholud be as function');
|
2086
|
+
}
|
2087
|
+
|
2088
|
+
options.parseInputDate = parseInputDate;
|
2089
|
+
|
2090
|
+
return picker;
|
2091
|
+
};
|
2092
|
+
|
2093
|
+
picker.disabledTimeIntervals = function (disabledTimeIntervals) {
|
2094
|
+
///<signature helpKeyword="$.fn.datetimepicker.disabledTimeIntervals">
|
2095
|
+
///<summary>Returns an array with the currently set disabled dates on the component.</summary>
|
2096
|
+
///<returns type="array">options.disabledTimeIntervals</returns>
|
2097
|
+
///</signature>
|
2098
|
+
///<signature>
|
2099
|
+
///<summary>Setting this takes precedence over options.minDate, options.maxDate configuration. Also calling this function removes the configuration of
|
2100
|
+
///options.enabledDates if such exist.</summary>
|
2101
|
+
///<param name="dates" locid="$.fn.datetimepicker.disabledTimeIntervals_p:dates">Takes an [ string or Date or moment ] of values and allows the user to select only from those days.</param>
|
2102
|
+
///</signature>
|
2103
|
+
if (arguments.length === 0) {
|
2104
|
+
return (options.disabledTimeIntervals ? $.extend({}, options.disabledTimeIntervals) : options.disabledTimeIntervals);
|
2105
|
+
}
|
2106
|
+
|
2107
|
+
if (!disabledTimeIntervals) {
|
2108
|
+
options.disabledTimeIntervals = false;
|
2109
|
+
update();
|
2110
|
+
return picker;
|
2111
|
+
}
|
2112
|
+
if (!(disabledTimeIntervals instanceof Array)) {
|
2113
|
+
throw new TypeError('disabledTimeIntervals() expects an array parameter');
|
2114
|
+
}
|
2115
|
+
options.disabledTimeIntervals = disabledTimeIntervals;
|
2116
|
+
update();
|
2117
|
+
return picker;
|
2118
|
+
};
|
2119
|
+
|
2120
|
+
picker.disabledHours = function (hours) {
|
2121
|
+
///<signature helpKeyword="$.fn.datetimepicker.disabledHours">
|
2122
|
+
///<summary>Returns an array with the currently set disabled hours on the component.</summary>
|
2123
|
+
///<returns type="array">options.disabledHours</returns>
|
2124
|
+
///</signature>
|
2125
|
+
///<signature>
|
2126
|
+
///<summary>Setting this takes precedence over options.minDate, options.maxDate configuration. Also calling this function removes the configuration of
|
2127
|
+
///options.enabledHours if such exist.</summary>
|
2128
|
+
///<param name="hours" locid="$.fn.datetimepicker.disabledHours_p:hours">Takes an [ int ] of values and disallows the user to select only from those hours.</param>
|
2129
|
+
///</signature>
|
2130
|
+
if (arguments.length === 0) {
|
2131
|
+
return (options.disabledHours ? $.extend({}, options.disabledHours) : options.disabledHours);
|
2132
|
+
}
|
2133
|
+
|
2134
|
+
if (!hours) {
|
2135
|
+
options.disabledHours = false;
|
2136
|
+
update();
|
2137
|
+
return picker;
|
2138
|
+
}
|
2139
|
+
if (!(hours instanceof Array)) {
|
2140
|
+
throw new TypeError('disabledHours() expects an array parameter');
|
2141
|
+
}
|
2142
|
+
options.disabledHours = indexGivenHours(hours);
|
2143
|
+
options.enabledHours = false;
|
2144
|
+
if (options.useCurrent && !options.keepInvalid) {
|
2145
|
+
var tries = 0;
|
2146
|
+
while (!isValid(date, 'h')) {
|
2147
|
+
date.add(1, 'h');
|
2148
|
+
if (tries === 24) {
|
2149
|
+
throw 'Tried 24 times to find a valid date';
|
2150
|
+
}
|
2151
|
+
tries++;
|
2152
|
+
}
|
2153
|
+
setValue(date);
|
2154
|
+
}
|
2155
|
+
update();
|
2156
|
+
return picker;
|
2157
|
+
};
|
2158
|
+
|
2159
|
+
picker.enabledHours = function (hours) {
|
2160
|
+
///<signature helpKeyword="$.fn.datetimepicker.enabledHours">
|
2161
|
+
///<summary>Returns an array with the currently set enabled hours on the component.</summary>
|
2162
|
+
///<returns type="array">options.enabledHours</returns>
|
2163
|
+
///</signature>
|
2164
|
+
///<signature>
|
2165
|
+
///<summary>Setting this takes precedence over options.minDate, options.maxDate configuration. Also calling this function removes the configuration of options.disabledHours if such exist.</summary>
|
2166
|
+
///<param name="hours" locid="$.fn.datetimepicker.enabledHours_p:hours">Takes an [ int ] of values and allows the user to select only from those hours.</param>
|
2167
|
+
///</signature>
|
2168
|
+
if (arguments.length === 0) {
|
2169
|
+
return (options.enabledHours ? $.extend({}, options.enabledHours) : options.enabledHours);
|
2170
|
+
}
|
2171
|
+
|
2172
|
+
if (!hours) {
|
2173
|
+
options.enabledHours = false;
|
2174
|
+
update();
|
2175
|
+
return picker;
|
2176
|
+
}
|
2177
|
+
if (!(hours instanceof Array)) {
|
2178
|
+
throw new TypeError('enabledHours() expects an array parameter');
|
2179
|
+
}
|
2180
|
+
options.enabledHours = indexGivenHours(hours);
|
2181
|
+
options.disabledHours = false;
|
2182
|
+
if (options.useCurrent && !options.keepInvalid) {
|
2183
|
+
var tries = 0;
|
2184
|
+
while (!isValid(date, 'h')) {
|
2185
|
+
date.add(1, 'h');
|
2186
|
+
if (tries === 24) {
|
2187
|
+
throw 'Tried 24 times to find a valid date';
|
2188
|
+
}
|
2189
|
+
tries++;
|
2190
|
+
}
|
2191
|
+
setValue(date);
|
2192
|
+
}
|
2193
|
+
update();
|
2194
|
+
return picker;
|
2195
|
+
};
|
2196
|
+
|
2197
|
+
picker.viewDate = function (newDate) {
|
2198
|
+
///<signature helpKeyword="$.fn.datetimepicker.viewDate">
|
2199
|
+
///<summary>Returns the component's model current viewDate, a moment object or null if not set.</summary>
|
2200
|
+
///<returns type="Moment">viewDate.clone()</returns>
|
2201
|
+
///</signature>
|
2202
|
+
///<signature>
|
2203
|
+
///<summary>Sets the components model current moment to it. Passing a null value unsets the components model current moment. Parsing of the newDate parameter is made using moment library with the options.format and options.useStrict components configuration.</summary>
|
2204
|
+
///<param name="newDate" locid="$.fn.datetimepicker.date_p:newDate">Takes string, viewDate, moment, null parameter.</param>
|
2205
|
+
///</signature>
|
2206
|
+
if (arguments.length === 0) {
|
2207
|
+
return viewDate.clone();
|
2208
|
+
}
|
2209
|
+
|
2210
|
+
if (!newDate) {
|
2211
|
+
viewDate = date.clone();
|
2212
|
+
return picker;
|
2213
|
+
}
|
2214
|
+
|
2215
|
+
if (typeof newDate !== 'string' && !moment.isMoment(newDate) && !(newDate instanceof Date)) {
|
2216
|
+
throw new TypeError('viewDate() parameter must be one of [string, moment or Date]');
|
2217
|
+
}
|
2218
|
+
|
2219
|
+
viewDate = parseInputDate(newDate);
|
2220
|
+
viewUpdate();
|
2221
|
+
return picker;
|
2222
|
+
};
|
2223
|
+
|
1837
2224
|
// initializing element and component attributes
|
1838
2225
|
if (element.is('input')) {
|
1839
2226
|
input = element;
|
@@ -1925,7 +2312,7 @@
|
|
1925
2312
|
},
|
1926
2313
|
useStrict: false,
|
1927
2314
|
sideBySide: false,
|
1928
|
-
daysOfWeekDisabled:
|
2315
|
+
daysOfWeekDisabled: false,
|
1929
2316
|
calendarWeeks: false,
|
1930
2317
|
viewMode: 'days',
|
1931
2318
|
toolbarPlacement: 'default',
|
@@ -1939,6 +2326,7 @@
|
|
1939
2326
|
widgetParent: null,
|
1940
2327
|
ignoreReadonly: false,
|
1941
2328
|
keepOpen: false,
|
2329
|
+
focusOnShow: true,
|
1942
2330
|
inline: false,
|
1943
2331
|
keepInvalid: false,
|
1944
2332
|
datepickerInput: '.datepickerinput',
|
@@ -2046,6 +2434,11 @@
|
|
2046
2434
|
this.clear();
|
2047
2435
|
}
|
2048
2436
|
},
|
2049
|
-
debug: false
|
2437
|
+
debug: false,
|
2438
|
+
allowInputToggle: false,
|
2439
|
+
disabledTimeIntervals: false,
|
2440
|
+
disabledHours: false,
|
2441
|
+
enabledHours: false,
|
2442
|
+
viewDate: false
|
2050
2443
|
};
|
2051
2444
|
}));
|