tempusdominus-core
Advanced tools
Comparing version 5.0.0-alpha9 to 5.0.0
@@ -6,9 +6,7 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
// ReSharper disable once InconsistentNaming | ||
var DateTimePicker = function ($) { | ||
var DateTimePicker = function ($, moment) { | ||
// ReSharper disable InconsistentNaming | ||
var NAME = 'datetimepicker', | ||
VERSION = '5.0.0-alpha7', | ||
DATA_KEY = '' + NAME, | ||
EVENT_KEY = '.' + DATA_KEY, | ||
EMIT_EVENT_KEY = DATA_KEY + '.', | ||
DATA_API_KEY = '.data-api', | ||
@@ -29,7 +27,59 @@ Selector = { | ||
//emitted | ||
UPDATE: EMIT_EVENT_KEY + 'update', | ||
ERROR: EMIT_EVENT_KEY + 'error', | ||
HIDE: EMIT_EVENT_KEY + 'hide', | ||
SHOW: EMIT_EVENT_KEY + 'show' | ||
UPDATE: 'update' + EVENT_KEY, | ||
ERROR: 'error' + EVENT_KEY, | ||
HIDE: 'hide' + EVENT_KEY, | ||
SHOW: 'show' + EVENT_KEY | ||
}, | ||
DatePickerModes = [{ | ||
CLASS_NAME: 'days', | ||
NAV_FUNCTION: 'M', | ||
NAV_STEP: 1 | ||
}, { | ||
CLASS_NAME: 'months', | ||
NAV_FUNCTION: 'y', | ||
NAV_STEP: 1 | ||
}, { | ||
CLASS_NAME: 'years', | ||
NAV_FUNCTION: 'y', | ||
NAV_STEP: 10 | ||
}, { | ||
CLASS_NAME: 'decades', | ||
NAV_FUNCTION: 'y', | ||
NAV_STEP: 100 | ||
}], | ||
KeyMap = { | ||
'up': 38, | ||
38: 'up', | ||
'down': 40, | ||
40: 'down', | ||
'left': 37, | ||
37: 'left', | ||
'right': 39, | ||
39: 'right', | ||
'tab': 9, | ||
9: 'tab', | ||
'escape': 27, | ||
27: 'escape', | ||
'enter': 13, | ||
13: 'enter', | ||
'pageUp': 33, | ||
33: 'pageUp', | ||
'pageDown': 34, | ||
34: 'pageDown', | ||
'shift': 16, | ||
16: 'shift', | ||
'control': 17, | ||
17: 'control', | ||
'space': 32, | ||
32: 'space', | ||
't': 84, | ||
84: 't', | ||
'delete': 46, | ||
46: 'delete' | ||
}, | ||
ViewModes = ['times', 'days', 'months', 'years', 'decades'], | ||
keyState = {}, | ||
keyPressHandled = {}; | ||
var MinViewModeNumber = 0, | ||
Default = { | ||
@@ -45,3 +95,3 @@ timeZone: '', | ||
collapse: true, | ||
locale: window.moment.locale(), | ||
locale: moment.locale(), | ||
defaultDate: false, | ||
@@ -201,2 +251,5 @@ disabledDates: false, | ||
enter: function enter() { | ||
if (!this.widget) { | ||
return false; | ||
} | ||
this.hide(); | ||
@@ -222,2 +275,5 @@ return true; | ||
t: function t() { | ||
if (!this.widget) { | ||
return false; | ||
} | ||
this.date(this.getMoment()); | ||
@@ -242,55 +298,4 @@ return true; | ||
multidateSeparator: ',' | ||
}, | ||
DatePickerModes = [{ | ||
CLASS_NAME: 'days', | ||
NAV_FUNCTION: 'M', | ||
NAV_STEP: 1 | ||
}, { | ||
CLASS_NAME: 'months', | ||
NAV_FUNCTION: 'y', | ||
NAV_STEP: 1 | ||
}, { | ||
CLASS_NAME: 'years', | ||
NAV_FUNCTION: 'y', | ||
NAV_STEP: 10 | ||
}, { | ||
CLASS_NAME: 'decades', | ||
NAV_FUNCTION: 'y', | ||
NAV_STEP: 100 | ||
}], | ||
KeyMap = { | ||
'up': 38, | ||
38: 'up', | ||
'down': 40, | ||
40: 'down', | ||
'left': 37, | ||
37: 'left', | ||
'right': 39, | ||
39: 'right', | ||
'tab': 9, | ||
9: 'tab', | ||
'escape': 27, | ||
27: 'escape', | ||
'enter': 13, | ||
13: 'enter', | ||
'pageUp': 33, | ||
33: 'pageUp', | ||
'pageDown': 34, | ||
34: 'pageDown', | ||
'shift': 16, | ||
16: 'shift', | ||
'control': 17, | ||
17: 'control', | ||
'space': 32, | ||
32: 'space', | ||
't': 84, | ||
84: 't', | ||
'delete': 46, | ||
46: 'delete' | ||
}, | ||
ViewModes = ['times', 'days', 'months', 'years', 'decades'], | ||
keyState = {}, | ||
keyPressHandled = {}; | ||
}; | ||
var MinViewModeNumber = 0; | ||
// ReSharper restore InconsistentNaming | ||
@@ -354,5 +359,5 @@ | ||
if (this.input !== undefined && this.input.is('input') && this.input.val().trim().length !== 0) { | ||
this._setValue(this._parseInputDate(this.input.val().trim())); | ||
this._setValue(this._parseInputDate(this.input.val().trim()), 0); | ||
} else if (this._options.defaultDate && this.input !== undefined && this.input.attr('placeholder') === undefined) { | ||
this._setValue(this._options.defaultDate); | ||
this._setValue(this._options.defaultDate, 0); | ||
} | ||
@@ -474,3 +479,3 @@ if (this._options.inline) { | ||
DateTimePicker.prototype._hasTimeZone = function _hasTimeZone() { | ||
return window.moment.tz !== undefined && this._options.timeZone !== undefined && this._options.timeZone !== null && this._options.timeZone !== ''; | ||
return moment.tz !== undefined && this._options.timeZone !== undefined && this._options.timeZone !== null && this._options.timeZone !== ''; | ||
}; | ||
@@ -496,2 +501,5 @@ | ||
return this.actualFormat.indexOf('s') !== -1; | ||
case 'a': | ||
case 'A': | ||
return this.actualFormat.toLowerCase().indexOf('a') !== -1; | ||
default: | ||
@@ -615,3 +623,3 @@ return false; | ||
if (this._options.parseInputDate === undefined) { | ||
if (!window.moment.isMoment(inputDate)) { | ||
if (!moment.isMoment(inputDate)) { | ||
inputDate = this.getMoment(inputDate); | ||
@@ -668,3 +676,3 @@ } | ||
if (handler) { | ||
if (handler.call(this.widget)) { | ||
if (handler.call(this)) { | ||
e.stopPropagation(); | ||
@@ -761,9 +769,9 @@ e.preventDefault(); | ||
if (d === undefined || d === null) { | ||
returnMoment = window.moment(); //TODO should this use format? and locale? | ||
returnMoment = moment(); //TODO should this use format? and locale? | ||
} else if (this._hasTimeZone()) { | ||
// There is a string to parse and a default time zone | ||
// parse with the tz function which takes a default time zone if it is not in the format string | ||
returnMoment = window.moment.tz(d, this.parseFormats, this._options.useStrict, this._options.timeZone); | ||
returnMoment = moment.tz(d, this.parseFormats, this._options.locale, this._options.useStrict, this._options.timeZone); | ||
} else { | ||
returnMoment = window.moment(d, this.parseFormats, this._options.useStrict); | ||
returnMoment = moment(d, this.parseFormats, this._options.locale, this._options.useStrict); | ||
} | ||
@@ -822,3 +830,3 @@ | ||
if (newDate !== null && typeof newDate !== 'string' && !window.moment.isMoment(newDate) && !(newDate instanceof Date)) { | ||
if (newDate !== null && typeof newDate !== 'string' && !moment.isMoment(newDate) && !(newDate instanceof Date)) { | ||
throw new TypeError('date() parameter must be one of [null, string, moment or Date]'); | ||
@@ -831,5 +839,2 @@ } | ||
DateTimePicker.prototype.format = function format(newFormat) { | ||
///<summary>test su</summary> | ||
///<param name="newFormat">info about para</param> | ||
///<returns type="string|boolean">returns foo</returns> | ||
if (arguments.length === 0) { | ||
@@ -1075,6 +1080,8 @@ return this._options.format; | ||
if (!window.moment.localeData(_locale)) { | ||
if (!moment.localeData(_locale)) { | ||
throw new TypeError('locale() locale ' + _locale + ' is not loaded from moment locales!'); | ||
} | ||
this._options.locale = _locale; | ||
for (var i = 0; i < this._dates.length; i++) { | ||
@@ -1448,3 +1455,3 @@ this._dates[i].locale(this._options.locale); | ||
if (typeof newDate !== 'string' && !window.moment.isMoment(newDate) && !(newDate instanceof Date)) { | ||
if (typeof newDate !== 'string' && !moment.isMoment(newDate) && !(newDate instanceof Date)) { | ||
throw new TypeError('viewDate() parameter must be one of [string, moment or Date]'); | ||
@@ -1488,12 +1495,2 @@ } | ||
}, { | ||
key: 'VERSION', | ||
get: function get() { | ||
return VERSION; | ||
} | ||
/** | ||
* @return {string} | ||
*/ | ||
}, { | ||
key: 'DATA_KEY', | ||
@@ -1557,2 +1554,5 @@ get: function get() { | ||
return Default; | ||
}, | ||
set: function set(value) { | ||
Default = value; | ||
} | ||
@@ -1570,2 +1570,2 @@ }, { | ||
return DateTimePicker; | ||
}(jQuery); | ||
}(jQuery, moment); |
@@ -1,1 +0,1 @@ | ||
function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),DateTimePicker=function(a){var b="datetimepicker",c="5.0.0-alpha7",d=""+b,e="."+d,f=d+".",g=".data-api",h={DATA_TOGGLE:'[data-toggle="'+d+'"]'},i={INPUT:b+"-input"},j={CHANGE:"change"+e,BLUR:"blur"+e,KEYUP:"keyup"+e,KEYDOWN:"keydown"+e,FOCUS:"focus"+e,CLICK_DATA_API:"click"+e+g,UPDATE:f+"update",ERROR:f+"error",HIDE:f+"hide",SHOW:f+"show"},k={timeZone:"",format:!1,dayViewHeaderFormat:"MMMM YYYY",extraFormats:!1,stepping:1,minDate:!1,maxDate:!1,useCurrent:!0,collapse:!0,locale:window.moment.locale(),defaultDate:!1,disabledDates:!1,enabledDates:!1,icons:{time:"fa fa-clock-o",date:"fa fa-calendar",up:"fa fa-arrow-up",down:"fa fa-arrow-down",previous:"fa fa-chevron-left",next:"fa fa-chevron-right",today:"fa fa-calendar-check-o",clear:"fa fa-delete",close:"fa fa-times"},tooltips:{today:"Go to today",clear:"Clear selection",close:"Close the picker",selectMonth:"Select Month",prevMonth:"Previous Month",nextMonth:"Next Month",selectYear:"Select Year",prevYear:"Previous Year",nextYear:"Next Year",selectDecade:"Select Decade",prevDecade:"Previous Decade",nextDecade:"Next Decade",prevCentury:"Previous Century",nextCentury:"Next Century",pickHour:"Pick Hour",incrementHour:"Increment Hour",decrementHour:"Decrement Hour",pickMinute:"Pick Minute",incrementMinute:"Increment Minute",decrementMinute:"Decrement Minute",pickSecond:"Pick Second",incrementSecond:"Increment Second",decrementSecond:"Decrement Second",togglePeriod:"Toggle Period",selectTime:"Select Time",selectDate:"Select Date"},useStrict:!1,sideBySide:!1,daysOfWeekDisabled:!1,calendarWeeks:!1,viewMode:"days",toolbarPlacement:"default",buttons:{showToday:!1,showClear:!1,showClose:!1},widgetPositioning:{horizontal:"auto",vertical:"auto"},widgetParent:null,ignoreReadonly:!1,keepOpen:!1,focusOnShow:!0,inline:!1,keepInvalid:!1,keyBinds:{up:function(){if(!this.widget)return!1;var a=this._dates[0]||this.getMoment();return this.widget.find(".datepicker").is(":visible")?this.date(a.clone().subtract(7,"d")):this.date(a.clone().add(this.stepping(),"m")),!0},down:function(){if(!this.widget)return this.show(),!1;var a=this._dates[0]||this.getMoment();return this.widget.find(".datepicker").is(":visible")?this.date(a.clone().add(7,"d")):this.date(a.clone().subtract(this.stepping(),"m")),!0},"control up":function(){if(!this.widget)return!1;var a=this._dates[0]||this.getMoment();return this.widget.find(".datepicker").is(":visible")?this.date(a.clone().subtract(1,"y")):this.date(a.clone().add(1,"h")),!0},"control down":function(){if(!this.widget)return!1;var a=this._dates[0]||this.getMoment();return this.widget.find(".datepicker").is(":visible")?this.date(a.clone().add(1,"y")):this.date(a.clone().subtract(1,"h")),!0},left:function(){if(!this.widget)return!1;var a=this._dates[0]||this.getMoment();return this.widget.find(".datepicker").is(":visible")&&this.date(a.clone().subtract(1,"d")),!0},right:function(){if(!this.widget)return!1;var a=this._dates[0]||this.getMoment();return this.widget.find(".datepicker").is(":visible")&&this.date(a.clone().add(1,"d")),!0},pageUp:function(){if(!this.widget)return!1;var a=this._dates[0]||this.getMoment();return this.widget.find(".datepicker").is(":visible")&&this.date(a.clone().subtract(1,"M")),!0},pageDown:function(){if(!this.widget)return!1;var a=this._dates[0]||this.getMoment();return this.widget.find(".datepicker").is(":visible")&&this.date(a.clone().add(1,"M")),!0},enter:function(){return this.hide(),!0},escape:function(){return!!this.widget&&(this.hide(),!0)},"control space":function(){return!!this.widget&&(this.widget.find(".timepicker").is(":visible")&&this.widget.find('.btn[data-action="togglePeriod"]').click(),!0)},t:function(){return this.date(this.getMoment()),!0},delete:function(){return!!this.widget&&(this.clear(),!0)}},debug:!1,allowInputToggle:!1,disabledTimeIntervals:!1,disabledHours:!1,enabledHours:!1,viewDate:!1,allowMultidate:!1,multidateSeparator:","},l=[{CLASS_NAME:"days",NAV_FUNCTION:"M",NAV_STEP:1},{CLASS_NAME:"months",NAV_FUNCTION:"y",NAV_STEP:1},{CLASS_NAME:"years",NAV_FUNCTION:"y",NAV_STEP:10},{CLASS_NAME:"decades",NAV_FUNCTION:"y",NAV_STEP:100}],m={up:38,38:"up",down:40,40:"down",left:37,37:"left",right:39,39:"right",tab:9,9:"tab",escape:27,27:"escape",enter:13,13:"enter",pageUp:33,33:"pageUp",pageDown:34,34:"pageDown",shift:16,16:"shift",control:17,17:"control",space:32,32:"space",t:84,84:"t",delete:46,46:"delete"},n=["times","days","months","years","decades"],o={},p={},q=0,r=function(){function f(a,b){_classCallCheck(this,f),this._options=this._getOptions(b),this._element=a,this._dates=[],this._datesFormatted=[],this._viewDate=null,this.unset=!0,this.component=!1,this.widget=!1,this.use24Hours=null,this.actualFormat=null,this.parseFormats=null,this.currentViewMode=null,this._int()}return f.prototype._int=function(){var b=this._element.data("target-input");this._element.is("input")?this.input=this._element:void 0!==b&&("nearest"===b?this.input=this._element.find("input"):this.input=a(b)),this._dates=[],this._dates[0]=this.getMoment(),this._viewDate=this.getMoment().clone(),a.extend(!0,this._options,this._dataToOptions()),this.options(this._options),this._initFormatting(),void 0!==this.input&&this.input.is("input")&&0!==this.input.val().trim().length?this._setValue(this._parseInputDate(this.input.val().trim())):this._options.defaultDate&&void 0!==this.input&&void 0===this.input.attr("placeholder")&&this._setValue(this._options.defaultDate),this._options.inline&&this.show()},f.prototype._update=function(){this.widget&&(this._fillDate(),this._fillTime())},f.prototype._setValue=function(a,b){var c=this.unset?null:this._dates[b],d="";if(!a)return this._options.allowMultidate&&1!==this._dates.length?(d=this._element.data("date")+",",d=d.replace(c.format(this.actualFormat)+",","").replace(",,","").replace(/,\s*$/,""),this._dates.splice(b,1),this._datesFormatted.splice(b,1)):(this.unset=!0,this._dates=[],this._datesFormatted=[]),void 0!==this.input&&(this.input.val(d),this.input.trigger("input")),this._element.data("date",d),this._notifyEvent({type:f.Event.CHANGE,date:!1,oldDate:c}),void this._update();if(a=a.clone().locale(this._options.locale),this._hasTimeZone()&&a.tz(this._options.timeZone),1!==this._options.stepping&&a.minutes(Math.round(a.minutes()/this._options.stepping)*this._options.stepping).seconds(0),this._isValid(a)){if(this._dates[b]=a,this._datesFormatted[b]=a.format("YYYY-MM-DD"),this._viewDate=a.clone(),this._options.allowMultidate&&this._dates.length>1){for(var e=0;e<this._dates.length;e++)d+=""+this._dates[e].format(this.actualFormat)+this._options.multidateSeparator;d=d.replace(/,\s*$/,"")}else d=this._dates[b].format(this.actualFormat);void 0!==this.input&&(this.input.val(d),this.input.trigger("input")),this._element.data("date",d),this.unset=!1,this._update(),this._notifyEvent({type:f.Event.CHANGE,date:this._dates[b].clone(),oldDate:c})}else this._options.keepInvalid?this._notifyEvent({type:f.Event.CHANGE,date:a,oldDate:c}):void 0!==this.input&&(this.input.val(""+(this.unset?"":this._dates[b].format(this.actualFormat))),this.input.trigger("input")),this._notifyEvent({type:f.Event.ERROR,date:a,oldDate:c})},f.prototype._change=function(b){var c=a(b.target).val().trim(),d=c?this._parseInputDate(c):null;return this._setValue(d),b.stopImmediatePropagation(),!1},f.prototype._getOptions=function(b){return b=a.extend(!0,{},k,b)},f.prototype._hasTimeZone=function(){return void 0!==window.moment.tz&&void 0!==this._options.timeZone&&null!==this._options.timeZone&&""!==this._options.timeZone},f.prototype._isEnabled=function(a){if("string"!=typeof a||a.length>1)throw new TypeError("isEnabled expects a single character string parameter");switch(a){case"y":return this.actualFormat.indexOf("Y")!==-1;case"M":return this.actualFormat.indexOf("M")!==-1;case"d":return this.actualFormat.toLowerCase().indexOf("d")!==-1;case"h":case"H":return this.actualFormat.toLowerCase().indexOf("h")!==-1;case"m":return this.actualFormat.indexOf("m")!==-1;case"s":return this.actualFormat.indexOf("s")!==-1;default:return!1}},f.prototype._hasTime=function(){return this._isEnabled("h")||this._isEnabled("m")||this._isEnabled("s")},f.prototype._hasDate=function(){return this._isEnabled("y")||this._isEnabled("M")||this._isEnabled("d")},f.prototype._dataToOptions=function(){var b=this._element.data(),c={};return b.dateOptions&&b.dateOptions instanceof Object&&(c=a.extend(!0,c,b.dateOptions)),a.each(this._options,function(a){var d="date"+a.charAt(0).toUpperCase()+a.slice(1);void 0!==b[d]?c[a]=b[d]:delete c[a]}),c},f.prototype._notifyEvent=function(a){a.type===f.Event.CHANGE&&a.date&&a.date.isSame(a.oldDate)||!a.date&&!a.oldDate||this._element.trigger(a)},f.prototype._viewUpdate=function(a){"y"===a&&(a="YYYY"),this._notifyEvent({type:f.Event.UPDATE,change:a,viewDate:this._viewDate.clone()})},f.prototype._showMode=function(a){this.widget&&(a&&(this.currentViewMode=Math.max(q,Math.min(3,this.currentViewMode+a))),this.widget.find(".datepicker > div").hide().filter(".datepicker-"+l[this.currentViewMode].CLASS_NAME).show())},f.prototype._isInDisabledDates=function(a){return this._options.disabledDates[a.format("YYYY-MM-DD")]===!0},f.prototype._isInEnabledDates=function(a){return this._options.enabledDates[a.format("YYYY-MM-DD")]===!0},f.prototype._isInDisabledHours=function(a){return this._options.disabledHours[a.format("H")]===!0},f.prototype._isInEnabledHours=function(a){return this._options.enabledHours[a.format("H")]===!0},f.prototype._isValid=function(b,c){if(!b.isValid())return!1;if(this._options.disabledDates&&"d"===c&&this._isInDisabledDates(b))return!1;if(this._options.enabledDates&&"d"===c&&!this._isInEnabledDates(b))return!1;if(this._options.minDate&&b.isBefore(this._options.minDate,c))return!1;if(this._options.maxDate&&b.isAfter(this._options.maxDate,c))return!1;if(this._options.daysOfWeekDisabled&&"d"===c&&this._options.daysOfWeekDisabled.indexOf(b.day())!==-1)return!1;if(this._options.disabledHours&&("h"===c||"m"===c||"s"===c)&&this._isInDisabledHours(b))return!1;if(this._options.enabledHours&&("h"===c||"m"===c||"s"===c)&&!this._isInEnabledHours(b))return!1;if(this._options.disabledTimeIntervals&&("h"===c||"m"===c||"s"===c)){var d=!1;if(a.each(this._options.disabledTimeIntervals,function(){if(b.isBetween(this[0],this[1]))return d=!0,!1}),d)return!1}return!0},f.prototype._parseInputDate=function(a){return void 0===this._options.parseInputDate?window.moment.isMoment(a)||(a=this.getMoment(a)):a=this._options.parseInputDate(a),a},f.prototype._keydown=function(a){var b=null,c=void 0,d=void 0,e=void 0,f=void 0,g=[],h={},i=a.which,j="p";o[i]=j;for(c in o)o.hasOwnProperty(c)&&o[c]===j&&(g.push(c),parseInt(c,10)!==i&&(h[c]=!0));for(c in this._options.keyBinds)if(this._options.keyBinds.hasOwnProperty(c)&&"function"==typeof this._options.keyBinds[c]&&(e=c.split(" "),e.length===g.length&&m[i]===e[e.length-1])){for(f=!0,d=e.length-2;d>=0;d--)if(!(m[e[d]]in h)){f=!1;break}if(f){b=this._options.keyBinds[c];break}}b&&b.call(this.widget)&&(a.stopPropagation(),a.preventDefault())},f.prototype._keyup=function(a){o[a.which]="r",p[a.which]&&(p[a.which]=!1,a.stopPropagation(),a.preventDefault())},f.prototype._indexGivenDates=function(b){var c={},d=this;return a.each(b,function(){var a=d._parseInputDate(this);a.isValid()&&(c[a.format("YYYY-MM-DD")]=!0)}),!!Object.keys(c).length&&c},f.prototype._indexGivenHours=function(b){var c={};return a.each(b,function(){c[this]=!0}),!!Object.keys(c).length&&c},f.prototype._initFormatting=function(){var a=this._options.format||"L LT",b=this;this.actualFormat=a.replace(/(\[[^\[]*])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,function(a){return b._dates[0].localeData().longDateFormat(a)||a}),this.parseFormats=this._options.extraFormats?this._options.extraFormats.slice():[],this.parseFormats.indexOf(a)<0&&this.parseFormats.indexOf(this.actualFormat)<0&&this.parseFormats.push(this.actualFormat),this.use24Hours=this.actualFormat.toLowerCase().indexOf("a")<1&&this.actualFormat.replace(/\[.*?]/g,"").indexOf("h")<1,this._isEnabled("y")&&(q=2),this._isEnabled("M")&&(q=1),this._isEnabled("d")&&(q=0),this.currentViewMode=Math.max(q,this.currentViewMode),this.unset||this._setValue(this._dates[0],0)},f.prototype._getLastPickedDate=function(){return this._dates[this._getLastPickedDateIndex()]},f.prototype._getLastPickedDateIndex=function(){return this._dates.length-1},f.prototype.getMoment=function(a){var b=void 0;return b=void 0===a||null===a?window.moment():this._hasTimeZone()?window.moment.tz(a,this.parseFormats,this._options.useStrict,this._options.timeZone):window.moment(a,this.parseFormats,this._options.useStrict),this._hasTimeZone()&&b.tz(this._options.timeZone),b},f.prototype.toggle=function(){return this.widget?this.hide():this.show()},f.prototype.ignoreReadonly=function(a){if(0===arguments.length)return this._options.ignoreReadonly;if("boolean"!=typeof a)throw new TypeError("ignoreReadonly () expects a boolean parameter");this._options.ignoreReadonly=a},f.prototype.options=function(b){if(0===arguments.length)return a.extend(!0,{},this._options);if(!(b instanceof Object))throw new TypeError("options() this.options parameter should be an object");a.extend(!0,this._options,b);var c=this;a.each(this._options,function(a,b){void 0!==c[a]&&c[a](b)})},f.prototype.date=function(a,b){if(b=b||0,0===arguments.length)return this.unset?null:this._options.allowMultidate?this._dates.join(this._options.multidateSeparator):this._dates[b].clone();if(!(null===a||"string"==typeof a||window.moment.isMoment(a)||a instanceof Date))throw new TypeError("date() parameter must be one of [null, string, moment or Date]");this._setValue(null===a?null:this._parseInputDate(a),b)},f.prototype.format=function(a){if(0===arguments.length)return this._options.format;if("string"!=typeof a&&("boolean"!=typeof a||a!==!1))throw new TypeError("format() expects a string or boolean:false parameter "+a);this._options.format=a,this.actualFormat&&this._initFormatting()},f.prototype.timeZone=function(a){if(0===arguments.length)return this._options.timeZone;if("string"!=typeof a)throw new TypeError("newZone() expects a string parameter");this._options.timeZone=a},f.prototype.dayViewHeaderFormat=function(a){if(0===arguments.length)return this._options.dayViewHeaderFormat;if("string"!=typeof a)throw new TypeError("dayViewHeaderFormat() expects a string parameter");this._options.dayViewHeaderFormat=a},f.prototype.extraFormats=function(a){if(0===arguments.length)return this._options.extraFormats;if(a!==!1&&!(a instanceof Array))throw new TypeError("extraFormats() expects an array or false parameter");this._options.extraFormats=a,this.parseFormats&&this._initFormatting()},f.prototype.disabledDates=function(b){if(0===arguments.length)return this._options.disabledDates?a.extend({},this._options.disabledDates):this._options.disabledDates;if(!b)return this._options.disabledDates=!1,this._update(),!0;if(!(b instanceof Array))throw new TypeError("disabledDates() expects an array parameter");this._options.disabledDates=this._indexGivenDates(b),this._options.enabledDates=!1,this._update()},f.prototype.enabledDates=function(b){if(0===arguments.length)return this._options.enabledDates?a.extend({},this._options.enabledDates):this._options.enabledDates;if(!b)return this._options.enabledDates=!1,this._update(),!0;if(!(b instanceof Array))throw new TypeError("enabledDates() expects an array parameter");this._options.enabledDates=this._indexGivenDates(b),this._options.disabledDates=!1,this._update()},f.prototype.daysOfWeekDisabled=function(a){if(0===arguments.length)return this._options.daysOfWeekDisabled.splice(0);if("boolean"==typeof a&&!a)return this._options.daysOfWeekDisabled=!1,this._update(),!0;if(!(a instanceof Array))throw new TypeError("daysOfWeekDisabled() expects an array parameter");if(this._options.daysOfWeekDisabled=a.reduce(function(a,b){return b=parseInt(b,10),b>6||b<0||isNaN(b)?a:(a.indexOf(b)===-1&&a.push(b),a)},[]).sort(),this._options.useCurrent&&!this._options.keepInvalid)for(var b=0;b<this._dates.length;b++){for(var c=0;!this._isValid(this._dates[b],"d");){if(this._dates[b].add(1,"d"),31===c)throw"Tried 31 times to find a valid date";c++}this._setValue(this._dates[b],b)}this._update()},f.prototype.maxDate=function(a){if(0===arguments.length)return this._options.maxDate?this._options.maxDate.clone():this._options.maxDate;if("boolean"==typeof a&&a===!1)return this._options.maxDate=!1,this._update(),!0;"string"==typeof a&&("now"!==a&&"moment"!==a||(a=this.getMoment()));var b=this._parseInputDate(a);if(!b.isValid())throw new TypeError("maxDate() Could not parse date parameter: "+a);if(this._options.minDate&&b.isBefore(this._options.minDate))throw new TypeError("maxDate() date parameter is before this.options.minDate: "+b.format(this.actualFormat));this._options.maxDate=b;for(var c=0;c<this._dates.length;c++)this._options.useCurrent&&!this._options.keepInvalid&&this._dates[c].isAfter(a)&&this._setValue(this._options.maxDate,c);this._viewDate.isAfter(b)&&(this._viewDate=b.clone().subtract(this._options.stepping,"m")),this._update()},f.prototype.minDate=function(a){if(0===arguments.length)return this._options.minDate?this._options.minDate.clone():this._options.minDate;if("boolean"==typeof a&&a===!1)return this._options.minDate=!1,this._update(),!0;"string"==typeof a&&("now"!==a&&"moment"!==a||(a=this.getMoment()));var b=this._parseInputDate(a);if(!b.isValid())throw new TypeError("minDate() Could not parse date parameter: "+a);if(this._options.maxDate&&b.isAfter(this._options.maxDate))throw new TypeError("minDate() date parameter is after this.options.maxDate: "+b.format(this.actualFormat));this._options.minDate=b;for(var c=0;c<this._dates.length;c++)this._options.useCurrent&&!this._options.keepInvalid&&this._dates[c].isBefore(a)&&this._setValue(this._options.minDate,c);this._viewDate.isBefore(b)&&(this._viewDate=b.clone().add(this._options.stepping,"m")),this._update()},f.prototype.defaultDate=function(a){if(0===arguments.length)return this._options.defaultDate?this._options.defaultDate.clone():this._options.defaultDate;if(!a)return this._options.defaultDate=!1,!0;"string"==typeof a&&(a="now"===a||"moment"===a?this.getMoment():this.getMoment(a));var b=this._parseInputDate(a);if(!b.isValid())throw new TypeError("defaultDate() Could not parse date parameter: "+a);if(!this._isValid(b))throw new TypeError("defaultDate() date passed is invalid according to component setup validations");this._options.defaultDate=b,(this._options.defaultDate&&this._options.inline||void 0!==this.input&&""===this.input.val().trim())&&this._setValue(this._options.defaultDate,0)},f.prototype.locale=function(a){if(0===arguments.length)return this._options.locale;if(!window.moment.localeData(a))throw new TypeError("locale() locale "+a+" is not loaded from moment locales!");for(var b=0;b<this._dates.length;b++)this._dates[b].locale(this._options.locale);this._viewDate.locale(this._options.locale),this.actualFormat&&this._initFormatting(),this.widget&&(this.hide(),this.show())},f.prototype.stepping=function(a){return 0===arguments.length?this._options.stepping:(a=parseInt(a,10),(isNaN(a)||a<1)&&(a=1),void(this._options.stepping=a))},f.prototype.useCurrent=function(a){var b=["year","month","day","hour","minute"];if(0===arguments.length)return this._options.useCurrent;if("boolean"!=typeof a&&"string"!=typeof a)throw new TypeError("useCurrent() expects a boolean or string parameter");if("string"==typeof a&&b.indexOf(a.toLowerCase())===-1)throw new TypeError("useCurrent() expects a string parameter of "+b.join(", "));this._options.useCurrent=a},f.prototype.collapse=function(a){if(0===arguments.length)return this._options.collapse;if("boolean"!=typeof a)throw new TypeError("collapse() expects a boolean parameter");return this._options.collapse===a||(this._options.collapse=a,void(this.widget&&(this.hide(),this.show())))},f.prototype.icons=function(b){if(0===arguments.length)return a.extend({},this._options.icons);if(!(b instanceof Object))throw new TypeError("icons() expects parameter to be an Object");a.extend(this._options.icons,b),this.widget&&(this.hide(),this.show())},f.prototype.tooltips=function(b){if(0===arguments.length)return a.extend({},this._options.tooltips);if(!(b instanceof Object))throw new TypeError("tooltips() expects parameter to be an Object");a.extend(this._options.tooltips,b),this.widget&&(this.hide(),this.show())},f.prototype.useStrict=function(a){if(0===arguments.length)return this._options.useStrict;if("boolean"!=typeof a)throw new TypeError("useStrict() expects a boolean parameter");this._options.useStrict=a},f.prototype.sideBySide=function(a){if(0===arguments.length)return this._options.sideBySide;if("boolean"!=typeof a)throw new TypeError("sideBySide() expects a boolean parameter");this._options.sideBySide=a,this.widget&&(this.hide(),this.show())},f.prototype.viewMode=function(a){if(0===arguments.length)return this._options.viewMode;if("string"!=typeof a)throw new TypeError("viewMode() expects a string parameter");if(f.ViewModes.indexOf(a)===-1)throw new TypeError("viewMode() parameter must be one of ("+f.ViewModes.join(", ")+") value");this._options.viewMode=a,this.currentViewMode=Math.max(f.ViewModes.indexOf(a)-1,f.MinViewModeNumber),this._showMode()},f.prototype.calendarWeeks=function(a){if(0===arguments.length)return this._options.calendarWeeks;if("boolean"!=typeof a)throw new TypeError("calendarWeeks() expects parameter to be a boolean value");this._options.calendarWeeks=a,this._update()},f.prototype.buttons=function(b){if(0===arguments.length)return a.extend({},this._options.buttons);if(!(b instanceof Object))throw new TypeError("buttons() expects parameter to be an Object");if(a.extend(this._options.buttons,b),"boolean"!=typeof this._options.buttons.showToday)throw new TypeError("buttons.showToday expects a boolean parameter");if("boolean"!=typeof this._options.buttons.showClear)throw new TypeError("buttons.showClear expects a boolean parameter");if("boolean"!=typeof this._options.buttons.showClose)throw new TypeError("buttons.showClose expects a boolean parameter");this.widget&&(this.hide(),this.show())},f.prototype.keepOpen=function(a){if(0===arguments.length)return this._options.keepOpen;if("boolean"!=typeof a)throw new TypeError("keepOpen() expects a boolean parameter");this._options.keepOpen=a},f.prototype.focusOnShow=function(a){if(0===arguments.length)return this._options.focusOnShow;if("boolean"!=typeof a)throw new TypeError("focusOnShow() expects a boolean parameter");this._options.focusOnShow=a},f.prototype.inline=function(a){if(0===arguments.length)return this._options.inline;if("boolean"!=typeof a)throw new TypeError("inline() expects a boolean parameter");this._options.inline=a},f.prototype.clear=function(){this._setValue(null)},f.prototype.keyBinds=function(a){return 0===arguments.length?this._options.keyBinds:void(this._options.keyBinds=a)},f.prototype.debug=function(a){if("boolean"!=typeof a)throw new TypeError("debug() expects a boolean parameter");this._options.debug=a},f.prototype.allowInputToggle=function(a){if(0===arguments.length)return this._options.allowInputToggle;if("boolean"!=typeof a)throw new TypeError("allowInputToggle() expects a boolean parameter");this._options.allowInputToggle=a},f.prototype.keepInvalid=function(a){if(0===arguments.length)return this._options.keepInvalid;if("boolean"!=typeof a)throw new TypeError("keepInvalid() expects a boolean parameter");this._options.keepInvalid=a},f.prototype.datepickerInput=function(a){if(0===arguments.length)return this._options.datepickerInput;if("string"!=typeof a)throw new TypeError("datepickerInput() expects a string parameter");this._options.datepickerInput=a},f.prototype.parseInputDate=function(a){if(0===arguments.length)return this._options.parseInputDate;if("function"!=typeof a)throw new TypeError("parseInputDate() should be as function");this._options.parseInputDate=a},f.prototype.disabledTimeIntervals=function(b){if(0===arguments.length)return this._options.disabledTimeIntervals?a.extend({},this._options.disabledTimeIntervals):this._options.disabledTimeIntervals;if(!b)return this._options.disabledTimeIntervals=!1,this._update(),!0;if(!(b instanceof Array))throw new TypeError("disabledTimeIntervals() expects an array parameter");this._options.disabledTimeIntervals=b,this._update()},f.prototype.disabledHours=function(b){if(0===arguments.length)return this._options.disabledHours?a.extend({},this._options.disabledHours):this._options.disabledHours;if(!b)return this._options.disabledHours=!1,this._update(),!0;if(!(b instanceof Array))throw new TypeError("disabledHours() expects an array parameter");if(this._options.disabledHours=this._indexGivenHours(b),this._options.enabledHours=!1,this._options.useCurrent&&!this._options.keepInvalid)for(var c=0;c<this._dates.length;c++){for(var d=0;!this._isValid(this._dates[c],"h");){if(this._dates[c].add(1,"h"),24===d)throw"Tried 24 times to find a valid date";d++}this._setValue(this._dates[c],c)}this._update()},f.prototype.enabledHours=function(b){if(0===arguments.length)return this._options.enabledHours?a.extend({},this._options.enabledHours):this._options.enabledHours;if(!b)return this._options.enabledHours=!1,this._update(),!0;if(!(b instanceof Array))throw new TypeError("enabledHours() expects an array parameter");if(this._options.enabledHours=this._indexGivenHours(b),this._options.disabledHours=!1,this._options.useCurrent&&!this._options.keepInvalid)for(var c=0;c<this._dates.length;c++){for(var d=0;!this._isValid(this._dates[c],"h");){if(this._dates[c].add(1,"h"),24===d)throw"Tried 24 times to find a valid date";d++}this._setValue(this._dates[c],c)}this._update()},f.prototype.viewDate=function(a){if(0===arguments.length)return this._viewDate.clone();if(!a)return this._viewDate=(this._dates[0]||this.getMoment()).clone(),!0;if(!("string"==typeof a||window.moment.isMoment(a)||a instanceof Date))throw new TypeError("viewDate() parameter must be one of [string, moment or Date]");this._viewDate=this._parseInputDate(a),this._viewUpdate()},f.prototype.allowMultidate=function(a){if("boolean"!=typeof a)throw new TypeError("allowMultidate() expects a boolean parameter");this._options.allowMultidate=a},f.prototype.multidateSeparator=function(a){if(0===arguments.length)return this._options.multidateSeparator;if("string"!=typeof a||a.length>1)throw new TypeError("multidateSeparator expects a single character string parameter");this._options.multidateSeparator=a},_createClass(f,null,[{key:"NAME",get:function(){return b}},{key:"VERSION",get:function(){return c}},{key:"DATA_KEY",get:function(){return d}},{key:"EVENT_KEY",get:function(){return e}},{key:"DATA_API_KEY",get:function(){return g}},{key:"DatePickerModes",get:function(){return l}},{key:"ViewModes",get:function(){return n}},{key:"MinViewModeNumber",get:function(){return q}},{key:"Event",get:function(){return j}},{key:"Selector",get:function(){return h}},{key:"Default",get:function(){return k}},{key:"ClassName",get:function(){return i}}]),f}();return r}(jQuery); | ||
var _createClass=function(){function o(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(t,e,i){return e&&o(t.prototype,e),i&&o(t,i),t}}();function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var DateTimePicker=function(s,i){var t="datetimepicker",e=""+t,o="."+e,a=".data-api",r={DATA_TOGGLE:'[data-toggle="'+e+'"]'},p={INPUT:t+"-input"},h={CHANGE:"change"+o,BLUR:"blur"+o,KEYUP:"keyup"+o,KEYDOWN:"keydown"+o,FOCUS:"focus"+o,CLICK_DATA_API:"click"+o+a,UPDATE:"update"+o,ERROR:"error"+o,HIDE:"hide"+o,SHOW:"show"+o},d=[{CLASS_NAME:"days",NAV_FUNCTION:"M",NAV_STEP:1},{CLASS_NAME:"months",NAV_FUNCTION:"y",NAV_STEP:1},{CLASS_NAME:"years",NAV_FUNCTION:"y",NAV_STEP:10},{CLASS_NAME:"decades",NAV_FUNCTION:"y",NAV_STEP:100}],l={up:38,38:"up",down:40,40:"down",left:37,37:"left",right:39,39:"right",tab:9,9:"tab",escape:27,27:"escape",enter:13,13:"enter",pageUp:33,33:"pageUp",pageDown:34,34:"pageDown",shift:16,16:"shift",control:17,17:"control",space:32,32:"space",t:84,84:"t",delete:46,46:"delete"},u=["times","days","months","years","decades"],f={},c={},_=0,m={timeZone:"",format:!1,dayViewHeaderFormat:"MMMM YYYY",extraFormats:!1,stepping:1,minDate:!1,maxDate:!1,useCurrent:!0,collapse:!0,locale:i.locale(),defaultDate:!1,disabledDates:!1,enabledDates:!1,icons:{time:"fa fa-clock-o",date:"fa fa-calendar",up:"fa fa-arrow-up",down:"fa fa-arrow-down",previous:"fa fa-chevron-left",next:"fa fa-chevron-right",today:"fa fa-calendar-check-o",clear:"fa fa-delete",close:"fa fa-times"},tooltips:{today:"Go to today",clear:"Clear selection",close:"Close the picker",selectMonth:"Select Month",prevMonth:"Previous Month",nextMonth:"Next Month",selectYear:"Select Year",prevYear:"Previous Year",nextYear:"Next Year",selectDecade:"Select Decade",prevDecade:"Previous Decade",nextDecade:"Next Decade",prevCentury:"Previous Century",nextCentury:"Next Century",pickHour:"Pick Hour",incrementHour:"Increment Hour",decrementHour:"Decrement Hour",pickMinute:"Pick Minute",incrementMinute:"Increment Minute",decrementMinute:"Decrement Minute",pickSecond:"Pick Second",incrementSecond:"Increment Second",decrementSecond:"Decrement Second",togglePeriod:"Toggle Period",selectTime:"Select Time",selectDate:"Select Date"},useStrict:!1,sideBySide:!1,daysOfWeekDisabled:!1,calendarWeeks:!1,viewMode:"days",toolbarPlacement:"default",buttons:{showToday:!1,showClear:!1,showClose:!1},widgetPositioning:{horizontal:"auto",vertical:"auto"},widgetParent:null,ignoreReadonly:!1,keepOpen:!1,focusOnShow:!0,inline:!1,keepInvalid:!1,keyBinds:{up:function(){if(!this.widget)return!1;var t=this._dates[0]||this.getMoment();return this.widget.find(".datepicker").is(":visible")?this.date(t.clone().subtract(7,"d")):this.date(t.clone().add(this.stepping(),"m")),!0},down:function(){if(!this.widget)return this.show(),!1;var t=this._dates[0]||this.getMoment();return this.widget.find(".datepicker").is(":visible")?this.date(t.clone().add(7,"d")):this.date(t.clone().subtract(this.stepping(),"m")),!0},"control up":function(){if(!this.widget)return!1;var t=this._dates[0]||this.getMoment();return this.widget.find(".datepicker").is(":visible")?this.date(t.clone().subtract(1,"y")):this.date(t.clone().add(1,"h")),!0},"control down":function(){if(!this.widget)return!1;var t=this._dates[0]||this.getMoment();return this.widget.find(".datepicker").is(":visible")?this.date(t.clone().add(1,"y")):this.date(t.clone().subtract(1,"h")),!0},left:function(){if(!this.widget)return!1;var t=this._dates[0]||this.getMoment();return this.widget.find(".datepicker").is(":visible")&&this.date(t.clone().subtract(1,"d")),!0},right:function(){if(!this.widget)return!1;var t=this._dates[0]||this.getMoment();return this.widget.find(".datepicker").is(":visible")&&this.date(t.clone().add(1,"d")),!0},pageUp:function(){if(!this.widget)return!1;var t=this._dates[0]||this.getMoment();return this.widget.find(".datepicker").is(":visible")&&this.date(t.clone().subtract(1,"M")),!0},pageDown:function(){if(!this.widget)return!1;var t=this._dates[0]||this.getMoment();return this.widget.find(".datepicker").is(":visible")&&this.date(t.clone().add(1,"M")),!0},enter:function(){return!!this.widget&&(this.hide(),!0)},escape:function(){return!!this.widget&&(this.hide(),!0)},"control space":function(){return!!this.widget&&(this.widget.find(".timepicker").is(":visible")&&this.widget.find('.btn[data-action="togglePeriod"]').click(),!0)},t:function(){return!!this.widget&&(this.date(this.getMoment()),!0)},delete:function(){return!!this.widget&&(this.clear(),!0)}},debug:!1,allowInputToggle:!1,disabledTimeIntervals:!1,disabledHours:!1,enabledHours:!1,viewDate:!1,allowMultidate:!1,multidateSeparator:","};return function(){function n(t,e){_classCallCheck(this,n),this._options=this._getOptions(e),this._element=t,this._dates=[],this._datesFormatted=[],this._viewDate=null,this.unset=!0,this.component=!1,this.widget=!1,this.use24Hours=null,this.actualFormat=null,this.parseFormats=null,this.currentViewMode=null,this._int()}return n.prototype._int=function(){var t=this._element.data("target-input");this._element.is("input")?this.input=this._element:void 0!==t&&(this.input="nearest"===t?this._element.find("input"):s(t)),this._dates=[],this._dates[0]=this.getMoment(),this._viewDate=this.getMoment().clone(),s.extend(!0,this._options,this._dataToOptions()),this.options(this._options),this._initFormatting(),void 0!==this.input&&this.input.is("input")&&0!==this.input.val().trim().length?this._setValue(this._parseInputDate(this.input.val().trim()),0):this._options.defaultDate&&void 0!==this.input&&void 0===this.input.attr("placeholder")&&this._setValue(this._options.defaultDate,0),this._options.inline&&this.show()},n.prototype._update=function(){this.widget&&(this._fillDate(),this._fillTime())},n.prototype._setValue=function(t,e){var i=this.unset?null:this._dates[e],o="";if(!t)return this._options.allowMultidate&&1!==this._dates.length?(o=(o=this._element.data("date")+",").replace(i.format(this.actualFormat)+",","").replace(",,","").replace(/,\s*$/,""),this._dates.splice(e,1),this._datesFormatted.splice(e,1)):(this.unset=!0,this._dates=[],this._datesFormatted=[]),void 0!==this.input&&(this.input.val(o),this.input.trigger("input")),this._element.data("date",o),this._notifyEvent({type:n.Event.CHANGE,date:!1,oldDate:i}),void this._update();if(t=t.clone().locale(this._options.locale),this._hasTimeZone()&&t.tz(this._options.timeZone),1!==this._options.stepping&&t.minutes(Math.round(t.minutes()/this._options.stepping)*this._options.stepping).seconds(0),this._isValid(t)){if(this._dates[e]=t,this._datesFormatted[e]=t.format("YYYY-MM-DD"),this._viewDate=t.clone(),this._options.allowMultidate&&1<this._dates.length){for(var s=0;s<this._dates.length;s++)o+=""+this._dates[s].format(this.actualFormat)+this._options.multidateSeparator;o=o.replace(/,\s*$/,"")}else o=this._dates[e].format(this.actualFormat);void 0!==this.input&&(this.input.val(o),this.input.trigger("input")),this._element.data("date",o),this.unset=!1,this._update(),this._notifyEvent({type:n.Event.CHANGE,date:this._dates[e].clone(),oldDate:i})}else this._options.keepInvalid?this._notifyEvent({type:n.Event.CHANGE,date:t,oldDate:i}):void 0!==this.input&&(this.input.val(""+(this.unset?"":this._dates[e].format(this.actualFormat))),this.input.trigger("input")),this._notifyEvent({type:n.Event.ERROR,date:t,oldDate:i})},n.prototype._change=function(t){var e=s(t.target).val().trim(),i=e?this._parseInputDate(e):null;return this._setValue(i),t.stopImmediatePropagation(),!1},n.prototype._getOptions=function(t){return t=s.extend(!0,{},m,t)},n.prototype._hasTimeZone=function(){return void 0!==i.tz&&void 0!==this._options.timeZone&&null!==this._options.timeZone&&""!==this._options.timeZone},n.prototype._isEnabled=function(t){if("string"!=typeof t||1<t.length)throw new TypeError("isEnabled expects a single character string parameter");switch(t){case"y":return-1!==this.actualFormat.indexOf("Y");case"M":return-1!==this.actualFormat.indexOf("M");case"d":return-1!==this.actualFormat.toLowerCase().indexOf("d");case"h":case"H":return-1!==this.actualFormat.toLowerCase().indexOf("h");case"m":return-1!==this.actualFormat.indexOf("m");case"s":return-1!==this.actualFormat.indexOf("s");case"a":case"A":return-1!==this.actualFormat.toLowerCase().indexOf("a");default:return!1}},n.prototype._hasTime=function(){return this._isEnabled("h")||this._isEnabled("m")||this._isEnabled("s")},n.prototype._hasDate=function(){return this._isEnabled("y")||this._isEnabled("M")||this._isEnabled("d")},n.prototype._dataToOptions=function(){var i=this._element.data(),o={};return i.dateOptions&&i.dateOptions instanceof Object&&(o=s.extend(!0,o,i.dateOptions)),s.each(this._options,function(t){var e="date"+t.charAt(0).toUpperCase()+t.slice(1);void 0!==i[e]?o[t]=i[e]:delete o[t]}),o},n.prototype._notifyEvent=function(t){t.type===n.Event.CHANGE&&t.date&&t.date.isSame(t.oldDate)||!t.date&&!t.oldDate||this._element.trigger(t)},n.prototype._viewUpdate=function(t){"y"===t&&(t="YYYY"),this._notifyEvent({type:n.Event.UPDATE,change:t,viewDate:this._viewDate.clone()})},n.prototype._showMode=function(t){this.widget&&(t&&(this.currentViewMode=Math.max(_,Math.min(3,this.currentViewMode+t))),this.widget.find(".datepicker > div").hide().filter(".datepicker-"+d[this.currentViewMode].CLASS_NAME).show())},n.prototype._isInDisabledDates=function(t){return!0===this._options.disabledDates[t.format("YYYY-MM-DD")]},n.prototype._isInEnabledDates=function(t){return!0===this._options.enabledDates[t.format("YYYY-MM-DD")]},n.prototype._isInDisabledHours=function(t){return!0===this._options.disabledHours[t.format("H")]},n.prototype._isInEnabledHours=function(t){return!0===this._options.enabledHours[t.format("H")]},n.prototype._isValid=function(t,e){if(!t.isValid())return!1;if(this._options.disabledDates&&"d"===e&&this._isInDisabledDates(t))return!1;if(this._options.enabledDates&&"d"===e&&!this._isInEnabledDates(t))return!1;if(this._options.minDate&&t.isBefore(this._options.minDate,e))return!1;if(this._options.maxDate&&t.isAfter(this._options.maxDate,e))return!1;if(this._options.daysOfWeekDisabled&&"d"===e&&-1!==this._options.daysOfWeekDisabled.indexOf(t.day()))return!1;if(this._options.disabledHours&&("h"===e||"m"===e||"s"===e)&&this._isInDisabledHours(t))return!1;if(this._options.enabledHours&&("h"===e||"m"===e||"s"===e)&&!this._isInEnabledHours(t))return!1;if(this._options.disabledTimeIntervals&&("h"===e||"m"===e||"s"===e)){var i=!1;if(s.each(this._options.disabledTimeIntervals,function(){if(t.isBetween(this[0],this[1]))return!(i=!0)}),i)return!1}return!0},n.prototype._parseInputDate=function(t){return void 0===this._options.parseInputDate?i.isMoment(t)||(t=this.getMoment(t)):t=this._options.parseInputDate(t),t},n.prototype._keydown=function(t){var e=null,i=void 0,o=void 0,s=void 0,n=void 0,a=[],r={},p=t.which;for(i in f[p]="p",f)f.hasOwnProperty(i)&&"p"===f[i]&&(a.push(i),parseInt(i,10)!==p&&(r[i]=!0));for(i in this._options.keyBinds)if(this._options.keyBinds.hasOwnProperty(i)&&"function"==typeof this._options.keyBinds[i]&&(s=i.split(" ")).length===a.length&&l[p]===s[s.length-1]){for(n=!0,o=s.length-2;0<=o;o--)if(!(l[s[o]]in r)){n=!1;break}if(n){e=this._options.keyBinds[i];break}}e&&e.call(this)&&(t.stopPropagation(),t.preventDefault())},n.prototype._keyup=function(t){f[t.which]="r",c[t.which]&&(c[t.which]=!1,t.stopPropagation(),t.preventDefault())},n.prototype._indexGivenDates=function(t){var e={},i=this;return s.each(t,function(){var t=i._parseInputDate(this);t.isValid()&&(e[t.format("YYYY-MM-DD")]=!0)}),!!Object.keys(e).length&&e},n.prototype._indexGivenHours=function(t){var e={};return s.each(t,function(){e[this]=!0}),!!Object.keys(e).length&&e},n.prototype._initFormatting=function(){var t=this._options.format||"L LT",e=this;this.actualFormat=t.replace(/(\[[^\[]*])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,function(t){return e._dates[0].localeData().longDateFormat(t)||t}),this.parseFormats=this._options.extraFormats?this._options.extraFormats.slice():[],this.parseFormats.indexOf(t)<0&&this.parseFormats.indexOf(this.actualFormat)<0&&this.parseFormats.push(this.actualFormat),this.use24Hours=this.actualFormat.toLowerCase().indexOf("a")<1&&this.actualFormat.replace(/\[.*?]/g,"").indexOf("h")<1,this._isEnabled("y")&&(_=2),this._isEnabled("M")&&(_=1),this._isEnabled("d")&&(_=0),this.currentViewMode=Math.max(_,this.currentViewMode),this.unset||this._setValue(this._dates[0],0)},n.prototype._getLastPickedDate=function(){return this._dates[this._getLastPickedDateIndex()]},n.prototype._getLastPickedDateIndex=function(){return this._dates.length-1},n.prototype.getMoment=function(t){var e=void 0;return e=null==t?i():this._hasTimeZone()?i.tz(t,this.parseFormats,this._options.locale,this._options.useStrict,this._options.timeZone):i(t,this.parseFormats,this._options.locale,this._options.useStrict),this._hasTimeZone()&&e.tz(this._options.timeZone),e},n.prototype.toggle=function(){return this.widget?this.hide():this.show()},n.prototype.ignoreReadonly=function(t){if(0===arguments.length)return this._options.ignoreReadonly;if("boolean"!=typeof t)throw new TypeError("ignoreReadonly () expects a boolean parameter");this._options.ignoreReadonly=t},n.prototype.options=function(t){if(0===arguments.length)return s.extend(!0,{},this._options);if(!(t instanceof Object))throw new TypeError("options() this.options parameter should be an object");s.extend(!0,this._options,t);var i=this;s.each(this._options,function(t,e){void 0!==i[t]&&i[t](e)})},n.prototype.date=function(t,e){if(e=e||0,0===arguments.length)return this.unset?null:this._options.allowMultidate?this._dates.join(this._options.multidateSeparator):this._dates[e].clone();if(!(null===t||"string"==typeof t||i.isMoment(t)||t instanceof Date))throw new TypeError("date() parameter must be one of [null, string, moment or Date]");this._setValue(null===t?null:this._parseInputDate(t),e)},n.prototype.format=function(t){if(0===arguments.length)return this._options.format;if("string"!=typeof t&&("boolean"!=typeof t||!1!==t))throw new TypeError("format() expects a string or boolean:false parameter "+t);this._options.format=t,this.actualFormat&&this._initFormatting()},n.prototype.timeZone=function(t){if(0===arguments.length)return this._options.timeZone;if("string"!=typeof t)throw new TypeError("newZone() expects a string parameter");this._options.timeZone=t},n.prototype.dayViewHeaderFormat=function(t){if(0===arguments.length)return this._options.dayViewHeaderFormat;if("string"!=typeof t)throw new TypeError("dayViewHeaderFormat() expects a string parameter");this._options.dayViewHeaderFormat=t},n.prototype.extraFormats=function(t){if(0===arguments.length)return this._options.extraFormats;if(!1!==t&&!(t instanceof Array))throw new TypeError("extraFormats() expects an array or false parameter");this._options.extraFormats=t,this.parseFormats&&this._initFormatting()},n.prototype.disabledDates=function(t){if(0===arguments.length)return this._options.disabledDates?s.extend({},this._options.disabledDates):this._options.disabledDates;if(!t)return this._options.disabledDates=!1,this._update(),!0;if(!(t instanceof Array))throw new TypeError("disabledDates() expects an array parameter");this._options.disabledDates=this._indexGivenDates(t),this._options.enabledDates=!1,this._update()},n.prototype.enabledDates=function(t){if(0===arguments.length)return this._options.enabledDates?s.extend({},this._options.enabledDates):this._options.enabledDates;if(!t)return this._options.enabledDates=!1,this._update(),!0;if(!(t instanceof Array))throw new TypeError("enabledDates() expects an array parameter");this._options.enabledDates=this._indexGivenDates(t),this._options.disabledDates=!1,this._update()},n.prototype.daysOfWeekDisabled=function(t){if(0===arguments.length)return this._options.daysOfWeekDisabled.splice(0);if("boolean"==typeof t&&!t)return this._options.daysOfWeekDisabled=!1,this._update(),!0;if(!(t instanceof Array))throw new TypeError("daysOfWeekDisabled() expects an array parameter");if(this._options.daysOfWeekDisabled=t.reduce(function(t,e){return 6<(e=parseInt(e,10))||e<0||isNaN(e)||-1===t.indexOf(e)&&t.push(e),t},[]).sort(),this._options.useCurrent&&!this._options.keepInvalid)for(var e=0;e<this._dates.length;e++){for(var i=0;!this._isValid(this._dates[e],"d");){if(this._dates[e].add(1,"d"),31===i)throw"Tried 31 times to find a valid date";i++}this._setValue(this._dates[e],e)}this._update()},n.prototype.maxDate=function(t){if(0===arguments.length)return this._options.maxDate?this._options.maxDate.clone():this._options.maxDate;if("boolean"==typeof t&&!1===t)return this._options.maxDate=!1,this._update(),!0;"string"==typeof t&&("now"!==t&&"moment"!==t||(t=this.getMoment()));var e=this._parseInputDate(t);if(!e.isValid())throw new TypeError("maxDate() Could not parse date parameter: "+t);if(this._options.minDate&&e.isBefore(this._options.minDate))throw new TypeError("maxDate() date parameter is before this.options.minDate: "+e.format(this.actualFormat));this._options.maxDate=e;for(var i=0;i<this._dates.length;i++)this._options.useCurrent&&!this._options.keepInvalid&&this._dates[i].isAfter(t)&&this._setValue(this._options.maxDate,i);this._viewDate.isAfter(e)&&(this._viewDate=e.clone().subtract(this._options.stepping,"m")),this._update()},n.prototype.minDate=function(t){if(0===arguments.length)return this._options.minDate?this._options.minDate.clone():this._options.minDate;if("boolean"==typeof t&&!1===t)return this._options.minDate=!1,this._update(),!0;"string"==typeof t&&("now"!==t&&"moment"!==t||(t=this.getMoment()));var e=this._parseInputDate(t);if(!e.isValid())throw new TypeError("minDate() Could not parse date parameter: "+t);if(this._options.maxDate&&e.isAfter(this._options.maxDate))throw new TypeError("minDate() date parameter is after this.options.maxDate: "+e.format(this.actualFormat));this._options.minDate=e;for(var i=0;i<this._dates.length;i++)this._options.useCurrent&&!this._options.keepInvalid&&this._dates[i].isBefore(t)&&this._setValue(this._options.minDate,i);this._viewDate.isBefore(e)&&(this._viewDate=e.clone().add(this._options.stepping,"m")),this._update()},n.prototype.defaultDate=function(t){if(0===arguments.length)return this._options.defaultDate?this._options.defaultDate.clone():this._options.defaultDate;if(!t)return!(this._options.defaultDate=!1);"string"==typeof t&&(t="now"===t||"moment"===t?this.getMoment():this.getMoment(t));var e=this._parseInputDate(t);if(!e.isValid())throw new TypeError("defaultDate() Could not parse date parameter: "+t);if(!this._isValid(e))throw new TypeError("defaultDate() date passed is invalid according to component setup validations");this._options.defaultDate=e,(this._options.defaultDate&&this._options.inline||void 0!==this.input&&""===this.input.val().trim())&&this._setValue(this._options.defaultDate,0)},n.prototype.locale=function(t){if(0===arguments.length)return this._options.locale;if(!i.localeData(t))throw new TypeError("locale() locale "+t+" is not loaded from moment locales!");this._options.locale=t;for(var e=0;e<this._dates.length;e++)this._dates[e].locale(this._options.locale);this._viewDate.locale(this._options.locale),this.actualFormat&&this._initFormatting(),this.widget&&(this.hide(),this.show())},n.prototype.stepping=function(t){if(0===arguments.length)return this._options.stepping;t=parseInt(t,10),(isNaN(t)||t<1)&&(t=1),this._options.stepping=t},n.prototype.useCurrent=function(t){var e=["year","month","day","hour","minute"];if(0===arguments.length)return this._options.useCurrent;if("boolean"!=typeof t&&"string"!=typeof t)throw new TypeError("useCurrent() expects a boolean or string parameter");if("string"==typeof t&&-1===e.indexOf(t.toLowerCase()))throw new TypeError("useCurrent() expects a string parameter of "+e.join(", "));this._options.useCurrent=t},n.prototype.collapse=function(t){if(0===arguments.length)return this._options.collapse;if("boolean"!=typeof t)throw new TypeError("collapse() expects a boolean parameter");if(this._options.collapse===t)return!0;this._options.collapse=t,this.widget&&(this.hide(),this.show())},n.prototype.icons=function(t){if(0===arguments.length)return s.extend({},this._options.icons);if(!(t instanceof Object))throw new TypeError("icons() expects parameter to be an Object");s.extend(this._options.icons,t),this.widget&&(this.hide(),this.show())},n.prototype.tooltips=function(t){if(0===arguments.length)return s.extend({},this._options.tooltips);if(!(t instanceof Object))throw new TypeError("tooltips() expects parameter to be an Object");s.extend(this._options.tooltips,t),this.widget&&(this.hide(),this.show())},n.prototype.useStrict=function(t){if(0===arguments.length)return this._options.useStrict;if("boolean"!=typeof t)throw new TypeError("useStrict() expects a boolean parameter");this._options.useStrict=t},n.prototype.sideBySide=function(t){if(0===arguments.length)return this._options.sideBySide;if("boolean"!=typeof t)throw new TypeError("sideBySide() expects a boolean parameter");this._options.sideBySide=t,this.widget&&(this.hide(),this.show())},n.prototype.viewMode=function(t){if(0===arguments.length)return this._options.viewMode;if("string"!=typeof t)throw new TypeError("viewMode() expects a string parameter");if(-1===n.ViewModes.indexOf(t))throw new TypeError("viewMode() parameter must be one of ("+n.ViewModes.join(", ")+") value");this._options.viewMode=t,this.currentViewMode=Math.max(n.ViewModes.indexOf(t)-1,n.MinViewModeNumber),this._showMode()},n.prototype.calendarWeeks=function(t){if(0===arguments.length)return this._options.calendarWeeks;if("boolean"!=typeof t)throw new TypeError("calendarWeeks() expects parameter to be a boolean value");this._options.calendarWeeks=t,this._update()},n.prototype.buttons=function(t){if(0===arguments.length)return s.extend({},this._options.buttons);if(!(t instanceof Object))throw new TypeError("buttons() expects parameter to be an Object");if(s.extend(this._options.buttons,t),"boolean"!=typeof this._options.buttons.showToday)throw new TypeError("buttons.showToday expects a boolean parameter");if("boolean"!=typeof this._options.buttons.showClear)throw new TypeError("buttons.showClear expects a boolean parameter");if("boolean"!=typeof this._options.buttons.showClose)throw new TypeError("buttons.showClose expects a boolean parameter");this.widget&&(this.hide(),this.show())},n.prototype.keepOpen=function(t){if(0===arguments.length)return this._options.keepOpen;if("boolean"!=typeof t)throw new TypeError("keepOpen() expects a boolean parameter");this._options.keepOpen=t},n.prototype.focusOnShow=function(t){if(0===arguments.length)return this._options.focusOnShow;if("boolean"!=typeof t)throw new TypeError("focusOnShow() expects a boolean parameter");this._options.focusOnShow=t},n.prototype.inline=function(t){if(0===arguments.length)return this._options.inline;if("boolean"!=typeof t)throw new TypeError("inline() expects a boolean parameter");this._options.inline=t},n.prototype.clear=function(){this._setValue(null)},n.prototype.keyBinds=function(t){if(0===arguments.length)return this._options.keyBinds;this._options.keyBinds=t},n.prototype.debug=function(t){if("boolean"!=typeof t)throw new TypeError("debug() expects a boolean parameter");this._options.debug=t},n.prototype.allowInputToggle=function(t){if(0===arguments.length)return this._options.allowInputToggle;if("boolean"!=typeof t)throw new TypeError("allowInputToggle() expects a boolean parameter");this._options.allowInputToggle=t},n.prototype.keepInvalid=function(t){if(0===arguments.length)return this._options.keepInvalid;if("boolean"!=typeof t)throw new TypeError("keepInvalid() expects a boolean parameter");this._options.keepInvalid=t},n.prototype.datepickerInput=function(t){if(0===arguments.length)return this._options.datepickerInput;if("string"!=typeof t)throw new TypeError("datepickerInput() expects a string parameter");this._options.datepickerInput=t},n.prototype.parseInputDate=function(t){if(0===arguments.length)return this._options.parseInputDate;if("function"!=typeof t)throw new TypeError("parseInputDate() should be as function");this._options.parseInputDate=t},n.prototype.disabledTimeIntervals=function(t){if(0===arguments.length)return this._options.disabledTimeIntervals?s.extend({},this._options.disabledTimeIntervals):this._options.disabledTimeIntervals;if(!t)return this._options.disabledTimeIntervals=!1,this._update(),!0;if(!(t instanceof Array))throw new TypeError("disabledTimeIntervals() expects an array parameter");this._options.disabledTimeIntervals=t,this._update()},n.prototype.disabledHours=function(t){if(0===arguments.length)return this._options.disabledHours?s.extend({},this._options.disabledHours):this._options.disabledHours;if(!t)return this._options.disabledHours=!1,this._update(),!0;if(!(t instanceof Array))throw new TypeError("disabledHours() expects an array parameter");if(this._options.disabledHours=this._indexGivenHours(t),this._options.enabledHours=!1,this._options.useCurrent&&!this._options.keepInvalid)for(var e=0;e<this._dates.length;e++){for(var i=0;!this._isValid(this._dates[e],"h");){if(this._dates[e].add(1,"h"),24===i)throw"Tried 24 times to find a valid date";i++}this._setValue(this._dates[e],e)}this._update()},n.prototype.enabledHours=function(t){if(0===arguments.length)return this._options.enabledHours?s.extend({},this._options.enabledHours):this._options.enabledHours;if(!t)return this._options.enabledHours=!1,this._update(),!0;if(!(t instanceof Array))throw new TypeError("enabledHours() expects an array parameter");if(this._options.enabledHours=this._indexGivenHours(t),this._options.disabledHours=!1,this._options.useCurrent&&!this._options.keepInvalid)for(var e=0;e<this._dates.length;e++){for(var i=0;!this._isValid(this._dates[e],"h");){if(this._dates[e].add(1,"h"),24===i)throw"Tried 24 times to find a valid date";i++}this._setValue(this._dates[e],e)}this._update()},n.prototype.viewDate=function(t){if(0===arguments.length)return this._viewDate.clone();if(!t)return this._viewDate=(this._dates[0]||this.getMoment()).clone(),!0;if(!("string"==typeof t||i.isMoment(t)||t instanceof Date))throw new TypeError("viewDate() parameter must be one of [string, moment or Date]");this._viewDate=this._parseInputDate(t),this._viewUpdate()},n.prototype.allowMultidate=function(t){if("boolean"!=typeof t)throw new TypeError("allowMultidate() expects a boolean parameter");this._options.allowMultidate=t},n.prototype.multidateSeparator=function(t){if(0===arguments.length)return this._options.multidateSeparator;if("string"!=typeof t||1<t.length)throw new TypeError("multidateSeparator expects a single character string parameter");this._options.multidateSeparator=t},_createClass(n,null,[{key:"NAME",get:function(){return t}},{key:"DATA_KEY",get:function(){return e}},{key:"EVENT_KEY",get:function(){return o}},{key:"DATA_API_KEY",get:function(){return a}},{key:"DatePickerModes",get:function(){return d}},{key:"ViewModes",get:function(){return u}},{key:"MinViewModeNumber",get:function(){return _}},{key:"Event",get:function(){return h}},{key:"Selector",get:function(){return r}},{key:"Default",get:function(){return m},set:function(t){m=t}},{key:"ClassName",get:function(){return p}}]),n}()}(jQuery,moment); |
@@ -141,6 +141,6 @@ module.exports = function (grunt) { | ||
'build:travis', | ||
'docs', | ||
'nugetpack' | ||
'docs'//, | ||
//'nugetpack' | ||
]); | ||
}); | ||
}; |
{ | ||
"license": "MIT", | ||
"main": "build/js/tempusdominus-core.js", | ||
"module": "src/js/tempusdominus-core.js", | ||
"name": "tempusdominus-core", | ||
@@ -12,8 +13,8 @@ "author": { | ||
"dependencies": { | ||
"jquery": "^1.9.1 || ^2.0 || ^3.0", | ||
"moment": "^2.10", | ||
"jquery": "^3.0", | ||
"moment": "^2.22.2", | ||
"moment-timezone": "^0.4.0" | ||
}, | ||
"peerDependenciesd": { | ||
"jquery": "^1.9.1 || ^2.0 || ^3.0", | ||
"jquery": "^3.0", | ||
"moment": "^2.10", | ||
@@ -26,14 +27,14 @@ "moment-timezone": "^0.4.0" | ||
"babel-preset-es2015": "^6.16.0", | ||
"grunt": "latest", | ||
"grunt": "^1.0.3", | ||
"grunt-babel": "6.0.0", | ||
"grunt-contrib-concat": "^1.0.1", | ||
"grunt-contrib-connect": "^1.0.1", | ||
"grunt-contrib-jasmine": "^1.0.3", | ||
"grunt-contrib-jasmine": "^2.0.1", | ||
"grunt-contrib-jshint": "latest", | ||
"grunt-contrib-less": "latest", | ||
"grunt-contrib-uglify": "latest", | ||
"grunt-contrib-watch": "^1.0.0", | ||
"grunt-contrib-watch": "^1.1.0", | ||
"grunt-env": "^0.4.4", | ||
"grunt-eslint": "^19.0.0", | ||
"grunt-nuget": "^0.1.5", | ||
"grunt-nuget": "^0.3.0", | ||
"grunt-string-replace": "latest", | ||
@@ -53,3 +54,3 @@ "load-grunt-tasks": "latest" | ||
}, | ||
"version": "5.0.0-alpha9", | ||
"version": "5.0.0", | ||
"files": [ | ||
@@ -56,0 +57,0 @@ "build", |
@@ -0,9 +1,10 @@ | ||
import jQuery from 'jquery'; | ||
import moment from 'moment'; | ||
// ReSharper disable once InconsistentNaming | ||
const DateTimePicker = ($ => { | ||
const DateTimePicker = (($, moment) => { | ||
// ReSharper disable InconsistentNaming | ||
const NAME = 'datetimepicker', | ||
VERSION = '5.0.0-alpha7', | ||
DATA_KEY = `${NAME}`, | ||
EVENT_KEY = `.${DATA_KEY}`, | ||
EMIT_EVENT_KEY = `${DATA_KEY}.`, | ||
DATA_API_KEY = '.data-api', | ||
@@ -24,7 +25,59 @@ Selector = { | ||
//emitted | ||
UPDATE: `${EMIT_EVENT_KEY}update`, | ||
ERROR: `${EMIT_EVENT_KEY}error`, | ||
HIDE: `${EMIT_EVENT_KEY}hide`, | ||
SHOW: `${EMIT_EVENT_KEY}show` | ||
UPDATE: `update${EVENT_KEY}`, | ||
ERROR: `error${EVENT_KEY}`, | ||
HIDE: `hide${EVENT_KEY}`, | ||
SHOW: `show${EVENT_KEY}` | ||
}, | ||
DatePickerModes = [{ | ||
CLASS_NAME: 'days', | ||
NAV_FUNCTION: 'M', | ||
NAV_STEP: 1 | ||
}, { | ||
CLASS_NAME: 'months', | ||
NAV_FUNCTION: 'y', | ||
NAV_STEP: 1 | ||
}, { | ||
CLASS_NAME: 'years', | ||
NAV_FUNCTION: 'y', | ||
NAV_STEP: 10 | ||
}, { | ||
CLASS_NAME: 'decades', | ||
NAV_FUNCTION: 'y', | ||
NAV_STEP: 100 | ||
}], | ||
KeyMap = { | ||
'up': 38, | ||
38: 'up', | ||
'down': 40, | ||
40: 'down', | ||
'left': 37, | ||
37: 'left', | ||
'right': 39, | ||
39: 'right', | ||
'tab': 9, | ||
9: 'tab', | ||
'escape': 27, | ||
27: 'escape', | ||
'enter': 13, | ||
13: 'enter', | ||
'pageUp': 33, | ||
33: 'pageUp', | ||
'pageDown': 34, | ||
34: 'pageDown', | ||
'shift': 16, | ||
16: 'shift', | ||
'control': 17, | ||
17: 'control', | ||
'space': 32, | ||
32: 'space', | ||
't': 84, | ||
84: 't', | ||
'delete': 46, | ||
46: 'delete' | ||
}, | ||
ViewModes = ['times', 'days', 'months', 'years', 'decades'], | ||
keyState = {}, | ||
keyPressHandled = {}; | ||
let MinViewModeNumber = 0, | ||
Default = { | ||
@@ -40,3 +93,3 @@ timeZone: '', | ||
collapse: true, | ||
locale: window.moment.locale(), | ||
locale: moment.locale(), | ||
defaultDate: false, | ||
@@ -196,2 +249,5 @@ disabledDates: false, | ||
enter: function () { | ||
if (!this.widget) { | ||
return false; | ||
} | ||
this.hide(); | ||
@@ -217,2 +273,5 @@ return true; | ||
t: function () { | ||
if (!this.widget) { | ||
return false; | ||
} | ||
this.date(this.getMoment()); | ||
@@ -237,55 +296,4 @@ return true; | ||
multidateSeparator: ',' | ||
}, | ||
DatePickerModes = [{ | ||
CLASS_NAME: 'days', | ||
NAV_FUNCTION: 'M', | ||
NAV_STEP: 1 | ||
}, { | ||
CLASS_NAME: 'months', | ||
NAV_FUNCTION: 'y', | ||
NAV_STEP: 1 | ||
}, { | ||
CLASS_NAME: 'years', | ||
NAV_FUNCTION: 'y', | ||
NAV_STEP: 10 | ||
}, { | ||
CLASS_NAME: 'decades', | ||
NAV_FUNCTION: 'y', | ||
NAV_STEP: 100 | ||
}], | ||
KeyMap = { | ||
'up': 38, | ||
38: 'up', | ||
'down': 40, | ||
40: 'down', | ||
'left': 37, | ||
37: 'left', | ||
'right': 39, | ||
39: 'right', | ||
'tab': 9, | ||
9: 'tab', | ||
'escape': 27, | ||
27: 'escape', | ||
'enter': 13, | ||
13: 'enter', | ||
'pageUp': 33, | ||
33: 'pageUp', | ||
'pageDown': 34, | ||
34: 'pageDown', | ||
'shift': 16, | ||
16: 'shift', | ||
'control': 17, | ||
17: 'control', | ||
'space': 32, | ||
32: 'space', | ||
't': 84, | ||
84: 't', | ||
'delete': 46, | ||
46: 'delete' | ||
}, | ||
ViewModes = ['times', 'days', 'months', 'years', 'decades'], | ||
keyState = {}, | ||
keyPressHandled = {}; | ||
}; | ||
let MinViewModeNumber = 0; | ||
// ReSharper restore InconsistentNaming | ||
@@ -326,9 +334,2 @@ | ||
*/ | ||
static get VERSION() { | ||
return VERSION; | ||
} | ||
/** | ||
* @return {string} | ||
*/ | ||
static get DATA_KEY() { | ||
@@ -379,2 +380,6 @@ return DATA_KEY; | ||
static set Default(value) { | ||
Default = value; | ||
} | ||
static get ClassName() { | ||
@@ -409,5 +414,5 @@ return ClassName; | ||
if (this.input !== undefined && this.input.is('input') && this.input.val().trim().length !== 0) { | ||
this._setValue(this._parseInputDate(this.input.val().trim())); | ||
this._setValue(this._parseInputDate(this.input.val().trim()), 0); | ||
} else if (this._options.defaultDate && this.input !== undefined && this.input.attr('placeholder') === undefined) { | ||
this._setValue(this._options.defaultDate); | ||
this._setValue(this._options.defaultDate, 0); | ||
} | ||
@@ -527,3 +532,3 @@ if (this._options.inline) { | ||
_hasTimeZone() { | ||
return window.moment.tz !== undefined && this._options.timeZone !== undefined && this._options.timeZone !== null && this._options.timeZone !== ''; | ||
return moment.tz !== undefined && this._options.timeZone !== undefined && this._options.timeZone !== null && this._options.timeZone !== ''; | ||
} | ||
@@ -549,2 +554,5 @@ | ||
return this.actualFormat.indexOf('s') !== -1; | ||
case 'a': | ||
case 'A': | ||
return this.actualFormat.toLowerCase().indexOf('a') !== -1; | ||
default: | ||
@@ -668,3 +676,3 @@ return false; | ||
if (this._options.parseInputDate === undefined) { | ||
if (!window.moment.isMoment(inputDate)) { | ||
if (!moment.isMoment(inputDate)) { | ||
inputDate = this.getMoment(inputDate); | ||
@@ -721,3 +729,3 @@ } | ||
if (handler) { | ||
if (handler.call(this.widget)) { | ||
if (handler.call(this)) { | ||
e.stopPropagation(); | ||
@@ -809,9 +817,9 @@ e.preventDefault(); | ||
if (d === undefined || d === null) { | ||
returnMoment = window.moment(); //TODO should this use format? and locale? | ||
returnMoment = moment(); //TODO should this use format? and locale? | ||
} else if (this._hasTimeZone()) { | ||
// There is a string to parse and a default time zone | ||
// parse with the tz function which takes a default time zone if it is not in the format string | ||
returnMoment = window.moment.tz(d, this.parseFormats, this._options.useStrict, this._options.timeZone); | ||
returnMoment = moment.tz(d, this.parseFormats, this._options.locale, this._options.useStrict, this._options.timeZone); | ||
} else { | ||
returnMoment = window.moment(d, this.parseFormats, this._options.useStrict); | ||
returnMoment = moment(d, this.parseFormats, this._options.locale, this._options.useStrict); | ||
} | ||
@@ -871,3 +879,3 @@ | ||
if (newDate !== null && typeof newDate !== 'string' && !window.moment.isMoment(newDate) && !(newDate instanceof Date)) { | ||
if (newDate !== null && typeof newDate !== 'string' && !moment.isMoment(newDate) && !(newDate instanceof Date)) { | ||
throw new TypeError('date() parameter must be one of [null, string, moment or Date]'); | ||
@@ -880,5 +888,2 @@ } | ||
format(newFormat) { | ||
///<summary>test su</summary> | ||
///<param name="newFormat">info about para</param> | ||
///<returns type="string|boolean">returns foo</returns> | ||
if (arguments.length === 0) { | ||
@@ -1124,6 +1129,8 @@ return this._options.format; | ||
if (!window.moment.localeData(locale)) { | ||
if (!moment.localeData(locale)) { | ||
throw new TypeError(`locale() locale ${locale} is not loaded from moment locales!`); | ||
} | ||
this._options.locale = locale; | ||
for (let i = 0; i < this._dates.length; i++) { | ||
@@ -1497,3 +1504,3 @@ this._dates[i].locale(this._options.locale); | ||
if (typeof newDate !== 'string' && !window.moment.isMoment(newDate) && !(newDate instanceof Date)) { | ||
if (typeof newDate !== 'string' && !moment.isMoment(newDate) && !(newDate instanceof Date)) { | ||
throw new TypeError('viewDate() parameter must be one of [string, moment or Date]'); | ||
@@ -1528,4 +1535,4 @@ } | ||
return DateTimePicker; | ||
})(jQuery); | ||
})(jQuery, moment); | ||
export default DateTimePicker; |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
265069
14
2826
0
Updatedjquery@^3.0
Updatedmoment@^2.22.2