diff --git a/README.md b/README.md
index 95fa790d..327c316d 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,9 @@
Timepicker Plugin for jQuery
========================
-[](http://jonthornton.github.com/jquery-timepicker)
+[](https://www.jonthornton.com/jquery-timepicker)
-[See a demo and examples here](http://jonthornton.github.com/jquery-timepicker)
+[See a demo and examples here](https://www.jonthornton.com/jquery-timepicker)
jquery.timepicker is a lightweight timepicker plugin for jQuery inspired by Google Calendar. It supports both mouse and keyboard navigation, and weighs in at 5.5kb minified and gzipped.
@@ -288,11 +288,16 @@ Submit a [GitHub Issues request](https://github.com/jonthornton/jquery-timepicke
Development guidelines
----------------------
-1. Install dependencies (jquery + grunt) `npm install`
-2. For sanity checks and minification run `grunt`, or just `grunt lint` to have the code linted
+After cloning, install dev dependencies with `npm install`.
+
+* `npm run build`: compile timepicker and place updated output in `dist/`
+* `npm run watch`: rebuild every time one of the source files changes
+* `npm run format`: apply code formatting rules
+* `npm run test`: run the jest test suite
+
jquery-timepicker follows [semantic versioning](http://semver.org/).
- - -
-This software is made available under the open source MIT License. © 2014 [Jon Thornton](http://www.jonthornton.com) and [contributors](https://github.com/jonthornton/jquery-timepicker/graphs/contributors)
+This software is made available under the open source MIT License. © 2020 [Jon Thornton](https://www.jonthornton.com) and [contributors](https://github.com/jonthornton/jquery-timepicker/graphs/contributors)
diff --git a/bower.json b/bower.json
index 6659df09..32330fef 100644
--- a/bower.json
+++ b/bower.json
@@ -1,6 +1,6 @@
{
"name": "jt.timepicker",
- "version": "1.13.4",
+ "version": "1.13.5",
"description": "A jQuery timepicker plugin inspired by Google Calendar.",
"homepage": "http://jonthornton.github.com/jquery-timepicker",
"main": ["./jquery.timepicker.js", "./jquery.timepicker.css"],
diff --git a/dist/jquery.timepicker.js b/dist/jquery.timepicker.js
index ee726334..ee2ca099 100644
--- a/dist/jquery.timepicker.js
+++ b/dist/jquery.timepicker.js
@@ -1,3 +1,8 @@
+/*!
+ * jquery-timepicker v1.13.5 - A jQuery timepicker plugin inspired by Google Calendar. It supports both mouse and keyboard navigation.
+ * Copyright (c) 2020 Jon Thornton - https://www.jonthornton.com/jquery-timepicker/
+ * License: MIT
+ */
(function () {
'use strict';
@@ -266,12 +271,6 @@
}
}
- /*!
- * jquery-timepicker v1.13.4 - A jQuery timepicker plugin inspired by Google Calendar. It supports both mouse and keyboard navigation.
- * Copyright (c) 2015 Jon Thornton - http://jonthornton.github.com/jquery-timepicker/
- * License: MIT
- */
-
(function(factory) {
if (
typeof exports === "object" &&
diff --git a/dist/jquery.timepicker.min.js b/dist/jquery.timepicker.min.js
index 6f2f82bc..1801dea5 100644
--- a/dist/jquery.timepicker.min.js
+++ b/dist/jquery.timepicker.min.js
@@ -1,6 +1 @@
-!function(){"use strict";const e=(e,t)=>{if(null===e)return null;if("number"!=typeof t.step)return e;var i=e%(60*t.step);return(i-=(t.minTime||0)%(60*t.step))>=30*t.step?e+=60*t.step-i:e-=i,function(e,t){if(86400==e&&t.show2400)return e;return e%86400}(e,t)};const t={appendTo:"body",className:null,closeOnWindowScroll:!1,disableTextInput:!1,disableTimeRanges:[],disableTouchKeyboard:!1,durationTime:null,forceRoundTime:!1,lang:{},maxTime:null,minTime:null,noneOption:!1,orientation:"l",roundingFunction:e,scrollDefault:null,selectOnBlur:!1,show2400:!1,showDuration:!1,showOn:["click","focus"],showOnFocus:!0,step:30,stopScrollPropagation:!1,timeFormat:"g:ia",typeaheadHighlight:!0,useSelect:!1,wrapHours:!0},i={am:"am",pm:"pm",AM:"AM",PM:"PM",decimal:".",mins:"mins",hr:"hr",hrs:"hrs"};class n{constructor(e,i={}){const s=n.extractAttrOptions(e,Object.keys(t));this.settings=this.parseSettings({...t,...i,...s})}static extractAttrOptions(e,t){const i={};for(const n of t)n in e.dataset&&(i[n]=e.dataset[n]);return i}time2int(e){if(""===e||null==e)return null;if(e instanceof Date)return 3600*e.getHours()+60*e.getMinutes()+e.getSeconds();if(e instanceof String)return e;"a"!=(e=e.toLowerCase().replace(/[\s\.]/g,"")).slice(-1)&&"p"!=e.slice(-1)||(e+="m");var t=e.match(/^(([^0-9]*))?([0-9]?[0-9])(\W?([0-5][0-9]))?(\W+([0-5][0-9]))?(([^0-9]*))$/);if(!t)return null;var i=parseInt(1*t[3],10),n=t[2]||t[9],s=i,r=1*t[5]||0,a=1*t[7]||0;if(i<=12&&n){var o=(n=n.trim())==this.settings.lang.pm||n==this.settings.lang.PM;s=12==i?o?12:0:i+(o?12:0)}else{if(3600*i+60*r+a>=86400+(this.settings.show2400?1:0)){if(!1===this.settings.wrapHours)return null;s=i%24}}var l=3600*s+60*r+a;if(i<12&&!n&&this.settings._twelveHourTime&&this.settings.scrollDefault){var c=l-this.settings.scrollDefault();c<0&&c>=-43200&&(l=(l+43200)%86400)}return l}parseSettings(e){if(e.lang={...i,...e.lang},this.settings=e,e.minTime&&(e.minTime=this.time2int(e.minTime)),e.maxTime&&(e.maxTime=this.time2int(e.maxTime)),e.durationTime&&"function"!=typeof e.durationTime&&(e.durationTime=this.time2int(e.durationTime)),"now"==e.scrollDefault)e.scrollDefault=()=>e.roundingFunction(this.time2int(new Date),e);else if(e.scrollDefault&&"function"!=typeof e.scrollDefault){var t=e.scrollDefault;e.scrollDefault=()=>e.roundingFunction(this.time2int(t),e)}else e.minTime&&(e.scrollDefault=function(){return e.roundingFunction(e.minTime,e)});if("string"==typeof e.timeFormat&&e.timeFormat.match(/[gh]/)&&(e._twelveHourTime=!0),!1===e.showOnFocus&&-1!=e.showOn.indexOf("focus")&&e.showOn.splice(e.showOn.indexOf("focus"),1),e.disableTimeRanges.length>0){for(var n in e.disableTimeRanges)e.disableTimeRanges[n]=[this.time2int(e.disableTimeRanges[n][0]),this.time2int(e.disableTimeRanges[n][1])];e.disableTimeRanges=e.disableTimeRanges.sort((function(e,t){return e[0]-t[0]}));for(n=e.disableTimeRanges.length-1;n>0;n--)e.disableTimeRanges[n][0]<=e.disableTimeRanges[n-1][1]&&(e.disableTimeRanges[n-1]=[Math.min(e.disableTimeRanges[n][0],e.disableTimeRanges[n-1][0]),Math.max(e.disableTimeRanges[n][1],e.disableTimeRanges[n-1][1])],e.disableTimeRanges.splice(n,1))}return e}}
-/*!
- * jquery-timepicker v1.13.4 - A jQuery timepicker plugin inspired by Google Calendar. It supports both mouse and keyboard navigation.
- * Copyright (c) 2015 Jon Thornton - http://jonthornton.github.com/jquery-timepicker/
- * License: MIT
- */var s;s=function(t){var i={},s={init:function(e){return this.each((function(){var r=t(this);const o=new n(this,e),l=o.settings;if(i=l.lang,r.data("timepicker-settings",l),r.data("timepicker-obj",o),r.addClass("ui-timepicker-input"),l.useSelect)a(r);else{if(r.prop("autocomplete","off"),l.showOn)for(var c in l.showOn)r.on(l.showOn[c]+".timepicker",s.show);r.on("change.timepicker",d),r.on("keydown.timepicker",k),r.on("keyup.timepicker",v),l.disableTextInput&&r.on("keydown.timepicker",g),r.on("cut.timepicker",v),r.on("paste.timepicker",v),d.call(r.get(0),null,"initial")}}))},show:function(e){var i=t(this),n=i.data("timepicker-settings"),o=i.data("timepicker-obj");if(e&&e.preventDefault(),n.useSelect)i.data("timepicker-list").focus();else{u(i)&&i.blur();var l=i.data("timepicker-list");if(!i.prop("readonly")&&(l&&0!==l.length&&"function"!=typeof n.durationTime||(a(i),l=i.data("timepicker-list")),!r(l))){i.data("ui-timepicker-value",i.val()),m(i,l),s.hide(),"number"==typeof n.listWidth&&(console.log(n.listWidth),l.width(i.outerWidth()*n.listWidth)),l.show();var d={};n.orientation.match(/r/)?d.left=i.offset().left+i.outerWidth()-l.outerWidth()+parseInt(l.css("marginLeft").replace("px",""),10):n.orientation.match(/l/)?d.left=i.offset().left+parseInt(l.css("marginLeft").replace("px",""),10):n.orientation.match(/c/)&&(d.left=i.offset().left+(i.outerWidth()-l.outerWidth())/2+parseInt(l.css("marginLeft").replace("px",""),10)),"t"==(n.orientation.match(/t/)?"t":n.orientation.match(/b/)?"b":i.offset().top+i.outerHeight(!0)+l.outerHeight()>t(window).height()+t(window).scrollTop()?"t":"b")?(l.addClass("ui-timepicker-positioned-top"),d.top=i.offset().top-l.outerHeight()+parseInt(l.css("marginTop").replace("px",""),10)):(l.removeClass("ui-timepicker-positioned-top"),d.top=i.offset().top+i.outerHeight()+parseInt(l.css("marginTop").replace("px",""),10)),l.offset(d);var h=l.find(".ui-timepicker-selected");if(!h.length){var g=o.time2int(f(i));null!==g?h=p(i,l,g):n.scrollDefault&&(h=p(i,l,n.scrollDefault()))}if(h.length&&!h.hasClass("ui-timepicker-disabled")||(h=l.find("li:not(.ui-timepicker-disabled):first")),h&&h.length){var k=l.scrollTop()+h.position().top-h.outerHeight();l.scrollTop(k)}else l.scrollTop(0);return n.stopScrollPropagation&&t(document).on("wheel.ui-timepicker",".ui-timepicker-wrapper",(function(e){e.preventDefault();var i=t(this).scrollTop();t(this).scrollTop(i+e.originalEvent.deltaY)})),t(document).on("touchstart.ui-timepicker mousedown.ui-timepicker",c),t(window).on("resize.ui-timepicker",c),n.closeOnWindowScroll&&t(document).on("scroll.ui-timepicker",c),i.trigger("showTimepicker"),this}}},hide:function(e){var i=t(this),n=i.data("timepicker-settings");return n&&n.useSelect&&i.blur(),t(".ui-timepicker-wrapper").each((function(){var e=t(this);if(r(e)){var i=e.data("timepicker-input"),n=i.data("timepicker-settings");n&&n.selectOnBlur&&T(i),e.hide(),i.trigger("hideTimepicker")}})),this},option:function(e,i){return"string"==typeof e&&void 0===i?t(this).data("timepicker-settings")[e]:this.each((function(){var n=t(this),s=n.data("timepicker-settings"),r=n.data("timepicker-obj"),o=n.data("timepicker-list");"object"==typeof e?s=t.extend(s,e):"string"==typeof e&&(s[e]=i),s=r.parseSettings(s),n.data("timepicker-settings",s),d.call(n.get(0),{type:"change"},"initial"),o&&(o.remove(),n.data("timepicker-list",!1)),s.useSelect&&a(n)}))},getSecondsFromMidnight:function(){return t(this).data("timepicker-obj").time2int(f(this))},getTime:function(e){var i=t(this),n=i.data("timepicker-obj"),s=f(i);if(!s)return null;var r=n.time2int(s);if(null===r)return null;e||(e=new Date);var a=new Date(e);return a.setHours(r/3600),a.setMinutes(r%3600/60),a.setSeconds(r%60),a.setMilliseconds(0),a},isVisible:function(){var e=this.data("timepicker-list");return!(!e||!r(e))},setTime:function(e){var t=this.data("timepicker-settings"),i=this.data("timepicker-obj");if(t.forceRoundTime)var n=l(i.time2int(e),t);else n=w(i.time2int(e),t);return e&&null===n&&t.noneOption&&(n=e),h(this,n,"initial"),d.call(this.get(0),{type:"change"},"initial"),this.data("timepicker-list")&&m(this,this.data("timepicker-list")),this},remove:function(){if(this.hasClass("ui-timepicker-input")){var e=this.data("timepicker-settings");return this.removeAttr("autocomplete","off"),this.removeClass("ui-timepicker-input"),this.removeData("timepicker-settings"),this.off(".timepicker"),this.data("timepicker-list")&&this.data("timepicker-list").remove(),e.useSelect&&this.show(),this.removeData("timepicker-list"),this}}};function r(e){var t=e[0];return t.offsetWidth>0&&t.offsetHeight>0}function a(i){var n=i.data("timepicker-settings"),r=i.data("timepicker-list"),a=i.data("timepicker-obj");if(r&&r.length&&(r.remove(),i.data("timepicker-list",!1)),n.useSelect){r=t("",{class:"ui-timepicker-select"}),i.attr("name")&&r.attr("name","ui-timepicker-"+i.attr("name"));var c=r}else r=t("
",{class:"ui-timepicker-list"}),(c=t("",{class:"ui-timepicker-wrapper",tabindex:-1})).css({display:"none",position:"absolute"}).append(r);if(n.noneOption)if(!0===n.noneOption&&(n.noneOption=n.useSelect?"Time...":"None"),t.isArray(n.noneOption)){for(var p in n.noneOption)if(parseInt(p,10)==p){var d=o(n.noneOption[p],n.useSelect);r.append(d)}}else d=o(n.noneOption,n.useSelect),r.append(d);n.className&&c.addClass(n.className),null===n.minTime&&null===n.durationTime||!n.showDuration||("function"==typeof n.step||n.step,c.addClass("ui-timepicker-with-duration"),c.addClass("ui-timepicker-step-"+n.step));var f=n.minTime;"function"==typeof n.durationTime?f=a.time2int(n.durationTime()):null!==n.durationTime&&(f=n.durationTime);var g=null!==n.minTime?n.minTime:0,k=null!==n.maxTime?n.maxTime:g+86400-1;k",{value:D})).text(D):((S=t("")).addClass(C%86400<43200?"ui-timepicker-am":"ui-timepicker-pm"),S.data("time",e(C,n)),S.text(D)),(null!==n.minTime||null!==n.durationTime)&&n.showDuration){var R=b(p-f,n.step);if(n.useSelect)S.text(S.text()+" ("+R+")");else{var F=t("",{class:"ui-timepicker-duration"});F.text(" ("+R+")"),S.append(F)}}y=v[y][1]&&(y+=1),v[y]&&C>=v[y][0]&&C",{value:r,class:s,text:n}):t("",{class:s,text:n}).data("time",String(r))}function l(e,t){if(null!==(e=t.roundingFunction(e,t)))return w(e,t)}function c(e){if(e.target!=window){var i=t(e.target);i.closest(".ui-timepicker-input").length||i.closest(".ui-timepicker-wrapper").length||(s.hide(),t(document).unbind(".ui-timepicker"),t(window).unbind(".ui-timepicker"))}}function u(e){var t=e.data("timepicker-settings");return(window.navigator.msMaxTouchPoints||"ontouchstart"in document)&&t.disableTouchKeyboard}function p(e,i,n){if(!n&&0!==n)return!1;var s=e.data("timepicker-settings"),r=!1;return n=s.roundingFunction(n,s),i.find("li").each((function(e,i){var s=t(i);if("number"==typeof s.data("time"))return s.data("time")==n?(r=s,!1):void 0})),r}function m(e,t){t.find("li").removeClass("ui-timepicker-selected");var i=e.data("timepicker-settings"),n=e.data("timepicker-obj").time2int(f(e));if(null!==n){var s=p(e,t,n);if(s){var r=s.offset().top-t.offset().top;(r+s.outerHeight()>t.outerHeight()||r<0)&&t.scrollTop(t.scrollTop()+s.position().top-s.outerHeight()),(i.forceRoundTime||s.data("time")===n)&&s.addClass("ui-timepicker-selected")}}}function d(e,i){if("timepicker"!=i){var n=t(this);if(""!==this.value){if(!n.is(":focus")||e&&"change"==e.type){var s=n.data("timepicker-settings"),r=n.data("timepicker-obj").time2int(this.value);if(null!==r){var a=!1;if(null!==s.minTime&&null!==s.maxTime&&(rs.maxTime)&&(a=!0),t.each(s.disableTimeRanges,(function(){if(r>=this[0]&&r0)return a=t(i),!1})),a.addClass("ui-timepicker-selected")),!1;case 40:return 0===(a=n.find(".ui-timepicker-selected")).length?(n.find("li").each((function(e,i){if(t(i).position().top>0)return a=t(i),!1})),a.addClass("ui-timepicker-selected")):a.is(":last-child")||(a.removeClass("ui-timepicker-selected"),a.next().addClass("ui-timepicker-selected"),a.next().position().top+2*a.outerHeight()>n.outerHeight()&&n.scrollTop(n.scrollTop()+a.outerHeight())),!1;case 27:n.find("li").removeClass("ui-timepicker-selected"),s.hide();break;case 9:s.hide();break;default:return!0}}function v(e){var i=t(this),n=i.data("timepicker-list"),s=i.data("timepicker-settings");if(!n||!r(n)||s.disableTextInput)return!0;if("paste"!==e.type&&"cut"!==e.type)switch(e.keyCode){case 96:case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:case 105:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:case 65:case 77:case 80:case 186:case 8:case 46:s.typeaheadHighlight?m(i,n):n.hide()}else setTimeout((function(){s.typeaheadHighlight?m(i,n):n.hide()}),0)}function T(e){var t=e.data("timepicker-settings"),i=null,n=e.data("timepicker-list").find(".ui-timepicker-selected");return!n.hasClass("ui-timepicker-disabled")&&(n.length&&(i=n.data("time")),null!==i&&("string"!=typeof i&&(i=w(i,t)),h(e,i,"select")),!0)}function b(e,t){e=Math.abs(e);var n,s,r=Math.round(e/60),a=[];return r<60?a=[r,i.mins]:(n=Math.floor(r/60),s=r%60,30==t&&30==s&&(n+=i.decimal+5),a.push(n),a.push(1==n?i.hr:i.hrs),30!=t&&s&&(a.push(s),a.push(i.mins))),a.join(" ")}function w(e,n){if("number"!=typeof e)return null;var s=parseInt(e%60),r=parseInt(e/60%60),a=parseInt(e/3600%24),o=new Date(1970,0,2,a,r,s,0);if(isNaN(o.getTime()))return null;if("function"===t.type(n.timeFormat))return n.timeFormat(o);for(var l,c,u="",p=0;p11?i.pm:i.am;break;case"A":u+=o.getHours()>11?i.PM:i.AM;break;case"g":u+=0==(l=o.getHours()%12)?"12":l;break;case"G":l=o.getHours(),86400===e&&(l=n.show2400?24:0),u+=l;break;case"h":0!=(l=o.getHours()%12)&&l<10&&(l="0"+l),u+=0===l?"12":l;break;case"H":l=o.getHours(),86400===e&&(l=n.show2400?24:0),u+=l>9?l:"0"+l;break;case"i":u+=(r=o.getMinutes())>9?r:"0"+r;break;case"s":u+=(s=o.getSeconds())>9?s:"0"+s;break;case"\\":p++,u+=n.timeFormat.charAt(p);break;default:u+=c}return u}t.fn.timepicker=function(e){return this.length?s[e]?this.hasClass("ui-timepicker-input")?s[e].apply(this,Array.prototype.slice.call(arguments,1)):this:"object"!=typeof e&&e?void t.error("Method "+e+" does not exist on jQuery.timepicker"):s.init.apply(this,arguments):this},t.fn.timepicker.defaults={appendTo:"body",className:null,closeOnWindowScroll:!1,disableTextInput:!1,disableTimeRanges:[],disableTouchKeyboard:!1,durationTime:null,forceRoundTime:!1,listWidth:null,maxTime:null,minTime:null,noneOption:!1,orientation:"l",roundingFunction:function(e,t){if(null===e)return null;if("number"!=typeof t.step)return e;var i=e%(60*t.step);return(i-=(t.minTime||0)%(60*t.step))>=30*t.step?e+=60*t.step-i:e-=i,_moduloSeconds(e,t)},scrollDefault:null,selectOnBlur:!1,show2400:!1,showDuration:!1,showOn:["click","focus"],showOnFocus:!0,step:30,stopScrollPropagation:!1,timeFormat:"g:ia",typeaheadHighlight:!0,useSelect:!1,wrapHours:!0}},"object"==typeof exports&&exports&&"object"==typeof module&&module&&module.exports===exports?s(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],s):s(jQuery)}();
+!function(){"use strict";const e=(e,t)=>{if(null===e)return null;if("number"!=typeof t.step)return e;var i=e%(60*t.step);return(i-=(t.minTime||0)%(60*t.step))>=30*t.step?e+=60*t.step-i:e-=i,function(e,t){if(86400==e&&t.show2400)return e;return e%86400}(e,t)};const t={appendTo:"body",className:null,closeOnWindowScroll:!1,disableTextInput:!1,disableTimeRanges:[],disableTouchKeyboard:!1,durationTime:null,forceRoundTime:!1,lang:{},maxTime:null,minTime:null,noneOption:!1,orientation:"l",roundingFunction:e,scrollDefault:null,selectOnBlur:!1,show2400:!1,showDuration:!1,showOn:["click","focus"],showOnFocus:!0,step:30,stopScrollPropagation:!1,timeFormat:"g:ia",typeaheadHighlight:!0,useSelect:!1,wrapHours:!0},i={am:"am",pm:"pm",AM:"AM",PM:"PM",decimal:".",mins:"mins",hr:"hr",hrs:"hrs"};class n{constructor(e,i={}){const s=n.extractAttrOptions(e,Object.keys(t));this.settings=this.parseSettings({...t,...i,...s})}static extractAttrOptions(e,t){const i={};for(const n of t)n in e.dataset&&(i[n]=e.dataset[n]);return i}time2int(e){if(""===e||null==e)return null;if(e instanceof Date)return 3600*e.getHours()+60*e.getMinutes()+e.getSeconds();if(e instanceof String)return e;"a"!=(e=e.toLowerCase().replace(/[\s\.]/g,"")).slice(-1)&&"p"!=e.slice(-1)||(e+="m");var t=e.match(/^(([^0-9]*))?([0-9]?[0-9])(\W?([0-5][0-9]))?(\W+([0-5][0-9]))?(([^0-9]*))$/);if(!t)return null;var i=parseInt(1*t[3],10),n=t[2]||t[9],s=i,r=1*t[5]||0,a=1*t[7]||0;if(i<=12&&n){var o=(n=n.trim())==this.settings.lang.pm||n==this.settings.lang.PM;s=12==i?o?12:0:i+(o?12:0)}else{if(3600*i+60*r+a>=86400+(this.settings.show2400?1:0)){if(!1===this.settings.wrapHours)return null;s=i%24}}var l=3600*s+60*r+a;if(i<12&&!n&&this.settings._twelveHourTime&&this.settings.scrollDefault){var c=l-this.settings.scrollDefault();c<0&&c>=-43200&&(l=(l+43200)%86400)}return l}parseSettings(e){if(e.lang={...i,...e.lang},this.settings=e,e.minTime&&(e.minTime=this.time2int(e.minTime)),e.maxTime&&(e.maxTime=this.time2int(e.maxTime)),e.durationTime&&"function"!=typeof e.durationTime&&(e.durationTime=this.time2int(e.durationTime)),"now"==e.scrollDefault)e.scrollDefault=()=>e.roundingFunction(this.time2int(new Date),e);else if(e.scrollDefault&&"function"!=typeof e.scrollDefault){var t=e.scrollDefault;e.scrollDefault=()=>e.roundingFunction(this.time2int(t),e)}else e.minTime&&(e.scrollDefault=function(){return e.roundingFunction(e.minTime,e)});if("string"==typeof e.timeFormat&&e.timeFormat.match(/[gh]/)&&(e._twelveHourTime=!0),!1===e.showOnFocus&&-1!=e.showOn.indexOf("focus")&&e.showOn.splice(e.showOn.indexOf("focus"),1),e.disableTimeRanges.length>0){for(var n in e.disableTimeRanges)e.disableTimeRanges[n]=[this.time2int(e.disableTimeRanges[n][0]),this.time2int(e.disableTimeRanges[n][1])];e.disableTimeRanges=e.disableTimeRanges.sort((function(e,t){return e[0]-t[0]}));for(n=e.disableTimeRanges.length-1;n>0;n--)e.disableTimeRanges[n][0]<=e.disableTimeRanges[n-1][1]&&(e.disableTimeRanges[n-1]=[Math.min(e.disableTimeRanges[n][0],e.disableTimeRanges[n-1][0]),Math.max(e.disableTimeRanges[n][1],e.disableTimeRanges[n-1][1])],e.disableTimeRanges.splice(n,1))}return e}}var s;s=function(t){var i={},s={init:function(e){return this.each((function(){var r=t(this);const o=new n(this,e),l=o.settings;if(i=l.lang,r.data("timepicker-settings",l),r.data("timepicker-obj",o),r.addClass("ui-timepicker-input"),l.useSelect)a(r);else{if(r.prop("autocomplete","off"),l.showOn)for(var c in l.showOn)r.on(l.showOn[c]+".timepicker",s.show);r.on("change.timepicker",d),r.on("keydown.timepicker",k),r.on("keyup.timepicker",v),l.disableTextInput&&r.on("keydown.timepicker",g),r.on("cut.timepicker",v),r.on("paste.timepicker",v),d.call(r.get(0),null,"initial")}}))},show:function(e){var i=t(this),n=i.data("timepicker-settings"),o=i.data("timepicker-obj");if(e&&e.preventDefault(),n.useSelect)i.data("timepicker-list").focus();else{u(i)&&i.blur();var l=i.data("timepicker-list");if(!i.prop("readonly")&&(l&&0!==l.length&&"function"!=typeof n.durationTime||(a(i),l=i.data("timepicker-list")),!r(l))){i.data("ui-timepicker-value",i.val()),m(i,l),s.hide(),"number"==typeof n.listWidth&&(console.log(n.listWidth),l.width(i.outerWidth()*n.listWidth)),l.show();var d={};n.orientation.match(/r/)?d.left=i.offset().left+i.outerWidth()-l.outerWidth()+parseInt(l.css("marginLeft").replace("px",""),10):n.orientation.match(/l/)?d.left=i.offset().left+parseInt(l.css("marginLeft").replace("px",""),10):n.orientation.match(/c/)&&(d.left=i.offset().left+(i.outerWidth()-l.outerWidth())/2+parseInt(l.css("marginLeft").replace("px",""),10)),"t"==(n.orientation.match(/t/)?"t":n.orientation.match(/b/)?"b":i.offset().top+i.outerHeight(!0)+l.outerHeight()>t(window).height()+t(window).scrollTop()?"t":"b")?(l.addClass("ui-timepicker-positioned-top"),d.top=i.offset().top-l.outerHeight()+parseInt(l.css("marginTop").replace("px",""),10)):(l.removeClass("ui-timepicker-positioned-top"),d.top=i.offset().top+i.outerHeight()+parseInt(l.css("marginTop").replace("px",""),10)),l.offset(d);var h=l.find(".ui-timepicker-selected");if(!h.length){var g=o.time2int(f(i));null!==g?h=p(i,l,g):n.scrollDefault&&(h=p(i,l,n.scrollDefault()))}if(h.length&&!h.hasClass("ui-timepicker-disabled")||(h=l.find("li:not(.ui-timepicker-disabled):first")),h&&h.length){var k=l.scrollTop()+h.position().top-h.outerHeight();l.scrollTop(k)}else l.scrollTop(0);return n.stopScrollPropagation&&t(document).on("wheel.ui-timepicker",".ui-timepicker-wrapper",(function(e){e.preventDefault();var i=t(this).scrollTop();t(this).scrollTop(i+e.originalEvent.deltaY)})),t(document).on("touchstart.ui-timepicker mousedown.ui-timepicker",c),t(window).on("resize.ui-timepicker",c),n.closeOnWindowScroll&&t(document).on("scroll.ui-timepicker",c),i.trigger("showTimepicker"),this}}},hide:function(e){var i=t(this),n=i.data("timepicker-settings");return n&&n.useSelect&&i.blur(),t(".ui-timepicker-wrapper").each((function(){var e=t(this);if(r(e)){var i=e.data("timepicker-input"),n=i.data("timepicker-settings");n&&n.selectOnBlur&&T(i),e.hide(),i.trigger("hideTimepicker")}})),this},option:function(e,i){return"string"==typeof e&&void 0===i?t(this).data("timepicker-settings")[e]:this.each((function(){var n=t(this),s=n.data("timepicker-settings"),r=n.data("timepicker-obj"),o=n.data("timepicker-list");"object"==typeof e?s=t.extend(s,e):"string"==typeof e&&(s[e]=i),s=r.parseSettings(s),n.data("timepicker-settings",s),d.call(n.get(0),{type:"change"},"initial"),o&&(o.remove(),n.data("timepicker-list",!1)),s.useSelect&&a(n)}))},getSecondsFromMidnight:function(){return t(this).data("timepicker-obj").time2int(f(this))},getTime:function(e){var i=t(this),n=i.data("timepicker-obj"),s=f(i);if(!s)return null;var r=n.time2int(s);if(null===r)return null;e||(e=new Date);var a=new Date(e);return a.setHours(r/3600),a.setMinutes(r%3600/60),a.setSeconds(r%60),a.setMilliseconds(0),a},isVisible:function(){var e=this.data("timepicker-list");return!(!e||!r(e))},setTime:function(e){var t=this.data("timepicker-settings"),i=this.data("timepicker-obj");if(t.forceRoundTime)var n=l(i.time2int(e),t);else n=w(i.time2int(e),t);return e&&null===n&&t.noneOption&&(n=e),h(this,n,"initial"),d.call(this.get(0),{type:"change"},"initial"),this.data("timepicker-list")&&m(this,this.data("timepicker-list")),this},remove:function(){if(this.hasClass("ui-timepicker-input")){var e=this.data("timepicker-settings");return this.removeAttr("autocomplete","off"),this.removeClass("ui-timepicker-input"),this.removeData("timepicker-settings"),this.off(".timepicker"),this.data("timepicker-list")&&this.data("timepicker-list").remove(),e.useSelect&&this.show(),this.removeData("timepicker-list"),this}}};function r(e){var t=e[0];return t.offsetWidth>0&&t.offsetHeight>0}function a(i){var n=i.data("timepicker-settings"),r=i.data("timepicker-list"),a=i.data("timepicker-obj");if(r&&r.length&&(r.remove(),i.data("timepicker-list",!1)),n.useSelect){r=t("",{class:"ui-timepicker-select"}),i.attr("name")&&r.attr("name","ui-timepicker-"+i.attr("name"));var c=r}else r=t("",{class:"ui-timepicker-list"}),(c=t("",{class:"ui-timepicker-wrapper",tabindex:-1})).css({display:"none",position:"absolute"}).append(r);if(n.noneOption)if(!0===n.noneOption&&(n.noneOption=n.useSelect?"Time...":"None"),t.isArray(n.noneOption)){for(var p in n.noneOption)if(parseInt(p,10)==p){var d=o(n.noneOption[p],n.useSelect);r.append(d)}}else d=o(n.noneOption,n.useSelect),r.append(d);n.className&&c.addClass(n.className),null===n.minTime&&null===n.durationTime||!n.showDuration||("function"==typeof n.step||n.step,c.addClass("ui-timepicker-with-duration"),c.addClass("ui-timepicker-step-"+n.step));var f=n.minTime;"function"==typeof n.durationTime?f=a.time2int(n.durationTime()):null!==n.durationTime&&(f=n.durationTime);var g=null!==n.minTime?n.minTime:0,k=null!==n.maxTime?n.maxTime:g+86400-1;k",{value:D})).text(D):((S=t("")).addClass(C%86400<43200?"ui-timepicker-am":"ui-timepicker-pm"),S.data("time",e(C,n)),S.text(D)),(null!==n.minTime||null!==n.durationTime)&&n.showDuration){var R=b(p-f,n.step);if(n.useSelect)S.text(S.text()+" ("+R+")");else{var F=t("",{class:"ui-timepicker-duration"});F.text(" ("+R+")"),S.append(F)}}y=v[y][1]&&(y+=1),v[y]&&C>=v[y][0]&&C",{value:r,class:s,text:n}):t("",{class:s,text:n}).data("time",String(r))}function l(e,t){if(null!==(e=t.roundingFunction(e,t)))return w(e,t)}function c(e){if(e.target!=window){var i=t(e.target);i.closest(".ui-timepicker-input").length||i.closest(".ui-timepicker-wrapper").length||(s.hide(),t(document).unbind(".ui-timepicker"),t(window).unbind(".ui-timepicker"))}}function u(e){var t=e.data("timepicker-settings");return(window.navigator.msMaxTouchPoints||"ontouchstart"in document)&&t.disableTouchKeyboard}function p(e,i,n){if(!n&&0!==n)return!1;var s=e.data("timepicker-settings"),r=!1;return n=s.roundingFunction(n,s),i.find("li").each((function(e,i){var s=t(i);if("number"==typeof s.data("time"))return s.data("time")==n?(r=s,!1):void 0})),r}function m(e,t){t.find("li").removeClass("ui-timepicker-selected");var i=e.data("timepicker-settings"),n=e.data("timepicker-obj").time2int(f(e));if(null!==n){var s=p(e,t,n);if(s){var r=s.offset().top-t.offset().top;(r+s.outerHeight()>t.outerHeight()||r<0)&&t.scrollTop(t.scrollTop()+s.position().top-s.outerHeight()),(i.forceRoundTime||s.data("time")===n)&&s.addClass("ui-timepicker-selected")}}}function d(e,i){if("timepicker"!=i){var n=t(this);if(""!==this.value){if(!n.is(":focus")||e&&"change"==e.type){var s=n.data("timepicker-settings"),r=n.data("timepicker-obj").time2int(this.value);if(null!==r){var a=!1;if(null!==s.minTime&&null!==s.maxTime&&(rs.maxTime)&&(a=!0),t.each(s.disableTimeRanges,(function(){if(r>=this[0]&&r0)return a=t(i),!1})),a.addClass("ui-timepicker-selected")),!1;case 40:return 0===(a=n.find(".ui-timepicker-selected")).length?(n.find("li").each((function(e,i){if(t(i).position().top>0)return a=t(i),!1})),a.addClass("ui-timepicker-selected")):a.is(":last-child")||(a.removeClass("ui-timepicker-selected"),a.next().addClass("ui-timepicker-selected"),a.next().position().top+2*a.outerHeight()>n.outerHeight()&&n.scrollTop(n.scrollTop()+a.outerHeight())),!1;case 27:n.find("li").removeClass("ui-timepicker-selected"),s.hide();break;case 9:s.hide();break;default:return!0}}function v(e){var i=t(this),n=i.data("timepicker-list"),s=i.data("timepicker-settings");if(!n||!r(n)||s.disableTextInput)return!0;if("paste"!==e.type&&"cut"!==e.type)switch(e.keyCode){case 96:case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:case 105:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:case 65:case 77:case 80:case 186:case 8:case 46:s.typeaheadHighlight?m(i,n):n.hide()}else setTimeout((function(){s.typeaheadHighlight?m(i,n):n.hide()}),0)}function T(e){var t=e.data("timepicker-settings"),i=null,n=e.data("timepicker-list").find(".ui-timepicker-selected");return!n.hasClass("ui-timepicker-disabled")&&(n.length&&(i=n.data("time")),null!==i&&("string"!=typeof i&&(i=w(i,t)),h(e,i,"select")),!0)}function b(e,t){e=Math.abs(e);var n,s,r=Math.round(e/60),a=[];return r<60?a=[r,i.mins]:(n=Math.floor(r/60),s=r%60,30==t&&30==s&&(n+=i.decimal+5),a.push(n),a.push(1==n?i.hr:i.hrs),30!=t&&s&&(a.push(s),a.push(i.mins))),a.join(" ")}function w(e,n){if("number"!=typeof e)return null;var s=parseInt(e%60),r=parseInt(e/60%60),a=parseInt(e/3600%24),o=new Date(1970,0,2,a,r,s,0);if(isNaN(o.getTime()))return null;if("function"===t.type(n.timeFormat))return n.timeFormat(o);for(var l,c,u="",p=0;p11?i.pm:i.am;break;case"A":u+=o.getHours()>11?i.PM:i.AM;break;case"g":u+=0==(l=o.getHours()%12)?"12":l;break;case"G":l=o.getHours(),86400===e&&(l=n.show2400?24:0),u+=l;break;case"h":0!=(l=o.getHours()%12)&&l<10&&(l="0"+l),u+=0===l?"12":l;break;case"H":l=o.getHours(),86400===e&&(l=n.show2400?24:0),u+=l>9?l:"0"+l;break;case"i":u+=(r=o.getMinutes())>9?r:"0"+r;break;case"s":u+=(s=o.getSeconds())>9?s:"0"+s;break;case"\\":p++,u+=n.timeFormat.charAt(p);break;default:u+=c}return u}t.fn.timepicker=function(e){return this.length?s[e]?this.hasClass("ui-timepicker-input")?s[e].apply(this,Array.prototype.slice.call(arguments,1)):this:"object"!=typeof e&&e?void t.error("Method "+e+" does not exist on jQuery.timepicker"):s.init.apply(this,arguments):this},t.fn.timepicker.defaults={appendTo:"body",className:null,closeOnWindowScroll:!1,disableTextInput:!1,disableTimeRanges:[],disableTouchKeyboard:!1,durationTime:null,forceRoundTime:!1,listWidth:null,maxTime:null,minTime:null,noneOption:!1,orientation:"l",roundingFunction:function(e,t){if(null===e)return null;if("number"!=typeof t.step)return e;var i=e%(60*t.step);return(i-=(t.minTime||0)%(60*t.step))>=30*t.step?e+=60*t.step-i:e-=i,_moduloSeconds(e,t)},scrollDefault:null,selectOnBlur:!1,show2400:!1,showDuration:!1,showOn:["click","focus"],showOnFocus:!0,step:30,stopScrollPropagation:!1,timeFormat:"g:ia",typeaheadHighlight:!0,useSelect:!1,wrapHours:!0}},"object"==typeof exports&&exports&&"object"==typeof module&&module&&module.exports===exports?s(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],s):s(jQuery)}();
diff --git a/jt.timepicker.jquery.json b/jt.timepicker.jquery.json
index 16902d5d..00574c5b 100644
--- a/jt.timepicker.jquery.json
+++ b/jt.timepicker.jquery.json
@@ -1,6 +1,6 @@
{
"name": "jt.timepicker",
- "version": "1.6.0",
+ "version": "1.13.5",
"title": "jquery-timepicker",
"description": "A jQuery timepicker plugin inspired by Google Calendar. It supports both mouse and keyboard navigation.",
"author": {
diff --git a/package-lock.json b/package-lock.json
index c81f83cc..a3e4dd44 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "timepicker",
- "version": "1.13.4",
+ "version": "1.13.5",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
diff --git a/package.json b/package.json
index 8749a8ef..2575aefe 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "timepicker",
- "version": "1.13.4",
+ "version": "1.13.5",
"title": "jquery-timepicker",
"author": {
"name": "Jon Thornton",
@@ -10,7 +10,6 @@
"build": "rollup --config rollup.config.js",
"watch": "rollup -w --config rollup.config.js",
"format": "prettier-eslint --write \"src/**/*.js\"",
- "lint": "eslint",
"test": "jest"
},
"license": "MIT",
diff --git a/rollup.config.js b/rollup.config.js
index 07b3d0b1..d345fc01 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -1,13 +1,20 @@
import { terser } from "rollup-plugin-terser";
import copy from 'rollup-plugin-copy'
+import { version } from './package.json';
+const banner = `/*!
+ * jquery-timepicker v${version} - A jQuery timepicker plugin inspired by Google Calendar. It supports both mouse and keyboard navigation.
+ * Copyright (c) 2020 Jon Thornton - https://www.jonthornton.com/jquery-timepicker/
+ * License: MIT
+ */`;
export default {
input: 'src/jquery.timepicker.js',
output: [
{
file: 'dist/jquery.timepicker.js',
- format: 'iife'
+ format: 'iife',
+ banner: banner
},
{
file: 'dist/jquery.timepicker.min.js',
diff --git a/src/jquery.timepicker.js b/src/jquery.timepicker.js
index 873e2a98..76032433 100644
--- a/src/jquery.timepicker.js
+++ b/src/jquery.timepicker.js
@@ -1,9 +1,3 @@
-/*!
- * jquery-timepicker v1.13.4 - A jQuery timepicker plugin inspired by Google Calendar. It supports both mouse and keyboard navigation.
- * Copyright (c) 2015 Jon Thornton - http://jonthornton.github.com/jquery-timepicker/
- * License: MIT
- */
-
import Timepicker from "./timepicker/index.js";
import moduloSeconds from "./timepicker/rounding.js";
import { ONE_DAY } from "./timepicker/constants.js";