diff --git a/build/js/tempusdominus-core.js b/build/js/tempusdominus-core.js index 647fd22..ff4856c 100644 --- a/build/js/tempusdominus-core.js +++ b/build/js/tempusdominus-core.js @@ -245,6 +245,9 @@ var DateTimePicker = function ($, moment) { return true; }, enter: function enter() { + if (!this.widget) { + return false; + } this.hide(); return true; }, @@ -265,6 +268,9 @@ var DateTimePicker = function ($, moment) { return true; }, t: function t() { + if (!this.widget) { + return false; + } this.date(this.getMoment()); return true; }, @@ -657,7 +663,7 @@ var DateTimePicker = function ($, moment) { } if (handler) { - if (handler.call(this.widget)) { + if (handler.call(this)) { e.stopPropagation(); e.preventDefault(); } diff --git a/build/js/tempusdominus-core.min.js b/build/js/tempusdominus-core.min.js index 08f2995..95811a6 100644 --- a/build/js/tempusdominus-core.min.js +++ b/build/js/tempusdominus-core.min.js @@ -1 +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;c1){for(var e=0;e1)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;case"a":case"A":return this.actualFormat.toLowerCase().indexOf("a")!==-1;default:return!1}},q.prototype._hasTime=function(){return this._isEnabled("h")||this._isEnabled("m")||this._isEnabled("s")},q.prototype._hasDate=function(){return this._isEnabled("y")||this._isEnabled("M")||this._isEnabled("d")},q.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},q.prototype._notifyEvent=function(a){a.type===q.Event.CHANGE&&a.date&&a.date.isSame(a.oldDate)||!a.date&&!a.oldDate||this._element.trigger(a)},q.prototype._viewUpdate=function(a){"y"===a&&(a="YYYY"),this._notifyEvent({type:q.Event.UPDATE,change:a,viewDate:this._viewDate.clone()})},q.prototype._showMode=function(a){this.widget&&(a&&(this.currentViewMode=Math.max(o,Math.min(3,this.currentViewMode+a))),this.widget.find(".datepicker > div").hide().filter(".datepicker-"+j[this.currentViewMode].CLASS_NAME).show())},q.prototype._isInDisabledDates=function(a){return this._options.disabledDates[a.format("YYYY-MM-DD")]===!0},q.prototype._isInEnabledDates=function(a){return this._options.enabledDates[a.format("YYYY-MM-DD")]===!0},q.prototype._isInDisabledHours=function(a){return this._options.disabledHours[a.format("H")]===!0},q.prototype._isInEnabledHours=function(a){return this._options.enabledHours[a.format("H")]===!0},q.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},q.prototype._parseInputDate=function(a){return void 0===this._options.parseInputDate?b.isMoment(a)||(a=this.getMoment(a)):a=this._options.parseInputDate(a),a},q.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";m[i]=j;for(c in m)m.hasOwnProperty(c)&&m[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&&k[i]===e[e.length-1])){for(f=!0,d=e.length-2;d>=0;d--)if(!(k[e[d]]in h)){f=!1;break}if(f){b=this._options.keyBinds[c];break}}b&&b.call(this.widget)&&(a.stopPropagation(),a.preventDefault())},q.prototype._keyup=function(a){m[a.which]="r",n[a.which]&&(n[a.which]=!1,a.stopPropagation(),a.preventDefault())},q.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},q.prototype._indexGivenHours=function(b){var c={};return a.each(b,function(){c[this]=!0}),!!Object.keys(c).length&&c},q.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")&&(o=2),this._isEnabled("M")&&(o=1),this._isEnabled("d")&&(o=0),this.currentViewMode=Math.max(o,this.currentViewMode),this.unset||this._setValue(this._dates[0],0)},q.prototype._getLastPickedDate=function(){return this._dates[this._getLastPickedDateIndex()]},q.prototype._getLastPickedDateIndex=function(){return this._dates.length-1},q.prototype.getMoment=function(a){var c=void 0;return c=void 0===a||null===a?b():this._hasTimeZone()?b.tz(a,this.parseFormats,this._options.useStrict,this._options.timeZone):b(a,this.parseFormats,this._options.useStrict),this._hasTimeZone()&&c.tz(this._options.timeZone),c},q.prototype.toggle=function(){return this.widget?this.hide():this.show()},q.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},q.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)})},q.prototype.date=function(a,c){if(c=c||0,0===arguments.length)return this.unset?null:this._options.allowMultidate?this._dates.join(this._options.multidateSeparator):this._dates[c].clone();if(!(null===a||"string"==typeof a||b.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),c)},q.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()},q.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},q.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},q.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()},q.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()},q.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()},q.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;b1)throw new TypeError("multidateSeparator expects a single character string parameter");this._options.multidateSeparator=a},_createClass(q,null,[{key:"NAME",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 f}},{key:"DatePickerModes",get:function(){return j}},{key:"ViewModes",get:function(){return l}},{key:"MinViewModeNumber",get:function(){return o}},{key:"Event",get:function(){return i}},{key:"Selector",get:function(){return g}},{key:"Default",get:function(){return p},set:function(a){p=a}},{key:"ClassName",get:function(){return h}}]),q}();return q}(jQuery,moment); \ No newline at end of file +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;c1){for(var e=0;e1)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;case"a":case"A":return this.actualFormat.toLowerCase().indexOf("a")!==-1;default:return!1}},q.prototype._hasTime=function(){return this._isEnabled("h")||this._isEnabled("m")||this._isEnabled("s")},q.prototype._hasDate=function(){return this._isEnabled("y")||this._isEnabled("M")||this._isEnabled("d")},q.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},q.prototype._notifyEvent=function(a){a.type===q.Event.CHANGE&&a.date&&a.date.isSame(a.oldDate)||!a.date&&!a.oldDate||this._element.trigger(a)},q.prototype._viewUpdate=function(a){"y"===a&&(a="YYYY"),this._notifyEvent({type:q.Event.UPDATE,change:a,viewDate:this._viewDate.clone()})},q.prototype._showMode=function(a){this.widget&&(a&&(this.currentViewMode=Math.max(o,Math.min(3,this.currentViewMode+a))),this.widget.find(".datepicker > div").hide().filter(".datepicker-"+j[this.currentViewMode].CLASS_NAME).show())},q.prototype._isInDisabledDates=function(a){return this._options.disabledDates[a.format("YYYY-MM-DD")]===!0},q.prototype._isInEnabledDates=function(a){return this._options.enabledDates[a.format("YYYY-MM-DD")]===!0},q.prototype._isInDisabledHours=function(a){return this._options.disabledHours[a.format("H")]===!0},q.prototype._isInEnabledHours=function(a){return this._options.enabledHours[a.format("H")]===!0},q.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},q.prototype._parseInputDate=function(a){return void 0===this._options.parseInputDate?b.isMoment(a)||(a=this.getMoment(a)):a=this._options.parseInputDate(a),a},q.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";m[i]=j;for(c in m)m.hasOwnProperty(c)&&m[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&&k[i]===e[e.length-1])){for(f=!0,d=e.length-2;d>=0;d--)if(!(k[e[d]]in h)){f=!1;break}if(f){b=this._options.keyBinds[c];break}}b&&b.call(this)&&(a.stopPropagation(),a.preventDefault())},q.prototype._keyup=function(a){m[a.which]="r",n[a.which]&&(n[a.which]=!1,a.stopPropagation(),a.preventDefault())},q.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},q.prototype._indexGivenHours=function(b){var c={};return a.each(b,function(){c[this]=!0}),!!Object.keys(c).length&&c},q.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")&&(o=2),this._isEnabled("M")&&(o=1),this._isEnabled("d")&&(o=0),this.currentViewMode=Math.max(o,this.currentViewMode),this.unset||this._setValue(this._dates[0],0)},q.prototype._getLastPickedDate=function(){return this._dates[this._getLastPickedDateIndex()]},q.prototype._getLastPickedDateIndex=function(){return this._dates.length-1},q.prototype.getMoment=function(a){var c=void 0;return c=void 0===a||null===a?b():this._hasTimeZone()?b.tz(a,this.parseFormats,this._options.useStrict,this._options.timeZone):b(a,this.parseFormats,this._options.useStrict),this._hasTimeZone()&&c.tz(this._options.timeZone),c},q.prototype.toggle=function(){return this.widget?this.hide():this.show()},q.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},q.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)})},q.prototype.date=function(a,c){if(c=c||0,0===arguments.length)return this.unset?null:this._options.allowMultidate?this._dates.join(this._options.multidateSeparator):this._dates[c].clone();if(!(null===a||"string"==typeof a||b.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),c)},q.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()},q.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},q.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},q.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()},q.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()},q.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()},q.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;b1)throw new TypeError("multidateSeparator expects a single character string parameter");this._options.multidateSeparator=a},_createClass(q,null,[{key:"NAME",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 f}},{key:"DatePickerModes",get:function(){return j}},{key:"ViewModes",get:function(){return l}},{key:"MinViewModeNumber",get:function(){return o}},{key:"Event",get:function(){return i}},{key:"Selector",get:function(){return g}},{key:"Default",get:function(){return p},set:function(a){p=a}},{key:"ClassName",get:function(){return h}}]),q}();return q}(jQuery,moment); \ No newline at end of file diff --git a/composer.json b/composer.json index 107ba73..1c792f5 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "tempusdominus/core", "type": "component", - "version": "5.0.0-alpha16", + "version": "5.0.0-alpha17", "description": "Tempus Dominus core", "keywords": [ "bootstrap", diff --git a/package.json b/package.json index 6e5c7ee..207d646 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "url": "https://github.com/tempusdominus/core/issues" }, "dependencies": { - "jquery": "^1.9.1 || ^2.0 || ^3.0", + "jquery": "^3.0", "moment": "^2.10", "moment-timezone": "^0.4.0" }, @@ -49,7 +49,7 @@ "type": "git", "url": "https://github.com/tempusdominus/core.git" }, - "version": "5.0.0-alpha16", + "version": "5.0.0-alpha17", "files": [ "build", "src/js/**/*.js", diff --git a/src/js/tempusdominus-core.js b/src/js/tempusdominus-core.js index 74168cd..576c5e1 100644 --- a/src/js/tempusdominus-core.js +++ b/src/js/tempusdominus-core.js @@ -244,6 +244,9 @@ const DateTimePicker = (($, moment) => { return true; }, enter: function () { + if (!this.widget) { + return false; + } this.hide(); return true; }, @@ -264,6 +267,9 @@ const DateTimePicker = (($, moment) => { return true; }, t: function () { + if (!this.widget) { + return false; + } this.date(this.getMoment()); return true; }, @@ -709,7 +715,7 @@ const DateTimePicker = (($, moment) => { } if (handler) { - if (handler.call(this.widget)) { + if (handler.call(this)) { e.stopPropagation(); e.preventDefault(); } diff --git a/tasks/bump-version.js b/tasks/bump-version.js index ec3a5e9..b06d50e 100644 --- a/tasks/bump-version.js +++ b/tasks/bump-version.js @@ -15,7 +15,19 @@ module.exports = function (grunt) { ] } }); - + + grunt.config('string-replace.package-json-lock', { + files: { 'package-lock.json': 'package-lock.json' }, + options: { + replacements: [ + { + pattern: /"version": .*/, + replacement: '"version": "' + version + '",' + } + ] + } + }); + grunt.config('string-replace.composer-json', { files: {'composer.json': 'composer.json'}, options: { @@ -46,4 +58,4 @@ module.exports = function (grunt) { 'string-replace:js' ]); }); -}; +}; \ No newline at end of file