LaravelTest
3505 строк · 107.2 Кб
1/*!@preserve
2* Tempus Dominus Bootstrap4 v5.39.0 (https://tempusdominus.github.io/bootstrap-4/)
3* Copyright 2016-2020 Jonathan Peterson and contributors
4* Licensed under MIT (https://github.com/tempusdominus/bootstrap-3/blob/master/LICENSE)
5*/
6
7if (typeof jQuery === 'undefined') {8throw new Error('Tempus Dominus Bootstrap4\'s requires jQuery. jQuery must be included before Tempus Dominus Bootstrap4\'s JavaScript.');9}
10
11+function ($) {12var version = $.fn.jquery.split(' ')[0].split('.');13if ((version[0] < 2 && version[1] < 9) || (version[0] === 1 && version[1] === 9 && version[2] < 1) || (version[0] >= 4)) {14throw 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') {20throw new Error('Tempus Dominus Bootstrap4\'s requires moment.js. Moment.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)) {25throw new Error('Tempus Dominus Bootstrap4\'s requires at least moment.js v2.17.0 but less than v3.0.0');26}
27
28+function () {29
30function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }31
32function _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); } }33
34function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }35
36// ReSharper disable once InconsistentNaming
37var DateTimePicker = function ($, moment) {38function escapeRegExp(text) {39return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');40}41
42function isValidDate(date) {43return Object.prototype.toString.call(date) === '[object Date]' && !isNaN(date.getTime());44}45
46function isValidDateTimeStr(str) {47return isValidDate(new Date(str));48} // ReSharper disable InconsistentNaming49
50
51var trim = function trim(str) {52return str.replace(/(^\s+)|(\s+$)/g, '');53},54NAME = 'datetimepicker',55DATA_KEY = "" + NAME,56EVENT_KEY = "." + DATA_KEY,57DATA_API_KEY = '.data-api',58Selector = {59DATA_TOGGLE: "[data-toggle=\"" + DATA_KEY + "\"]"60},61ClassName = {62INPUT: NAME + "-input"63},64Event = {65CHANGE: "change" + EVENT_KEY,66BLUR: "blur" + EVENT_KEY,67KEYUP: "keyup" + EVENT_KEY,68KEYDOWN: "keydown" + EVENT_KEY,69FOCUS: "focus" + EVENT_KEY,70CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY,71//emitted72UPDATE: "update" + EVENT_KEY,73ERROR: "error" + EVENT_KEY,74HIDE: "hide" + EVENT_KEY,75SHOW: "show" + EVENT_KEY76},77DatePickerModes = [{78CLASS_NAME: 'days',79NAV_FUNCTION: 'M',80NAV_STEP: 181}, {82CLASS_NAME: 'months',83NAV_FUNCTION: 'y',84NAV_STEP: 185}, {86CLASS_NAME: 'years',87NAV_FUNCTION: 'y',88NAV_STEP: 1089}, {90CLASS_NAME: 'decades',91NAV_FUNCTION: 'y',92NAV_STEP: 10093}],94KeyMap = {95'up': 38,9638: 'up',97'down': 40,9840: 'down',99'left': 37,10037: 'left',101'right': 39,10239: 'right',103'tab': 9,1049: 'tab',105'escape': 27,10627: 'escape',107'enter': 13,10813: 'enter',109'pageUp': 33,11033: 'pageUp',111'pageDown': 34,11234: 'pageDown',113'shift': 16,11416: 'shift',115'control': 17,11617: 'control',117'space': 32,11832: 'space',119't': 84,12084: 't',121'delete': 46,12246: 'delete'123},124ViewModes = ['times', 'days', 'months', 'years', 'decades'],125keyState = {},126keyPressHandled = {},127optionsSortMap = {128timeZone: -39,129format: -38,130dayViewHeaderFormat: -37,131extraFormats: -36,132stepping: -35,133minDate: -34,134maxDate: -33,135useCurrent: -32,136collapse: -31,137locale: -30,138defaultDate: -29,139disabledDates: -28,140enabledDates: -27,141icons: -26,142tooltips: -25,143useStrict: -24,144sideBySide: -23,145daysOfWeekDisabled: -22,146calendarWeeks: -21,147viewMode: -20,148toolbarPlacement: -19,149buttons: -18,150widgetPositioning: -17,151widgetParent: -16,152ignoreReadonly: -15,153keepOpen: -14,154focusOnShow: -13,155inline: -12,156keepInvalid: -11,157keyBinds: -10,158debug: -9,159allowInputToggle: -8,160disabledTimeIntervals: -7,161disabledHours: -6,162enabledHours: -5,163viewDate: -4,164allowMultidate: -3,165multidateSeparator: -2,166updateOnlyThroughDateOption: -1,167date: 1168},169defaultFeatherIcons = {170time: 'clock',171date: 'calendar',172up: 'arrow-up',173down: 'arrow-down',174previous: 'arrow-left',175next: 'arrow-right',176today: 'arrow-down-circle',177clear: 'trash-2',178close: 'x'179};180
181function optionsSortFn(optionKeyA, optionKeyB) {182if (optionsSortMap[optionKeyA] && optionsSortMap[optionKeyB]) {183if (optionsSortMap[optionKeyA] < 0 && optionsSortMap[optionKeyB] < 0) {184return Math.abs(optionsSortMap[optionKeyB]) - Math.abs(optionsSortMap[optionKeyA]);185} else if (optionsSortMap[optionKeyA] < 0) {186return -1;187} else if (optionsSortMap[optionKeyB] < 0) {188return 1;189}190
191return optionsSortMap[optionKeyA] - optionsSortMap[optionKeyB];192} else if (optionsSortMap[optionKeyA]) {193return optionsSortMap[optionKeyA];194} else if (optionsSortMap[optionKeyB]) {195return optionsSortMap[optionKeyB];196}197
198return 0;199}200
201var Default = {202timeZone: '',203format: false,204dayViewHeaderFormat: 'MMMM YYYY',205extraFormats: false,206stepping: 1,207minDate: false,208maxDate: false,209useCurrent: true,210collapse: true,211locale: moment.locale(),212defaultDate: false,213disabledDates: false,214enabledDates: false,215icons: {216type: 'class',217time: 'fa fa-clock-o',218date: 'fa fa-calendar',219up: 'fa fa-arrow-up',220down: 'fa fa-arrow-down',221previous: 'fa fa-chevron-left',222next: 'fa fa-chevron-right',223today: 'fa fa-calendar-check-o',224clear: 'fa fa-trash',225close: 'fa fa-times'226},227tooltips: {228today: 'Go to today',229clear: 'Clear selection',230close: 'Close the picker',231selectMonth: 'Select Month',232prevMonth: 'Previous Month',233nextMonth: 'Next Month',234selectYear: 'Select Year',235prevYear: 'Previous Year',236nextYear: 'Next Year',237selectDecade: 'Select Decade',238prevDecade: 'Previous Decade',239nextDecade: 'Next Decade',240prevCentury: 'Previous Century',241nextCentury: 'Next Century',242pickHour: 'Pick Hour',243incrementHour: 'Increment Hour',244decrementHour: 'Decrement Hour',245pickMinute: 'Pick Minute',246incrementMinute: 'Increment Minute',247decrementMinute: 'Decrement Minute',248pickSecond: 'Pick Second',249incrementSecond: 'Increment Second',250decrementSecond: 'Decrement Second',251togglePeriod: 'Toggle Period',252selectTime: 'Select Time',253selectDate: 'Select Date'254},255useStrict: false,256sideBySide: false,257daysOfWeekDisabled: false,258calendarWeeks: false,259viewMode: 'days',260toolbarPlacement: 'default',261buttons: {262showToday: false,263showClear: false,264showClose: false265},266widgetPositioning: {267horizontal: 'auto',268vertical: 'auto'269},270widgetParent: null,271readonly: false,272ignoreReadonly: false,273keepOpen: false,274focusOnShow: true,275inline: false,276keepInvalid: false,277keyBinds: {278up: function up() {279if (!this.widget) {280return false;281}282
283var d = this._dates[0] || this.getMoment();284
285if (this.widget.find('.datepicker').is(':visible')) {286this.date(d.clone().subtract(7, 'd'));287} else {288this.date(d.clone().add(this.stepping(), 'm'));289}290
291return true;292},293down: function down() {294if (!this.widget) {295this.show();296return false;297}298
299var d = this._dates[0] || this.getMoment();300
301if (this.widget.find('.datepicker').is(':visible')) {302this.date(d.clone().add(7, 'd'));303} else {304this.date(d.clone().subtract(this.stepping(), 'm'));305}306
307return true;308},309'control up': function controlUp() {310if (!this.widget) {311return false;312}313
314var d = this._dates[0] || this.getMoment();315
316if (this.widget.find('.datepicker').is(':visible')) {317this.date(d.clone().subtract(1, 'y'));318} else {319this.date(d.clone().add(1, 'h'));320}321
322return true;323},324'control down': function controlDown() {325if (!this.widget) {326return false;327}328
329var d = this._dates[0] || this.getMoment();330
331if (this.widget.find('.datepicker').is(':visible')) {332this.date(d.clone().add(1, 'y'));333} else {334this.date(d.clone().subtract(1, 'h'));335}336
337return true;338},339left: function left() {340if (!this.widget) {341return false;342}343
344var d = this._dates[0] || this.getMoment();345
346if (this.widget.find('.datepicker').is(':visible')) {347this.date(d.clone().subtract(1, 'd'));348}349
350return true;351},352right: function right() {353if (!this.widget) {354return false;355}356
357var d = this._dates[0] || this.getMoment();358
359if (this.widget.find('.datepicker').is(':visible')) {360this.date(d.clone().add(1, 'd'));361}362
363return true;364},365pageUp: function pageUp() {366if (!this.widget) {367return false;368}369
370var d = this._dates[0] || this.getMoment();371
372if (this.widget.find('.datepicker').is(':visible')) {373this.date(d.clone().subtract(1, 'M'));374}375
376return true;377},378pageDown: function pageDown() {379if (!this.widget) {380return false;381}382
383var d = this._dates[0] || this.getMoment();384
385if (this.widget.find('.datepicker').is(':visible')) {386this.date(d.clone().add(1, 'M'));387}388
389return true;390},391enter: function enter() {392if (!this.widget) {393return false;394}395
396this.hide();397return true;398},399escape: function escape() {400if (!this.widget) {401return false;402}403
404this.hide();405return true;406},407'control space': function controlSpace() {408if (!this.widget) {409return false;410}411
412if (this.widget.find('.timepicker').is(':visible')) {413this.widget.find('.btn[data-action="togglePeriod"]').click();414}415
416return true;417},418t: function t() {419if (!this.widget) {420return false;421}422
423this.date(this.getMoment());424return true;425},426'delete': function _delete() {427if (!this.widget) {428return false;429}430
431this.clear();432return true;433}434},435debug: false,436allowInputToggle: false,437disabledTimeIntervals: false,438disabledHours: false,439enabledHours: false,440viewDate: false,441allowMultidate: false,442multidateSeparator: ', ',443updateOnlyThroughDateOption: false,444promptTimeOnDateChange: false,445promptTimeOnDateChangeTransitionDelay: 200446}; // ReSharper restore InconsistentNaming447// ReSharper disable once DeclarationHides448// ReSharper disable once InconsistentNaming449
450var DateTimePicker = /*#__PURE__*/function () {451/** @namespace eData.dateOptions */452
453/** @namespace moment.tz */454function DateTimePicker(element, options) {455this._options = this._getOptions(options);456this._element = element;457this._dates = [];458this._datesFormatted = [];459this._viewDate = null;460this.unset = true;461this.component = false;462this.widget = false;463this.use24Hours = null;464this.actualFormat = null;465this.parseFormats = null;466this.currentViewMode = null;467this.MinViewModeNumber = 0;468this.isInitFormatting = false;469this.isInit = false;470this.isDateUpdateThroughDateOptionFromClientCode = false;471this.hasInitDate = false;472this.initDate = void 0;473this._notifyChangeEventContext = void 0;474this._currentPromptTimeTimeout = null;475
476this._int();477}478/**479* @return {string}
480*/
481
482
483var _proto = DateTimePicker.prototype;484
485//private486_proto._int = function _int() {487this.isInit = true;488
489var targetInput = this._element.data('target-input');490
491if (this._element.is('input')) {492this.input = this._element;493} else if (targetInput !== undefined) {494if (targetInput === 'nearest') {495this.input = this._element.find('input');496} else {497this.input = $(targetInput);498}499}500
501this._dates = [];502this._dates[0] = this.getMoment();503this._viewDate = this.getMoment().clone();504$.extend(true, this._options, this._dataToOptions());505this.hasInitDate = false;506this.initDate = void 0;507this.options(this._options);508this.isInitFormatting = true;509
510this._initFormatting();511
512this.isInitFormatting = false;513
514if (this.input !== undefined && this.input.is('input') && this.input.val().trim().length !== 0) {515this._setValue(this._parseInputDate(this.input.val().trim()), 0);516} else if (this._options.defaultDate && this.input !== undefined && this.input.attr('placeholder') === undefined) {517this._setValue(this._options.defaultDate, 0);518}519
520if (this.hasInitDate) {521this.date(this.initDate);522}523
524if (this._options.inline) {525this.show();526}527
528this.isInit = false;529};530
531_proto._update = function _update() {532if (!this.widget) {533return;534}535
536this._fillDate();537
538this._fillTime();539};540
541_proto._setValue = function _setValue(targetMoment, index) {542var noIndex = typeof index === 'undefined',543isClear = !targetMoment && noIndex,544isDateUpdateThroughDateOptionFromClientCode = this.isDateUpdateThroughDateOptionFromClientCode,545isNotAllowedProgrammaticUpdate = !this.isInit && this._options.updateOnlyThroughDateOption && !isDateUpdateThroughDateOptionFromClientCode;546var outpValue = '',547isInvalid = false,548oldDate = this.unset ? null : this._dates[index];549
550if (!oldDate && !this.unset && noIndex && isClear) {551oldDate = this._dates[this._dates.length - 1];552} // case of calling setValue(null or false)553
554
555if (!targetMoment) {556if (isNotAllowedProgrammaticUpdate) {557this._notifyEvent({558type: DateTimePicker.Event.CHANGE,559date: targetMoment,560oldDate: oldDate,561isClear: isClear,562isInvalid: isInvalid,563isDateUpdateThroughDateOptionFromClientCode: isDateUpdateThroughDateOptionFromClientCode,564isInit: this.isInit565});566
567return;568}569
570if (!this._options.allowMultidate || this._dates.length === 1 || isClear) {571this.unset = true;572this._dates = [];573this._datesFormatted = [];574} else {575outpValue = "" + this._element.data('date') + this._options.multidateSeparator;576outpValue = oldDate && outpValue.replace("" + oldDate.format(this.actualFormat) + this._options.multidateSeparator, '').replace("" + this._options.multidateSeparator + this._options.multidateSeparator, '').replace(new RegExp(escapeRegExp(this._options.multidateSeparator) + "\\s*$"), '') || '';577
578this._dates.splice(index, 1);579
580this._datesFormatted.splice(index, 1);581}582
583outpValue = trim(outpValue);584
585if (this.input !== undefined) {586this.input.val(outpValue);587this.input.trigger('input');588}589
590this._element.data('date', outpValue);591
592this._notifyEvent({593type: DateTimePicker.Event.CHANGE,594date: false,595oldDate: oldDate,596isClear: isClear,597isInvalid: isInvalid,598isDateUpdateThroughDateOptionFromClientCode: isDateUpdateThroughDateOptionFromClientCode,599isInit: this.isInit600});601
602this._update();603
604return;605}606
607targetMoment = targetMoment.clone().locale(this._options.locale);608
609if (this._hasTimeZone()) {610targetMoment.tz(this._options.timeZone);611}612
613if (this._options.stepping !== 1) {614targetMoment.minutes(Math.round(targetMoment.minutes() / this._options.stepping) * this._options.stepping).seconds(0);615}616
617if (this._isValid(targetMoment)) {618if (isNotAllowedProgrammaticUpdate) {619this._notifyEvent({620type: DateTimePicker.Event.CHANGE,621date: targetMoment.clone(),622oldDate: oldDate,623isClear: isClear,624isInvalid: isInvalid,625isDateUpdateThroughDateOptionFromClientCode: isDateUpdateThroughDateOptionFromClientCode,626isInit: this.isInit627});628
629return;630}631
632this._dates[index] = targetMoment;633this._datesFormatted[index] = targetMoment.format('YYYY-MM-DD');634this._viewDate = targetMoment.clone();635
636if (this._options.allowMultidate && this._dates.length > 1) {637for (var i = 0; i < this._dates.length; i++) {638outpValue += "" + this._dates[i].format(this.actualFormat) + this._options.multidateSeparator;639}640
641outpValue = outpValue.replace(new RegExp(this._options.multidateSeparator + "\\s*$"), '');642} else {643outpValue = this._dates[index].format(this.actualFormat);644}645
646outpValue = trim(outpValue);647
648if (this.input !== undefined) {649this.input.val(outpValue);650this.input.trigger('input');651}652
653this._element.data('date', outpValue);654
655this.unset = false;656
657this._update();658
659this._notifyEvent({660type: DateTimePicker.Event.CHANGE,661date: this._dates[index].clone(),662oldDate: oldDate,663isClear: isClear,664isInvalid: isInvalid,665isDateUpdateThroughDateOptionFromClientCode: isDateUpdateThroughDateOptionFromClientCode,666isInit: this.isInit667});668} else {669isInvalid = true;670
671if (!this._options.keepInvalid) {672if (this.input !== undefined) {673this.input.val("" + (this.unset ? '' : this._dates[index].format(this.actualFormat)));674this.input.trigger('input');675}676} else {677this._notifyEvent({678type: DateTimePicker.Event.CHANGE,679date: targetMoment,680oldDate: oldDate,681isClear: isClear,682isInvalid: isInvalid,683isDateUpdateThroughDateOptionFromClientCode: isDateUpdateThroughDateOptionFromClientCode,684isInit: this.isInit685});686}687
688this._notifyEvent({689type: DateTimePicker.Event.ERROR,690date: targetMoment,691oldDate: oldDate692});693}694};695
696_proto._change = function _change(e) {697var val = $(e.target).val().trim(),698parsedDate = val ? this._parseInputDate(val) : null;699
700this._setValue(parsedDate, 0);701
702e.stopImmediatePropagation();703return false;704} //noinspection JSMethodCanBeStatic705;706
707_proto._getOptions = function _getOptions(options) {708options = $.extend(true, {}, Default, options && options.icons && options.icons.type === 'feather' ? {709icons: defaultFeatherIcons710} : {}, options);711return options;712};713
714_proto._hasTimeZone = function _hasTimeZone() {715return moment.tz !== undefined && this._options.timeZone !== undefined && this._options.timeZone !== null && this._options.timeZone !== '';716};717
718_proto._isEnabled = function _isEnabled(granularity) {719if (typeof granularity !== 'string' || granularity.length > 1) {720throw new TypeError('isEnabled expects a single character string parameter');721}722
723switch (granularity) {724case 'y':725return this.actualFormat.indexOf('Y') !== -1;726
727case 'M':728return this.actualFormat.indexOf('M') !== -1;729
730case 'd':731return this.actualFormat.toLowerCase().indexOf('d') !== -1;732
733case 'h':734case 'H':735return this.actualFormat.toLowerCase().indexOf('h') !== -1;736
737case 'm':738return this.actualFormat.indexOf('m') !== -1;739
740case 's':741return this.actualFormat.indexOf('s') !== -1;742
743case 'a':744case 'A':745return this.actualFormat.toLowerCase().indexOf('a') !== -1;746
747default:748return false;749}750};751
752_proto._hasTime = function _hasTime() {753return this._isEnabled('h') || this._isEnabled('m') || this._isEnabled('s');754};755
756_proto._hasDate = function _hasDate() {757return this._isEnabled('y') || this._isEnabled('M') || this._isEnabled('d');758};759
760_proto._dataToOptions = function _dataToOptions() {761var eData = this._element.data();762
763var dataOptions = {};764
765if (eData.dateOptions && eData.dateOptions instanceof Object) {766dataOptions = $.extend(true, dataOptions, eData.dateOptions);767}768
769$.each(this._options, function (key) {770var attributeName = "date" + key.charAt(0).toUpperCase() + key.slice(1); //todo data api key771
772if (eData[attributeName] !== undefined) {773dataOptions[key] = eData[attributeName];774} else {775delete dataOptions[key];776}777});778return dataOptions;779};780
781_proto._format = function _format() {782return this._options.format || 'YYYY-MM-DD HH:mm';783};784
785_proto._areSameDates = function _areSameDates(a, b) {786var format = this._format();787
788return a && b && (a.isSame(b) || moment(a.format(format), format).isSame(moment(b.format(format), format)));789};790
791_proto._notifyEvent = function _notifyEvent(e) {792if (e.type === DateTimePicker.Event.CHANGE) {793this._notifyChangeEventContext = this._notifyChangeEventContext || 0;794this._notifyChangeEventContext++;795
796if (e.date && this._areSameDates(e.date, e.oldDate) || !e.isClear && !e.date && !e.oldDate || this._notifyChangeEventContext > 1) {797this._notifyChangeEventContext = void 0;798return;799}800
801this._handlePromptTimeIfNeeded(e);802}803
804this._element.trigger(e);805
806this._notifyChangeEventContext = void 0;807};808
809_proto._handlePromptTimeIfNeeded = function _handlePromptTimeIfNeeded(e) {810if (this._options.promptTimeOnDateChange) {811if (!e.oldDate && this._options.useCurrent) {812// First time ever. If useCurrent option is set to true (default), do nothing813// because the first date is selected automatically.814return;815} else if (e.oldDate && e.date && (e.oldDate.format('YYYY-MM-DD') === e.date.format('YYYY-MM-DD') || e.oldDate.format('YYYY-MM-DD') !== e.date.format('YYYY-MM-DD') && e.oldDate.format('HH:mm:ss') !== e.date.format('HH:mm:ss'))) {816// Date didn't change (time did) or date changed because time did.817return;818}819
820var that = this;821clearTimeout(this._currentPromptTimeTimeout);822this._currentPromptTimeTimeout = setTimeout(function () {823if (that.widget) {824that.widget.find('[data-action="togglePicker"]').click();825}826}, this._options.promptTimeOnDateChangeTransitionDelay);827}828};829
830_proto._viewUpdate = function _viewUpdate(e) {831if (e === 'y') {832e = 'YYYY';833}834
835this._notifyEvent({836type: DateTimePicker.Event.UPDATE,837change: e,838viewDate: this._viewDate.clone()839});840};841
842_proto._showMode = function _showMode(dir) {843if (!this.widget) {844return;845}846
847if (dir) {848this.currentViewMode = Math.max(this.MinViewModeNumber, Math.min(3, this.currentViewMode + dir));849}850
851this.widget.find('.datepicker > div').hide().filter(".datepicker-" + DatePickerModes[this.currentViewMode].CLASS_NAME).show();852};853
854_proto._isInDisabledDates = function _isInDisabledDates(testDate) {855return this._options.disabledDates[testDate.format('YYYY-MM-DD')] === true;856};857
858_proto._isInEnabledDates = function _isInEnabledDates(testDate) {859return this._options.enabledDates[testDate.format('YYYY-MM-DD')] === true;860};861
862_proto._isInDisabledHours = function _isInDisabledHours(testDate) {863return this._options.disabledHours[testDate.format('H')] === true;864};865
866_proto._isInEnabledHours = function _isInEnabledHours(testDate) {867return this._options.enabledHours[testDate.format('H')] === true;868};869
870_proto._isValid = function _isValid(targetMoment, granularity) {871if (!targetMoment || !targetMoment.isValid()) {872return false;873}874
875if (this._options.disabledDates && granularity === 'd' && this._isInDisabledDates(targetMoment)) {876return false;877}878
879if (this._options.enabledDates && granularity === 'd' && !this._isInEnabledDates(targetMoment)) {880return false;881}882
883if (this._options.minDate && targetMoment.isBefore(this._options.minDate, granularity)) {884return false;885}886
887if (this._options.maxDate && targetMoment.isAfter(this._options.maxDate, granularity)) {888return false;889}890
891if (this._options.daysOfWeekDisabled && granularity === 'd' && this._options.daysOfWeekDisabled.indexOf(targetMoment.day()) !== -1) {892return false;893}894
895if (this._options.disabledHours && (granularity === 'h' || granularity === 'm' || granularity === 's') && this._isInDisabledHours(targetMoment)) {896return false;897}898
899if (this._options.enabledHours && (granularity === 'h' || granularity === 'm' || granularity === 's') && !this._isInEnabledHours(targetMoment)) {900return false;901}902
903if (this._options.disabledTimeIntervals && (granularity === 'h' || granularity === 'm' || granularity === 's')) {904var found = false;905$.each(this._options.disabledTimeIntervals, function () {906if (targetMoment.isBetween(this[0], this[1])) {907found = true;908return false;909}910});911
912if (found) {913return false;914}915}916
917return true;918};919
920_proto._parseInputDate = function _parseInputDate(inputDate, _temp) {921var _ref = _temp === void 0 ? {} : _temp,922_ref$isPickerShow = _ref.isPickerShow,923isPickerShow = _ref$isPickerShow === void 0 ? false : _ref$isPickerShow;924
925if (this._options.parseInputDate === undefined || isPickerShow) {926if (!moment.isMoment(inputDate)) {927inputDate = this.getMoment(inputDate);928}929} else {930inputDate = this._options.parseInputDate(inputDate);931} //inputDate.locale(this.options.locale);932
933
934return inputDate;935};936
937_proto._keydown = function _keydown(e) {938var handler = null,939index,940index2,941keyBindKeys,942allModifiersPressed;943var pressedKeys = [],944pressedModifiers = {},945currentKey = e.which,946pressed = 'p';947keyState[currentKey] = pressed;948
949for (index in keyState) {950if (keyState.hasOwnProperty(index) && keyState[index] === pressed) {951pressedKeys.push(index);952
953if (parseInt(index, 10) !== currentKey) {954pressedModifiers[index] = true;955}956}957}958
959for (index in this._options.keyBinds) {960if (this._options.keyBinds.hasOwnProperty(index) && typeof this._options.keyBinds[index] === 'function') {961keyBindKeys = index.split(' ');962
963if (keyBindKeys.length === pressedKeys.length && KeyMap[currentKey] === keyBindKeys[keyBindKeys.length - 1]) {964allModifiersPressed = true;965
966for (index2 = keyBindKeys.length - 2; index2 >= 0; index2--) {967if (!(KeyMap[keyBindKeys[index2]] in pressedModifiers)) {968allModifiersPressed = false;969break;970}971}972
973if (allModifiersPressed) {974handler = this._options.keyBinds[index];975break;976}977}978}979}980
981if (handler) {982if (handler.call(this)) {983e.stopPropagation();984e.preventDefault();985}986}987} //noinspection JSMethodCanBeStatic,SpellCheckingInspection988;989
990_proto._keyup = function _keyup(e) {991keyState[e.which] = 'r';992
993if (keyPressHandled[e.which]) {994keyPressHandled[e.which] = false;995e.stopPropagation();996e.preventDefault();997}998};999
1000_proto._indexGivenDates = function _indexGivenDates(givenDatesArray) {1001// Store given enabledDates and disabledDates as keys.1002// This way we can check their existence in O(1) time instead of looping through whole array.1003// (for example: options.enabledDates['2014-02-27'] === true)1004var givenDatesIndexed = {},1005self = this;1006$.each(givenDatesArray, function () {1007var dDate = self._parseInputDate(this);1008
1009if (dDate.isValid()) {1010givenDatesIndexed[dDate.format('YYYY-MM-DD')] = true;1011}1012});1013return Object.keys(givenDatesIndexed).length ? givenDatesIndexed : false;1014};1015
1016_proto._indexGivenHours = function _indexGivenHours(givenHoursArray) {1017// Store given enabledHours and disabledHours as keys.1018// This way we can check their existence in O(1) time instead of looping through whole array.1019// (for example: options.enabledHours['2014-02-27'] === true)1020var givenHoursIndexed = {};1021$.each(givenHoursArray, function () {1022givenHoursIndexed[this] = true;1023});1024return Object.keys(givenHoursIndexed).length ? givenHoursIndexed : false;1025};1026
1027_proto._initFormatting = function _initFormatting() {1028var format = this._options.format || 'L LT',1029self = this;1030this.actualFormat = format.replace(/(\[[^\[]*])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g, function (formatInput) {1031return (self.isInitFormatting && self._options.date === null ? self.getMoment() : self._dates[0]).localeData().longDateFormat(formatInput) || formatInput; //todo taking the first date should be ok1032});1033this.parseFormats = this._options.extraFormats ? this._options.extraFormats.slice() : [];1034
1035if (this.parseFormats.indexOf(format) < 0 && this.parseFormats.indexOf(this.actualFormat) < 0) {1036this.parseFormats.push(this.actualFormat);1037}1038
1039this.use24Hours = this.actualFormat.toLowerCase().indexOf('a') < 1 && this.actualFormat.replace(/\[.*?]/g, '').indexOf('h') < 1;1040
1041if (this._isEnabled('y')) {1042this.MinViewModeNumber = 2;1043}1044
1045if (this._isEnabled('M')) {1046this.MinViewModeNumber = 1;1047}1048
1049if (this._isEnabled('d')) {1050this.MinViewModeNumber = 0;1051}1052
1053this.currentViewMode = Math.max(this.MinViewModeNumber, this.currentViewMode);1054
1055if (!this.unset) {1056this._setValue(this._dates[0], 0);1057}1058};1059
1060_proto._getLastPickedDate = function _getLastPickedDate() {1061var lastPickedDate = this._dates[this._getLastPickedDateIndex()];1062
1063if (!lastPickedDate && this._options.allowMultidate) {1064lastPickedDate = moment(new Date());1065}1066
1067return lastPickedDate;1068};1069
1070_proto._getLastPickedDateIndex = function _getLastPickedDateIndex() {1071return this._dates.length - 1;1072} //public1073;1074
1075_proto.getMoment = function getMoment(d) {1076var returnMoment;1077
1078if (d === undefined || d === null) {1079// TODO: Should this use format?1080returnMoment = moment().clone().locale(this._options.locale);1081} else if (this._hasTimeZone()) {1082// There is a string to parse and a default time zone1083// parse with the tz function which takes a default time zone if it is not in the format string1084returnMoment = moment.tz(d, this.parseFormats, this._options.locale, this._options.useStrict, this._options.timeZone);1085} else {1086returnMoment = moment(d, this.parseFormats, this._options.locale, this._options.useStrict);1087}1088
1089if (this._hasTimeZone()) {1090returnMoment.tz(this._options.timeZone);1091}1092
1093return returnMoment;1094};1095
1096_proto.toggle = function toggle() {1097return this.widget ? this.hide() : this.show();1098};1099
1100_proto.readonly = function readonly(_readonly) {1101if (arguments.length === 0) {1102return this._options.readonly;1103}1104
1105if (typeof _readonly !== 'boolean') {1106throw new TypeError('readonly() expects a boolean parameter');1107}1108
1109this._options.readonly = _readonly;1110
1111if (this.input !== undefined) {1112this.input.prop('readonly', this._options.readonly);1113}1114
1115if (this.widget) {1116this.hide();1117this.show();1118}1119};1120
1121_proto.ignoreReadonly = function ignoreReadonly(_ignoreReadonly) {1122if (arguments.length === 0) {1123return this._options.ignoreReadonly;1124}1125
1126if (typeof _ignoreReadonly !== 'boolean') {1127throw new TypeError('ignoreReadonly() expects a boolean parameter');1128}1129
1130this._options.ignoreReadonly = _ignoreReadonly;1131};1132
1133_proto.options = function options(newOptions) {1134if (arguments.length === 0) {1135return $.extend(true, {}, this._options);1136}1137
1138if (!(newOptions instanceof Object)) {1139throw new TypeError('options() this.options parameter should be an object');1140}1141
1142$.extend(true, this._options, newOptions);1143var self = this,1144optionsKeys = Object.keys(this._options).sort(optionsSortFn);1145$.each(optionsKeys, function (i, key) {1146var value = self._options[key];1147
1148if (self[key] !== undefined) {1149if (self.isInit && key === 'date') {1150self.hasInitDate = true;1151self.initDate = value;1152return;1153}1154
1155self[key](value);1156}1157});1158};1159
1160_proto.date = function date(newDate, index) {1161index = index || 0;1162
1163if (arguments.length === 0) {1164if (this.unset) {1165return null;1166}1167
1168if (this._options.allowMultidate) {1169return this._dates.join(this._options.multidateSeparator);1170} else {1171return this._dates[index].clone();1172}1173}1174
1175if (newDate !== null && typeof newDate !== 'string' && !moment.isMoment(newDate) && !(newDate instanceof Date)) {1176throw new TypeError('date() parameter must be one of [null, string, moment or Date]');1177}1178
1179if (typeof newDate === 'string' && isValidDateTimeStr(newDate)) {1180newDate = new Date(newDate);1181}1182
1183this._setValue(newDate === null ? null : this._parseInputDate(newDate), index);1184};1185
1186_proto.updateOnlyThroughDateOption = function updateOnlyThroughDateOption(_updateOnlyThroughDateOption) {1187if (typeof _updateOnlyThroughDateOption !== 'boolean') {1188throw new TypeError('updateOnlyThroughDateOption() expects a boolean parameter');1189}1190
1191this._options.updateOnlyThroughDateOption = _updateOnlyThroughDateOption;1192};1193
1194_proto.format = function format(newFormat) {1195if (arguments.length === 0) {1196return this._options.format;1197}1198
1199if (typeof newFormat !== 'string' && (typeof newFormat !== 'boolean' || newFormat !== false)) {1200throw new TypeError("format() expects a string or boolean:false parameter " + newFormat);1201}1202
1203this._options.format = newFormat;1204
1205if (this.actualFormat) {1206this._initFormatting(); // reinitialize formatting1207
1208}1209};1210
1211_proto.timeZone = function timeZone(newZone) {1212if (arguments.length === 0) {1213return this._options.timeZone;1214}1215
1216if (typeof newZone !== 'string') {1217throw new TypeError('newZone() expects a string parameter');1218}1219
1220this._options.timeZone = newZone;1221};1222
1223_proto.dayViewHeaderFormat = function dayViewHeaderFormat(newFormat) {1224if (arguments.length === 0) {1225return this._options.dayViewHeaderFormat;1226}1227
1228if (typeof newFormat !== 'string') {1229throw new TypeError('dayViewHeaderFormat() expects a string parameter');1230}1231
1232this._options.dayViewHeaderFormat = newFormat;1233};1234
1235_proto.extraFormats = function extraFormats(formats) {1236if (arguments.length === 0) {1237return this._options.extraFormats;1238}1239
1240if (formats !== false && !(formats instanceof Array)) {1241throw new TypeError('extraFormats() expects an array or false parameter');1242}1243
1244this._options.extraFormats = formats;1245
1246if (this.parseFormats) {1247this._initFormatting(); // reinit formatting1248
1249}1250};1251
1252_proto.disabledDates = function disabledDates(dates) {1253if (arguments.length === 0) {1254return this._options.disabledDates ? $.extend({}, this._options.disabledDates) : this._options.disabledDates;1255}1256
1257if (!dates) {1258this._options.disabledDates = false;1259
1260this._update();1261
1262return true;1263}1264
1265if (!(dates instanceof Array)) {1266throw new TypeError('disabledDates() expects an array parameter');1267}1268
1269this._options.disabledDates = this._indexGivenDates(dates);1270this._options.enabledDates = false;1271
1272this._update();1273};1274
1275_proto.enabledDates = function enabledDates(dates) {1276if (arguments.length === 0) {1277return this._options.enabledDates ? $.extend({}, this._options.enabledDates) : this._options.enabledDates;1278}1279
1280if (!dates) {1281this._options.enabledDates = false;1282
1283this._update();1284
1285return true;1286}1287
1288if (!(dates instanceof Array)) {1289throw new TypeError('enabledDates() expects an array parameter');1290}1291
1292this._options.enabledDates = this._indexGivenDates(dates);1293this._options.disabledDates = false;1294
1295this._update();1296};1297
1298_proto.daysOfWeekDisabled = function daysOfWeekDisabled(_daysOfWeekDisabled) {1299if (arguments.length === 0) {1300return this._options.daysOfWeekDisabled.splice(0);1301}1302
1303if (typeof _daysOfWeekDisabled === 'boolean' && !_daysOfWeekDisabled) {1304this._options.daysOfWeekDisabled = false;1305
1306this._update();1307
1308return true;1309}1310
1311if (!(_daysOfWeekDisabled instanceof Array)) {1312throw new TypeError('daysOfWeekDisabled() expects an array parameter');1313}1314
1315this._options.daysOfWeekDisabled = _daysOfWeekDisabled.reduce(function (previousValue, currentValue) {1316currentValue = parseInt(currentValue, 10);1317
1318if (currentValue > 6 || currentValue < 0 || isNaN(currentValue)) {1319return previousValue;1320}1321
1322if (previousValue.indexOf(currentValue) === -1) {1323previousValue.push(currentValue);1324}1325
1326return previousValue;1327}, []).sort();1328
1329if (this._options.useCurrent && !this._options.keepInvalid) {1330for (var i = 0; i < this._dates.length; i++) {1331var tries = 0;1332
1333while (!this._isValid(this._dates[i], 'd')) {1334this._dates[i].add(1, 'd');1335
1336if (tries === 31) {1337throw 'Tried 31 times to find a valid date';1338}1339
1340tries++;1341}1342
1343this._setValue(this._dates[i], i);1344}1345}1346
1347this._update();1348};1349
1350_proto.maxDate = function maxDate(_maxDate) {1351if (arguments.length === 0) {1352return this._options.maxDate ? this._options.maxDate.clone() : this._options.maxDate;1353}1354
1355if (typeof _maxDate === 'boolean' && _maxDate === false) {1356this._options.maxDate = false;1357
1358this._update();1359
1360return true;1361}1362
1363if (typeof _maxDate === 'string') {1364if (_maxDate === 'now' || _maxDate === 'moment') {1365_maxDate = this.getMoment();1366}1367}1368
1369var parsedDate = this._parseInputDate(_maxDate);1370
1371if (!parsedDate.isValid()) {1372throw new TypeError("maxDate() Could not parse date parameter: " + _maxDate);1373}1374
1375if (this._options.minDate && parsedDate.isBefore(this._options.minDate)) {1376throw new TypeError("maxDate() date parameter is before this.options.minDate: " + parsedDate.format(this.actualFormat));1377}1378
1379this._options.maxDate = parsedDate;1380
1381for (var i = 0; i < this._dates.length; i++) {1382if (this._options.useCurrent && !this._options.keepInvalid && this._dates[i].isAfter(_maxDate)) {1383this._setValue(this._options.maxDate, i);1384}1385}1386
1387if (this._viewDate.isAfter(parsedDate)) {1388this._viewDate = parsedDate.clone().subtract(this._options.stepping, 'm');1389}1390
1391this._update();1392};1393
1394_proto.minDate = function minDate(_minDate) {1395if (arguments.length === 0) {1396return this._options.minDate ? this._options.minDate.clone() : this._options.minDate;1397}1398
1399if (typeof _minDate === 'boolean' && _minDate === false) {1400this._options.minDate = false;1401
1402this._update();1403
1404return true;1405}1406
1407if (typeof _minDate === 'string') {1408if (_minDate === 'now' || _minDate === 'moment') {1409_minDate = this.getMoment();1410}1411}1412
1413var parsedDate = this._parseInputDate(_minDate);1414
1415if (!parsedDate.isValid()) {1416throw new TypeError("minDate() Could not parse date parameter: " + _minDate);1417}1418
1419if (this._options.maxDate && parsedDate.isAfter(this._options.maxDate)) {1420throw new TypeError("minDate() date parameter is after this.options.maxDate: " + parsedDate.format(this.actualFormat));1421}1422
1423this._options.minDate = parsedDate;1424
1425for (var i = 0; i < this._dates.length; i++) {1426if (this._options.useCurrent && !this._options.keepInvalid && this._dates[i].isBefore(_minDate)) {1427this._setValue(this._options.minDate, i);1428}1429}1430
1431if (this._viewDate.isBefore(parsedDate)) {1432this._viewDate = parsedDate.clone().add(this._options.stepping, 'm');1433}1434
1435this._update();1436};1437
1438_proto.defaultDate = function defaultDate(_defaultDate) {1439if (arguments.length === 0) {1440return this._options.defaultDate ? this._options.defaultDate.clone() : this._options.defaultDate;1441}1442
1443if (!_defaultDate) {1444this._options.defaultDate = false;1445return true;1446}1447
1448if (typeof _defaultDate === 'string') {1449if (_defaultDate === 'now' || _defaultDate === 'moment') {1450_defaultDate = this.getMoment();1451} else {1452_defaultDate = this.getMoment(_defaultDate);1453}1454}1455
1456var parsedDate = this._parseInputDate(_defaultDate);1457
1458if (!parsedDate.isValid()) {1459throw new TypeError("defaultDate() Could not parse date parameter: " + _defaultDate);1460}1461
1462if (!this._isValid(parsedDate)) {1463throw new TypeError('defaultDate() date passed is invalid according to component setup validations');1464}1465
1466this._options.defaultDate = parsedDate;1467
1468if (this._options.defaultDate && this._options.inline || this.input !== undefined && this.input.val().trim() === '') {1469this._setValue(this._options.defaultDate, 0);1470}1471};1472
1473_proto.locale = function locale(_locale) {1474if (arguments.length === 0) {1475return this._options.locale;1476}1477
1478if (!moment.localeData(_locale)) {1479throw new TypeError("locale() locale " + _locale + " is not loaded from moment locales!");1480}1481
1482this._options.locale = _locale;1483
1484for (var i = 0; i < this._dates.length; i++) {1485this._dates[i].locale(this._options.locale);1486}1487
1488this._viewDate.locale(this._options.locale);1489
1490if (this.actualFormat) {1491this._initFormatting(); // reinitialize formatting1492
1493}1494
1495if (this.widget) {1496this.hide();1497this.show();1498}1499};1500
1501_proto.stepping = function stepping(_stepping) {1502if (arguments.length === 0) {1503return this._options.stepping;1504}1505
1506_stepping = parseInt(_stepping, 10);1507
1508if (isNaN(_stepping) || _stepping < 1) {1509_stepping = 1;1510}1511
1512this._options.stepping = _stepping;1513};1514
1515_proto.useCurrent = function useCurrent(_useCurrent) {1516var useCurrentOptions = ['year', 'month', 'day', 'hour', 'minute'];1517
1518if (arguments.length === 0) {1519return this._options.useCurrent;1520}1521
1522if (typeof _useCurrent !== 'boolean' && typeof _useCurrent !== 'string') {1523throw new TypeError('useCurrent() expects a boolean or string parameter');1524}1525
1526if (typeof _useCurrent === 'string' && useCurrentOptions.indexOf(_useCurrent.toLowerCase()) === -1) {1527throw new TypeError("useCurrent() expects a string parameter of " + useCurrentOptions.join(', '));1528}1529
1530this._options.useCurrent = _useCurrent;1531};1532
1533_proto.collapse = function collapse(_collapse) {1534if (arguments.length === 0) {1535return this._options.collapse;1536}1537
1538if (typeof _collapse !== 'boolean') {1539throw new TypeError('collapse() expects a boolean parameter');1540}1541
1542if (this._options.collapse === _collapse) {1543return true;1544}1545
1546this._options.collapse = _collapse;1547
1548if (this.widget) {1549this.hide();1550this.show();1551}1552};1553
1554_proto.icons = function icons(_icons) {1555if (arguments.length === 0) {1556return $.extend({}, this._options.icons);1557}1558
1559if (!(_icons instanceof Object)) {1560throw new TypeError('icons() expects parameter to be an Object');1561}1562
1563$.extend(this._options.icons, _icons);1564
1565if (this.widget) {1566this.hide();1567this.show();1568}1569};1570
1571_proto.tooltips = function tooltips(_tooltips) {1572if (arguments.length === 0) {1573return $.extend({}, this._options.tooltips);1574}1575
1576if (!(_tooltips instanceof Object)) {1577throw new TypeError('tooltips() expects parameter to be an Object');1578}1579
1580$.extend(this._options.tooltips, _tooltips);1581
1582if (this.widget) {1583this.hide();1584this.show();1585}1586};1587
1588_proto.useStrict = function useStrict(_useStrict) {1589if (arguments.length === 0) {1590return this._options.useStrict;1591}1592
1593if (typeof _useStrict !== 'boolean') {1594throw new TypeError('useStrict() expects a boolean parameter');1595}1596
1597this._options.useStrict = _useStrict;1598};1599
1600_proto.sideBySide = function sideBySide(_sideBySide) {1601if (arguments.length === 0) {1602return this._options.sideBySide;1603}1604
1605if (typeof _sideBySide !== 'boolean') {1606throw new TypeError('sideBySide() expects a boolean parameter');1607}1608
1609this._options.sideBySide = _sideBySide;1610
1611if (this.widget) {1612this.hide();1613this.show();1614}1615};1616
1617_proto.viewMode = function viewMode(_viewMode) {1618if (arguments.length === 0) {1619return this._options.viewMode;1620}1621
1622if (typeof _viewMode !== 'string') {1623throw new TypeError('viewMode() expects a string parameter');1624}1625
1626if (DateTimePicker.ViewModes.indexOf(_viewMode) === -1) {1627throw new TypeError("viewMode() parameter must be one of (" + DateTimePicker.ViewModes.join(', ') + ") value");1628}1629
1630this._options.viewMode = _viewMode;1631this.currentViewMode = Math.max(DateTimePicker.ViewModes.indexOf(_viewMode) - 1, this.MinViewModeNumber);1632
1633this._showMode();1634};1635
1636_proto.calendarWeeks = function calendarWeeks(_calendarWeeks) {1637if (arguments.length === 0) {1638return this._options.calendarWeeks;1639}1640
1641if (typeof _calendarWeeks !== 'boolean') {1642throw new TypeError('calendarWeeks() expects parameter to be a boolean value');1643}1644
1645this._options.calendarWeeks = _calendarWeeks;1646
1647this._update();1648};1649
1650_proto.buttons = function buttons(_buttons) {1651if (arguments.length === 0) {1652return $.extend({}, this._options.buttons);1653}1654
1655if (!(_buttons instanceof Object)) {1656throw new TypeError('buttons() expects parameter to be an Object');1657}1658
1659$.extend(this._options.buttons, _buttons);1660
1661if (typeof this._options.buttons.showToday !== 'boolean') {1662throw new TypeError('buttons.showToday expects a boolean parameter');1663}1664
1665if (typeof this._options.buttons.showClear !== 'boolean') {1666throw new TypeError('buttons.showClear expects a boolean parameter');1667}1668
1669if (typeof this._options.buttons.showClose !== 'boolean') {1670throw new TypeError('buttons.showClose expects a boolean parameter');1671}1672
1673if (this.widget) {1674this.hide();1675this.show();1676}1677};1678
1679_proto.keepOpen = function keepOpen(_keepOpen) {1680if (arguments.length === 0) {1681return this._options.keepOpen;1682}1683
1684if (typeof _keepOpen !== 'boolean') {1685throw new TypeError('keepOpen() expects a boolean parameter');1686}1687
1688this._options.keepOpen = _keepOpen;1689};1690
1691_proto.focusOnShow = function focusOnShow(_focusOnShow) {1692if (arguments.length === 0) {1693return this._options.focusOnShow;1694}1695
1696if (typeof _focusOnShow !== 'boolean') {1697throw new TypeError('focusOnShow() expects a boolean parameter');1698}1699
1700this._options.focusOnShow = _focusOnShow;1701};1702
1703_proto.inline = function inline(_inline) {1704if (arguments.length === 0) {1705return this._options.inline;1706}1707
1708if (typeof _inline !== 'boolean') {1709throw new TypeError('inline() expects a boolean parameter');1710}1711
1712this._options.inline = _inline;1713};1714
1715_proto.clear = function clear() {1716this._setValue(null); //todo1717
1718};1719
1720_proto.keyBinds = function keyBinds(_keyBinds) {1721if (arguments.length === 0) {1722return this._options.keyBinds;1723}1724
1725this._options.keyBinds = _keyBinds;1726};1727
1728_proto.debug = function debug(_debug) {1729if (typeof _debug !== 'boolean') {1730throw new TypeError('debug() expects a boolean parameter');1731}1732
1733this._options.debug = _debug;1734};1735
1736_proto.allowInputToggle = function allowInputToggle(_allowInputToggle) {1737if (arguments.length === 0) {1738return this._options.allowInputToggle;1739}1740
1741if (typeof _allowInputToggle !== 'boolean') {1742throw new TypeError('allowInputToggle() expects a boolean parameter');1743}1744
1745this._options.allowInputToggle = _allowInputToggle;1746};1747
1748_proto.keepInvalid = function keepInvalid(_keepInvalid) {1749if (arguments.length === 0) {1750return this._options.keepInvalid;1751}1752
1753if (typeof _keepInvalid !== 'boolean') {1754throw new TypeError('keepInvalid() expects a boolean parameter');1755}1756
1757this._options.keepInvalid = _keepInvalid;1758};1759
1760_proto.datepickerInput = function datepickerInput(_datepickerInput) {1761if (arguments.length === 0) {1762return this._options.datepickerInput;1763}1764
1765if (typeof _datepickerInput !== 'string') {1766throw new TypeError('datepickerInput() expects a string parameter');1767}1768
1769this._options.datepickerInput = _datepickerInput;1770};1771
1772_proto.parseInputDate = function parseInputDate(_parseInputDate2) {1773if (arguments.length === 0) {1774return this._options.parseInputDate;1775}1776
1777if (typeof _parseInputDate2 !== 'function') {1778throw new TypeError('parseInputDate() should be as function');1779}1780
1781this._options.parseInputDate = _parseInputDate2;1782};1783
1784_proto.disabledTimeIntervals = function disabledTimeIntervals(_disabledTimeIntervals) {1785if (arguments.length === 0) {1786return this._options.disabledTimeIntervals ? $.extend({}, this._options.disabledTimeIntervals) : this._options.disabledTimeIntervals;1787}1788
1789if (!_disabledTimeIntervals) {1790this._options.disabledTimeIntervals = false;1791
1792this._update();1793
1794return true;1795}1796
1797if (!(_disabledTimeIntervals instanceof Array)) {1798throw new TypeError('disabledTimeIntervals() expects an array parameter');1799}1800
1801this._options.disabledTimeIntervals = _disabledTimeIntervals;1802
1803this._update();1804};1805
1806_proto.disabledHours = function disabledHours(hours) {1807if (arguments.length === 0) {1808return this._options.disabledHours ? $.extend({}, this._options.disabledHours) : this._options.disabledHours;1809}1810
1811if (!hours) {1812this._options.disabledHours = false;1813
1814this._update();1815
1816return true;1817}1818
1819if (!(hours instanceof Array)) {1820throw new TypeError('disabledHours() expects an array parameter');1821}1822
1823this._options.disabledHours = this._indexGivenHours(hours);1824this._options.enabledHours = false;1825
1826if (this._options.useCurrent && !this._options.keepInvalid) {1827for (var i = 0; i < this._dates.length; i++) {1828var tries = 0;1829
1830while (!this._isValid(this._dates[i], 'h')) {1831this._dates[i].add(1, 'h');1832
1833if (tries === 24) {1834throw 'Tried 24 times to find a valid date';1835}1836
1837tries++;1838}1839
1840this._setValue(this._dates[i], i);1841}1842}1843
1844this._update();1845};1846
1847_proto.enabledHours = function enabledHours(hours) {1848if (arguments.length === 0) {1849return this._options.enabledHours ? $.extend({}, this._options.enabledHours) : this._options.enabledHours;1850}1851
1852if (!hours) {1853this._options.enabledHours = false;1854
1855this._update();1856
1857return true;1858}1859
1860if (!(hours instanceof Array)) {1861throw new TypeError('enabledHours() expects an array parameter');1862}1863
1864this._options.enabledHours = this._indexGivenHours(hours);1865this._options.disabledHours = false;1866
1867if (this._options.useCurrent && !this._options.keepInvalid) {1868for (var i = 0; i < this._dates.length; i++) {1869var tries = 0;1870
1871while (!this._isValid(this._dates[i], 'h')) {1872this._dates[i].add(1, 'h');1873
1874if (tries === 24) {1875throw 'Tried 24 times to find a valid date';1876}1877
1878tries++;1879}1880
1881this._setValue(this._dates[i], i);1882}1883}1884
1885this._update();1886};1887
1888_proto.viewDate = function viewDate(newDate) {1889if (arguments.length === 0) {1890return this._viewDate.clone();1891}1892
1893if (!newDate) {1894this._viewDate = (this._dates[0] || this.getMoment()).clone();1895return true;1896}1897
1898if (typeof newDate !== 'string' && !moment.isMoment(newDate) && !(newDate instanceof Date)) {1899throw new TypeError('viewDate() parameter must be one of [string, moment or Date]');1900}1901
1902this._viewDate = this._parseInputDate(newDate);1903
1904this._update();1905
1906this._viewUpdate(DatePickerModes[this.currentViewMode] && DatePickerModes[this.currentViewMode].NAV_FUNCTION);1907};1908
1909_proto._fillDate = function _fillDate() {};1910
1911_proto._useFeatherIcons = function _useFeatherIcons() {1912return this._options.icons.type === 'feather';1913};1914
1915_proto.allowMultidate = function allowMultidate(_allowMultidate) {1916if (typeof _allowMultidate !== 'boolean') {1917throw new TypeError('allowMultidate() expects a boolean parameter');1918}1919
1920this._options.allowMultidate = _allowMultidate;1921};1922
1923_proto.multidateSeparator = function multidateSeparator(_multidateSeparator) {1924if (arguments.length === 0) {1925return this._options.multidateSeparator;1926}1927
1928if (typeof _multidateSeparator !== 'string') {1929throw new TypeError('multidateSeparator expects a string parameter');1930}1931
1932this._options.multidateSeparator = _multidateSeparator;1933};1934
1935_createClass(DateTimePicker, null, [{1936key: "NAME",1937get: function get() {1938return NAME;1939}1940/**1941* @return {string}
1942*/
1943
1944}, {1945key: "DATA_KEY",1946get: function get() {1947return DATA_KEY;1948}1949/**1950* @return {string}
1951*/
1952
1953}, {1954key: "EVENT_KEY",1955get: function get() {1956return EVENT_KEY;1957}1958/**1959* @return {string}
1960*/
1961
1962}, {1963key: "DATA_API_KEY",1964get: function get() {1965return DATA_API_KEY;1966}1967}, {1968key: "DatePickerModes",1969get: function get() {1970return DatePickerModes;1971}1972}, {1973key: "ViewModes",1974get: function get() {1975return ViewModes;1976}1977}, {1978key: "Event",1979get: function get() {1980return Event;1981}1982}, {1983key: "Selector",1984get: function get() {1985return Selector;1986}1987}, {1988key: "Default",1989get: function get() {1990return Default;1991},1992set: function set(value) {1993Default = value;1994}1995}, {1996key: "ClassName",1997get: function get() {1998return ClassName;1999}2000}]);2001
2002return DateTimePicker;2003}();2004
2005return DateTimePicker;2006}(jQuery, moment); //noinspection JSUnusedGlobalSymbols2007
2008/* global DateTimePicker */
2009
2010/* global feather */
2011
2012
2013var TempusDominusBootstrap4 = function ($) {2014// eslint-disable-line no-unused-vars2015// ReSharper disable once InconsistentNaming2016var JQUERY_NO_CONFLICT = $.fn[DateTimePicker.NAME],2017verticalModes = ['top', 'bottom', 'auto'],2018horizontalModes = ['left', 'right', 'auto'],2019toolbarPlacements = ['default', 'top', 'bottom'],2020getSelectorFromElement = function getSelectorFromElement($element) {2021var selector = $element.data('target'),2022$selector;2023
2024if (!selector) {2025selector = $element.attr('href') || '';2026selector = /^#[a-z]/i.test(selector) ? selector : null;2027}2028
2029$selector = $(selector);2030
2031if ($selector.length === 0) {2032return $element;2033}2034
2035if (!$selector.data(DateTimePicker.DATA_KEY)) {2036$.extend({}, $selector.data(), $(this).data());2037}2038
2039return $selector;2040}; // ReSharper disable once InconsistentNaming2041
2042
2043var TempusDominusBootstrap4 = /*#__PURE__*/function (_DateTimePicker) {2044_inheritsLoose(TempusDominusBootstrap4, _DateTimePicker);2045
2046function TempusDominusBootstrap4(element, options) {2047var _this;2048
2049_this = _DateTimePicker.call(this, element, options) || this;2050
2051_this._init();2052
2053return _this;2054}2055
2056var _proto2 = TempusDominusBootstrap4.prototype;2057
2058_proto2._init = function _init() {2059if (this._element.hasClass('input-group')) {2060var datepickerButton = this._element.find('.datepickerbutton');2061
2062if (datepickerButton.length === 0) {2063this.component = this._element.find('[data-toggle="datetimepicker"]');2064} else {2065this.component = datepickerButton;2066}2067}2068};2069
2070_proto2._iconTag = function _iconTag(iconName) {2071if (typeof feather !== 'undefined' && this._useFeatherIcons() && feather.icons[iconName]) {2072return $('<span>').html(feather.icons[iconName].toSvg());2073} else {2074return $('<span>').addClass(iconName);2075}2076};2077
2078_proto2._getDatePickerTemplate = function _getDatePickerTemplate() {2079var headTemplate = $('<thead>').append($('<tr>').append($('<th>').addClass('prev').attr('data-action', 'previous').append(this._iconTag(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(this._iconTag(this._options.icons.next)))),2080contTemplate = $('<tbody>').append($('<tr>').append($('<td>').attr('colspan', "" + (this._options.calendarWeeks ? '8' : '7'))));2081return [$('<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()))];2082};2083
2084_proto2._getTimePickerMainTemplate = function _getTimePickerMainTemplate() {2085var topRow = $('<tr>'),2086middleRow = $('<tr>'),2087bottomRow = $('<tr>');2088
2089if (this._isEnabled('h')) {2090topRow.append($('<td>').append($('<a>').attr({2091href: '#',2092tabindex: '-1',2093'title': this._options.tooltips.incrementHour2094}).addClass('btn').attr('data-action', 'incrementHours').append(this._iconTag(this._options.icons.up))));2095middleRow.append($('<td>').append($('<span>').addClass('timepicker-hour').attr({2096'data-time-component': 'hours',2097'title': this._options.tooltips.pickHour2098}).attr('data-action', 'showHours')));2099bottomRow.append($('<td>').append($('<a>').attr({2100href: '#',2101tabindex: '-1',2102'title': this._options.tooltips.decrementHour2103}).addClass('btn').attr('data-action', 'decrementHours').append(this._iconTag(this._options.icons.down))));2104}2105
2106if (this._isEnabled('m')) {2107if (this._isEnabled('h')) {2108topRow.append($('<td>').addClass('separator'));2109middleRow.append($('<td>').addClass('separator').html(':'));2110bottomRow.append($('<td>').addClass('separator'));2111}2112
2113topRow.append($('<td>').append($('<a>').attr({2114href: '#',2115tabindex: '-1',2116'title': this._options.tooltips.incrementMinute2117}).addClass('btn').attr('data-action', 'incrementMinutes').append(this._iconTag(this._options.icons.up))));2118middleRow.append($('<td>').append($('<span>').addClass('timepicker-minute').attr({2119'data-time-component': 'minutes',2120'title': this._options.tooltips.pickMinute2121}).attr('data-action', 'showMinutes')));2122bottomRow.append($('<td>').append($('<a>').attr({2123href: '#',2124tabindex: '-1',2125'title': this._options.tooltips.decrementMinute2126}).addClass('btn').attr('data-action', 'decrementMinutes').append(this._iconTag(this._options.icons.down))));2127}2128
2129if (this._isEnabled('s')) {2130if (this._isEnabled('m')) {2131topRow.append($('<td>').addClass('separator'));2132middleRow.append($('<td>').addClass('separator').html(':'));2133bottomRow.append($('<td>').addClass('separator'));2134}2135
2136topRow.append($('<td>').append($('<a>').attr({2137href: '#',2138tabindex: '-1',2139'title': this._options.tooltips.incrementSecond2140}).addClass('btn').attr('data-action', 'incrementSeconds').append(this._iconTag(this._options.icons.up))));2141middleRow.append($('<td>').append($('<span>').addClass('timepicker-second').attr({2142'data-time-component': 'seconds',2143'title': this._options.tooltips.pickSecond2144}).attr('data-action', 'showSeconds')));2145bottomRow.append($('<td>').append($('<a>').attr({2146href: '#',2147tabindex: '-1',2148'title': this._options.tooltips.decrementSecond2149}).addClass('btn').attr('data-action', 'decrementSeconds').append(this._iconTag(this._options.icons.down))));2150}2151
2152if (!this.use24Hours) {2153topRow.append($('<td>').addClass('separator'));2154middleRow.append($('<td>').append($('<button>').addClass('btn btn-primary').attr({2155'data-action': 'togglePeriod',2156tabindex: '-1',2157'title': this._options.tooltips.togglePeriod2158})));2159bottomRow.append($('<td>').addClass('separator'));2160}2161
2162return $('<div>').addClass('timepicker-picker').append($('<table>').addClass('table-condensed').append([topRow, middleRow, bottomRow]));2163};2164
2165_proto2._getTimePickerTemplate = function _getTimePickerTemplate() {2166var hoursView = $('<div>').addClass('timepicker-hours').append($('<table>').addClass('table-condensed')),2167minutesView = $('<div>').addClass('timepicker-minutes').append($('<table>').addClass('table-condensed')),2168secondsView = $('<div>').addClass('timepicker-seconds').append($('<table>').addClass('table-condensed')),2169ret = [this._getTimePickerMainTemplate()];2170
2171if (this._isEnabled('h')) {2172ret.push(hoursView);2173}2174
2175if (this._isEnabled('m')) {2176ret.push(minutesView);2177}2178
2179if (this._isEnabled('s')) {2180ret.push(secondsView);2181}2182
2183return ret;2184};2185
2186_proto2._getToolbar = function _getToolbar() {2187var row = [];2188
2189if (this._options.buttons.showToday) {2190row.push($('<td>').append($('<a>').attr({2191href: '#',2192tabindex: '-1',2193'data-action': 'today',2194'title': this._options.tooltips.today2195}).append(this._iconTag(this._options.icons.today))));2196}2197
2198if (!this._options.sideBySide && this._options.collapse && this._hasDate() && this._hasTime()) {2199var title, icon;2200
2201if (this._options.viewMode === 'times') {2202title = this._options.tooltips.selectDate;2203icon = this._options.icons.date;2204} else {2205title = this._options.tooltips.selectTime;2206icon = this._options.icons.time;2207}2208
2209row.push($('<td>').append($('<a>').attr({2210href: '#',2211tabindex: '-1',2212'data-action': 'togglePicker',2213'title': title2214}).append(this._iconTag(icon))));2215}2216
2217if (this._options.buttons.showClear) {2218row.push($('<td>').append($('<a>').attr({2219href: '#',2220tabindex: '-1',2221'data-action': 'clear',2222'title': this._options.tooltips.clear2223}).append(this._iconTag(this._options.icons.clear))));2224}2225
2226if (this._options.buttons.showClose) {2227row.push($('<td>').append($('<a>').attr({2228href: '#',2229tabindex: '-1',2230'data-action': 'close',2231'title': this._options.tooltips.close2232}).append(this._iconTag(this._options.icons.close))));2233}2234
2235return row.length === 0 ? '' : $('<table>').addClass('table-condensed').append($('<tbody>').append($('<tr>').append(row)));2236};2237
2238_proto2._getTemplate = function _getTemplate() {2239var template = $('<div>').addClass(("bootstrap-datetimepicker-widget dropdown-menu " + (this._options.calendarWeeks ? 'tempusdominus-bootstrap-datetimepicker-widget-with-calendar-weeks' : '') + " " + ((this._useFeatherIcons() ? 'tempusdominus-bootstrap-datetimepicker-widget-with-feather-icons' : '') + " ")).trim()),2240dateView = $('<div>').addClass('datepicker').append(this._getDatePickerTemplate()),2241timeView = $('<div>').addClass('timepicker').append(this._getTimePickerTemplate()),2242content = $('<ul>').addClass('list-unstyled'),2243toolbar = $('<li>').addClass(("picker-switch" + (this._options.collapse ? ' accordion-toggle' : '') + " " + ("" + (this._useFeatherIcons() ? 'picker-switch-with-feathers-icons' : ''))).trim()).append(this._getToolbar());2244
2245if (this._options.inline) {2246template.removeClass('dropdown-menu');2247}2248
2249if (this.use24Hours) {2250template.addClass('usetwentyfour');2251}2252
2253if (this.input !== undefined && this.input.prop('readonly') || this._options.readonly) {2254template.addClass('bootstrap-datetimepicker-widget-readonly');2255}2256
2257if (this._isEnabled('s') && !this.use24Hours) {2258template.addClass('wider');2259}2260
2261if (this._options.sideBySide && this._hasDate() && this._hasTime()) {2262template.addClass('timepicker-sbs');2263
2264if (this._options.toolbarPlacement === 'top') {2265template.append(toolbar);2266}2267
2268template.append($('<div>').addClass('row').append(dateView.addClass('col-md-6')).append(timeView.addClass('col-md-6')));2269
2270if (this._options.toolbarPlacement === 'bottom' || this._options.toolbarPlacement === 'default') {2271template.append(toolbar);2272}2273
2274return template;2275}2276
2277if (this._options.toolbarPlacement === 'top') {2278content.append(toolbar);2279}2280
2281if (this._hasDate()) {2282content.append($('<li>').addClass(this._options.collapse && this._hasTime() ? 'collapse' : '').addClass(this._options.collapse && this._hasTime() && this._options.viewMode === 'times' ? '' : 'show').append(dateView));2283}2284
2285if (this._options.toolbarPlacement === 'default') {2286content.append(toolbar);2287}2288
2289if (this._hasTime()) {2290content.append($('<li>').addClass(this._options.collapse && this._hasDate() ? 'collapse' : '').addClass(this._options.collapse && this._hasDate() && this._options.viewMode === 'times' ? 'show' : '').append(timeView));2291}2292
2293if (this._options.toolbarPlacement === 'bottom') {2294content.append(toolbar);2295}2296
2297return template.append(content);2298};2299
2300_proto2._place = function _place(e) {2301var self = e && e.data && e.data.picker || this,2302vertical = self._options.widgetPositioning.vertical,2303horizontal = self._options.widgetPositioning.horizontal,2304parent;2305var position = (self.component && self.component.length ? self.component : self._element).position(),2306offset = (self.component && self.component.length ? self.component : self._element).offset();2307
2308if (self._options.widgetParent) {2309parent = self._options.widgetParent.append(self.widget);2310} else if (self._element.is('input')) {2311parent = self._element.after(self.widget).parent();2312} else if (self._options.inline) {2313parent = self._element.append(self.widget);2314return;2315} else {2316parent = self._element;2317
2318self._element.children().first().after(self.widget);2319} // Top and bottom logic2320
2321
2322if (vertical === 'auto') {2323//noinspection JSValidateTypes2324if (offset.top + self.widget.height() * 1.5 >= $(window).height() + $(window).scrollTop() && self.widget.height() + self._element.outerHeight() < offset.top) {2325vertical = 'top';2326} else {2327vertical = 'bottom';2328}2329} // Left and right logic2330
2331
2332if (horizontal === 'auto') {2333if (parent.width() < offset.left + self.widget.outerWidth() / 2 && offset.left + self.widget.outerWidth() > $(window).width()) {2334horizontal = 'right';2335} else {2336horizontal = 'left';2337}2338}2339
2340if (vertical === 'top') {2341self.widget.addClass('top').removeClass('bottom');2342} else {2343self.widget.addClass('bottom').removeClass('top');2344}2345
2346if (horizontal === 'right') {2347self.widget.addClass('float-right');2348} else {2349self.widget.removeClass('float-right');2350} // find the first parent element that has a relative css positioning2351
2352
2353if (parent.css('position') !== 'relative') {2354parent = parent.parents().filter(function () {2355return $(this).css('position') === 'relative';2356}).first();2357}2358
2359if (parent.length === 0) {2360throw new Error('datetimepicker component should be placed within a relative positioned container');2361}2362
2363self.widget.css({2364top: vertical === 'top' ? 'auto' : position.top + self._element.outerHeight() + 'px',2365bottom: vertical === 'top' ? parent.outerHeight() - (parent === self._element ? 0 : position.top) + 'px' : 'auto',2366left: horizontal === 'left' ? (parent === self._element ? 0 : position.left) + 'px' : 'auto',2367right: horizontal === 'left' ? 'auto' : parent.outerWidth() - self._element.outerWidth() - (parent === self._element ? 0 : position.left) + 'px'2368});2369};2370
2371_proto2._fillDow = function _fillDow() {2372var row = $('<tr>'),2373currentDate = this._viewDate.clone().startOf('w').startOf('d');2374
2375if (this._options.calendarWeeks === true) {2376row.append($('<th>').addClass('cw').text('#'));2377}2378
2379while (currentDate.isBefore(this._viewDate.clone().endOf('w'))) {2380row.append($('<th>').addClass('dow').text(currentDate.format('dd')));2381currentDate.add(1, 'd');2382}2383
2384this.widget.find('.datepicker-days thead').append(row);2385};2386
2387_proto2._fillMonths = function _fillMonths() {2388var spans = [],2389monthsShort = this._viewDate.clone().startOf('y').startOf('d');2390
2391while (monthsShort.isSame(this._viewDate, 'y')) {2392spans.push($('<span>').attr('data-action', 'selectMonth').addClass('month').text(monthsShort.format('MMM')));2393monthsShort.add(1, 'M');2394}2395
2396this.widget.find('.datepicker-months td').empty().append(spans);2397};2398
2399_proto2._updateMonths = function _updateMonths() {2400var monthsView = this.widget.find('.datepicker-months'),2401monthsViewHeader = monthsView.find('th'),2402months = monthsView.find('tbody').find('span'),2403self = this,2404lastPickedDate = this._getLastPickedDate();2405
2406monthsViewHeader.eq(0).find('span').attr('title', this._options.tooltips.prevYear);2407monthsViewHeader.eq(1).attr('title', this._options.tooltips.selectYear);2408monthsViewHeader.eq(2).find('span').attr('title', this._options.tooltips.nextYear);2409monthsView.find('.disabled').removeClass('disabled');2410
2411if (!this._isValid(this._viewDate.clone().subtract(1, 'y'), 'y')) {2412monthsViewHeader.eq(0).addClass('disabled');2413}2414
2415monthsViewHeader.eq(1).text(this._viewDate.year());2416
2417if (!this._isValid(this._viewDate.clone().add(1, 'y'), 'y')) {2418monthsViewHeader.eq(2).addClass('disabled');2419}2420
2421months.removeClass('active');2422
2423if (lastPickedDate && lastPickedDate.isSame(this._viewDate, 'y') && !this.unset) {2424months.eq(lastPickedDate.month()).addClass('active');2425}2426
2427months.each(function (index) {2428if (!self._isValid(self._viewDate.clone().month(index), 'M')) {2429$(this).addClass('disabled');2430}2431});2432};2433
2434_proto2._getStartEndYear = function _getStartEndYear(factor, year) {2435var step = factor / 10,2436startYear = Math.floor(year / factor) * factor,2437endYear = startYear + step * 9,2438focusValue = Math.floor(year / step) * step;2439return [startYear, endYear, focusValue];2440};2441
2442_proto2._updateYears = function _updateYears() {2443var yearsView = this.widget.find('.datepicker-years'),2444yearsViewHeader = yearsView.find('th'),2445yearCaps = this._getStartEndYear(10, this._viewDate.year()),2446startYear = this._viewDate.clone().year(yearCaps[0]),2447endYear = this._viewDate.clone().year(yearCaps[1]);2448
2449var html = '';2450yearsViewHeader.eq(0).find('span').attr('title', this._options.tooltips.prevDecade);2451yearsViewHeader.eq(1).attr('title', this._options.tooltips.selectDecade);2452yearsViewHeader.eq(2).find('span').attr('title', this._options.tooltips.nextDecade);2453yearsView.find('.disabled').removeClass('disabled');2454
2455if (this._options.minDate && this._options.minDate.isAfter(startYear, 'y')) {2456yearsViewHeader.eq(0).addClass('disabled');2457}2458
2459yearsViewHeader.eq(1).text(startYear.year() + "-" + endYear.year());2460
2461if (this._options.maxDate && this._options.maxDate.isBefore(endYear, 'y')) {2462yearsViewHeader.eq(2).addClass('disabled');2463}2464
2465html += "<span data-action=\"selectYear\" class=\"year old" + (!this._isValid(startYear, 'y') ? ' disabled' : '') + "\">" + (startYear.year() - 1) + "</span>";2466
2467while (!startYear.isAfter(endYear, 'y')) {2468html += "<span data-action=\"selectYear\" class=\"year" + (startYear.isSame(this._getLastPickedDate(), 'y') && !this.unset ? ' active' : '') + (!this._isValid(startYear, 'y') ? ' disabled' : '') + "\">" + startYear.year() + "</span>";2469startYear.add(1, 'y');2470}2471
2472html += "<span data-action=\"selectYear\" class=\"year old" + (!this._isValid(startYear, 'y') ? ' disabled' : '') + "\">" + startYear.year() + "</span>";2473yearsView.find('td').html(html);2474};2475
2476_proto2._updateDecades = function _updateDecades() {2477var decadesView = this.widget.find('.datepicker-decades'),2478decadesViewHeader = decadesView.find('th'),2479yearCaps = this._getStartEndYear(100, this._viewDate.year()),2480startDecade = this._viewDate.clone().year(yearCaps[0]),2481endDecade = this._viewDate.clone().year(yearCaps[1]),2482lastPickedDate = this._getLastPickedDate();2483
2484var minDateDecade = false,2485maxDateDecade = false,2486endDecadeYear,2487html = '';2488decadesViewHeader.eq(0).find('span').attr('title', this._options.tooltips.prevCentury);2489decadesViewHeader.eq(2).find('span').attr('title', this._options.tooltips.nextCentury);2490decadesView.find('.disabled').removeClass('disabled');2491
2492if (startDecade.year() === 0 || this._options.minDate && this._options.minDate.isAfter(startDecade, 'y')) {2493decadesViewHeader.eq(0).addClass('disabled');2494}2495
2496decadesViewHeader.eq(1).text(startDecade.year() + "-" + endDecade.year());2497
2498if (this._options.maxDate && this._options.maxDate.isBefore(endDecade, 'y')) {2499decadesViewHeader.eq(2).addClass('disabled');2500}2501
2502if (startDecade.year() - 10 < 0) {2503html += '<span> </span>';2504} else {2505html += "<span data-action=\"selectDecade\" class=\"decade old\" data-selection=\"" + (startDecade.year() + 6) + "\">" + (startDecade.year() - 10) + "</span>";2506}2507
2508while (!startDecade.isAfter(endDecade, 'y')) {2509endDecadeYear = startDecade.year() + 11;2510minDateDecade = this._options.minDate && this._options.minDate.isAfter(startDecade, 'y') && this._options.minDate.year() <= endDecadeYear;2511maxDateDecade = this._options.maxDate && this._options.maxDate.isAfter(startDecade, 'y') && this._options.maxDate.year() <= endDecadeYear;2512html += "<span data-action=\"selectDecade\" class=\"decade" + (lastPickedDate && lastPickedDate.isAfter(startDecade) && lastPickedDate.year() <= endDecadeYear ? ' active' : '') + (!this._isValid(startDecade, 'y') && !minDateDecade && !maxDateDecade ? ' disabled' : '') + "\" data-selection=\"" + (startDecade.year() + 6) + "\">" + startDecade.year() + "</span>";2513startDecade.add(10, 'y');2514}2515
2516html += "<span data-action=\"selectDecade\" class=\"decade old\" data-selection=\"" + (startDecade.year() + 6) + "\">" + startDecade.year() + "</span>";2517decadesView.find('td').html(html);2518};2519
2520_proto2._fillDate = function _fillDate() {2521_DateTimePicker.prototype._fillDate.call(this);2522
2523var daysView = this.widget.find('.datepicker-days'),2524daysViewHeader = daysView.find('th'),2525html = [];2526var currentDate, row, clsName, i;2527
2528if (!this._hasDate()) {2529return;2530}2531
2532daysViewHeader.eq(0).find('span').attr('title', this._options.tooltips.prevMonth);2533daysViewHeader.eq(1).attr('title', this._options.tooltips.selectMonth);2534daysViewHeader.eq(2).find('span').attr('title', this._options.tooltips.nextMonth);2535daysView.find('.disabled').removeClass('disabled');2536daysViewHeader.eq(1).text(this._viewDate.format(this._options.dayViewHeaderFormat));2537
2538if (!this._isValid(this._viewDate.clone().subtract(1, 'M'), 'M')) {2539daysViewHeader.eq(0).addClass('disabled');2540}2541
2542if (!this._isValid(this._viewDate.clone().add(1, 'M'), 'M')) {2543daysViewHeader.eq(2).addClass('disabled');2544}2545
2546currentDate = this._viewDate.clone().startOf('M').startOf('w').startOf('d');2547
2548for (i = 0; i < 42; i++) {2549//always display 42 days (should show 6 weeks)2550if (currentDate.weekday() === 0) {2551row = $('<tr>');2552
2553if (this._options.calendarWeeks) {2554row.append("<td class=\"cw\">" + currentDate.week() + "</td>");2555}2556
2557html.push(row);2558}2559
2560clsName = '';2561
2562if (currentDate.isBefore(this._viewDate, 'M')) {2563clsName += ' old';2564}2565
2566if (currentDate.isAfter(this._viewDate, 'M')) {2567clsName += ' new';2568}2569
2570if (this._options.allowMultidate) {2571var index = this._datesFormatted.indexOf(currentDate.format('YYYY-MM-DD'));2572
2573if (index !== -1) {2574if (currentDate.isSame(this._datesFormatted[index], 'd') && !this.unset) {2575clsName += ' active';2576}2577}2578} else {2579if (currentDate.isSame(this._getLastPickedDate(), 'd') && !this.unset) {2580clsName += ' active';2581}2582}2583
2584if (!this._isValid(currentDate, 'd')) {2585clsName += ' disabled';2586}2587
2588if (currentDate.isSame(this.getMoment(), 'd')) {2589clsName += ' today';2590}2591
2592if (currentDate.day() === 0 || currentDate.day() === 6) {2593clsName += ' weekend';2594}2595
2596row.append("<td data-action=\"selectDay\" data-day=\"" + currentDate.format('L') + "\" class=\"day" + clsName + "\">" + currentDate.date() + "</td>");2597currentDate.add(1, 'd');2598}2599
2600$('body').addClass('tempusdominus-bootstrap-datetimepicker-widget-day-click');2601$('body').append('<div class="tempusdominus-bootstrap-datetimepicker-widget-day-click-glass-panel"></div>');2602daysView.find('tbody').empty().append(html);2603$('body').find('.tempusdominus-bootstrap-datetimepicker-widget-day-click-glass-panel').remove();2604$('body').removeClass('tempusdominus-bootstrap-datetimepicker-widget-day-click');2605
2606this._updateMonths();2607
2608this._updateYears();2609
2610this._updateDecades();2611};2612
2613_proto2._fillHours = function _fillHours() {2614var table = this.widget.find('.timepicker-hours table'),2615currentHour = this._viewDate.clone().startOf('d'),2616html = [];2617
2618var row = $('<tr>');2619
2620if (this._viewDate.hour() > 11 && !this.use24Hours) {2621currentHour.hour(12);2622}2623
2624while (currentHour.isSame(this._viewDate, 'd') && (this.use24Hours || this._viewDate.hour() < 12 && currentHour.hour() < 12 || this._viewDate.hour() > 11)) {2625if (currentHour.hour() % 4 === 0) {2626row = $('<tr>');2627html.push(row);2628}2629
2630row.append("<td data-action=\"selectHour\" class=\"hour" + (!this._isValid(currentHour, 'h') ? ' disabled' : '') + "\">" + currentHour.format(this.use24Hours ? 'HH' : 'hh') + "</td>");2631currentHour.add(1, 'h');2632}2633
2634table.empty().append(html);2635};2636
2637_proto2._fillMinutes = function _fillMinutes() {2638var table = this.widget.find('.timepicker-minutes table'),2639currentMinute = this._viewDate.clone().startOf('h'),2640html = [],2641step = this._options.stepping === 1 ? 5 : this._options.stepping;2642
2643var row = $('<tr>');2644
2645while (this._viewDate.isSame(currentMinute, 'h')) {2646if (currentMinute.minute() % (step * 4) === 0) {2647row = $('<tr>');2648html.push(row);2649}2650
2651row.append("<td data-action=\"selectMinute\" class=\"minute" + (!this._isValid(currentMinute, 'm') ? ' disabled' : '') + "\">" + currentMinute.format('mm') + "</td>");2652currentMinute.add(step, 'm');2653}2654
2655table.empty().append(html);2656};2657
2658_proto2._fillSeconds = function _fillSeconds() {2659var table = this.widget.find('.timepicker-seconds table'),2660currentSecond = this._viewDate.clone().startOf('m'),2661html = [];2662
2663var row = $('<tr>');2664
2665while (this._viewDate.isSame(currentSecond, 'm')) {2666if (currentSecond.second() % 20 === 0) {2667row = $('<tr>');2668html.push(row);2669}2670
2671row.append("<td data-action=\"selectSecond\" class=\"second" + (!this._isValid(currentSecond, 's') ? ' disabled' : '') + "\">" + currentSecond.format('ss') + "</td>");2672currentSecond.add(5, 's');2673}2674
2675table.empty().append(html);2676};2677
2678_proto2._fillTime = function _fillTime() {2679var toggle, newDate;2680
2681var timeComponents = this.widget.find('.timepicker span[data-time-component]'),2682lastPickedDate = this._getLastPickedDate();2683
2684if (!this.use24Hours) {2685toggle = this.widget.find('.timepicker [data-action=togglePeriod]');2686newDate = lastPickedDate ? lastPickedDate.clone().add(lastPickedDate.hours() >= 12 ? -12 : 12, 'h') : void 0;2687lastPickedDate && toggle.text(lastPickedDate.format('A'));2688
2689if (this._isValid(newDate, 'h')) {2690toggle.removeClass('disabled');2691} else {2692toggle.addClass('disabled');2693}2694}2695
2696lastPickedDate && timeComponents.filter('[data-time-component=hours]').text(lastPickedDate.format("" + (this.use24Hours ? 'HH' : 'hh')));2697lastPickedDate && timeComponents.filter('[data-time-component=minutes]').text(lastPickedDate.format('mm'));2698lastPickedDate && timeComponents.filter('[data-time-component=seconds]').text(lastPickedDate.format('ss'));2699
2700this._fillHours();2701
2702this._fillMinutes();2703
2704this._fillSeconds();2705};2706
2707_proto2._doAction = function _doAction(e, action) {2708var lastPicked = this._getLastPickedDate();2709
2710if ($(e.currentTarget).is('.disabled')) {2711return false;2712}2713
2714action = action || $(e.currentTarget).data('action');2715
2716switch (action) {2717case 'next':2718{2719var navFnc = DateTimePicker.DatePickerModes[this.currentViewMode].NAV_FUNCTION;2720
2721this._viewDate.add(DateTimePicker.DatePickerModes[this.currentViewMode].NAV_STEP, navFnc);2722
2723this._fillDate();2724
2725this._viewUpdate(navFnc);2726
2727break;2728}2729
2730case 'previous':2731{2732var _navFnc = DateTimePicker.DatePickerModes[this.currentViewMode].NAV_FUNCTION;2733
2734this._viewDate.subtract(DateTimePicker.DatePickerModes[this.currentViewMode].NAV_STEP, _navFnc);2735
2736this._fillDate();2737
2738this._viewUpdate(_navFnc);2739
2740break;2741}2742
2743case 'pickerSwitch':2744this._showMode(1);2745
2746break;2747
2748case 'selectMonth':2749{2750var month = $(e.target).closest('tbody').find('span').index($(e.target));2751
2752this._viewDate.month(month);2753
2754if (this.currentViewMode === this.MinViewModeNumber) {2755this._setValue(lastPicked.clone().year(this._viewDate.year()).month(this._viewDate.month()), this._getLastPickedDateIndex());2756
2757if (!this._options.inline) {2758this.hide();2759}2760} else {2761this._showMode(-1);2762
2763this._fillDate();2764}2765
2766this._viewUpdate('M');2767
2768break;2769}2770
2771case 'selectYear':2772{2773var year = parseInt($(e.target).text(), 10) || 0;2774
2775this._viewDate.year(year);2776
2777if (this.currentViewMode === this.MinViewModeNumber) {2778this._setValue(lastPicked.clone().year(this._viewDate.year()), this._getLastPickedDateIndex());2779
2780if (!this._options.inline) {2781this.hide();2782}2783} else {2784this._showMode(-1);2785
2786this._fillDate();2787}2788
2789this._viewUpdate('YYYY');2790
2791break;2792}2793
2794case 'selectDecade':2795{2796var _year = parseInt($(e.target).data('selection'), 10) || 0;2797
2798this._viewDate.year(_year);2799
2800if (this.currentViewMode === this.MinViewModeNumber) {2801this._setValue(lastPicked.clone().year(this._viewDate.year()), this._getLastPickedDateIndex());2802
2803if (!this._options.inline) {2804this.hide();2805}2806} else {2807this._showMode(-1);2808
2809this._fillDate();2810}2811
2812this._viewUpdate('YYYY');2813
2814break;2815}2816
2817case 'selectDay':2818{2819var day = this._viewDate.clone();2820
2821if ($(e.target).is('.old')) {2822day.subtract(1, 'M');2823}2824
2825if ($(e.target).is('.new')) {2826day.add(1, 'M');2827}2828
2829var selectDate = day.date(parseInt($(e.target).text(), 10)),2830index = 0;2831
2832if (this._options.allowMultidate) {2833index = this._datesFormatted.indexOf(selectDate.format('YYYY-MM-DD'));2834
2835if (index !== -1) {2836this._setValue(null, index); //deselect multidate2837
2838} else {2839this._setValue(selectDate, this._getLastPickedDateIndex() + 1);2840}2841} else {2842this._setValue(selectDate, this._getLastPickedDateIndex());2843}2844
2845if (!this._hasTime() && !this._options.keepOpen && !this._options.inline && !this._options.allowMultidate) {2846this.hide();2847}2848
2849break;2850}2851
2852case 'incrementHours':2853{2854if (!lastPicked) {2855break;2856}2857
2858var newDate = lastPicked.clone().add(1, 'h');2859
2860if (this._isValid(newDate, 'h')) {2861if (this._getLastPickedDateIndex() < 0) {2862this.date(newDate);2863}2864
2865this._setValue(newDate, this._getLastPickedDateIndex());2866}2867
2868break;2869}2870
2871case 'incrementMinutes':2872{2873if (!lastPicked) {2874break;2875}2876
2877var _newDate = lastPicked.clone().add(this._options.stepping, 'm');2878
2879if (this._isValid(_newDate, 'm')) {2880if (this._getLastPickedDateIndex() < 0) {2881this.date(_newDate);2882}2883
2884this._setValue(_newDate, this._getLastPickedDateIndex());2885}2886
2887break;2888}2889
2890case 'incrementSeconds':2891{2892if (!lastPicked) {2893break;2894}2895
2896var _newDate2 = lastPicked.clone().add(1, 's');2897
2898if (this._isValid(_newDate2, 's')) {2899if (this._getLastPickedDateIndex() < 0) {2900this.date(_newDate2);2901}2902
2903this._setValue(_newDate2, this._getLastPickedDateIndex());2904}2905
2906break;2907}2908
2909case 'decrementHours':2910{2911if (!lastPicked) {2912break;2913}2914
2915var _newDate3 = lastPicked.clone().subtract(1, 'h');2916
2917if (this._isValid(_newDate3, 'h')) {2918if (this._getLastPickedDateIndex() < 0) {2919this.date(_newDate3);2920}2921
2922this._setValue(_newDate3, this._getLastPickedDateIndex());2923}2924
2925break;2926}2927
2928case 'decrementMinutes':2929{2930if (!lastPicked) {2931break;2932}2933
2934var _newDate4 = lastPicked.clone().subtract(this._options.stepping, 'm');2935
2936if (this._isValid(_newDate4, 'm')) {2937if (this._getLastPickedDateIndex() < 0) {2938this.date(_newDate4);2939}2940
2941this._setValue(_newDate4, this._getLastPickedDateIndex());2942}2943
2944break;2945}2946
2947case 'decrementSeconds':2948{2949if (!lastPicked) {2950break;2951}2952
2953var _newDate5 = lastPicked.clone().subtract(1, 's');2954
2955if (this._isValid(_newDate5, 's')) {2956if (this._getLastPickedDateIndex() < 0) {2957this.date(_newDate5);2958}2959
2960this._setValue(_newDate5, this._getLastPickedDateIndex());2961}2962
2963break;2964}2965
2966case 'togglePeriod':2967{2968this._setValue(lastPicked.clone().add(lastPicked.hours() >= 12 ? -12 : 12, 'h'), this._getLastPickedDateIndex());2969
2970break;2971}2972
2973case 'togglePicker':2974{2975var $this = $(e.target),2976$link = $this.closest('a'),2977$parent = $this.closest('ul'),2978expanded = $parent.find('.show'),2979closed = $parent.find('.collapse:not(.show)'),2980$span = $this.is('span') ? $this : $this.find('span');2981var collapseData, inactiveIcon, iconTest;2982
2983if (expanded && expanded.length) {2984collapseData = expanded.data('collapse');2985
2986if (collapseData && collapseData.transitioning) {2987return true;2988}2989
2990if (expanded.collapse) {2991// if collapse plugin is available through bootstrap.js then use it2992expanded.collapse('hide');2993closed.collapse('show');2994} else {2995// otherwise just toggle in class on the two views2996expanded.removeClass('show');2997closed.addClass('show');2998}2999
3000if (this._useFeatherIcons()) {3001$link.toggleClass(this._options.icons.time + ' ' + this._options.icons.date);3002inactiveIcon = $link.hasClass(this._options.icons.time) ? this._options.icons.date : this._options.icons.time;3003$link.html(this._iconTag(inactiveIcon));3004} else {3005$span.toggleClass(this._options.icons.time + ' ' + this._options.icons.date);3006}3007
3008if (this._useFeatherIcons()) {3009iconTest = $link.hasClass(this._options.icons.date);3010} else {3011iconTest = $span.hasClass(this._options.icons.date);3012}3013
3014if (iconTest) {3015$link.attr('title', this._options.tooltips.selectDate);3016} else {3017$link.attr('title', this._options.tooltips.selectTime);3018}3019}3020}3021break;3022
3023case 'showPicker':3024this.widget.find('.timepicker > div:not(.timepicker-picker)').hide();3025this.widget.find('.timepicker .timepicker-picker').show();3026break;3027
3028case 'showHours':3029this.widget.find('.timepicker .timepicker-picker').hide();3030this.widget.find('.timepicker .timepicker-hours').show();3031break;3032
3033case 'showMinutes':3034this.widget.find('.timepicker .timepicker-picker').hide();3035this.widget.find('.timepicker .timepicker-minutes').show();3036break;3037
3038case 'showSeconds':3039this.widget.find('.timepicker .timepicker-picker').hide();3040this.widget.find('.timepicker .timepicker-seconds').show();3041break;3042
3043case 'selectHour':3044{3045var hour = parseInt($(e.target).text(), 10);3046
3047if (!this.use24Hours) {3048if (lastPicked.hours() >= 12) {3049if (hour !== 12) {3050hour += 12;3051}3052} else {3053if (hour === 12) {3054hour = 0;3055}3056}3057}3058
3059this._setValue(lastPicked.clone().hours(hour), this._getLastPickedDateIndex());3060
3061if (!this._isEnabled('a') && !this._isEnabled('m') && !this._options.keepOpen && !this._options.inline) {3062this.hide();3063} else {3064this._doAction(e, 'showPicker');3065}3066
3067break;3068}3069
3070case 'selectMinute':3071this._setValue(lastPicked.clone().minutes(parseInt($(e.target).text(), 10)), this._getLastPickedDateIndex());3072
3073if (!this._isEnabled('a') && !this._isEnabled('s') && !this._options.keepOpen && !this._options.inline) {3074this.hide();3075} else {3076this._doAction(e, 'showPicker');3077}3078
3079break;3080
3081case 'selectSecond':3082this._setValue(lastPicked.clone().seconds(parseInt($(e.target).text(), 10)), this._getLastPickedDateIndex());3083
3084if (!this._isEnabled('a') && !this._options.keepOpen && !this._options.inline) {3085this.hide();3086} else {3087this._doAction(e, 'showPicker');3088}3089
3090break;3091
3092case 'clear':3093this.clear();3094break;3095
3096case 'close':3097this.hide();3098break;3099
3100case 'today':3101{3102var todaysDate = this.getMoment();3103
3104if (this._isValid(todaysDate, 'd')) {3105this._setValue(todaysDate, this._getLastPickedDateIndex());3106}3107
3108break;3109}3110}3111
3112return false;3113} //public3114;3115
3116_proto2.hide = function hide() {3117var transitioning = false;3118
3119if (!this.widget) {3120return;3121} // Ignore event if in the middle of a picker transition3122
3123
3124this.widget.find('.collapse').each(function () {3125var collapseData = $(this).data('collapse');3126
3127if (collapseData && collapseData.transitioning) {3128transitioning = true;3129return false;3130}3131
3132return true;3133});3134
3135if (transitioning) {3136return;3137}3138
3139if (this.component && this.component.hasClass('btn')) {3140this.component.toggleClass('active');3141}3142
3143this.widget.hide();3144$(window).off('resize', this._place);3145this.widget.off('click', '[data-action]');3146this.widget.off('mousedown', false);3147this.widget.remove();3148this.widget = false;3149
3150if (this.input !== undefined && this.input.val() !== undefined && this.input.val().trim().length !== 0) {3151this._setValue(this._parseInputDate(this.input.val().trim(), {3152isPickerShow: false3153}), 0);3154}3155
3156var lastPickedDate = this._getLastPickedDate();3157
3158this._notifyEvent({3159type: DateTimePicker.Event.HIDE,3160date: this.unset ? null : lastPickedDate ? lastPickedDate.clone() : void 03161});3162
3163if (this.input !== undefined) {3164this.input.blur();3165}3166
3167this._viewDate = lastPickedDate ? lastPickedDate.clone() : this.getMoment();3168};3169
3170_proto2.show = function show() {3171var currentMoment,3172shouldUseCurrentIfUnset = false;3173var useCurrentGranularity = {3174'year': function year(m) {3175return m.month(0).date(1).hours(0).seconds(0).minutes(0);3176},3177'month': function month(m) {3178return m.date(1).hours(0).seconds(0).minutes(0);3179},3180'day': function day(m) {3181return m.hours(0).seconds(0).minutes(0);3182},3183'hour': function hour(m) {3184return m.seconds(0).minutes(0);3185},3186'minute': function minute(m) {3187return m.seconds(0);3188}3189};3190
3191if (this.input !== undefined) {3192if (this.input.prop('disabled') || !this._options.ignoreReadonly && this.input.prop('readonly') || this.widget) {3193return;3194}3195
3196if (this.input.val() !== undefined && this.input.val().trim().length !== 0) {3197this._setValue(this._parseInputDate(this.input.val().trim(), {3198isPickerShow: true3199}), 0);3200} else {3201shouldUseCurrentIfUnset = true;3202}3203} else {3204shouldUseCurrentIfUnset = true;3205}3206
3207if (shouldUseCurrentIfUnset && this.unset && this._options.useCurrent) {3208currentMoment = this.getMoment();3209
3210if (typeof this._options.useCurrent === 'string') {3211currentMoment = useCurrentGranularity[this._options.useCurrent](currentMoment);3212}3213
3214this._setValue(currentMoment, 0);3215}3216
3217this.widget = this._getTemplate();3218
3219this._fillDow();3220
3221this._fillMonths();3222
3223this.widget.find('.timepicker-hours').hide();3224this.widget.find('.timepicker-minutes').hide();3225this.widget.find('.timepicker-seconds').hide();3226
3227this._update();3228
3229this._showMode();3230
3231$(window).on('resize', {3232picker: this3233}, this._place);3234this.widget.on('click', '[data-action]', $.proxy(this._doAction, this)); // this handles clicks on the widget3235
3236this.widget.on('mousedown', false);3237
3238if (this.component && this.component.hasClass('btn')) {3239this.component.toggleClass('active');3240}3241
3242this._place();3243
3244this.widget.show();3245
3246if (this.input !== undefined && this._options.focusOnShow && !this.input.is(':focus')) {3247this.input.focus();3248}3249
3250this._notifyEvent({3251type: DateTimePicker.Event.SHOW3252});3253};3254
3255_proto2.destroy = function destroy() {3256this.hide(); //todo doc off?3257
3258this._element.removeData(DateTimePicker.DATA_KEY);3259
3260this._element.removeData('date');3261};3262
3263_proto2.disable = function disable() {3264this.hide();3265
3266if (this.component && this.component.hasClass('btn')) {3267this.component.addClass('disabled');3268}3269
3270if (this.input !== undefined) {3271this.input.prop('disabled', true); //todo disable this/comp if input is null3272}3273};3274
3275_proto2.enable = function enable() {3276if (this.component && this.component.hasClass('btn')) {3277this.component.removeClass('disabled');3278}3279
3280if (this.input !== undefined) {3281this.input.prop('disabled', false); //todo enable comp/this if input is null3282}3283};3284
3285_proto2.toolbarPlacement = function toolbarPlacement(_toolbarPlacement) {3286if (arguments.length === 0) {3287return this._options.toolbarPlacement;3288}3289
3290if (typeof _toolbarPlacement !== 'string') {3291throw new TypeError('toolbarPlacement() expects a string parameter');3292}3293
3294if (toolbarPlacements.indexOf(_toolbarPlacement) === -1) {3295throw new TypeError("toolbarPlacement() parameter must be one of (" + toolbarPlacements.join(', ') + ") value");3296}3297
3298this._options.toolbarPlacement = _toolbarPlacement;3299
3300if (this.widget) {3301this.hide();3302this.show();3303}3304};3305
3306_proto2.widgetPositioning = function widgetPositioning(_widgetPositioning) {3307if (arguments.length === 0) {3308return $.extend({}, this._options.widgetPositioning);3309}3310
3311if ({}.toString.call(_widgetPositioning) !== '[object Object]') {3312throw new TypeError('widgetPositioning() expects an object variable');3313}3314
3315if (_widgetPositioning.horizontal) {3316if (typeof _widgetPositioning.horizontal !== 'string') {3317throw new TypeError('widgetPositioning() horizontal variable must be a string');3318}3319
3320_widgetPositioning.horizontal = _widgetPositioning.horizontal.toLowerCase();3321
3322if (horizontalModes.indexOf(_widgetPositioning.horizontal) === -1) {3323throw new TypeError("widgetPositioning() expects horizontal parameter to be one of (" + horizontalModes.join(', ') + ")");3324}3325
3326this._options.widgetPositioning.horizontal = _widgetPositioning.horizontal;3327}3328
3329if (_widgetPositioning.vertical) {3330if (typeof _widgetPositioning.vertical !== 'string') {3331throw new TypeError('widgetPositioning() vertical variable must be a string');3332}3333
3334_widgetPositioning.vertical = _widgetPositioning.vertical.toLowerCase();3335
3336if (verticalModes.indexOf(_widgetPositioning.vertical) === -1) {3337throw new TypeError("widgetPositioning() expects vertical parameter to be one of (" + verticalModes.join(', ') + ")");3338}3339
3340this._options.widgetPositioning.vertical = _widgetPositioning.vertical;3341}3342
3343this._update();3344};3345
3346_proto2.widgetParent = function widgetParent(_widgetParent) {3347if (arguments.length === 0) {3348return this._options.widgetParent;3349}3350
3351if (typeof _widgetParent === 'string') {3352_widgetParent = $(_widgetParent);3353}3354
3355if (_widgetParent !== null && typeof _widgetParent !== 'string' && !(_widgetParent instanceof $)) {3356throw new TypeError('widgetParent() expects a string or a jQuery object parameter');3357}3358
3359this._options.widgetParent = _widgetParent;3360
3361if (this.widget) {3362this.hide();3363this.show();3364}3365};3366
3367_proto2.setMultiDate = function setMultiDate(multiDateArray) {3368var dateFormat = this._options.format;3369this.clear();3370
3371for (var index = 0; index < multiDateArray.length; index++) {3372var date = moment(multiDateArray[index], dateFormat);3373
3374this._setValue(date, index);3375}3376} //static3377;3378
3379TempusDominusBootstrap4._jQueryHandleThis = function _jQueryHandleThis(me, option, argument) {3380var data = $(me).data(DateTimePicker.DATA_KEY);3381
3382if (typeof option === 'object') {3383$.extend({}, DateTimePicker.Default, option);3384}3385
3386if (!data) {3387data = new TempusDominusBootstrap4($(me), option);3388$(me).data(DateTimePicker.DATA_KEY, data);3389}3390
3391if (typeof option === 'string') {3392if (data[option] === undefined) {3393throw new Error("No method named \"" + option + "\"");3394}3395
3396if (argument === undefined) {3397return data[option]();3398} else {3399if (option === 'date') {3400data.isDateUpdateThroughDateOptionFromClientCode = true;3401}3402
3403var ret = data[option](argument);3404data.isDateUpdateThroughDateOptionFromClientCode = false;3405return ret;3406}3407}3408};3409
3410TempusDominusBootstrap4._jQueryInterface = function _jQueryInterface(option, argument) {3411if (this.length === 1) {3412return TempusDominusBootstrap4._jQueryHandleThis(this[0], option, argument);3413}3414
3415return this.each(function () {3416TempusDominusBootstrap4._jQueryHandleThis(this, option, argument);3417});3418};3419
3420return TempusDominusBootstrap4;3421}(DateTimePicker);3422/**3423* ------------------------------------------------------------------------
3424* jQuery
3425* ------------------------------------------------------------------------
3426*/
3427
3428
3429$(document).on(DateTimePicker.Event.CLICK_DATA_API, DateTimePicker.Selector.DATA_TOGGLE, function () {3430var $originalTarget = $(this),3431$target = getSelectorFromElement($originalTarget),3432config = $target.data(DateTimePicker.DATA_KEY);3433
3434if ($target.length === 0) {3435return;3436}3437
3438if (config._options.allowInputToggle && $originalTarget.is('input[data-toggle="datetimepicker"]')) {3439return;3440}3441
3442TempusDominusBootstrap4._jQueryInterface.call($target, 'toggle');3443}).on(DateTimePicker.Event.CHANGE, "." + DateTimePicker.ClassName.INPUT, function (event) {3444var $target = getSelectorFromElement($(this));3445
3446if ($target.length === 0 || event.isInit) {3447return;3448}3449
3450TempusDominusBootstrap4._jQueryInterface.call($target, '_change', event);3451}).on(DateTimePicker.Event.BLUR, "." + DateTimePicker.ClassName.INPUT, function (event) {3452var $target = getSelectorFromElement($(this)),3453config = $target.data(DateTimePicker.DATA_KEY);3454
3455if ($target.length === 0) {3456return;3457}3458
3459if (config._options.debug || window.debug) {3460return;3461}3462
3463TempusDominusBootstrap4._jQueryInterface.call($target, 'hide', event);3464}).on(DateTimePicker.Event.KEYDOWN, "." + DateTimePicker.ClassName.INPUT, function (event) {3465var $target = getSelectorFromElement($(this));3466
3467if ($target.length === 0) {3468return;3469}3470
3471TempusDominusBootstrap4._jQueryInterface.call($target, '_keydown', event);3472}).on(DateTimePicker.Event.KEYUP, "." + DateTimePicker.ClassName.INPUT, function (event) {3473var $target = getSelectorFromElement($(this));3474
3475if ($target.length === 0) {3476return;3477}3478
3479TempusDominusBootstrap4._jQueryInterface.call($target, '_keyup', event);3480}).on(DateTimePicker.Event.FOCUS, "." + DateTimePicker.ClassName.INPUT, function (event) {3481var $target = getSelectorFromElement($(this)),3482config = $target.data(DateTimePicker.DATA_KEY);3483
3484if ($target.length === 0) {3485return;3486}3487
3488if (!config._options.allowInputToggle) {3489return;3490}3491
3492TempusDominusBootstrap4._jQueryInterface.call($target, 'show', event);3493});3494$.fn[DateTimePicker.NAME] = TempusDominusBootstrap4._jQueryInterface;3495$.fn[DateTimePicker.NAME].Constructor = TempusDominusBootstrap4;3496
3497$.fn[DateTimePicker.NAME].noConflict = function () {3498$.fn[DateTimePicker.NAME] = JQUERY_NO_CONFLICT;3499return TempusDominusBootstrap4._jQueryInterface;3500};3501
3502return TempusDominusBootstrap4;3503}(jQuery);3504
3505}();3506