1/*@preserve 2 * Tempus Dominus Bootstrap4 v5.1.2 (https://tempusdominus.github.io/bootstrap-4/) 3 * Copyright 2016-2018 Jonathan Peterson 4 * Licensed under MIT (https://github.com/tempusdominus/bootstrap-3/blob/master/LICENSE) 5 */ 6 7if (typeof jQuery === 'undefined') { 8 throw new Error('Tempus Dominus Bootstrap4\'s requires jQuery. jQuery must be included before Tempus Dominus Bootstrap4\'s JavaScript.'); 9} 10 11+function ($) { 12 var version = $.fn.jquery.split(' ')[0].split('.'); 13 if ((version[0] < 2 && version[1] < 9) || (version[0] === 1 && version[1] === 9 && version[2] < 1) || (version[0] >= 4)) { 14 throw new Error('Tempus Dominus Bootstrap4\'s requires at least jQuery v3.0.0 but less than v4.0.0'); 15 } 16}(jQuery); 17 18 19if (typeof moment === 'undefined') { 20 throw new Error('Tempus Dominus Bootstrap4\'s requires moment.min.js. moment.min.js must be included before Tempus Dominus Bootstrap4\'s JavaScript.'); 21} 22 23var version = moment.version.split('.') 24if ((version[0] <= 2 && version[1] < 17) || (version[0] >= 3)) { 25 throw new Error('Tempus Dominus Bootstrap4\'s requires at least moment.min.js v2.17.0 but less than v3.0.0'); 26} 27 28+function () { 29 30var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; 31 32var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 33 34function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } 35 36function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } 37 38function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 39 40// ReSharper disable once InconsistentNaming 41var DateTimePicker = function ($, moment) { 42 // ReSharper disable InconsistentNaming 43 var NAME = 'datetimepicker', 44 DATA_KEY = '' + NAME, 45 EVENT_KEY = '.' + DATA_KEY, 46 DATA_API_KEY = '.data-api', 47 Selector = { 48 DATA_TOGGLE: '[data-toggle="' + DATA_KEY + '"]' 49 }, 50 ClassName = { 51 INPUT: NAME + '-input' 52 }, 53 Event = { 54 CHANGE: 'change' + EVENT_KEY, 55 BLUR: 'blur' + EVENT_KEY, 56 KEYUP: 'keyup' + EVENT_KEY, 57 KEYDOWN: 'keydown' + EVENT_KEY, 58 FOCUS: 'focus' + EVENT_KEY, 59 CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY, 60 //emitted 61 UPDATE: 'update' + EVENT_KEY, 62 ERROR: 'error' + EVENT_KEY, 63 HIDE: 'hide' + EVENT_KEY, 64 SHOW: 'show' + EVENT_KEY 65 }, 66 DatePickerModes = [{ 67 CLASS_NAME: 'days', 68 NAV_FUNCTION: 'M', 69 NAV_STEP: 1 70 }, { 71 CLASS_NAME: 'months', 72 NAV_FUNCTION: 'y', 73 NAV_STEP: 1 74 }, { 75 CLASS_NAME: 'years', 76 NAV_FUNCTION: 'y', 77 NAV_STEP: 10 78 }, { 79 CLASS_NAME: 'decades', 80 NAV_FUNCTION: 'y', 81 NAV_STEP: 100 82 }], 83 KeyMap = { 84 'up': 38, 85 38: 'up', 86 'down': 40, 87 40: 'down', 88 'left': 37, 89 37: 'left', 90 'right': 39, 91 39: 'right', 92 'tab': 9, 93 9: 'tab', 94 'escape': 27, 95 27: 'escape', 96 'enter': 13, 97 13: 'enter', 98 'pageUp': 33, 99 33: 'pageUp', 100 'pageDown': 34, 101 34: 'pageDown', 102 'shift': 16, 103 16: 'shift', 104 'control': 17, 105 17: 'control', 106 'space': 32, 107 32: 'space', 108 't': 84, 109 84: 't', 110 'delete': 46, 111 46: 'delete' 112 }, 113 ViewModes = ['times', 'days', 'months', 'years', 'decades'], 114 keyState = {}, 115 keyPressHandled = {}; 116 117 var Default = { 118 timeZone: '', 119 format: false, 120 dayViewHeaderFormat: 'MMMM YYYY', 121 extraFormats: false, 122 stepping: 1, 123 minDate: false, 124 maxDate: false, 125 useCurrent: true, 126 collapse: true, 127 locale: moment.locale(), 128 defaultDate: false, 129 disabledDates: false, 130 enabledDates: false, 131 icons: { 132 time: 'fa fa-clock-o', 133 date: 'fa fa-calendar', 134 up: 'fa fa-arrow-up', 135 down: 'fa fa-arrow-down', 136 previous: 'fa fa-chevron-left', 137 next: 'fa fa-chevron-right', 138 today: 'fa fa-calendar-check-o', 139 clear: 'fa fa-delete', 140 close: 'fa fa-times' 141 }, 142 tooltips: { 143 today: 'Go to today', 144 clear: 'Clear selection', 145 close: 'Close the picker', 146 selectMonth: 'Select Month', 147 prevMonth: 'Previous Month', 148 nextMonth: 'Next Month', 149 selectYear: 'Select Year', 150 prevYear: 'Previous Year', 151 nextYear: 'Next Year', 152 selectDecade: 'Select Decade', 153 prevDecade: 'Previous Decade', 154 nextDecade: 'Next Decade', 155 prevCentury: 'Previous Century', 156 nextCentury: 'Next Century', 157 pickHour: 'Pick Hour', 158 incrementHour: 'Increment Hour', 159 decrementHour: 'Decrement Hour', 160 pickMinute: 'Pick Minute', 161 incrementMinute: 'Increment Minute', 162 decrementMinute: 'Decrement Minute', 163 pickSecond: 'Pick Second', 164 incrementSecond: 'Increment Second', 165 decrementSecond: 'Decrement Second',
vendor: 7,801 bytes, lines 166-389
166 togglePeriod: 'Toggle Period', 167 selectTime: 'Select Time', 168 selectDate: 'Select Date' 169 }, 170 useStrict: false, 171 sideBySide: false, 172 daysOfWeekDisabled: false, 173 calendarWeeks: false, 174 viewMode: 'days', 175 toolbarPlacement: 'default', 176 buttons: { 177 showToday: false, 178 showClear: false, 179 showClose: false 180 }, 181 widgetPositioning: { 182 horizontal: 'auto', 183 vertical: 'auto' 184 }, 185 widgetParent: null, 186 ignoreReadonly: false, 187 keepOpen: false, 188 focusOnShow: true, 189 inline: false, 190 keepInvalid: false, 191 keyBinds: { 192 up: function up() { 193 if (!this.widget) { 194 return false; 195 } 196 var d = this._dates[0] || this.getMoment(); 197 if (this.widget.find('.datepicker').is(':visible')) { 198 this.date(d.clone().subtract(7, 'd')); 199 } else { 200 this.date(d.clone().add(this.stepping(), 'm')); 201 } 202 return true; 203 }, 204 down: function down() { 205 if (!this.widget) { 206 this.show(); 207 return false; 208 } 209 var d = this._dates[0] || this.getMoment(); 210 if (this.widget.find('.datepicker').is(':visible')) { 211 this.date(d.clone().add(7, 'd')); 212 } else { 213 this.date(d.clone().subtract(this.stepping(), 'm')); 214 } 215 return true; 216 }, 217 'control up': function controlUp() { 218 if (!this.widget) { 219 return false; 220 } 221 var d = this._dates[0] || this.getMoment(); 222 if (this.widget.find('.datepicker').is(':visible')) { 223 this.date(d.clone().subtract(1, 'y')); 224 } else { 225 this.date(d.clone().add(1, 'h')); 226 } 227 return true; 228 }, 229 'control down': function controlDown() { 230 if (!this.widget) { 231 return false; 232 } 233 var d = this._dates[0] || this.getMoment(); 234 if (this.widget.find('.datepicker').is(':visible')) { 235 this.date(d.clone().add(1, 'y')); 236 } else { 237 this.date(d.clone().subtract(1, 'h')); 238 } 239 return true; 240 }, 241 left: function left() { 242 if (!this.widget) { 243 return false; 244 } 245 var d = this._dates[0] || this.getMoment(); 246 if (this.widget.find('.datepicker').is(':visible')) { 247 this.date(d.clone().subtract(1, 'd')); 248 } 249 return true; 250 }, 251 right: function right() { 252 if (!this.widget) { 253 return false; 254 } 255 var d = this._dates[0] || this.getMoment(); 256 if (this.widget.find('.datepicker').is(':visible')) { 257 this.date(d.clone().add(1, 'd')); 258 } 259 return true; 260 }, 261 pageUp: function pageUp() { 262 if (!this.widget) { 263 return false; 264 } 265 var d = this._dates[0] || this.getMoment(); 266 if (this.widget.find('.datepicker').is(':visible')) { 267 this.date(d.clone().subtract(1, 'M')); 268 } 269 return true; 270 }, 271 pageDown: function pageDown() { 272 if (!this.widget) { 273 return false; 274 } 275 var d = this._dates[0] || this.getMoment(); 276 if (this.widget.find('.datepicker').is(':visible')) { 277 this.date(d.clone().add(1, 'M')); 278 } 279 return true; 280 }, 281 enter: function enter() { 282 if (!this.widget) { 283 return false; 284 } 285 this.hide(); 286 return true; 287 }, 288 escape: function escape() { 289 if (!this.widget) { 290 return false; 291 } 292 this.hide(); 293 return true; 294 }, 295 'control space': function controlSpace() { 296 if (!this.widget) { 297 return false; 298 } 299 if (this.widget.find('.timepicker').is(':visible')) { 300 this.widget.find('.btn[data-action="togglePeriod"]').click(); 301 } 302 return true; 303 }, 304 t: function t() { 305 if (!this.widget) { 306 return false; 307 } 308 this.date(this.getMoment()); 309 return true; 310 }, 311 'delete': function _delete() { 312 if (!this.widget) { 313 return false; 314 } 315 this.clear(); 316 return true; 317 } 318 }, 319 debug: false, 320 allowInputToggle: false, 321 disabledTimeIntervals: false, 322 disabledHours: false, 323 enabledHours: false, 324 viewDate: false, 325 allowMultidate: false, 326 multidateSeparator: ',' 327 }; 328 329 // ReSharper restore InconsistentNaming 330 331 // ReSharper disable once DeclarationHides 332 // ReSharper disable once InconsistentNaming 333 334 var DateTimePicker = function () { 335 /** @namespace eData.dateOptions */ 336 /** @namespace moment.tz */ 337 338 function DateTimePicker(element, options) { 339 _classCallCheck(this, DateTimePicker); 340 341 this._options = this._getOptions(options); 342 this._element = element; 343 this._dates = []; 344 this._datesFormatted = []; 345 this._viewDate = null; 346 this.unset = true; 347 this.component = false; 348 this.widget = false; 349 this.use24Hours = null; 350 this.actualFormat = null; 351 this.parseFormats = null; 352 this.currentViewMode = null; 353 this.MinViewModeNumber = 0; 354 355 this._int(); 356 } 357 358 /** 359 * @return {string} 360 */ 361 362 363 //private 364 365 DateTimePicker.prototype._int = function _int() { 366 var targetInput = this._element.data('target-input'); 367 if (this._element.is('input')) { 368 this.input = this._element; 369 } else if (targetInput !== undefined) { 370 if (targetInput === 'nearest') { 371 this.input = this._element.find('input'); 372 } else { 373 this.input = $(targetInput); 374 } 375 } 376 377 this._dates = []; 378 this._dates[0] = this.getMoment(); 379 this._viewDate = this.getMoment().clone(); 380 381 $.extend(true, this._options, this._dataToOptions()); 382 383 this.options(this._options); 384 385 this._initFormatting(); 386 387 if (this.input !== undefined && this.input.is('input') && this.input.val().trim().length !== 0) { 388 this._setValue(this._parseInputDate(this.input.val().trim()), 0); 389 } else if (this._options.defaultDate && this.input !== undefined && this.input.attr('placeholder')
389=== undefined) { 390 this._setValue(this._options.defaultDate, 0); 391 } 392 if (this._options.inline) { 393 this.show(); 394 } 395 }; 396 397 DateTimePicker.prototype._update = function _update() { 398 if (!this.widget) { 399 return; 400 } 401 this._fillDate(); 402 this._fillTime(); 403 }; 404 405 DateTimePicker.prototype._setValue = function _setValue(targetMoment, index) { 406 var oldDate = this.unset ? null : this._dates[index]; 407 var outpValue = ''; 408 // case of calling setValue(null or false) 409 if (!targetMoment) { 410 if (!this._options.allowMultidate || this._dates.length === 1) { 411 this.unset = true; 412 this._dates = []; 413 this._datesFormatted = []; 414 } else { 415 outpValue = this._element.data('date') + ','; 416 outpValue = outpValue.replace(oldDate.format(this.actualFormat) + ',', '').replace(',,', '').replace(/,\s*$/, ''); 417 this._dates.splice(index, 1); 418 this._datesFormatted.splice(index, 1); 419 } 420 if (this.input !== undefined) { 421 this.input.val(outpValue); 422 this.input.trigger('input'); 423 } 424 this._element.data('date', outpValue); 425 this._notifyEvent({ 426 type: DateTimePicker.Event.CHANGE, 427 date: false, 428 oldDate: oldDate 429 }); 430 this._update(); 431 return; 432 } 433 434 targetMoment = targetMoment.clone().locale(this._options.locale); 435 436 if (this._hasTimeZone()) { 437 targetMoment.tz(this._options.timeZone); 438 } 439 440 if (this._options.stepping !== 1) { 441 targetMoment.minutes(Math.round(targetMoment.minutes() / this._options.stepping) * this._options.stepping).seconds(0); 442 } 443 444 if (this._isValid(targetMoment)) { 445 this._dates[index] = targetMoment; 446 this._datesFormatted[index] = targetMoment.format('YYYY-MM-DD'); 447 this._viewDate = targetMoment.clone(); 448 if (this._options.allowMultidate && this._dates.length > 1) { 449 for (var i = 0; i < this._dates.length; i++) { 450 outpValue += '' + this._dates[i].format(this.actualFormat) + this._options.multidateSeparator; 451 } 452 outpValue = outpValue.replace(/,\s*$/, ''); 453 } else { 454 outpValue = this._dates[index].format(this.actualFormat); 455 } 456 if (this.input !== undefined) { 457 this.input.val(outpValue); 458 this.input.trigger('input'); 459 } 460 this._element.data('date', outpValue); 461 462 this.unset = false; 463 this._update(); 464 this._notifyEvent({ 465 type: DateTimePicker.Event.CHANGE, 466 date: this._dates[index].clone(), 467 oldDate: oldDate 468 }); 469 } else { 470 if (!this._options.keepInvalid) { 471 if (this.input !== undefined) { 472 this.input.val('' + (this.unset ? '' : this._dates[index].format(this.actualFormat))); 473 this.input.trigger('input'); 474 } 475 } else { 476 this._notifyEvent({ 477 type: DateTimePicker.Event.CHANGE, 478 date: targetMoment, 479 oldDate: oldDate 480 }); 481 } 482 this._notifyEvent({ 483 type: DateTimePicker.Event.ERROR, 484 date: targetMoment, 485 oldDate: oldDate 486 }); 487 } 488 }; 489 490 DateTimePicker.prototype._change = function _change(e) { 491 var val = $(e.target).val().trim(),
vendor: 15,701 bytes, lines 492-857
492 parsedDate = val ? this._parseInputDate(val) : null; 493 this._setValue(parsedDate); 494 e.stopImmediatePropagation(); 495 return false; 496 }; 497 498 //noinspection JSMethodCanBeStatic 499 500 501 DateTimePicker.prototype._getOptions = function _getOptions(options) { 502 options = $.extend(true, {}, Default, options); 503 return options; 504 }; 505 506 DateTimePicker.prototype._hasTimeZone = function _hasTimeZone() { 507 return moment.tz !== undefined && this._options.timeZone !== undefined && this._options.timeZone !== null && this._options.timeZone !== ''; 508 }; 509 510 DateTimePicker.prototype._isEnabled = function _isEnabled(granularity) { 511 if (typeof granularity !== 'string' || granularity.length > 1) { 512 throw new TypeError('isEnabled expects a single character string parameter'); 513 } 514 switch (granularity) { 515 case 'y': 516 return this.actualFormat.indexOf('Y') !== -1; 517 case 'M': 518 return this.actualFormat.indexOf('M') !== -1; 519 case 'd': 520 return this.actualFormat.toLowerCase().indexOf('d') !== -1; 521 case 'h': 522 case 'H': 523 return this.actualFormat.toLowerCase().indexOf('h') !== -1; 524 case 'm': 525 return this.actualFormat.indexOf('m') !== -1; 526 case 's': 527 return this.actualFormat.indexOf('s') !== -1; 528 case 'a': 529 case 'A': 530 return this.actualFormat.toLowerCase().indexOf('a') !== -1; 531 default: 532 return false; 533 } 534 }; 535 536 DateTimePicker.prototype._hasTime = function _hasTime() { 537 return this._isEnabled('h') || this._isEnabled('m') || this._isEnabled('s'); 538 }; 539 540 DateTimePicker.prototype._hasDate = function _hasDate() { 541 return this._isEnabled('y') || this._isEnabled('M') || this._isEnabled('d'); 542 }; 543 544 DateTimePicker.prototype._dataToOptions = function _dataToOptions() { 545 var eData = this._element.data(); 546 var dataOptions = {}; 547 548 if (eData.dateOptions && eData.dateOptions instanceof Object) { 549 dataOptions = $.extend(true, dataOptions, eData.dateOptions); 550 } 551 552 $.each(this._options, function (key) { 553 var attributeName = 'date' + key.charAt(0).toUpperCase() + key.slice(1); //todo data api key 554 if (eData[attributeName] !== undefined) { 555 dataOptions[key] = eData[attributeName]; 556 } else { 557 delete dataOptions[key]; 558 } 559 }); 560 return dataOptions; 561 }; 562 563 DateTimePicker.prototype._notifyEvent = function _notifyEvent(e) { 564 if (e.type === DateTimePicker.Event.CHANGE && e.date && e.date.isSame(e.oldDate) || !e.date && !e.oldDate) { 565 return; 566 } 567 this._element.trigger(e); 568 }; 569 570 DateTimePicker.prototype._viewUpdate = function _viewUpdate(e) { 571 if (e === 'y') { 572 e = 'YYYY'; 573 } 574 this._notifyEvent({ 575 type: DateTimePicker.Event.UPDATE, 576 change: e, 577 viewDate: this._viewDate.clone() 578 }); 579 }; 580 581 DateTimePicker.prototype._showMode = function _showMode(dir) { 582 if (!this.widget) { 583 return; 584 } 585 if (dir) { 586 this.currentViewMode = Math.max(this.MinViewModeNumber, Math.min(3, this.currentViewMode + dir)); 587 } 588 this.widget.find('.datepicker > div').hide().filter('.datepicker-' + DatePickerModes[this.currentViewMode].CLASS_NAME).show(); 589 }; 590 591 DateTimePicker.prototype._isInDisabledDates = function _isInDisabledDates(testDate) { 592 return this._options.disabledDates[testDate.format('YYYY-MM-DD')] === true; 593 }; 594 595 DateTimePicker.prototype._isInEnabledDates = function _isInEnabledDates(testDate) { 596 return this._options.enabledDates[testDate.format('YYYY-MM-DD')] === true; 597 }; 598 599 DateTimePicker.prototype._isInDisabledHours = function _isInDisabledHours(testDate) { 600 return this._options.disabledHours[testDate.format('H')] === true; 601 }; 602 603 DateTimePicker.prototype._isInEnabledHours = function _isInEnabledHours(testDate) { 604 return this._options.enabledHours[testDate.format('H')] === true; 605 }; 606 607 DateTimePicker.prototype._isValid = function _isValid(targetMoment, granularity) { 608 if (!targetMoment.isValid()) { 609 return false; 610 } 611 if (this._options.disabledDates && granularity === 'd' && this._isInDisabledDates(targetMoment)) { 612 return false; 613 } 614 if (this._options.enabledDates && granularity === 'd' && !this._isInEnabledDates(targetMoment)) { 615 return false; 616 } 617 if (this._options.minDate && targetMoment.isBefore(this._options.minDate, granularity)) { 618 return false; 619 } 620 if (this._options.maxDate && targetMoment.isAfter(this._options.maxDate, granularity)) { 621 return false; 622 } 623 if (this._options.daysOfWeekDisabled && granularity === 'd' && this._options.daysOfWeekDisabled.indexOf(targetMoment.day()) !== -1) { 624 return false; 625 } 626 if (this._options.disabledHours && (granularity === 'h' || granularity === 'm' || granularity === 's') && this._isInDisabledHours(targetMoment)) { 627 return false; 628 } 629 if (this._options.enabledHours && (granularity === 'h' || granularity === 'm' || granularity === 's') && !this._isInEnabledHours(targetMoment)) { 630 return false; 631 } 632 if (this._options.disabledTimeIntervals && (granularity === 'h' || granularity === 'm' || granularity === 's')) { 633 var found = false; 634 $.each(this._options.disabledTimeIntervals, function () { 635 if (targetMoment.isBetween(this[0], this[1])) { 636 found = true; 637 return false; 638 } 639 }); 640 if (found) { 641 return false; 642 } 643 } 644 return true; 645 }; 646 647 DateTimePicker.prototype._parseInputDate = function _parseInputDate(inputDate) { 648 if (this._options.parseInputDate === undefined) { 649 if (!moment.isMoment(inputDate)) { 650 inputDate = this.getMoment(inputDate); 651 } 652 } else { 653 inputDate = this._options.parseInputDate(inputDate); 654 } 655 //inputDate.locale(this.options.locale); 656 return inputDate; 657 }; 658 659 DateTimePicker.prototype._keydown = function _keydown(e) { 660 var handler = null, 661 index = void 0, 662 index2 = void 0, 663 keyBindKeys = void 0, 664 allModifiersPressed = void 0; 665 var pressedKeys = [], 666 pressedModifiers = {}, 667 currentKey = e.which, 668 pressed = 'p'; 669 670 keyState[currentKey] = pressed; 671 672 for (index in keyState) { 673 if (keyState.hasOwnProperty(index) && keyState[index] === pressed) { 674 pressedKeys.push(index); 675 if (parseInt(index, 10) !== currentKey) { 676 pressedModifiers[index] = true; 677 } 678 } 679 } 680 681 for (index in this._options.keyBinds) { 682 if (this._options.keyBinds.hasOwnProperty(index) && typeof this._options.keyBinds[index] === 'function') { 683 keyBindKeys = index.split(' '); 684 if (keyBindKeys.length === pressedKeys.length && KeyMap[currentKey] === keyBindKeys[keyBindKeys.length - 1]) { 685 allModifiersPressed = true; 686 for (index2 = keyBindKeys.length - 2; index2 >= 0; index2--) { 687 if (!(KeyMap[keyBindKeys[index2]] in pressedModifiers)) { 688 allModifiersPressed = false; 689 break; 690 } 691 } 692 if (allModifiersPressed) { 693 handler = this._options.keyBinds[index]; 694 break; 695 } 696 } 697 } 698 } 699 700 if (handler) { 701 if (handler.call(this)) { 702 e.stopPropagation(); 703 e.preventDefault(); 704 } 705 } 706 }; 707 708 //noinspection JSMethodCanBeStatic,SpellCheckingInspection 709 710 711 DateTimePicker.prototype._keyup = function _keyup(e) { 712 keyState[e.which] = 'r'; 713 if (keyPressHandled[e.which]) { 714 keyPressHandled[e.which] = false; 715 e.stopPropagation(); 716 e.preventDefault(); 717 } 718 }; 719 720 DateTimePicker.prototype._indexGivenDates = function _indexGivenDates(givenDatesArray) { 721 // Store given enabledDates and disabledDates as keys. 722 // This way we can check their existence in O(1) time instead of looping through whole array. 723 // (for example: options.enabledDates['2014-02-27'] === true) 724 var givenDatesIndexed = {}, 725 self = this; 726 $.each(givenDatesArray, function () { 727 var dDate = self._parseInputDate(this); 728 if (dDate.isValid()) { 729 givenDatesIndexed[dDate.format('YYYY-MM-DD')] = true; 730 } 731 }); 732 return Object.keys(givenDatesIndexed).length ? givenDatesIndexed : false; 733 }; 734 735 DateTimePicker.prototype._indexGivenHours = function _indexGivenHours(givenHoursArray) { 736 // Store given enabledHours and disabledHours as keys. 737 // This way we can check their existence in O(1) time instead of looping through whole array. 738 // (for example: options.enabledHours['2014-02-27'] === true) 739 var givenHoursIndexed = {}; 740 $.each(givenHoursArray, function () { 741 givenHoursIndexed[this] = true; 742 }); 743 return Object.keys(givenHoursIndexed).length ? givenHoursIndexed : false; 744 }; 745 746 DateTimePicker.prototype._initFormatting = function _initFormatting() { 747 var format = this._options.format || 'L LT', 748 self = this; 749 750 this.actualFormat = format.replace(/(\[[^\[]*])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g, function (formatInput) { 751 return self._dates[0].localeData().longDateFormat(formatInput) || formatInput; //todo taking the first date should be ok 752 }); 753 754 this.parseFormats = this._options.extraFormats ? this._options.extraFormats.slice() : []; 755 if (this.parseFormats.indexOf(format) < 0 && this.parseFormats.indexOf(this.actualFormat) < 0) { 756 this.parseFormats.push(this.actualFormat); 757 } 758 759 this.use24Hours = this.actualFormat.toLowerCase().indexOf('a') < 1 && this.actualFormat.replace(/\[.*?]/g, '').indexOf('h') < 1; 760 761 if (this._isEnabled('y')) { 762 this.MinViewModeNumber = 2; 763 } 764 if (this._isEnabled('M')) { 765 this.MinViewModeNumber = 1; 766 } 767 if (this._isEnabled('d')) { 768 this.MinViewModeNumber = 0; 769 } 770 771 this.currentViewMode = Math.max(this.MinViewModeNumber, this.currentViewMode); 772 773 if (!this.unset) { 774 this._setValue(this._dates[0], 0); 775 } 776 }; 777 778 DateTimePicker.prototype._getLastPickedDate = function _getLastPickedDate() { 779 return this._dates[this._getLastPickedDateIndex()]; 780 }; 781 782 DateTimePicker.prototype._getLastPickedDateIndex = function _getLastPickedDateIndex() { 783 return this._dates.length - 1; 784 }; 785 786 //public 787 788 789 DateTimePicker.prototype.getMoment = function getMoment(d) { 790 var returnMoment = void 0; 791 792 if (d === undefined || d === null) { 793 returnMoment = moment(); //TODO should this use format? and locale? 794 } else if (this._hasTimeZone()) { 795 // There is a string to parse and a default time zone 796 // parse with the tz function which takes a default time zone if it is not in the format string 797 returnMoment = moment.tz(d, this.parseFormats, this._options.locale, this._options.useStrict, this._options.timeZone); 798 } else { 799 returnMoment = moment(d, this.parseFormats, this._options.locale, this._options.useStrict); 800 } 801 802 if (this._hasTimeZone()) { 803 returnMoment.tz(this._options.timeZone); 804 } 805 806 return returnMoment; 807 }; 808 809 DateTimePicker.prototype.toggle = function toggle() { 810 return this.widget ? this.hide() : this.show(); 811 }; 812 813 DateTimePicker.prototype.ignoreReadonly = function ignoreReadonly(_ignoreReadonly) { 814 if (arguments.length === 0) { 815 return this._options.ignoreReadonly; 816 } 817 if (typeof _ignoreReadonly !== 'boolean') { 818 throw new TypeError('ignoreReadonly () expects a boolean parameter'); 819 } 820 this._options.ignoreReadonly = _ignoreReadonly; 821 }; 822 823 DateTimePicker.prototype.options = function options(newOptions) { 824 if (arguments.length === 0) { 825 return $.extend(true, {}, this._options); 826 } 827 828 if (!(newOptions instanceof Object)) { 829 throw new TypeError('options() this.options parameter should be an object'); 830 } 831 $.extend(true, this._options, newOptions); 832 var self = this; 833 $.each(this._options, function (key, value) { 834 if (self[key] !== undefined) { 835 self[key](value); 836 } 837 }); 838 }; 839 840 DateTimePicker.prototype.date = function date(newDate, index) { 841 index = index || 0; 842 if (arguments.length === 0) { 843 if (this.unset) { 844 return null; 845 } 846 if (this._options.allowMultidate) { 847 return this._dates.join(this._options.multidateSeparator); 848 } else { 849 return this._dates[index].clone(); 850 } 851 } 852 853 if (newDate !== null && typeof newDate !== 'string' && !moment.isMoment(newDate) && !(newDate instanceof Date)) { 854 throw new TypeError('date() parameter must be one of [null, string, moment or Date]'); 855 } 856 857 this._setValue(newDate === null ? null : this._parseInputDate(newDate), index)
vendor: 24,413 bytes, lines 857-1480
857; 858 }; 859 860 DateTimePicker.prototype.format = function format(newFormat) { 861 if (arguments.length === 0) { 862 return this._options.format; 863 } 864 865 if (typeof newFormat !== 'string' && (typeof newFormat !== 'boolean' || newFormat !== false)) { 866 throw new TypeError('format() expects a string or boolean:false parameter ' + newFormat); 867 } 868 869 this._options.format = newFormat; 870 if (this.actualFormat) { 871 this._initFormatting(); // reinitialize formatting 872 } 873 }; 874 875 DateTimePicker.prototype.timeZone = function timeZone(newZone) { 876 if (arguments.length === 0) { 877 return this._options.timeZone; 878 } 879 880 if (typeof newZone !== 'string') { 881 throw new TypeError('newZone() expects a string parameter'); 882 } 883 884 this._options.timeZone = newZone; 885 }; 886 887 DateTimePicker.prototype.dayViewHeaderFormat = function dayViewHeaderFormat(newFormat) { 888 if (arguments.length === 0) { 889 return this._options.dayViewHeaderFormat; 890 } 891 892 if (typeof newFormat !== 'string') { 893 throw new TypeError('dayViewHeaderFormat() expects a string parameter'); 894 } 895 896 this._options.dayViewHeaderFormat = newFormat; 897 }; 898 899 DateTimePicker.prototype.extraFormats = function extraFormats(formats) { 900 if (arguments.length === 0) { 901 return this._options.extraFormats; 902 } 903 904 if (formats !== false && !(formats instanceof Array)) { 905 throw new TypeError('extraFormats() expects an array or false parameter'); 906 } 907 908 this._options.extraFormats = formats; 909 if (this.parseFormats) { 910 this._initFormatting(); // reinit formatting 911 } 912 }; 913 914 DateTimePicker.prototype.disabledDates = function disabledDates(dates) { 915 if (arguments.length === 0) { 916 return this._options.disabledDates ? $.extend({}, this._options.disabledDates) : this._options.disabledDates; 917 } 918 919 if (!dates) { 920 this._options.disabledDates = false; 921 this._update(); 922 return true; 923 } 924 if (!(dates instanceof Array)) { 925 throw new TypeError('disabledDates() expects an array parameter'); 926 } 927 this._options.disabledDates = this._indexGivenDates(dates); 928 this._options.enabledDates = false; 929 this._update(); 930 }; 931 932 DateTimePicker.prototype.enabledDates = function enabledDates(dates) { 933 if (arguments.length === 0) { 934 return this._options.enabledDates ? $.extend({}, this._options.enabledDates) : this._options.enabledDates; 935 } 936 937 if (!dates) { 938 this._options.enabledDates = false; 939 this._update(); 940 return true; 941 } 942 if (!(dates instanceof Array)) { 943 throw new TypeError('enabledDates() expects an array parameter'); 944 } 945 this._options.enabledDates = this._indexGivenDates(dates); 946 this._options.disabledDates = false; 947 this._update(); 948 }; 949 950 DateTimePicker.prototype.daysOfWeekDisabled = function daysOfWeekDisabled(_daysOfWeekDisabled) { 951 if (arguments.length === 0) { 952 return this._options.daysOfWeekDisabled.splice(0); 953 } 954 955 if (typeof _daysOfWeekDisabled === 'boolean' && !_daysOfWeekDisabled) { 956 this._options.daysOfWeekDisabled = false; 957 this._update(); 958 return true; 959 } 960 961 if (!(_daysOfWeekDisabled instanceof Array)) { 962 throw new TypeError('daysOfWeekDisabled() expects an array parameter'); 963 } 964 this._options.daysOfWeekDisabled = _daysOfWeekDisabled.reduce(function (previousValue, currentValue) { 965 currentValue = parseInt(currentValue, 10); 966 if (currentValue > 6 || currentValue < 0 || isNaN(currentValue)) { 967 return previousValue; 968 } 969 if (previousValue.indexOf(currentValue) === -1) { 970 previousValue.push(currentValue); 971 } 972 return previousValue; 973 }, []).sort(); 974 if (this._options.useCurrent && !this._options.keepInvalid) { 975 for (var i = 0; i < this._dates.length; i++) { 976 var tries = 0; 977 while (!this._isValid(this._dates[i], 'd')) { 978 this._dates[i].add(1, 'd'); 979 if (tries === 31) { 980 throw 'Tried 31 times to find a valid date'; 981 } 982 tries++; 983 } 984 this._setValue(this._dates[i], i); 985 } 986 } 987 this._update(); 988 }; 989 990 DateTimePicker.prototype.maxDate = function maxDate(_maxDate) { 991 if (arguments.length === 0) { 992 return this._options.maxDate ? this._options.maxDate.clone() : this._options.maxDate; 993 } 994 995 if (typeof _maxDate === 'boolean' && _maxDate === false) { 996 this._options.maxDate = false; 997 this._update(); 998 return true; 999 } 1000 1001 if (typeof _maxDate === 'string') { 1002 if (_maxDate === 'now' || _maxDate === 'moment') { 1003 _maxDate = this.getMoment(); 1004 } 1005 } 1006 1007 var parsedDate = this._parseInputDate(_maxDate); 1008 1009 if (!parsedDate.isValid()) { 1010 throw new TypeError('maxDate() Could not parse date parameter: ' + _maxDate); 1011 } 1012 if (this._options.minDate && parsedDate.isBefore(this._options.minDate)) { 1013 throw new TypeError('maxDate() date parameter is before this.options.minDate: ' + parsedDate.format(this.actualFormat)); 1014 } 1015 this._options.maxDate = parsedDate; 1016 for (var i = 0; i < this._dates.length; i++) { 1017 if (this._options.useCurrent && !this._options.keepInvalid && this._dates[i].isAfter(_maxDate)) { 1018 this._setValue(this._options.maxDate, i); 1019 } 1020 } 1021 if (this._viewDate.isAfter(parsedDate)) { 1022 this._viewDate = parsedDate.clone().subtract(this._options.stepping, 'm'); 1023 } 1024 this._update(); 1025 }; 1026 1027 DateTimePicker.prototype.minDate = function minDate(_minDate) { 1028 if (arguments.length === 0) { 1029 return this._options.minDate ? this._options.minDate.clone() : this._options.minDate; 1030 } 1031 1032 if (typeof _minDate === 'boolean' && _minDate === false) { 1033 this._options.minDate = false; 1034 this._update(); 1035 return true; 1036 } 1037 1038 if (typeof _minDate === 'string') { 1039 if (_minDate === 'now' || _minDate === 'moment') { 1040 _minDate = this.getMoment(); 1041 } 1042 } 1043 1044 var parsedDate = this._parseInputDate(_minDate); 1045 1046 if (!parsedDate.isValid()) { 1047 throw new TypeError('minDate() Could not parse date parameter: ' + _minDate); 1048 } 1049 if (this._options.maxDate && parsedDate.isAfter(this._options.maxDate)) { 1050 throw new TypeError('minDate() date parameter is after this.options.maxDate: ' + parsedDate.format(this.actualFormat)); 1051 } 1052 this._options.minDate = parsedDate; 1053 for (var i = 0; i < this._dates.length; i++) { 1054 if (this._options.useCurrent && !this._options.keepInvalid && this._dates[i].isBefore(_minDate)) { 1055 this._setValue(this._options.minDate, i); 1056 } 1057 } 1058 if (this._viewDate.isBefore(parsedDate)) { 1059 this._viewDate = parsedDate.clone().add(this._options.stepping, 'm'); 1060 } 1061 this._update(); 1062 }; 1063 1064 DateTimePicker.prototype.defaultDate = function defaultDate(_defaultDate) { 1065 if (arguments.length === 0) { 1066 return this._options.defaultDate ? this._options.defaultDate.clone() : this._options.defaultDate; 1067 } 1068 if (!_defaultDate) { 1069 this._options.defaultDate = false; 1070 return true; 1071 } 1072 1073 if (typeof _defaultDate === 'string') { 1074 if (_defaultDate === 'now' || _defaultDate === 'moment') { 1075 _defaultDate = this.getMoment(); 1076 } else { 1077 _defaultDate = this.getMoment(_defaultDate); 1078 } 1079 } 1080 1081 var parsedDate = this._parseInputDate(_defaultDate); 1082 if (!parsedDate.isValid()) { 1083 throw new TypeError('defaultDate() Could not parse date parameter: ' + _defaultDate); 1084 } 1085 if (!this._isValid(parsedDate)) { 1086 throw new TypeError('defaultDate() date passed is invalid according to component setup validations'); 1087 } 1088 1089 this._options.defaultDate = parsedDate; 1090 1091 if (this._options.defaultDate && this._options.inline || this.input !== undefined && this.input.val().trim() === '') { 1092 this._setValue(this._options.defaultDate, 0); 1093 } 1094 }; 1095 1096 DateTimePicker.prototype.locale = function locale(_locale) { 1097 if (arguments.length === 0) { 1098 return this._options.locale; 1099 } 1100 1101 if (!moment.localeData(_locale)) { 1102 throw new TypeError('locale() locale ' + _locale + ' is not loaded from moment locales!'); 1103 } 1104 1105 this._options.locale = _locale; 1106 1107 for (var i = 0; i < this._dates.length; i++) { 1108 this._dates[i].locale(this._options.locale); 1109 } 1110 this._viewDate.locale(this._options.locale); 1111 1112 if (this.actualFormat) { 1113 this._initFormatting(); // reinitialize formatting 1114 } 1115 if (this.widget) { 1116 this.hide(); 1117 this.show(); 1118 } 1119 }; 1120 1121 DateTimePicker.prototype.stepping = function stepping(_stepping) { 1122 if (arguments.length === 0) { 1123 return this._options.stepping; 1124 } 1125 1126 _stepping = parseInt(_stepping, 10); 1127 if (isNaN(_stepping) || _stepping < 1) { 1128 _stepping = 1; 1129 } 1130 this._options.stepping = _stepping; 1131 }; 1132 1133 DateTimePicker.prototype.useCurrent = function useCurrent(_useCurrent) { 1134 var useCurrentOptions = ['year', 'month', 'day', 'hour', 'minute']; 1135 if (arguments.length === 0) { 1136 return this._options.useCurrent; 1137 } 1138 1139 if (typeof _useCurrent !== 'boolean' && typeof _useCurrent !== 'string') { 1140 throw new TypeError('useCurrent() expects a boolean or string parameter'); 1141 } 1142 if (typeof _useCurrent === 'string' && useCurrentOptions.indexOf(_useCurrent.toLowerCase()) === -1) { 1143 throw new TypeError('useCurrent() expects a string parameter of ' + useCurrentOptions.join(', ')); 1144 } 1145 this._options.useCurrent = _useCurrent; 1146 }; 1147 1148 DateTimePicker.prototype.collapse = function collapse(_collapse) { 1149 if (arguments.length === 0) { 1150 return this._options.collapse; 1151 } 1152 1153 if (typeof _collapse !== 'boolean') { 1154 throw new TypeError('collapse() expects a boolean parameter'); 1155 } 1156 if (this._options.collapse === _collapse) { 1157 return true; 1158 } 1159 this._options.collapse = _collapse; 1160 if (this.widget) { 1161 this.hide(); 1162 this.show(); 1163 } 1164 }; 1165 1166 DateTimePicker.prototype.icons = function icons(_icons) { 1167 if (arguments.length === 0) { 1168 return $.extend({}, this._options.icons); 1169 } 1170 1171 if (!(_icons instanceof Object)) { 1172 throw new TypeError('icons() expects parameter to be an Object'); 1173 } 1174 1175 $.extend(this._options.icons, _icons); 1176 1177 if (this.widget) { 1178 this.hide(); 1179 this.show(); 1180 } 1181 }; 1182 1183 DateTimePicker.prototype.tooltips = function tooltips(_tooltips) { 1184 if (arguments.length === 0) { 1185 return $.extend({}, this._options.tooltips); 1186 } 1187 1188 if (!(_tooltips instanceof Object)) { 1189 throw new TypeError('tooltips() expects parameter to be an Object'); 1190 } 1191 $.extend(this._options.tooltips, _tooltips); 1192 if (this.widget) { 1193 this.hide(); 1194 this.show(); 1195 } 1196 }; 1197 1198 DateTimePicker.prototype.useStrict = function useStrict(_useStrict) { 1199 if (arguments.length === 0) { 1200 return this._options.useStrict; 1201 } 1202 1203 if (typeof _useStrict !== 'boolean') { 1204 throw new TypeError('useStrict() expects a boolean parameter'); 1205 } 1206 this._options.useStrict = _useStrict; 1207 }; 1208 1209 DateTimePicker.prototype.sideBySide = function sideBySide(_sideBySide) { 1210 if (arguments.length === 0) { 1211 return this._options.sideBySide; 1212 } 1213 1214 if (typeof _sideBySide !== 'boolean') { 1215 throw new TypeError('sideBySide() expects a boolean parameter'); 1216 } 1217 this._options.sideBySide = _sideBySide; 1218 if (this.widget) { 1219 this.hide(); 1220 this.show(); 1221 } 1222 }; 1223 1224 DateTimePicker.prototype.viewMode = function viewMode(_viewMode) { 1225 if (arguments.length === 0) { 1226 return this._options.viewMode; 1227 } 1228 1229 if (typeof _viewMode !== 'string') { 1230 throw new TypeError('viewMode() expects a string parameter'); 1231 } 1232 1233 if (DateTimePicker.ViewModes.indexOf(_viewMode) === -1) { 1234 throw new TypeError('viewMode() parameter must be one of (' + DateTimePicker.ViewModes.join(', ') + ') value'); 1235 } 1236 1237 this._options.viewMode = _viewMode; 1238 this.currentViewMode = Math.max(DateTimePicker.ViewModes.indexOf(_viewMode) - 1, this.MinViewModeNumber); 1239 1240 this._showMode(); 1241 }; 1242 1243 DateTimePicker.prototype.calendarWeeks = function calendarWeeks(_calendarWeeks) { 1244 if (arguments.length === 0) { 1245 return this._options.calendarWeeks; 1246 } 1247 1248 if (typeof _calendarWeeks !== 'boolean') { 1249 throw new TypeError('calendarWeeks() expects parameter to be a boolean value'); 1250 } 1251 1252 this._options.calendarWeeks = _calendarWeeks; 1253 this._update(); 1254 }; 1255 1256 DateTimePicker.prototype.buttons = function buttons(_buttons) { 1257 if (arguments.length === 0) { 1258 return $.extend({}, this._options.buttons); 1259 } 1260 1261 if (!(_buttons instanceof Object)) { 1262 throw new TypeError('buttons() expects parameter to be an Object'); 1263 } 1264 1265 $.extend(this._options.buttons, _buttons); 1266 1267 if (typeof this._options.buttons.showToday !== 'boolean') { 1268 throw new TypeError('buttons.showToday expects a boolean parameter'); 1269 } 1270 if (typeof this._options.buttons.showClear !== 'boolean') { 1271 throw new TypeError('buttons.showClear expects a boolean parameter'); 1272 } 1273 if (typeof this._options.buttons.showClose !== 'boolean') { 1274 throw new TypeError('buttons.showClose expects a boolean parameter'); 1275 } 1276 1277 if (this.widget) { 1278 this.hide(); 1279 this.show(); 1280 } 1281 }; 1282 1283 DateTimePicker.prototype.keepOpen = function keepOpen(_keepOpen) { 1284 if (arguments.length === 0) { 1285 return this._options.keepOpen; 1286 } 1287 1288 if (typeof _keepOpen !== 'boolean') { 1289 throw new TypeError('keepOpen() expects a boolean parameter'); 1290 } 1291 1292 this._options.keepOpen = _keepOpen; 1293 }; 1294 1295 DateTimePicker.prototype.focusOnShow = function focusOnShow(_focusOnShow) { 1296 if (arguments.length === 0) { 1297 return this._options.focusOnShow; 1298 } 1299 1300 if (typeof _focusOnShow !== 'boolean') { 1301 throw new TypeError('focusOnShow() expects a boolean parameter'); 1302 } 1303 1304 this._options.focusOnShow = _focusOnShow; 1305 }; 1306 1307 DateTimePicker.prototype.inline = function inline(_inline) { 1308 if (arguments.length === 0) { 1309 return this._options.inline; 1310 } 1311 1312 if (typeof _inline !== 'boolean') { 1313 throw new TypeError('inline() expects a boolean parameter'); 1314 } 1315 1316 this._options.inline = _inline; 1317 }; 1318 1319 DateTimePicker.prototype.clear = function clear() { 1320 this._setValue(null); //todo 1321 }; 1322 1323 DateTimePicker.prototype.keyBinds = function keyBinds(_keyBinds) { 1324 if (arguments.length === 0) { 1325 return this._options.keyBinds; 1326 } 1327 1328 this._options.keyBinds = _keyBinds; 1329 }; 1330 1331 DateTimePicker.prototype.debug = function debug(_debug) { 1332 if (typeof _debug !== 'boolean') { 1333 throw new TypeError('debug() expects a boolean parameter'); 1334 } 1335 1336 this._options.debug = _debug; 1337 }; 1338 1339 DateTimePicker.prototype.allowInputToggle = function allowInputToggle(_allowInputToggle) { 1340 if (arguments.length === 0) { 1341 return this._options.allowInputToggle; 1342 } 1343 1344 if (typeof _allowInputToggle !== 'boolean') { 1345 throw new TypeError('allowInputToggle() expects a boolean parameter'); 1346 } 1347 1348 this._options.allowInputToggle = _allowInputToggle; 1349 }; 1350 1351 DateTimePicker.prototype.keepInvalid = function keepInvalid(_keepInvalid) { 1352 if (arguments.length === 0) { 1353 return this._options.keepInvalid; 1354 } 1355 1356 if (typeof _keepInvalid !== 'boolean') { 1357 throw new TypeError('keepInvalid() expects a boolean parameter'); 1358 } 1359 this._options.keepInvalid = _keepInvalid; 1360 }; 1361 1362 DateTimePicker.prototype.datepickerInput = function datepickerInput(_datepickerInput) { 1363 if (arguments.length === 0) { 1364 return this._options.datepickerInput; 1365 } 1366 1367 if (typeof _datepickerInput !== 'string') { 1368 throw new TypeError('datepickerInput() expects a string parameter'); 1369 } 1370 1371 this._options.datepickerInput = _datepickerInput; 1372 }; 1373 1374 DateTimePicker.prototype.parseInputDate = function parseInputDate(_parseInputDate2) { 1375 if (arguments.length === 0) { 1376 return this._options.parseInputDate; 1377 } 1378 1379 if (typeof _parseInputDate2 !== 'function') { 1380 throw new TypeError('parseInputDate() should be as function'); 1381 } 1382 1383 this._options.parseInputDate = _parseInputDate2; 1384 }; 1385 1386 DateTimePicker.prototype.disabledTimeIntervals = function disabledTimeIntervals(_disabledTimeIntervals) { 1387 if (arguments.length === 0) { 1388 return this._options.disabledTimeIntervals ? $.extend({}, this._options.disabledTimeIntervals) : this._options.disabledTimeIntervals; 1389 } 1390 1391 if (!_disabledTimeIntervals) { 1392 this._options.disabledTimeIntervals = false; 1393 this._update(); 1394 return true; 1395 } 1396 if (!(_disabledTimeIntervals instanceof Array)) { 1397 throw new TypeError('disabledTimeIntervals() expects an array parameter'); 1398 } 1399 this._options.disabledTimeIntervals = _disabledTimeIntervals; 1400 this._update(); 1401 }; 1402 1403 DateTimePicker.prototype.disabledHours = function disabledHours(hours) { 1404 if (arguments.length === 0) { 1405 return this._options.disabledHours ? $.extend({}, this._options.disabledHours) : this._options.disabledHours; 1406 } 1407 1408 if (!hours) { 1409 this._options.disabledHours = false; 1410 this._update(); 1411 return true; 1412 } 1413 if (!(hours instanceof Array)) { 1414 throw new TypeError('disabledHours() expects an array parameter'); 1415 } 1416 this._options.disabledHours = this._indexGivenHours(hours); 1417 this._options.enabledHours = false; 1418 if (this._options.useCurrent && !this._options.keepInvalid) { 1419 for (var i = 0; i < this._dates.length; i++) { 1420 var tries = 0; 1421 while (!this._isValid(this._dates[i], 'h')) { 1422 this._dates[i].add(1, 'h'); 1423 if (tries === 24) { 1424 throw 'Tried 24 times to find a valid date'; 1425 } 1426 tries++; 1427 } 1428 this._setValue(this._dates[i], i); 1429 } 1430 } 1431 this._update(); 1432 }; 1433 1434 DateTimePicker.prototype.enabledHours = function enabledHours(hours) { 1435 if (arguments.length === 0) { 1436 return this._options.enabledHours ? $.extend({}, this._options.enabledHours) : this._options.enabledHours; 1437 } 1438 1439 if (!hours) { 1440 this._options.enabledHours = false; 1441 this._update(); 1442 return true; 1443 } 1444 if (!(hours instanceof Array)) { 1445 throw new TypeError('enabledHours() expects an array parameter'); 1446 } 1447 this._options.enabledHours = this._indexGivenHours(hours); 1448 this._options.disabledHours = false; 1449 if (this._options.useCurrent && !this._options.keepInvalid) { 1450 for (var i = 0; i < this._dates.length; i++) { 1451 var tries = 0; 1452 while (!this._isValid(this._dates[i], 'h')) { 1453 this._dates[i].add(1, 'h'); 1454 if (tries === 24) { 1455 throw 'Tried 24 times to find a valid date'; 1456 } 1457 tries++; 1458 } 1459 this._setValue(this._dates[i], i); 1460 } 1461 } 1462 this._update(); 1463 }; 1464 1465 DateTimePicker.prototype.viewDate = function viewDate(newDate) { 1466 if (arguments.length === 0) { 1467 return this._viewDate.clone(); 1468 } 1469 1470 if (!newDate) { 1471 this._viewDate = (this._dates[0] || this.getMoment()).clone(); 1472 return true; 1473 } 1474 1475 if (typeof newDate !== 'string' && !moment.isMoment(newDate) && !(newDate instanceof Date)) { 1476 throw new TypeError('viewDate() parameter must be one of [string, moment or Date]'); 1477 } 1478 1479 this._viewDate = this._parseInputDate(newDate); 1480 this._
vendor: 60,054 bytes, lines 1480-2767
1480viewUpdate(); 1481 }; 1482 1483 DateTimePicker.prototype.allowMultidate = function allowMultidate(_allowMultidate) { 1484 if (typeof _allowMultidate !== 'boolean') { 1485 throw new TypeError('allowMultidate() expects a boolean parameter'); 1486 } 1487 1488 this._options.allowMultidate = _allowMultidate; 1489 }; 1490 1491 DateTimePicker.prototype.multidateSeparator = function multidateSeparator(_multidateSeparator) { 1492 if (arguments.length === 0) { 1493 return this._options.multidateSeparator; 1494 } 1495 1496 if (typeof _multidateSeparator !== 'string' || _multidateSeparator.length > 1) { 1497 throw new TypeError('multidateSeparator expects a single character string parameter'); 1498 } 1499 1500 this._options.multidateSeparator = _multidateSeparator; 1501 }; 1502 1503 _createClass(DateTimePicker, null, [{ 1504 key: 'NAME', 1505 get: function get() { 1506 return NAME; 1507 } 1508 1509 /** 1510 * @return {string} 1511 */ 1512 1513 }, { 1514 key: 'DATA_KEY', 1515 get: function get() { 1516 return DATA_KEY; 1517 } 1518 1519 /** 1520 * @return {string} 1521 */ 1522 1523 }, { 1524 key: 'EVENT_KEY', 1525 get: function get() { 1526 return EVENT_KEY; 1527 } 1528 1529 /** 1530 * @return {string} 1531 */ 1532 1533 }, { 1534 key: 'DATA_API_KEY', 1535 get: function get() { 1536 return DATA_API_KEY; 1537 } 1538 }, { 1539 key: 'DatePickerModes', 1540 get: function get() { 1541 return DatePickerModes; 1542 } 1543 }, { 1544 key: 'ViewModes', 1545 get: function get() { 1546 return ViewModes; 1547 } 1548 }, { 1549 key: 'Event', 1550 get: function get() { 1551 return Event; 1552 } 1553 }, { 1554 key: 'Selector', 1555 get: function get() { 1556 return Selector; 1557 } 1558 }, { 1559 key: 'Default', 1560 get: function get() { 1561 return Default; 1562 }, 1563 set: function set(value) { 1564 Default = value; 1565 } 1566 }, { 1567 key: 'ClassName', 1568 get: function get() { 1569 return ClassName; 1570 } 1571 }]); 1572 1573 return DateTimePicker; 1574 }(); 1575 1576 return DateTimePicker; 1577}(jQuery, moment); 1578 1579//noinspection JSUnusedGlobalSymbols 1580/* global DateTimePicker */ 1581var TempusDominusBootstrap4 = function ($) { 1582 // eslint-disable-line no-unused-vars 1583 // ReSharper disable once InconsistentNaming 1584 var JQUERY_NO_CONFLICT = $.fn[DateTimePicker.NAME], 1585 verticalModes = ['top', 'bottom', 'auto'], 1586 horizontalModes = ['left', 'right', 'auto'], 1587 toolbarPlacements = ['default', 'top', 'bottom'], 1588 getSelectorFromElement = function getSelectorFromElement($element) { 1589 var selector = $element.data('target'), 1590 $selector = void 0; 1591 1592 if (!selector) { 1593 selector = $element.attr('href') || ''; 1594 selector = /^#[a-z]/i.test(selector) ? selector : null; 1595 } 1596 $selector = $(selector); 1597 if ($selector.length === 0) { 1598 return $selector; 1599 } 1600 1601 if (!$selector.data(DateTimePicker.DATA_KEY)) { 1602 $.extend({}, $selector.data(), $(this).data()); 1603 } 1604 1605 return $selector; 1606 }; 1607 1608 // ReSharper disable once InconsistentNaming 1609 1610 var TempusDominusBootstrap4 = function (_DateTimePicker) { 1611 _inherits(TempusDominusBootstrap4, _DateTimePicker); 1612 1613 function TempusDominusBootstrap4(element, options) { 1614 _classCallCheck(this, TempusDominusBootstrap4); 1615 1616 var _this = _possibleConstructorReturn(this, _DateTimePicker.call(this, element, options)); 1617 1618 _this._init(); 1619 return _this; 1620 } 1621 1622 TempusDominusBootstrap4.prototype._init = function _init() { 1623 if (this._element.hasClass('input-group')) { 1624 var datepickerButton = this._element.find('.datepickerbutton'); 1625 if (datepickerButton.length === 0) { 1626 this.component = this._element.find('[data-toggle="datetimepicker"]'); 1627 } else { 1628 this.component = datepickerButton; 1629 } 1630 } 1631 }; 1632 1633 TempusDominusBootstrap4.prototype._getDatePickerTemplate = function _getDatePickerTemplate() { 1634 var headTemplate = $('<thead>').append($('<tr>').append($('<th>').addClass('prev').attr('data-action', 'previous').append($('<span>').addClass(this._options.icons.previous))).append($('<th>').addClass('picker-switch').attr('data-action', 'pickerSwitch').attr('colspan', '' + (this._options.calendarWeeks ? '6' : '5'))).append($('<th>').addClass('next').attr('data-action', 'next').append($('<span>').addClass(this._options.icons.next)))), 1635 contTemplate = $('<tbody>').append($('<tr>').append($('<td>').attr('colspan', '' + (this._options.calendarWeeks ? '8' : '7')))); 1636 1637 return [$('<div>').addClass('datepicker-days').append($('<table>').addClass('table table-sm').append(headTemplate).append($('<tbody>'))), $('<div>').addClass('datepicker-months').append($('<table>').addClass('table-condensed').append(headTemplate.clone()).append(contTemplate.clone())), $('<div>').addClass('datepicker-years').append($('<table>').addClass('table-condensed').append(headTemplate.clone()).append(contTemplate.clone())), $('<div>').addClass('datepicker-decades').append($('<table>').addClass('table-condensed').append(headTemplate.clone()).append(contTemplate.clone()))]; 1638 }; 1639 1640 TempusDominusBootstrap4.prototype._getTimePickerMainTemplate = function _getTimePickerMainTemplate() { 1641 var topRow = $('<tr>'), 1642 middleRow = $('<tr>'), 1643 bottomRow = $('<tr>'); 1644 1645 if (this._isEnabled('h')) { 1646 topRow.append($('<td>').append($('<a>').attr({ 1647 href: '#', 1648 tabindex: '-1', 1649 'title': this._options.tooltips.incrementHour 1650 }).addClass('btn').attr('data-action', 'incrementHours').append($('<span>').addClass(this._options.icons.up)))); 1651 middleRow.append($('<td>').append($('<span>').addClass('timepicker-hour').attr({ 1652 'data-time-component': 'hours', 1653 'title': this._options.tooltips.pickHour 1654 }).attr('data-action', 'showHours'))); 1655 bottomRow.append($('<td>').append($('<a>').attr({ 1656 href: '#', 1657 tabindex: '-1', 1658 'title': this._options.tooltips.decrementHour 1659 }).addClass('btn').attr('data-action', 'decrementHours').append($('<span>').addClass(this._options.icons.down)))); 1660 } 1661 if (this._isEnabled('m')) { 1662 if (this._isEnabled('h')) { 1663 topRow.append($('<td>').addClass('separator')); 1664 middleRow.append($('<td>').addClass('separator').html(':')); 1665 bottomRow.append($('<td>').addClass('separator')); 1666 } 1667 topRow.append($('<td>').append($('<a>').attr({ 1668 href: '#', 1669 tabindex: '-1', 1670 'title': this._options.tooltips.incrementMinute 1671 }).addClass('btn').attr('data-action', 'incrementMinutes').append($('<span>').addClass(this._options.icons.up)))); 1672 middleRow.append($('<td>').append($('<span>').addClass('timepicker-minute').attr({ 1673 'data-time-component': 'minutes', 1674 'title': this._options.tooltips.pickMinute 1675 }).attr('data-action', 'showMinutes'))); 1676 bottomRow.append($('<td>').append($('<a>').attr({ 1677 href: '#', 1678 tabindex: '-1', 1679 'title': this._options.tooltips.decrementMinute 1680 }).addClass('btn').attr('data-action', 'decrementMinutes').append($('<span>').addClass(this._options.icons.down)))); 1681 } 1682 if (this._isEnabled('s')) { 1683 if (this._isEnabled('m')) { 1684 topRow.append($('<td>').addClass('separator')); 1685 middleRow.append($('<td>').addClass('separator').html(':')); 1686 bottomRow.append($('<td>').addClass('separator')); 1687 } 1688 topRow.append($('<td>').append($('<a>').attr({ 1689 href: '#', 1690 tabindex: '-1', 1691 'title': this._options.tooltips.incrementSecond 1692 }).addClass('btn').attr('data-action', 'incrementSeconds').append($('<span>').addClass(this._options.icons.up)))); 1693 middleRow.append($('<td>').append($('<span>').addClass('timepicker-second').attr({ 1694 'data-time-component': 'seconds', 1695 'title': this._options.tooltips.pickSecond 1696 }).attr('data-action', 'showSeconds'))); 1697 bottomRow.append($('<td>').append($('<a>').attr({ 1698 href: '#', 1699 tabindex: '-1', 1700 'title': this._options.tooltips.decrementSecond 1701 }).addClass('btn').attr('data-action', 'decrementSeconds').append($('<span>').addClass(this._options.icons.down)))); 1702 } 1703 1704 if (!this.use24Hours) { 1705 topRow.append($('<td>').addClass('separator')); 1706 middleRow.append($('<td>').append($('<button>').addClass('btn btn-primary').attr({ 1707 'data-action': 'togglePeriod', 1708 tabindex: '-1', 1709 'title': this._options.tooltips.togglePeriod 1710 }))); 1711 bottomRow.append($('<td>').addClass('separator')); 1712 } 1713 1714 return $('<div>').addClass('timepicker-picker').append($('<table>').addClass('table-condensed').append([topRow, middleRow, bottomRow])); 1715 }; 1716 1717 TempusDominusBootstrap4.prototype._getTimePickerTemplate = function _getTimePickerTemplate() { 1718 var hoursView = $('<div>').addClass('timepicker-hours').append($('<table>').addClass('table-condensed')), 1719 minutesView = $('<div>').addClass('timepicker-minutes').append($('<table>').addClass('table-condensed')), 1720 secondsView = $('<div>').addClass('timepicker-seconds').append($('<table>').addClass('table-condensed')), 1721 ret = [this._getTimePickerMainTemplate()]; 1722 1723 if (this._isEnabled('h')) { 1724 ret.push(hoursView); 1725 } 1726 if (this._isEnabled('m')) { 1727 ret.push(minutesView); 1728 } 1729 if (this._isEnabled('s')) { 1730 ret.push(secondsView); 1731 } 1732 1733 return ret; 1734 }; 1735 1736 TempusDominusBootstrap4.prototype._getToolbar = function _getToolbar() { 1737 var row = []; 1738 if (this._options.buttons.showToday) { 1739 row.push($('<td>').append($('<a>').attr({ 1740 href: '#', 1741 tabindex: '-1', 1742 'data-action': 'today', 1743 'title': this._options.tooltips.today 1744 }).append($('<span>').addClass(this._options.icons.today)))); 1745 } 1746 if (!this._options.sideBySide && this._hasDate() && this._hasTime()) { 1747 var title = void 0, 1748 icon = void 0; 1749 if (this._options.viewMode === 'times') { 1750 title = this._options.tooltips.selectDate; 1751 icon = this._options.icons.date; 1752 } else { 1753 title = this._options.tooltips.selectTime; 1754 icon = this._options.icons.time; 1755 } 1756 row.push($('<td>').append($('<a>').attr({ 1757 href: '#', 1758 tabindex: '-1', 1759 'data-action': 'togglePicker', 1760 'title': title 1761 }).append($('<span>').addClass(icon)))); 1762 } 1763 if (this._options.buttons.showClear) { 1764 row.push($('<td>').append($('<a>').attr({ 1765 href: '#', 1766 tabindex: '-1', 1767 'data-action': 'clear', 1768 'title': this._options.tooltips.clear 1769 }).append($('<span>').addClass(this._options.icons.clear)))); 1770 } 1771 if (this._options.buttons.showClose) { 1772 row.push($('<td>').append($('<a>').attr({ 1773 href: '#', 1774 tabindex: '-1', 1775 'data-action': 'close', 1776 'title': this._options.tooltips.close 1777 }).append($('<span>').addClass(this._options.icons.close)))); 1778 } 1779 return row.length === 0 ? '' : $('<table>').addClass('table-condensed').append($('<tbody>').append($('<tr>').append(row))); 1780 }; 1781 1782 TempusDominusBootstrap4.prototype._getTemplate = function _getTemplate() { 1783 var template = $('<div>').addClass('bootstrap-datetimepicker-widget dropdown-menu'), 1784 dateView = $('<div>').addClass('datepicker').append(this._getDatePickerTemplate()), 1785 timeView = $('<div>').addClass('timepicker').append(this._getTimePickerTemplate()), 1786 content = $('<ul>').addClass('list-unstyled'), 1787 toolbar = $('<li>').addClass('picker-switch' + (this._options.collapse ? ' accordion-toggle' : '')).append(this._getToolbar()); 1788 1789 if (this._options.inline) { 1790 template.removeClass('dropdown-menu'); 1791 } 1792 1793 if (this.use24Hours) { 1794 template.addClass('usetwentyfour'); 1795 } 1796 if (this._isEnabled('s') && !this.use24Hours) { 1797 template.addClass('wider'); 1798 } 1799 1800 if (this._options.sideBySide && this._hasDate() && this._hasTime()) { 1801 template.addClass('timepicker-sbs'); 1802 if (this._options.toolbarPlacement === 'top') { 1803 template.append(toolbar); 1804 } 1805 template.append($('<div>').addClass('row').append(dateView.addClass('col-md-6')).append(timeView.addClass('col-md-6'))); 1806 if (this._options.toolbarPlacement === 'bottom' || this._options.toolbarPlacement === 'default') { 1807 template.append(toolbar); 1808 } 1809 return template; 1810 } 1811 1812 if (this._options.toolbarPlacement === 'top') { 1813 content.append(toolbar); 1814 } 1815 if (this._hasDate()) { 1816 content.append($('<li>').addClass(this._options.collapse && this._hasTime() ? 'collapse' : '').addClass(this._options.collapse && this._hasTime() && this._options.viewMode === 'times' ? '' : 'show').append(dateView)); 1817 } 1818 if (this._options.toolbarPlacement === 'default') { 1819 content.append(toolbar); 1820 } 1821 if (this._hasTime()) { 1822 content.append($('<li>').addClass(this._options.collapse && this._hasDate() ? 'collapse' : '').addClass(this._options.collapse && this._hasDate() && this._options.viewMode === 'times' ? 'show' : '').append(timeView)); 1823 } 1824 if (this._options.toolbarPlacement === 'bottom') { 1825 content.append(toolbar); 1826 } 1827 return template.append(content); 1828 }; 1829 1830 TempusDominusBootstrap4.prototype._place = function _place(e) { 1831 var self = e && e.data && e.data.picker || this, 1832 vertical = self._options.widgetPositioning.vertical, 1833 horizontal = self._options.widgetPositioning.horizontal, 1834 parent = void 0; 1835 var position = (self.component && self.component.length ? self.component : self._element).position(), 1836 offset = (self.component && self.component.length ? self.component : self._element).offset(); 1837 if (self._options.widgetParent) { 1838 parent = self._options.widgetParent.append(self.widget); 1839 } else if (self._element.is('input')) { 1840 parent = self._element.after(self.widget).parent(); 1841 } else if (self._options.inline) { 1842 parent = self._element.append(self.widget); 1843 return; 1844 } else { 1845 parent = self._element; 1846 self._element.children().first().after(self.widget); 1847 } 1848 1849 // Top and bottom logic 1850 if (vertical === 'auto') { 1851 //noinspection JSValidateTypes 1852 if (offset.top + self.widget.height() * 1.5 >= $(window).height() + $(window).scrollTop() && self.widget.height() + self._element.outerHeight() < offset.top) { 1853 vertical = 'top'; 1854 } else { 1855 vertical = 'bottom'; 1856 } 1857 } 1858 1859 // Left and right logic 1860 if (horizontal === 'auto') { 1861 if (parent.width() < offset.left + self.widget.outerWidth() / 2 && offset.left + self.widget.outerWidth() > $(window).width()) { 1862 horizontal = 'right'; 1863 } else { 1864 horizontal = 'left'; 1865 } 1866 } 1867 1868 if (vertical === 'top') { 1869 self.widget.addClass('top').removeClass('bottom'); 1870 } else { 1871 self.widget.addClass('bottom').removeClass('top'); 1872 } 1873 1874 if (horizontal === 'right') { 1875 self.widget.addClass('float-right'); 1876 } else { 1877 self.widget.removeClass('float-right'); 1878 } 1879 1880 // find the first parent element that has a relative css positioning 1881 if (parent.css('position') !== 'relative') { 1882 parent = parent.parents().filter(function () { 1883 return $(this).css('position') === 'relative'; 1884 }).first(); 1885 } 1886 1887 if (parent.length === 0) { 1888 throw new Error('datetimepicker component should be placed within a relative positioned container'); 1889 } 1890 1891 self.widget.css({ 1892 top: vertical === 'top' ? 'auto' : position.top + self._element.outerHeight() + 'px', 1893 bottom: vertical === 'top' ? parent.outerHeight() - (parent === self._element ? 0 : position.top) + 'px' : 'auto', 1894 left: horizontal === 'left' ? (parent === self._element ? 0 : position.left) + 'px' : 'auto', 1895 right: horizontal === 'left' ? 'auto' : parent.outerWidth() - self._element.outerWidth() - (parent === self._element ? 0 : position.left) + 'px' 1896 }); 1897 }; 1898 1899 TempusDominusBootstrap4.prototype._fillDow = function _fillDow() { 1900 var row = $('<tr>'), 1901 currentDate = this._viewDate.clone().startOf('w').startOf('d'); 1902 1903 if (this._options.calendarWeeks === true) { 1904 row.append($('<th>').addClass('cw').text('#')); 1905 } 1906 1907 while (currentDate.isBefore(this._viewDate.clone().endOf('w'))) { 1908 row.append($('<th>').addClass('dow').text(currentDate.format('dd'))); 1909 currentDate.add(1, 'd'); 1910 } 1911 this.widget.find('.datepicker-days thead').append(row); 1912 }; 1913 1914 TempusDominusBootstrap4.prototype._fillMonths = function _fillMonths() { 1915 var spans = [], 1916 monthsShort = this._viewDate.clone().startOf('y').startOf('d'); 1917 while (monthsShort.isSame(this._viewDate, 'y')) { 1918 spans.push($('<span>').attr('data-action', 'selectMonth').addClass('month').text(monthsShort.format('MMM'))); 1919 monthsShort.add(1, 'M'); 1920 } 1921 this.widget.find('.datepicker-months td').empty().append(spans); 1922 }; 1923 1924 TempusDominusBootstrap4.prototype._updateMonths = function _updateMonths() { 1925 var monthsView = this.widget.find('.datepicker-months'), 1926 monthsViewHeader = monthsView.find('th'), 1927 months = monthsView.find('tbody').find('span'), 1928 self = this; 1929 1930 monthsViewHeader.eq(0).find('span').attr('title', this._options.tooltips.prevYear); 1931 monthsViewHeader.eq(1).attr('title', this._options.tooltips.selectYear); 1932 monthsViewHeader.eq(2).find('span').attr('title', this._options.tooltips.nextYear); 1933 1934 monthsView.find('.disabled').removeClass('disabled'); 1935 1936 if (!this._isValid(this._viewDate.clone().subtract(1, 'y'), 'y')) { 1937 monthsViewHeader.eq(0).addClass('disabled'); 1938 } 1939 1940 monthsViewHeader.eq(1).text(this._viewDate.year()); 1941 1942 if (!this._isValid(this._viewDate.clone().add(1, 'y'), 'y')) { 1943 monthsViewHeader.eq(2).addClass('disabled'); 1944 } 1945 1946 months.removeClass('active'); 1947 if (this._getLastPickedDate().isSame(this._viewDate, 'y') && !this.unset) { 1948 months.eq(this._getLastPickedDate().month()).addClass('active'); 1949 } 1950 1951 months.each(function (index) { 1952 if (!self._isValid(self._viewDate.clone().month(index), 'M')) { 1953 $(this).addClass('disabled'); 1954 } 1955 }); 1956 }; 1957 1958 TempusDominusBootstrap4.prototype._getStartEndYear = function _getStartEndYear(factor, year) { 1959 var step = factor / 10, 1960 startYear = Math.floor(year / factor) * factor, 1961 endYear = startYear + step * 9, 1962 focusValue = Math.floor(year / step) * step; 1963 return [startYear, endYear, focusValue]; 1964 }; 1965 1966 TempusDominusBootstrap4.prototype._updateYears = function _updateYears() { 1967 var yearsView = this.widget.find('.datepicker-years'), 1968 yearsViewHeader = yearsView.find('th'), 1969 yearCaps = this._getStartEndYear(10, this._viewDate.year()), 1970 startYear = this._viewDate.clone().year(yearCaps[0]), 1971 endYear = this._viewDate.clone().year(yearCaps[1]); 1972 var html = ''; 1973 1974 yearsViewHeader.eq(0).find('span').attr('title', this._options.tooltips.prevDecade); 1975 yearsViewHeader.eq(1).attr('title', this._options.tooltips.selectDecade); 1976 yearsViewHeader.eq(2).find('span').attr('title', this._options.tooltips.nextDecade); 1977 1978 yearsView.find('.disabled').removeClass('disabled'); 1979 1980 if (this._options.minDate && this._options.minDate.isAfter(startYear, 'y')) { 1981 yearsViewHeader.eq(0).addClass('disabled'); 1982 } 1983 1984 yearsViewHeader.eq(1).text(startYear.year() + '-' + endYear.year()); 1985 1986 if (this._options.maxDate && this._options.maxDate.isBefore(endYear, 'y')) { 1987 yearsViewHeader.eq(2).addClass('disabled'); 1988 } 1989 1990 html += '<span data-action="selectYear" class="year old' + (!this._isValid(startYear, 'y') ? ' disabled' : '') + '">' + (startYear.year() - 1) + '</span>'; 1991 while (!startYear.isAfter(endYear, 'y')) { 1992 html += '<span data-action="selectYear" class="year' + (startYear.isSame(this._getLastPickedDate(), 'y') && !this.unset ? ' active' : '') + (!this._isValid(startYear, 'y') ? ' disabled' : '') + '">' + startYear.year() + '</span>'; 1993 startYear.add(1, 'y'); 1994 } 1995 html += '<span data-action="selectYear" class="year old' + (!this._isValid(startYear, 'y') ? ' disabled' : '') + '">' + startYear.year() + '</span>'; 1996 1997 yearsView.find('td').html(html); 1998 }; 1999 2000 TempusDominusBootstrap4.prototype._updateDecades = function _updateDecades() { 2001 var decadesView = this.widget.find('.datepicker-decades'), 2002 decadesViewHeader = decadesView.find('th'), 2003 yearCaps = this._getStartEndYear(100, this._viewDate.year()), 2004 startDecade = this._viewDate.clone().year(yearCaps[0]), 2005 endDecade = this._viewDate.clone().year(yearCaps[1]); 2006 var minDateDecade = false, 2007 maxDateDecade = false, 2008 endDecadeYear = void 0, 2009 html = ''; 2010 2011 decadesViewHeader.eq(0).find('span').attr('title', this._options.tooltips.prevCentury); 2012 decadesViewHeader.eq(2).find('span').attr('title', this._options.tooltips.nextCentury); 2013 2014 decadesView.find('.disabled').removeClass('disabled'); 2015 2016 if (startDecade.year() === 0 || this._options.minDate && this._options.minDate.isAfter(startDecade, 'y')) { 2017 decadesViewHeader.eq(0).addClass('disabled'); 2018 } 2019 2020 decadesViewHeader.eq(1).text(startDecade.year() + '-' + endDecade.year()); 2021 2022 if (this._options.maxDate && this._options.maxDate.isBefore(endDecade, 'y')) { 2023 decadesViewHeader.eq(2).addClass('disabled'); 2024 } 2025 2026 if (startDecade.year() - 10 < 0) { 2027 html += '<span> </span>'; 2028 } else { 2029 html += '<span data-action="selectDecade" class="decade old" data-selection="' + (startDecade.year() + 6) + '">' + (startDecade.year() - 10) + '</span>'; 2030 } 2031 2032 while (!startDecade.isAfter(endDecade, 'y')) { 2033 endDecadeYear = startDecade.year() + 11; 2034 minDateDecade = this._options.minDate && this._options.minDate.isAfter(startDecade, 'y') && this._options.minDate.year() <= endDecadeYear; 2035 maxDateDecade = this._options.maxDate && this._options.maxDate.isAfter(startDecade, 'y') && this._options.maxDate.year() <= endDecadeYear; 2036 html += '<span data-action="selectDecade" class="decade' + (this._getLastPickedDate().isAfter(startDecade) && this._getLastPickedDate().year() <= endDecadeYear ? ' active' : '') + (!this._isValid(startDecade, 'y') && !minDateDecade && !maxDateDecade ? ' disabled' : '') + '" data-selection="' + (startDecade.year() + 6) + '">' + startDecade.year() + '</span>'; 2037 startDecade.add(10, 'y'); 2038 } 2039 html += '<span data-action="selectDecade" class="decade old" data-selection="' + (startDecade.year() + 6) + '">' + startDecade.year() + '</span>'; 2040 2041 decadesView.find('td').html(html); 2042 }; 2043 2044 TempusDominusBootstrap4.prototype._fillDate = function _fillDate() { 2045 var daysView = this.widget.find('.datepicker-days'), 2046 daysViewHeader = daysView.find('th'), 2047 html = []; 2048 var currentDate = void 0, 2049 row = void 0, 2050 clsName = void 0, 2051 i = void 0; 2052 2053 if (!this._hasDate()) { 2054 return; 2055 } 2056 2057 daysViewHeader.eq(0).find('span').attr('title', this._options.tooltips.prevMonth); 2058 daysViewHeader.eq(1).attr('title', this._options.tooltips.selectMonth); 2059 daysViewHeader.eq(2).find('span').attr('title', this._options.tooltips.nextMonth); 2060 2061 daysView.find('.disabled').removeClass('disabled'); 2062 daysViewHeader.eq(1).text(this._viewDate.format(this._options.dayViewHeaderFormat)); 2063 2064 if (!this._isValid(this._viewDate.clone().subtract(1, 'M'), 'M')) { 2065 daysViewHeader.eq(0).addClass('disabled'); 2066 } 2067 if (!this._isValid(this._viewDate.clone().add(1, 'M'), 'M')) { 2068 daysViewHeader.eq(2).addClass('disabled'); 2069 } 2070 2071 currentDate = this._viewDate.clone().startOf('M').startOf('w').startOf('d'); 2072 2073 for (i = 0; i < 42; i++) { 2074 //always display 42 days (should show 6 weeks) 2075 if (currentDate.weekday() === 0) { 2076 row = $('<tr>'); 2077 if (this._options.calendarWeeks) { 2078 row.append('<td class="cw">' + currentDate.week() + '</td>'); 2079 } 2080 html.push(row); 2081 } 2082 clsName = ''; 2083 if (currentDate.isBefore(this._viewDate, 'M')) { 2084 clsName += ' old'; 2085 } 2086 if (currentDate.isAfter(this._viewDate, 'M')) { 2087 clsName += ' new'; 2088 } 2089 if (this._options.allowMultidate) { 2090 var index = this._datesFormatted.indexOf(currentDate.format('YYYY-MM-DD')); 2091 if (index !== -1) { 2092 if (currentDate.isSame(this._datesFormatted[index], 'd') && !this.unset) { 2093 clsName += ' active'; 2094 } 2095 } 2096 } else { 2097 if (currentDate.isSame(this._getLastPickedDate(), 'd') && !this.unset) { 2098 clsName += ' active'; 2099 } 2100 } 2101 if (!this._isValid(currentDate, 'd')) { 2102 clsName += ' disabled'; 2103 } 2104 if (currentDate.isSame(this.getMoment(), 'd')) { 2105 clsName += ' today'; 2106 } 2107 if (currentDate.day() === 0 || currentDate.day() === 6) { 2108 clsName += ' weekend'; 2109 } 2110 row.append('<td data-action="selectDay" data-day="' + currentDate.format('L') + '" class="day' + clsName + '">' + currentDate.date() + '</td>'); 2111 currentDate.add(1, 'd'); 2112 } 2113 2114 daysView.find('tbody').empty().append(html); 2115 2116 this._updateMonths(); 2117 2118 this._updateYears(); 2119 2120 this._updateDecades(); 2121 }; 2122 2123 TempusDominusBootstrap4.prototype._fillHours = function _fillHours() { 2124 var table = this.widget.find('.timepicker-hours table'), 2125 currentHour = this._viewDate.clone().startOf('d'), 2126 html = []; 2127 var row = $('<tr>'); 2128 2129 if (this._viewDate.hour() > 11 && !this.use24Hours) { 2130 currentHour.hour(12); 2131 } 2132 while (currentHour.isSame(this._viewDate, 'd') && (this.use24Hours || this._viewDate.hour() < 12 && currentHour.hour() < 12 || this._viewDate.hour() > 11)) { 2133 if (currentHour.hour() % 4 === 0) { 2134 row = $('<tr>'); 2135 html.push(row); 2136 } 2137 row.append('<td data-action="selectHour" class="hour' + (!this._isValid(currentHour, 'h') ? ' disabled' : '') + '">' + currentHour.format(this.use24Hours ? 'HH' : 'hh') + '</td>'); 2138 currentHour.add(1, 'h'); 2139 } 2140 table.empty().append(html); 2141 }; 2142 2143 TempusDominusBootstrap4.prototype._fillMinutes = function _fillMinutes() { 2144 var table = this.widget.find('.timepicker-minutes table'), 2145 currentMinute = this._viewDate.clone().startOf('h'), 2146 html = [], 2147 step = this._options.stepping === 1 ? 5 : this._options.stepping; 2148 var row = $('<tr>'); 2149 2150 while (this._viewDate.isSame(currentMinute, 'h')) { 2151 if (currentMinute.minute() % (step * 4) === 0) { 2152 row = $('<tr>'); 2153 html.push(row); 2154 } 2155 row.append('<td data-action="selectMinute" class="minute' + (!this._isValid(currentMinute, 'm') ? ' disabled' : '') + '">' + currentMinute.format('mm') + '</td>'); 2156 currentMinute.add(step, 'm'); 2157 } 2158 table.empty().append(html); 2159 }; 2160 2161 TempusDominusBootstrap4.prototype._fillSeconds = function _fillSeconds() { 2162 var table = this.widget.find('.timepicker-seconds table'), 2163 currentSecond = this._viewDate.clone().startOf('m'), 2164 html = []; 2165 var row = $('<tr>'); 2166 2167 while (this._viewDate.isSame(currentSecond, 'm')) { 2168 if (currentSecond.second() % 20 === 0) { 2169 row = $('<tr>'); 2170 html.push(row); 2171 } 2172 row.append('<td data-action="selectSecond" class="second' + (!this._isValid(currentSecond, 's') ? ' disabled' : '') + '">' + currentSecond.format('ss') + '</td>'); 2173 currentSecond.add(5, 's'); 2174 } 2175 2176 table.empty().append(html); 2177 }; 2178 2179 TempusDominusBootstrap4.prototype._fillTime = function _fillTime() { 2180 var toggle = void 0, 2181 newDate = void 0; 2182 var timeComponents = this.widget.find('.timepicker span[data-time-component]'); 2183 2184 if (!this.use24Hours) { 2185 toggle = this.widget.find('.timepicker [data-action=togglePeriod]'); 2186 newDate = this._getLastPickedDate().clone().add(this._getLastPickedDate().hours() >= 12 ? -12 : 12, 'h'); 2187 2188 toggle.text(this._getLastPickedDate().format('A')); 2189 2190 if (this._isValid(newDate, 'h')) { 2191 toggle.removeClass('disabled'); 2192 } else { 2193 toggle.addClass('disabled'); 2194 } 2195 } 2196 timeComponents.filter('[data-time-component=hours]').text(this._getLastPickedDate().format('' + (this.use24Hours ? 'HH' : 'hh'))); 2197 timeComponents.filter('[data-time-component=minutes]').text(this._getLastPickedDate().format('mm')); 2198 timeComponents.filter('[data-time-component=seconds]').text(this._getLastPickedDate().format('ss')); 2199 2200 this._fillHours(); 2201 this._fillMinutes(); 2202 this._fillSeconds(); 2203 }; 2204 2205 TempusDominusBootstrap4.prototype._doAction = function _doAction(e, action) { 2206 var lastPicked = this._getLastPickedDate(); 2207 if ($(e.currentTarget).is('.disabled')) { 2208 return false; 2209 } 2210 action = action || $(e.currentTarget).data('action'); 2211 switch (action) { 2212 case 'next': 2213 { 2214 var navFnc = DateTimePicker.DatePickerModes[this.currentViewMode].NAV_FUNCTION; 2215 this._viewDate.add(DateTimePicker.DatePickerModes[this.currentViewMode].NAV_STEP, navFnc); 2216 this._fillDate(); 2217 this._viewUpdate(navFnc); 2218 break; 2219 } 2220 case 'previous': 2221 { 2222 var _navFnc = DateTimePicker.DatePickerModes[this.currentViewMode].NAV_FUNCTION; 2223 this._viewDate.subtract(DateTimePicker.DatePickerModes[this.currentViewMode].NAV_STEP, _navFnc); 2224 this._fillDate(); 2225 this._viewUpdate(_navFnc); 2226 break; 2227 } 2228 case 'pickerSwitch': 2229 this._showMode(1); 2230 break; 2231 case 'selectMonth': 2232 { 2233 var month = $(e.target).closest('tbody').find('span').index($(e.target)); 2234 this._viewDate.month(month); 2235 if (this.currentViewMode === this.MinViewModeNumber) { 2236 this._setValue(lastPicked.clone().year(this._viewDate.year()).month(this._viewDate.month()), this._getLastPickedDateIndex()); 2237 if (!this._options.inline) { 2238 this.hide(); 2239 } 2240 } else { 2241 this._showMode(-1); 2242 this._fillDate(); 2243 } 2244 this._viewUpdate('M'); 2245 break; 2246 } 2247 case 'selectYear': 2248 { 2249 var year = parseInt($(e.target).text(), 10) || 0; 2250 this._viewDate.year(year); 2251 if (this.currentViewMode === this.MinViewModeNumber) { 2252 this._setValue(lastPicked.clone().year(this._viewDate.year()), this._getLastPickedDateIndex()); 2253 if (!this._options.inline) { 2254 this.hide(); 2255 } 2256 } else { 2257 this._showMode(-1); 2258 this._fillDate(); 2259 } 2260 this._viewUpdate('YYYY'); 2261 break; 2262 } 2263 case 'selectDecade': 2264 { 2265 var _year = parseInt($(e.target).data('selection'), 10) || 0; 2266 this._viewDate.year(_year); 2267 if (this.currentViewMode === this.MinViewModeNumber) { 2268 this._setValue(lastPicked.clone().year(this._viewDate.year()), this._getLastPickedDateIndex()); 2269 if (!this._options.inline) { 2270 this.hide(); 2271 } 2272 } else { 2273 this._showMode(-1); 2274 this._fillDate(); 2275 } 2276 this._viewUpdate('YYYY'); 2277 break; 2278 } 2279 case 'selectDay': 2280 { 2281 var day = this._viewDate.clone(); 2282 if ($(e.target).is('.old')) { 2283 day.subtract(1, 'M'); 2284 } 2285 if ($(e.target).is('.new')) { 2286 day.add(1, 'M'); 2287 } 2288 2289 var selectDate = day.date(parseInt($(e.target).text(), 10)), 2290 index = 0; 2291 if (this._options.allowMultidate) { 2292 index = this._datesFormatted.indexOf(selectDate.format('YYYY-MM-DD')); 2293 if (index !== -1) { 2294 this._setValue(null, index); //deselect multidate 2295 } else { 2296 this._setValue(selectDate, this._getLastPickedDateIndex() + 1); 2297 } 2298 } else { 2299 this._setValue(selectDate, this._getLastPickedDateIndex()); 2300 } 2301 2302 if (!this._hasTime() && !this._options.keepOpen && !this._options.inline && !this._options.allowMultidate) { 2303 this.hide(); 2304 } 2305 break; 2306 } 2307 case 'incrementHours': 2308 { 2309 var newDate = lastPicked.clone().add(1, 'h'); 2310 if (this._isValid(newDate, 'h')) { 2311 this._setValue(newDate, this._getLastPickedDateIndex()); 2312 } 2313 break; 2314 } 2315 case 'incrementMinutes': 2316 { 2317 var _newDate = lastPicked.clone().add(this._options.stepping, 'm'); 2318 if (this._isValid(_newDate, 'm')) { 2319 this._setValue(_newDate, this._getLastPickedDateIndex()); 2320 } 2321 break; 2322 } 2323 case 'incrementSeconds': 2324 { 2325 var _newDate2 = lastPicked.clone().add(1, 's'); 2326 if (this._isValid(_newDate2, 's')) { 2327 this._setValue(_newDate2, this._getLastPickedDateIndex()); 2328 } 2329 break; 2330 } 2331 case 'decrementHours': 2332 { 2333 var _newDate3 = lastPicked.clone().subtract(1, 'h'); 2334 if (this._isValid(_newDate3, 'h')) { 2335 this._setValue(_newDate3, this._getLastPickedDateIndex()); 2336 } 2337 break; 2338 } 2339 case 'decrementMinutes': 2340 { 2341 var _newDate4 = lastPicked.clone().subtract(this._options.stepping, 'm'); 2342 if (this._isValid(_newDate4, 'm')) { 2343 this._setValue(_newDate4, this._getLastPickedDateIndex()); 2344 } 2345 break; 2346 } 2347 case 'decrementSeconds': 2348 { 2349 var _newDate5 = lastPicked.clone().subtract(1, 's'); 2350 if (this._isValid(_newDate5, 's')) { 2351 this._setValue(_newDate5, this._getLastPickedDateIndex()); 2352 } 2353 break; 2354 } 2355 case 'togglePeriod': 2356 { 2357 this._setValue(lastPicked.clone().add(lastPicked.hours() >= 12 ? -12 : 12, 'h'), this._getLastPickedDateIndex()); 2358 break; 2359 } 2360 case 'togglePicker': 2361 { 2362 var $this = $(e.target), 2363 $link = $this.closest('a'), 2364 $parent = $this.closest('ul'), 2365 expanded = $parent.find('.show'), 2366 closed = $parent.find('.collapse:not(.show)'), 2367 $span = $this.is('span') ? $this : $this.find('span'); 2368 var collapseData = void 0; 2369 2370 if (expanded && expanded.length) { 2371 collapseData = expanded.data('collapse'); 2372 if (collapseData && collapseData.transitioning) { 2373 return true; 2374 } 2375 if (expanded.collapse) { 2376 // if collapse plugin is available through bootstrap.js then use it 2377 expanded.collapse('hide'); 2378 closed.collapse('show'); 2379 } else { 2380 // otherwise just toggle in class on the two views 2381 expanded.removeClass('show'); 2382 closed.addClass('show'); 2383 } 2384 $span.toggleClass(this._options.icons.time + ' ' + this._options.icons.date); 2385 2386 if ($span.hasClass(this._options.icons.date)) { 2387 $link.attr('title', this._options.tooltips.selectDate); 2388 } else { 2389 $link.attr('title', this._options.tooltips.selectTime); 2390 } 2391 } 2392 } 2393 break; 2394 case 'showPicker': 2395 this.widget.find('.timepicker > div:not(.timepicker-picker)').hide(); 2396 this.widget.find('.timepicker .timepicker-picker').show(); 2397 break; 2398 case 'showHours': 2399 this.widget.find('.timepicker .timepicker-picker').hide(); 2400 this.widget.find('.timepicker .timepicker-hours').show(); 2401 break; 2402 case 'showMinutes': 2403 this.widget.find('.timepicker .timepicker-picker').hide(); 2404 this.widget.find('.timepicker .timepicker-minutes').show(); 2405 break; 2406 case 'showSeconds': 2407 this.widget.find('.timepicker .timepicker-picker').hide(); 2408 this.widget.find('.timepicker .timepicker-seconds').show(); 2409 break; 2410 case 'selectHour': 2411 { 2412 var hour = parseInt($(e.target).text(), 10); 2413 2414 if (!this.use24Hours) { 2415 if (lastPicked.hours() >= 12) { 2416 if (hour !== 12) { 2417 hour += 12; 2418 } 2419 } else { 2420 if (hour === 12) { 2421 hour = 0; 2422 } 2423 } 2424 } 2425 this._setValue(lastPicked.clone().hours(hour), this._getLastPickedDateIndex()); 2426 if (!this._isEnabled('a') && !this._isEnabled('m') && !this._options.keepOpen && !this._options.inline) { 2427 this.hide(); 2428 } else { 2429 this._doAction(e, 'showPicker'); 2430 } 2431 break; 2432 } 2433 case 'selectMinute': 2434 this._setValue(lastPicked.clone().minutes(parseInt($(e.target).text(), 10)), this._getLastPickedDateIndex()); 2435 if (!this._isEnabled('a') && !this._isEnabled('s') && !this._options.keepOpen && !this._options.inline) { 2436 this.hide(); 2437 } else { 2438 this._doAction(e, 'showPicker'); 2439 } 2440 break; 2441 case 'selectSecond': 2442 this._setValue(lastPicked.clone().seconds(parseInt($(e.target).text(), 10)), this._getLastPickedDateIndex()); 2443 if (!this._isEnabled('a') && !this._options.keepOpen && !this._options.inline) { 2444 this.hide(); 2445 } else { 2446 this._doAction(e, 'showPicker'); 2447 } 2448 break; 2449 case 'clear': 2450 this.clear(); 2451 break; 2452 case 'close': 2453 this.hide(); 2454 break; 2455 case 'today': 2456 { 2457 var todaysDate = this.getMoment(); 2458 if (this._isValid(todaysDate, 'd')) { 2459 this._setValue(todaysDate, this._getLastPickedDateIndex()); 2460 } 2461 break; 2462 } 2463 } 2464 return false; 2465 }; 2466 2467 //public 2468 2469 2470 TempusDominusBootstrap4.prototype.hide = function hide() { 2471 var transitioning = false; 2472 if (!this.widget) { 2473 return; 2474 } 2475 // Ignore event if in the middle of a picker transition 2476 this.widget.find('.collapse').each(function () { 2477 var collapseData = $(this).data('collapse'); 2478 if (collapseData && collapseData.transitioning) { 2479 transitioning = true; 2480 return false; 2481 } 2482 return true; 2483 }); 2484 if (transitioning) { 2485 return; 2486 } 2487 if (this.component && this.component.hasClass('btn')) { 2488 this.component.toggleClass('active'); 2489 } 2490 this.widget.hide(); 2491 2492 $(window).off('resize', this._place()); 2493 this.widget.off('click', '[data-action]'); 2494 this.widget.off('mousedown', false); 2495 2496 this.widget.remove(); 2497 this.widget = false; 2498 2499 this._notifyEvent({ 2500 type: DateTimePicker.Event.HIDE, 2501 date: this._getLastPickedDate().clone() 2502 }); 2503 2504 if (this.input !== undefined) { 2505 this.input.blur(); 2506 } 2507 2508 this._viewDate = this._getLastPickedDate().clone(); 2509 }; 2510 2511 TempusDominusBootstrap4.prototype.show = function show() { 2512 var currentMoment = void 0; 2513 var useCurrentGranularity = { 2514 'year': function year(m) { 2515 return m.month(0).date(1).hours(0).seconds(0).minutes(0); 2516 }, 2517 'month': function month(m) { 2518 return m.date(1).hours(0).seconds(0).minutes(0); 2519 }, 2520 'day': function day(m) { 2521 return m.hours(0).seconds(0).minutes(0); 2522 }, 2523 'hour': function hour(m) { 2524 return m.seconds(0).minutes(0); 2525 }, 2526 'minute': function minute(m) { 2527 return m.seconds(0); 2528 } 2529 }; 2530 2531 if (this.input !== undefined) { 2532 if (this.input.prop('disabled') || !this._options.ignoreReadonly && this.input.prop('readonly') || this.widget) { 2533 return; 2534 } 2535 if (this.input.val() !== undefined && this.input.val().trim().length !== 0) { 2536 this._setValue(this._parseInputDate(this.input.val().trim()), 0); 2537 } else if (this.unset && this._options.useCurrent) { 2538 currentMoment = this.getMoment(); 2539 if (typeof this._options.useCurrent === 'string') { 2540 currentMoment = useCurrentGranularity[this._options.useCurrent](currentMoment); 2541 } 2542 this._setValue(currentMoment, 0); 2543 } 2544 } else if (this.unset && this._options.useCurrent) { 2545 currentMoment = this.getMoment(); 2546 if (typeof this._options.useCurrent === 'string') { 2547 currentMoment = useCurrentGranularity[this._options.useCurrent](currentMoment); 2548 } 2549 this._setValue(currentMoment, 0); 2550 } 2551 2552 this.widget = this._getTemplate(); 2553 2554 this._fillDow(); 2555 this._fillMonths(); 2556 2557 this.widget.find('.timepicker-hours').hide(); 2558 this.widget.find('.timepicker-minutes').hide(); 2559 this.widget.find('.timepicker-seconds').hide(); 2560 2561 this._update(); 2562 this._showMode(); 2563 2564 $(window).on('resize', { picker: this }, this._place); 2565 this.widget.on('click', '[data-action]', $.proxy(this._doAction, this)); // this handles clicks on the widget 2566 this.widget.on('mousedown', false); 2567 2568 if (this.component && this.component.hasClass('btn')) { 2569 this.component.toggleClass('active'); 2570 } 2571 this._place(); 2572 this.widget.show(); 2573 if (this.input !== undefined && this._options.focusOnShow && !this.input.is(':focus')) { 2574 this.input.focus(); 2575 } 2576 2577 this._notifyEvent({ 2578 type: DateTimePicker.Event.SHOW 2579 }); 2580 }; 2581 2582 TempusDominusBootstrap4.prototype.destroy = function destroy() { 2583 this.hide(); 2584 //todo doc off? 2585 this._element.removeData(DateTimePicker.DATA_KEY); 2586 this._element.removeData('date'); 2587 }; 2588 2589 TempusDominusBootstrap4.prototype.disable = function disable() { 2590 this.hide(); 2591 if (this.component && this.component.hasClass('btn')) { 2592 this.component.addClass('disabled'); 2593 } 2594 if (this.input !== undefined) { 2595 this.input.prop('disabled', true); //todo disable this/comp if input is null 2596 } 2597 }; 2598 2599 TempusDominusBootstrap4.prototype.enable = function enable() { 2600 if (this.component && this.component.hasClass('btn')) { 2601 this.component.removeClass('disabled'); 2602 } 2603 if (this.input !== undefined) { 2604 this.input.prop('disabled', false); //todo enable comp/this if input is null 2605 } 2606 }; 2607 2608 TempusDominusBootstrap4.prototype.toolbarPlacement = function toolbarPlacement(_toolbarPlacement) { 2609 if (arguments.length === 0) { 2610 return this._options.toolbarPlacement; 2611 } 2612 2613 if (typeof _toolbarPlacement !== 'string') { 2614 throw new TypeError('toolbarPlacement() expects a string parameter'); 2615 } 2616 if (toolbarPlacements.indexOf(_toolbarPlacement) === -1) { 2617 throw new TypeError('toolbarPlacement() parameter must be one of (' + toolbarPlacements.join(', ') + ') value'); 2618 } 2619 this._options.toolbarPlacement = _toolbarPlacement; 2620 2621 if (this.widget) { 2622 this.hide(); 2623 this.show(); 2624 } 2625 }; 2626 2627 TempusDominusBootstrap4.prototype.widgetPositioning = function widgetPositioning(_widgetPositioning) { 2628 if (arguments.length === 0) { 2629 return $.extend({}, this._options.widgetPositioning); 2630 } 2631 2632 if ({}.toString.call(_widgetPositioning) !== '[object Object]') { 2633 throw new TypeError('widgetPositioning() expects an object variable'); 2634 } 2635 if (_widgetPositioning.horizontal) { 2636 if (typeof _widgetPositioning.horizontal !== 'string') { 2637 throw new TypeError('widgetPositioning() horizontal variable must be a string'); 2638 } 2639 _widgetPositioning.horizontal = _widgetPositioning.horizontal.toLowerCase(); 2640 if (horizontalModes.indexOf(_widgetPositioning.horizontal) === -1) { 2641 throw new TypeError('widgetPositioning() expects horizontal parameter to be one of (' + horizontalModes.join(', ') + ')'); 2642 } 2643 this._options.widgetPositioning.horizontal = _widgetPositioning.horizontal; 2644 } 2645 if (_widgetPositioning.vertical) { 2646 if (typeof _widgetPositioning.vertical !== 'string') { 2647 throw new TypeError('widgetPositioning() vertical variable must be a string'); 2648 } 2649 _widgetPositioning.vertical = _widgetPositioning.vertical.toLowerCase(); 2650 if (verticalModes.indexOf(_widgetPositioning.vertical) === -1) { 2651 throw new TypeError('widgetPositioning() expects vertical parameter to be one of (' + verticalModes.join(', ') + ')'); 2652 } 2653 this._options.widgetPositioning.vertical = _widgetPositioning.vertical; 2654 } 2655 this._update(); 2656 }; 2657 2658 TempusDominusBootstrap4.prototype.widgetParent = function widgetParent(_widgetParent) { 2659 if (arguments.length === 0) { 2660 return this._options.widgetParent; 2661 } 2662 2663 if (typeof _widgetParent === 'string') { 2664 _widgetParent = $(_widgetParent); 2665 } 2666 2667 if (_widgetParent !== null && typeof _widgetParent !== 'string' && !(_widgetParent instanceof $)) { 2668 throw new TypeError('widgetParent() expects a string or a jQuery object parameter'); 2669 } 2670 2671 this._options.widgetParent = _widgetParent; 2672 if (this.widget) { 2673 this.hide(); 2674 this.show(); 2675 } 2676 }; 2677 2678 //static 2679 2680 2681 TempusDominusBootstrap4._jQueryHandleThis = function _jQueryHandleThis(me, option, argument) { 2682 var data = $(me).data(DateTimePicker.DATA_KEY); 2683 if ((typeof option === 'undefined' ? 'undefined' : _typeof(option)) === 'object') { 2684 $.extend({}, DateTimePicker.Default, option); 2685 } 2686 2687 if (!data) { 2688 data = new TempusDominusBootstrap4($(me), option); 2689 $(me).data(DateTimePicker.DATA_KEY, data); 2690 } 2691 2692 if (typeof option === 'string') { 2693 if (data[option] === undefined) { 2694 throw new Error('No method named "' + option + '"'); 2695 } 2696 if (argument === undefined) { 2697 return data[option](); 2698 } else { 2699 return data[option](argument); 2700 } 2701 } 2702 }; 2703 2704 TempusDominusBootstrap4._jQueryInterface = function _jQueryInterface(option, argument) { 2705 if (this.length === 1) { 2706 return TempusDominusBootstrap4._jQueryHandleThis(this[0], option, argument); 2707 } 2708 return this.each(function () { 2709 TempusDominusBootstrap4._jQueryHandleThis(this, option, argument); 2710 }); 2711 }; 2712 2713 return TempusDominusBootstrap4; 2714 }(DateTimePicker); 2715 2716 /** 2717 * ------------------------------------------------------------------------ 2718 * jQuery 2719 * ------------------------------------------------------------------------ 2720 */ 2721 2722 2723 $(document).on(DateTimePicker.Event.CLICK_DATA_API, DateTimePicker.Selector.DATA_TOGGLE, function () { 2724 var $target = getSelectorFromElement($(this)); 2725 if ($target.length === 0) { 2726 return; 2727 } 2728 TempusDominusBootstrap4._jQueryInterface.call($target, 'toggle'); 2729 }).on(DateTimePicker.Event.CHANGE, '.' + DateTimePicker.ClassName.INPUT, function (event) { 2730 var $target = getSelectorFromElement($(this)); 2731 if ($target.length === 0) { 2732 return; 2733 } 2734 TempusDominusBootstrap4._jQueryInterface.call($target, '_change', event); 2735 }).on(DateTimePicker.Event.BLUR, '.' + DateTimePicker.ClassName.INPUT, function (event) { 2736 var $target = getSelectorFromElement($(this)), 2737 config = $target.data(DateTimePicker.DATA_KEY); 2738 if ($target.length === 0) { 2739 return; 2740 } 2741 if (config._options.debug || window.debug) { 2742 return; 2743 } 2744 TempusDominusBootstrap4._jQueryInterface.call($target, 'hide', event); 2745 }).on(DateTimePicker.Event.KEYDOWN, '.' + DateTimePicker.ClassName.INPUT, function (event) { 2746 var $target = getSelectorFromElement($(this)); 2747 if ($target.length === 0) { 2748 return; 2749 } 2750 TempusDominusBootstrap4._jQueryInterface.call($target, '_keydown', event); 2751 }).on(DateTimePicker.Event.KEYUP, '.' + DateTimePicker.ClassName.INPUT, function (event) { 2752 var $target = getSelectorFromElement($(this)); 2753 if ($target.length === 0) { 2754 return; 2755 } 2756 TempusDominusBootstrap4._jQueryInterface.call($target, '_keyup', event); 2757 }).on(DateTimePicker.Event.FOCUS, '.' + DateTimePicker.ClassName.INPUT, function (event) { 2758 var $target = getSelectorFromElement($(this)), 2759 config = $target.data(DateTimePicker.DATA_KEY); 2760 if ($target.length === 0) { 2761 return; 2762 } 2763 if (!config._options.allowInputToggle) { 2764 return; 2765 } 2766 TempusDominusBootstrap4._jQueryInterface.call($target, 'show', event); 2767 });
2768 2769 $.fn[DateTimePicker.NAME] = TempusDominusBootstrap4._jQueryInterface; 2770 $.fn[DateTimePicker.NAME].Constructor = TempusDominusBootstrap4; 2771 $.fn[DateTimePicker.NAME].noConflict = function () { 2772 $.fn[DateTimePicker.NAME] = JQUERY_NO_CONFLICT; 2773 return TempusDominusBootstrap4._jQueryInterface; 2774 }; 2775 2776 return TempusDominusBootstrap4; 2777}(jQuery); 2778 2779}(); 2780 2781jQuery(document).ready(function () { 2782 2783 2784$.fn.datetimepicker.Constructor.Default = $.extend({}, $.fn.datetimepicker.Constructor.Default, { 2785 widgetPositioning: { 2786 vertical: 'bottom' 2787 }, 2788 icons: { 2789 time: 'far fa-clock', 2790 date: 'far fa-calendar-alt', 2791 up: 'fas fa-arrow-up', 2792 down: 'fas fa-arrow-down', 2793 previous: 'fas fa-chevron-left', 2794 next: 'fas fa-chevron-right', 2795 today: 'far fa-calendar-check', 2796 clear: 'far fa-trash-alt', 2797 close: 'fas fa-times' 2798 } }); 2799 2800});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.