-
Notifications
You must be signed in to change notification settings - Fork 22
/
jquery-clock-timepicker.min.js
1 lines (1 loc) · 32.2 KB
/
jquery-clock-timepicker.min.js
1
!function(e){e.fn.clockTimePicker=function(t,o){if("string"==typeof t&&("value"==t||"val"==t)&&!o)return e(this).val();var i,r=e.extend(!0,{afternoonHoursInOuterCircle:!1,alwaysSelectHoursFirst:!1,autosize:!1,contextmenu:!1,colors:{buttonTextColor:"#0797FF",clockFaceColor:"#EEEEEE",clockInnerCircleTextColor:"#888888",clockInnerCircleUnselectableTextColor:"#CCCCCC",clockOuterCircleTextColor:"#000000",clockOuterCircleUnselectableTextColor:"#CCCCCC",hoverCircleColor:"#DDDDDD",popupBackgroundColor:"#FFFFFF",popupHeaderBackgroundColor:"#0797FF",popupHeaderTextColor:"#FFFFFF",selectorColor:"#0797FF",selectorNumberColor:"#FFFFFF",signButtonColor:"#FFFFFF",signButtonBackgroundColor:"#0797FF"},duration:!1,durationNegative:!1,fonts:{fontFamily:"Arial",clockOuterCircleFontSize:14,clockInnerCircleFontSize:12,buttonFontSize:20},hideUnselectableNumbers:!1,i18n:{okButton:"OK",cancelButton:"Cancel"},maximum:"23:59",minimum:"-23:59",modeSwitchSpeed:500,onlyShowClockOnMobile:!1,onAdjust:function(e,t){},onChange:function(e,t){},onClose:function(){},onModeSwitch:function(){},onOpen:function(){},popupWidthOnDesktop:200,precision:1,required:!1,separator:":",useDurationPlusSign:!1,vibrate:!0},"object"==typeof t?t:{}),a=".clock-timepicker input { caret-color: transparent; }";if(n()&&(a+=" .clock-timepicker input::selection { background:rgba(255,255,255,0.6); } .clock-timepicker input::-moz-selection { background:rgba(255,255,255,0.6); }"),i=!1,e("head style").each(function(){if(e(this).text()==a)return i=!0,!1}),!i){var c=document.createElement("style");c.type="text/css",c.styleSheet?c.styleSheet.cssText=a:c.appendChild(document.createTextNode(a)),(document.head||document.getElementsByTagName("head")[0]).appendChild(c)}return this.each(function(){var i,a=e(this),c=a.data();for(var s in c)r.hasOwnProperty(s)&&(r[s]=c[s]);if(r.precision=parseInt(r.precision),r.modeSwitchSpeed=parseInt(r.modeSwitchSpeed),r.popupWidthOnDesktop=parseInt(r.popupWidthOnDesktop),r.fonts.clockOuterCircleFontSize=parseInt(r.fonts.clockOuterCircleFontSize),r.fonts.clockInnerCircleFontSize=parseInt(r.fonts.clockInnerCircleFontSize),r.fonts.buttonFontSize=parseInt(r.fonts.buttonFontSize),1!=r.precision&&5!=r.precision&&10!=r.precision&&15!=r.precision&&30!=r.precision&&60!=r.precision&&(console.error("%c[jquery-clock-timepicker] Invalid precision specified: "+r.precision+"! Precision has to be 1, 5, 10, 15, 30 or 60. For now, the precision has been set back to: 1","color:orange"),r.precision=1),(!r.separator||(""+r.separator).match(/[0-9]+/))&&(console.error("%c[jquery-clock-timepicker] Invalid separator specified: "+(r.separator?r.separator:"(empty)")+"! The separator cannot be empty nor can it contain any decimals. For now, the separator has been set back to a colon (:).","color:orange"),r.separator=":"),r.durationNegative&&!r.duration&&console.log("%c[jquery-clock-timepicker] durationNegative is set to true, but this has no effect because duration is false!","color:orange"),r.maximum&&!r.maximum.match(/^-?[0-9]+:[0-9]{2}$/)&&(console.log('%c[jquery-clock-timepicker] Invalid time format for option "maximum": '+r.maximum+"! Maximum not used...","color:orange"),r.maximum=null),r.minimum&&!r.minimum.match(/^-?[0-9]+:[0-9]{2}$/)&&(console.log('%c[jquery-clock-timepicker] Invalid time format for option "minimum": '+r.minimum+"! Minimum not used...","color:orange"),r.minimum=null),r.minimum&&r.maximum&&(r.minimum==r.maximum||!l(r.minimum,r.maximum))&&(console.log('%c[jquery-clock-timepicker] Option "minimum" must be smaller than the option "maximum"!',"color:orange"),r.minimum=null),"vibrate"in navigator||(r.vibrate=!1),"string"==typeof t){if(e(this).parent().hasClass("clock-timepicker")){if("dispose"==(t=t.toLowerCase()))ec(e(this));else if("value"==t||"val"==t){e(this).val(ea(o));var m=e(this).parent().find(".clock-timepicker-mobile-input");m.length>0&&m.val(ea(o))}else"show"==t?e(this).parent().find("canvas:first").trigger("keydown"):"hide"==t?(e(this).parent().find(".clock-timepicker-popup").css("display","none"),e(this).blur()):console.log("%c[jquery-clock-timepicker] Invalid option passed to clockTimePicker: "+t,"color:red")}else console.log("%c[jquery-clock-timepicker] Before calling a function, please initialize the ClockTimePicker!","color:red");return}e(this).parent().hasClass("clock-timepicker")&&ec(e(this)),a.val(ea(a.val())),n()&&a.prop("readonly",!0);var u=a.val(),p="",$="HOUR",d=!1,f=!1,k=n()?e(document).width()-80:r.popupWidthOnDesktop,g=k-(n()?50:20),v=parseInt(g/2),h=parseInt(g/2),_=parseInt(g/2),x=v-16,b=x-29,y=!1,C=0;a.wrap('<div class="clock-timepicker" style="display:inline-block; position:relative">');var w=e('<div class="clock-timepicker-autosize">');if(w.css("position","absolute").css("opacity",0).css("display","none").css("top",parseInt(a.css("margin-top"))+"px").css("left","0px").css("font-size",a.css("font-size")).css("font-family",a.css("font-family")).css("font-weight",a.css("font-weight")).css("line-height",a.css("line-height")),a.parent().append(w),a.css("min-width",a.outerWidth()),er(),n()){function P(e){e.preventDefault()}function T(e){return e.preventDefault(),e.stopImmediatePropagation(),"HOUR"==$?eo():ei(),!1}(i=e('<div class="clock-timepicker-background">')).css("zIndex",99998).css("display","none").css("position","fixed").css("top","0px").css("left","0px").css("width","100%").css("height","100%").css("backgroundColor","rgba(0,0,0,0.6)"),a.parent().append(i),i.off("touchmove",P),i.on("touchmove",P),i.off("click",T),i.on("click",T)}var I=e('<div class="clock-timepicker-popup">');if(I.css("display","none").css("zIndex",99999).css("cursor","default").css("position","fixed").css("width",k+"px").css("backgroundColor",r.colors.popupBackgroundColor).css("box-shadow","0 4px 20px 0px rgba(0, 0, 0, 0.14)").css("border-radius","5px").css("overflow","hidden").css("user-select","none"),I.on("contextmenu",function(){return!1}),n()){function O(e){e.preventDefault()}function S(e){return e.stopImmediatePropagation(),"HOUR"==$?eo():ei(),!1}I.css("left","40px").css("top","40px"),window.addEventListener("orientationchange",function(){setTimeout(function(){J(),Y()},500)}),I.off("touchmove",O),I.on("touchmove",O),I.off("click",S),I.on("click",S)}if(a.parent().append(I),!n()){function F(t){"none"==I.css("display")||e(t.target)[0]==H[0]||e.contains(H.parent()[0],e(t.target)[0])||Z()}e(window).off("click.clockTimePicker",F),e(window).on("click.clockTimePicker",F)}var H=a;if(n()){(H=e('<div class="clock-timepicker-mobile-time">')).css("width","100%").css("fontFamily",r.fonts.fontFamily).css("fontSize","40px").css("padding","10px 0px").css("textAlign","center").css("color",r.colors.popupHeaderTextColor).css("backgroundColor",r.colors.popupHeaderBackgroundColor);var z=e('<span class="clock-timepicker-mobile-time-hours">');H.append(z);var U=e("<span>");U.html(r.separator),H.append(U);var N=e('<span class="clock-timepicker-mobile-time-minutes">');H.append(N),I.append(H)}a.attr("autocomplete")&&a.attr("data-autocomplete-orig",a.attr("autocomplete")),a.prop("autocomplete","off"),a.attr("autocorrect")&&a.attr("data-autocorrect-orig",a.attr("autocorrect")),a.prop("autocorrect","off"),a.attr("autocapitalize")&&a.attr("data-autocapitalize-orig",a.attr("autocapitalize")),a.prop("autocapitalize","off"),a.attr("spellcheck")&&a.attr("data-spellcheck-orig",a.attr("spellcheck")),a.prop("spellcheck",!1),H.on("drag.clockTimePicker dragend.clockTimePicker dragover.clockTimePicker dragenter.clockTimePicker dragstart.clockTimePicker dragleave.clockTimePicker drop.clockTimePicker selectstart.clockTimePicker contextmenu.clockTimePicker",function e(t){if(!r.contextmenu||1==t.which)return t.stopImmediatePropagation(),t.preventDefault(),!1}),H.on("mousedown.clockTimePicker",en),H.on("keyup.clockTimePicker",function e(t){if(!t.shiftKey&&!t.ctrlKey&&!t.altKey&&t.key.match(/^[0-9]{1}$/)){var o=el().replace(/.[0-9]+$/,""),i=el().replace(/^(\+|-)?[0-9]+./,""),c="-"==el()[0],n=el();p+=t.key;var s=("HOUR"==$?(c?"-":"")+(r.duration||1!=p.length?"":"0")+p:o)+r.separator+("HOUR"==$?i:(1==p.length?"0":"")+p);l(s,r.minimum)&&(s=r.minimum),l(r.maximum,s)&&(s=r.maximum),s=ea(s),es(s),y=!0;var m=("HOUR"==$?(c?"-":"")+p+"0":o)+r.separator+("HOUR"==$?"00":p+"0");if("MINUTE"==$&&(2==p.length||parseInt(p+"0")>=60)||"HOUR"==$&&!r.duration&&2==p.length||(c?!l(r.minimum,m):!l(m,r.maximum))){if(p="","HOUR"==$){if(60==r.precision||s==r.maximum&&r.maximum.match(/00$/)||"-"==r.minimum[0]&&s==r.minimum&&r.minimum.match(/00$/)){Z();return}et(),ei();return}Z();return}"HOUR"==$?eo():ei(),s!=n&&(a.attr("value",s.replace(/^\+/,"")),r.onAdjust.call(a.get(0),s.replace(/^\+/,""),n.replace(/^\+/,""))),er(),Y()}}),H.on("keydown.clockTimePicker",function e(t){if(9==t.keyCode)Z();else if(13==t.keyCode)Z();else if(27==t.keyCode)es(ea(u)),Z();else if(8==t.keyCode||46==t.keyCode){if(p="",!el())return!1;var o,i=el();t.preventDefault(),RegExp("^(-|\\+)?([0-9]+)(.([0-9]{1,2}))?$").test(el());var c=!!r.duration&&!!r.durationNegative&&"-"==RegExp.$1,n=parseInt(RegExp.$2),s=RegExp.$4?parseInt(RegExp.$4):0;"HOUR"==$?(es(ea(o=0==n?r.required?(r.duration?"":"0")+"0"+r.separator+"00":"":(r.duration?"":"0")+"0"+r.separator+(s<10?"0":"")+s)),o?eo():Z(),i!=o&&(a.attr("value",o.replace(/^\+/,"")),r.onAdjust.call(a.get(0),o.replace(/^\+/,""),i.replace(/^\+/,"")))):0==s?0!=n||r.required?(ee(),eo()):(es(""),""!=i&&(a.attr("value",""),r.onAdjust.call(a.get(0),"",i.replace(/^\+/,""))),Z()):(es(ea(o=(c?"-":"")+(n<10&&!r.duration?"0":"")+n+r.separator+"00")),ei(),i!=o&&(a.attr("value",o.replace(/^\+/,"")),r.onAdjust.call(a.get(0),o.replace(/^\+/,""),i.replace(/^\+/,"")))),er()}else if((36==t.keyCode||37==t.keyCode)&&""!=el())es(ea(el())),"HOUR"!=$?(eo(),ee()):(t.preventDefault(),t.stopPropagation());else if((35==t.keyCode||39==t.keyCode)&&""!=el())es(ea(el())),60!=r.precision&&"MINUTE"!=$?(ei(),et()):(t.preventDefault(),t.stopPropagation());else if(190==t.keyCode||t.key==r.separator)t.preventDefault(),0==el().length&&es("0"),es(ea(el())),60!=r.precision?(ei(),"MINUTE"!=$&&et()):eo();else if("+"==t.key&&r.duration&&r.durationNegative){t.preventDefault();var i=el();if("-"==i[0]){var o=i.substring(1);es(ea(o)),a.attr("value",o),r.onAdjust.call(a.get(0),o,i),er(),Y(),"HOUR"==$?eo():ei()}}else if("-"==t.key&&r.duration&&r.durationNegative){t.preventDefault();var i=el().replace(/^\+/,"");if("-"!=i[0]){var o="-"+i;es(ea(o)),a.attr("value",o),r.onAdjust.call(a.get(0),o,i),er(),Y(),"HOUR"==$?eo():ei()}}else{if(38!=t.keyCode&&"+"!=t.key&&40!=t.keyCode&&"-"!=t.key)return t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),!1;t.preventDefault();var i=el();RegExp("^(-|\\+)?([0-9]+)(.([0-9]{1,2}))?$").test(i);var n=parseInt(RegExp.$2);r.duration&&r.durationNegative&&"-"==RegExp.$1&&(n=-n);var s=RegExp.$4?parseInt(RegExp.$4):0;"HOUR"==$?n+=38==t.keyCode||"+"==t.key?1:-1:(s+=(38==t.keyCode||"+"==t.key?1:-1)*r.precision)<0?s=0:s>59&&(s=60-r.precision);var m=r.minimum;r.duration&&r.durationNegative||"-"!=m[0]||(m="0:00");var d=r.maximum;if(1!=r.precision){var f=parseInt(d.replace(/^(\+|-)?[0-9]+./,""));d=d.replace(/.[0-9]+$/,"")+r.separator+(f-f%r.precision)}var o=(n<0?"-":"")+(n<10&&!r.duration?"0":"")+Math.abs(n)+r.separator+(s<10?"0":"")+s;"HOUR"!=$||(l(o,d)?l(m,o)||(o=m):o=d),i!=o&&(es(ea(o)),a.attr("value",o.replace(/^\+/,"")),r.onAdjust.call(a.get(0),o.replace(/^\+/,""),i.replace(/^\+/,"")),er(),Y(),"HOUR"==$?eo():ei())}}),a.on("mousewheel.clockTimePicker",function e(t){a.is(":focus")&&M(t)}),a.on("focus.clockTimePicker",function e(t){n()?(Q(),ee(!0),eo()):setTimeout(function(){"none"==I.css("display")&&en(t)},50)});var R=e("<div>");R.css("position","relative").css("width",g+"px").css("height",g+"px").css("margin","10px "+(n()?25:10)+"px"),I.append(R);var D=e('<canvas class="clock-timepicker-hour-canvas">');D.css("cursor","default").css("position","absolute").css("top","0px").css("left","0px"),D.attr("width",g),D.attr("height",g),W(D),R.append(D);var E=e('<canvas class="clock-timepicker-minute-canvas">');if(E.css("cursor","default").css("position","absolute").css("top","0px").css("left","0px").css("display","none"),E.attr("width",g),E.attr("height",g),W(E),R.append(E),n()){var j=e("<div>");j.css("text-align","right").css("padding","15px 30px"),r.fonts.fontFamily=r.fonts.fontFamily.replace(/\"/g,"").replace(/\'/g,"");var A='<a style="text-decoration:none; color:'+r.colors.buttonTextColor+"; font-family:"+r.fonts.fontFamily+"; font-size:"+r.fonts.buttonFontSize+'px; padding-left:30px">',q=e(A);q.html(r.i18n.cancelButton),q.on("click",function(){Z()}),j.append(q);var B=e(A);B.html(r.i18n.okButton),B.on("click",function(){n()&&a.val(el()),r.vibrate&&navigator.vibrate(10),Z()}),j.append(B),I.append(j)}function W(t){n()?(t.on("touchstart",function(t){t.preventDefault();var o=t.originalEvent.touches[0].pageX-e(this).offset().left,i=t.originalEvent.touches[0].pageY-e(this).offset().top,c=Math.sqrt(Math.pow(Math.abs(o-h),2)+Math.pow(Math.abs(i-_),2));if(r.duration&&r.durationNegative&&c<=20){f=!0;var n=el();newVal=n.match(/^-/)?n.substring(1):"-"+n.replace(/^(-|\+)/,""),r.minimum&&!l(r.minimum,newVal)&&(newVal=ea(r.minimum)),r.maximum&&!l(newVal,r.maximum)&&(newVal=ea(r.maximum)),es(ea(newVal)),Y(),a.attr("value",newVal.replace(/^\+/,"")),r.onAdjust.call(a.get(0),newVal.replace(/^\+/,""),n.replace(/^\+/,"")),"HOUR"==$?eo():ei();return}d=!0,X(o,i)}),t.on("touchend",function(e){e.preventDefault(),d=!1,f||60==r.precision||(et(),ei()),f=!1}),t.on("touchmove",function(t){if(t.preventDefault(),d){var o=t.originalEvent.touches[0].pageX-e(this).offset().left,i=t.originalEvent.touches[0].pageY-e(this).offset().top;X(o,i)}})):(t.on("mousedown",function(t){var o=t.pageX-e(this).offset().left,i=t.pageY-e(this).offset().top;X(o,i),d=!0}),t.on("mouseup",function(t){d=!1;var o=t.pageX-e(this).offset().left,i=t.pageY-e(this).offset().top,c=Math.sqrt(Math.pow(Math.abs(o-h),2)+Math.pow(Math.abs(i-_),2));if(r.duration&&r.durationNegative&&c<=20){var n=el();newVal=n.match(/^-/)?n.substring(1):"-"+n.replace(/^(-|\+)/,""),r.minimum&&!l(r.minimum,newVal)&&(newVal=ea(r.minimum)),r.maximum&&!l(newVal,r.maximum)&&(newVal=ea(r.maximum)),es(ea(newVal)),Y(),a.attr("value",newVal.replace(/^\+/,"")),r.onAdjust.call(a.get(0),newVal.replace(/^\+/,""),n.replace(/^\+/,"")),"HOUR"==$?eo():ei();return}if(!X(o,i,!0))return 60==r.precision?Z():"HOUR"==$?(et(),ei()):Z(),!1;"MINUTE"==$||60==r.precision?Z():(et(),ei())}),t.on("mousemove",function(t){var o=t.pageX-e(this).offset().left,i=t.pageY-e(this).offset().top;X(o,i)}),t.on("mouseleave",function(e){"HOUR"==$?L():G()}),t.on("mousewheel",function(e){M(e)})),t.on("keydown",function(e){e.preventDefault(),X(),ee(),eo(),u=el()})}function M(e){var t=window.event||e;if(e.preventDefault(),!(new Date().getTime()-C<100)){C=new Date().getTime();var o=Math.max(-1,Math.min(1,t.wheelDelta||-t.detail));RegExp("^(-|\\+)?([0-9]+)(.([0-9]{1,2}))?$").test(el());var i=!!r.duration&&!!r.durationNegative&&"-"==RegExp.$1,c=parseInt(RegExp.$2);i&&(c=-c);var n=RegExp.$4?parseInt(RegExp.$4):0;"HOUR"==$?(r.duration&&r.durationNegative&&0==c&&!i&&-1==o?i=!0:r.duration&&r.durationNegative&&0==c&&i&&1==o?i=!1:c+=o,-1!=c||(r.duration?r.durationNegative||(c=0):c=23),24!=c||r.duration||(c=0)):((n+=o*r.precision)<0&&(n=60+n),n>=60&&(n-=60));var s=el(),m=(c<10&&!r.duration?"0":"")+(i&&0==c?"-"+c:c)+r.separator+(n<10?"0":"")+n,u=!0;r.maximum&&!l(m,r.maximum)&&(u=!1),r.minimum&&!l(r.minimum,m)&&(u=!1),u||"HOUR"!=$||(m=o>0?ea(r.maximum):ea(r.minimum),u=!0),u&&(es(ea(m)),er(),Y(),"HOUR"==$?eo():ei(),m!=s&&(a.attr("value",m.replace(/^\+/,"")),r.onAdjust.call(a.get(0),m.replace(/^\+/,""),s.replace(/^\+/,""))))}}function X(e,t,o){var i=360*Math.atan((t-_)/(e-h))/(2*Math.PI)+90,c=Math.sqrt(Math.pow(Math.abs(e-h),2)+Math.pow(Math.abs(t-_),2)),n=0,s=0,m=!1;if(RegExp("^(-|\\+)?([0-9]+).([0-9]{2})$").test(el())&&(m=!!r.duration&&!!r.durationNegative&&"-"==RegExp.$1,n=parseInt(RegExp.$2),s=parseInt(RegExp.$3)),"HOUR"==$){i=Math.round(i/30);var u=-1;if(c<v+10&&c>v-28?e-h>=0?u=0==i?12:i:e-h<0&&(u=i+6):c<v-28&&c>v-65&&(e-h>=0?u=0!=i?i+12:0:e-h<0&&24==(u=i+18)&&(u=0)),r.afternoonHoursInOuterCircle&&(u+=u>=12?-12:12),!(u>-1))return L(null,r.duration&&r.durationNegative&&c<=12),!1;var p=(m?"-":"")+(u<10&&!r.duration?"0":"")+u+r.separator+(s<10?"0":"")+s;if(d||o){var f=!0;if(r.maximum&&!l(p,r.maximum)&&(f=!1),r.minimum&&!l(r.minimum,p)&&(f=!1),f||(r.maximum&&l((m?"-":"")+(u<10&&!r.duration?"0":"")+u+r.separator+"00",r.maximum)&&(p=ea(r.maximum),f=!0),!r.minimum||l(r.minimum,(m?"-":"")+(u<10&&!r.duration?"0":"")+u+r.separator+"00")||(p=ea(r.minimum),f=!0)),f){var k=el();p!=k&&(r.vibrate&&navigator.vibrate(10),a.attr("value",p.replace(/^\+/,"")),r.onAdjust.call(a.get(0),p.replace(/^\+/,""),k.replace(/^\+/,""))),es(ea(p)),er()}}return y=!0,L(0==u?24:u,r.duration&&r.durationNegative&&c<=12),!0}if("MINUTE"==$){i=Math.round(i/6);var g=-1;if(c<v+10&&c>v-40&&(e-h>=0?g=i:e-h<0&&60==(g=i+30)&&(g=0)),!(g>-1))return G(null,r.duration&&r.durationNegative&&c<=12),!1;if(1!=r.precision){var x=Math.floor(g/r.precision);(g=x*r.precision+(1==Math.round((g-x*r.precision)/r.precision)?r.precision:0))>=60&&(g=0)}var p=(m?"-":"")+(n<10&&!r.duration?"0":"")+n+r.separator+(g<10?"0":"")+g,f=!0;if(r.maximum&&!l(p,r.maximum)&&(f=!1),r.minimum&&!l(r.minimum,p)&&(f=!1),(d||o)&&f){var k=el();p!=k&&(r.vibrate&&navigator.vibrate(10),a.attr("value",p.replace(/^\+/,"")),r.onAdjust.call(a.get(0),p.replace(/^\+/,""),k.replace(/^\+/,""))),es(ea(p))}return y=!0,G(0==g?60:g,r.duration&&r.durationNegative&&c<=12),!0}}function Y(){"HOUR"==$?L():G()}function K(e,t){e.beginPath(),e.arc(h,_,12,0,2*Math.PI,!1),e.fillStyle=r.colors.signButtonBackgroundColor,e.fill(),t&&(e.beginPath(),e.arc(h,_,14,0,2*Math.PI,!1),e.strokeStyle=r.colors.signButtonBackgroundColor,e.stroke()),e.beginPath(),e.moveTo(h-6,_),e.lineTo(h+6,_),e.lineWidth=2,e.strokeStyle=r.colors.signButtonColor,e.stroke(),el().match(/^-/)||(e.beginPath(),e.moveTo(h,_-6),e.lineTo(h,_+6),e.lineWidth=2,e.strokeStyle=r.colors.signButtonColor,e.stroke())}function L(e,t){var o=D.get(0).getContext("2d");RegExp("^(-|\\+)?([0-9]+).([0-9]{1,2})$").test(el());var i="-"==RegExp.$1,a=parseInt(RegExp.$2);if(o.clearRect(0,0,g,g),a>=24){I.css("visibility","hidden");return}if(r.onlyShowClockOnMobile||I.css("visibility","visible"),0==a&&(a=24),el()||(a=-1),o.beginPath(),o.arc(h,_,v,0,2*Math.PI,!1),o.fillStyle=r.colors.clockFaceColor,o.fill(),!n()&&e){var c=!0;r.maximum&&!l((i?"-":"")+(24==e?"00":e)+":00",r.maximum)&&(c=!1),r.minimum&&!l(r.minimum,(i?"-":"")+(24==e?"00":e)+":00",!0)&&(c=!1),c&&(o.beginPath(),o.arc(h+Math.cos(Math.PI/6*(e%12-3))*(e>12?r.afternoonHoursInOuterCircle?x:b:r.afternoonHoursInOuterCircle?b:x),_+Math.sin(Math.PI/6*(e%12-3))*(e>12?r.afternoonHoursInOuterCircle?x:b:r.afternoonHoursInOuterCircle?b:x),15,0,2*Math.PI,!1),o.fillStyle=r.colors.hoverCircleColor,o.fill())}o.beginPath(),o.arc(h,_,3,0,2*Math.PI,!1),o.fillStyle=r.colors.selectorColor,o.fill(),a>-1&&(!r.maximum||24==a||l(a,r.maximum))&&(o.beginPath(),o.moveTo(h,_),o.lineTo(h+Math.cos(Math.PI/6*(a%12-3))*(a>12?r.afternoonHoursInOuterCircle?x:b:r.afternoonHoursInOuterCircle?b:x),_+Math.sin(Math.PI/6*(a%12-3))*(a>12?r.afternoonHoursInOuterCircle?x:b:r.afternoonHoursInOuterCircle?b:x)),o.lineWidth=1,o.strokeStyle=r.colors.selectorColor,o.stroke(),o.beginPath(),o.arc(h+Math.cos(Math.PI/6*(a%12-3))*(a>12?r.afternoonHoursInOuterCircle?x:b:r.afternoonHoursInOuterCircle?b:x),_+Math.sin(Math.PI/6*(a%12-3))*(a>12?r.afternoonHoursInOuterCircle?x:b:r.afternoonHoursInOuterCircle?b:x),15,0,2*Math.PI,!1),o.fillStyle=r.colors.selectorColor,o.fill()),o.font=r.fonts.clockOuterCircleFontSize+"px "+r.fonts.fontFamily;for(let s=1;s<=12;s++){var m=Math.PI/6*(s-3),u=s;r.afternoonHoursInOuterCircle?(u=s+12,a==s+12?o.fillStyle=r.colors.selectorNumberColor:o.fillStyle=r.colors.clockInnerCircleTextColor,24==u&&(u="00")):a==s?o.fillStyle=r.colors.selectorNumberColor:o.fillStyle=r.colors.clockOuterCircleTextColor,(!r.maximum||l((i?"-":"")+u+":00",r.maximum))&&(!r.minimum||l(r.minimum,(i?"-":"")+u+":00",!0))?o.fillText(u,h+Math.cos(m)*x-o.measureText(u).width/2,_+Math.sin(m)*x+r.fonts.clockOuterCircleFontSize/3):r.hideUnselectableNumbers||(o.fillStyle=r.colors.clockOuterCircleUnselectableTextColor,o.fillText(u,h+Math.cos(m)*x-o.measureText(u).width/2,_+Math.sin(m)*x+r.fonts.clockOuterCircleFontSize/3))}o.font=r.fonts.clockInnerCircleFontSize+"px "+r.fonts.fontFamily;for(let p=1;p<=12;p++){var m=Math.PI/6*(p-3),u=p;r.afternoonHoursInOuterCircle?a==p?o.fillStyle=r.colors.selectorNumberColor:o.fillStyle=r.colors.clockOuterCircleTextColor:(u=p+12,a==p+12?o.fillStyle=r.colors.selectorNumberColor:o.fillStyle=r.colors.clockInnerCircleTextColor,24==u&&(u="00")),(!r.maximum||l((i?"-":"")+u+":00",r.maximum))&&(!r.minimum||l(r.minimum,(i?"-":"")+u+":00",!0))?o.fillText(u,h+Math.cos(m)*b-o.measureText(u).width/2,_+Math.sin(m)*b+r.fonts.clockInnerCircleFontSize/3):r.hideUnselectableNumbers||(o.fillStyle=r.colors.clockInnerCircleUnselectableTextColor,o.fillText(u,h+Math.cos(m)*b-o.measureText(u).width/2,_+Math.sin(m)*b+r.fonts.clockInnerCircleFontSize/3))}r.duration&&r.durationNegative&&K(o,t)}function G(e,t){var o=E.get(0).getContext("2d");RegExp("^(-|\\+)?([0-9]+).([0-9]{1,2})$").test(el());var i="-"==RegExp.$1,a=parseInt(RegExp.$2),c=parseInt(RegExp.$3);if(el()||(c=-1),r.onlyShowClockOnMobile||I.css("visibility","visible"),o.clearRect(0,0,g,g),o.beginPath(),o.arc(h,_,v,0,2*Math.PI,!1),o.fillStyle=r.colors.clockFaceColor,o.fill(),!n()&&e){60==e&&(e=0);var s=!0;r.maximum&&!l((i?"-":"")+a+":"+(e<10?"0":"")+e,r.maximum)&&(s=!1),r.minimum&&!l(r.minimum,(i?"-":"")+a+":"+(e<10?"0":"")+e)&&(s=!1),s&&(o.beginPath(),o.arc(h+Math.cos(Math.PI/6*(e/5-3))*x,_+Math.sin(Math.PI/6*(e/5-3))*x,15,0,2*Math.PI,!1),o.fillStyle=r.colors.hoverCircleColor,o.fill())}o.beginPath(),o.arc(h,_,3,0,2*Math.PI,!1),o.fillStyle=r.colors.selectorColor,o.fill(),c>-1&&(!r.maximum||l(a+":"+c,r.maximum))&&(!r.minimum||l(r.minimum,a+":"+c))&&(o.beginPath(),o.moveTo(h,_),o.lineTo(h+Math.cos(Math.PI/6*(c/5-3))*x,_+Math.sin(Math.PI/6*(c/5-3))*x),o.lineWidth=1,o.strokeStyle=r.colors.selectorColor,o.stroke(),o.beginPath(),o.arc(h+Math.cos(Math.PI/6*(c/5-3))*x,_+Math.sin(Math.PI/6*(c/5-3))*x,15,0,2*Math.PI,!1),o.fillStyle=r.colors.selectorColor,o.fill()),o.font=r.fonts.clockOuterCircleFontSize+"px "+r.fonts.fontFamily;for(let m=1;m<=12;m++)if(Math.floor(5*m/r.precision)==5*m/r.precision){var u=Math.PI/6*(m-3);c==5*m||0==c&&12==m?o.fillStyle=r.colors.selectorNumberColor:o.fillStyle=r.colors.clockOuterCircleTextColor;var p=5*m==5?"05":5*m;60==p&&(p="00");var s=!0;r.maximum&&!l((i?"-":"")+a+":"+p,r.maximum)&&(s=!1),r.minimum&&!l(r.minimum,(i?"-":"")+a+":"+p)&&(s=!1),s?o.fillText(p,h+Math.cos(u)*x-o.measureText(p).width/2,_+Math.sin(u)*x+r.fonts.clockOuterCircleFontSize/3):r.hideUnselectableNumbers||(o.fillStyle=r.colors.clockOuterCircleUnselectableTextColor,o.fillText(p,h+Math.cos(u)*x-o.measureText(p).width/2,_+Math.sin(u)*x+r.fonts.clockOuterCircleFontSize/3))}c>-1&&c%5!=0&&(o.beginPath(),o.arc(h+Math.cos(Math.PI/6*(c/5-3))*x,_+Math.sin(Math.PI/6*(c/5-3))*x,2,0,2*Math.PI,!1),o.fillStyle="white",o.fill()),r.duration&&r.durationNegative&&K(o,t)}function J(){window.innerHeight<400?(k=window.innerHeight-60,I.css("width",k+200+"px"),H.css("position","absolute").css("left","0px").css("top","0px").css("width","200px").css("height",k+20+"px"),R.css("margin","10px 25px 0px 230px"),t=k+parseInt(R.css("margin-top"))+parseInt(R.css("margin-bottom"))):((k=window.innerWidth-80)>300&&(k=300),I.css("width",k+"px"),H.css("position","static").css("width","100%").css("height","auto"),R.css("margin","10px 25px 10px 25px"),t=k+parseInt(R.css("margin-top"))+parseInt(R.css("margin-bottom"))+65),I.css("left",parseInt((e("body").prop("clientWidth")-I.outerWidth())/2)+"px"),I.css("top",parseInt((window.innerHeight-t)/2)+"px"),v=parseInt((g=k-50)/2),h=parseInt(g/2),_=parseInt(g/2),b=(x=v-16)-29,R.css("width",g+"px"),R.css("height",g+"px");var t,o=window.devicePixelRatio||1,i=D.get(0),r=E.get(0);i.width=g*o,i.height=g*o,r.width=g*o,r.height=g*o;var a=i.getContext("2d"),c=r.getContext("2d");a.scale(o,o),c.scale(o,o),D.css("width",g),D.css("height",g),E.css("width",g),E.css("height",g)}function Q(){a.val()?es(ea(a.val())):es(ea("00:00")),!n()&&r.onlyShowClockOnMobile&&I.css("visibility","hidden"),n()&&J(),I.css("display","block"),Y(),n()?i&&i.stop().css("opacity",0).css("display","block").animate({opacity:1},300):(V(),e(window).on("scroll.clockTimePicker",e=>{V()})),r.onOpen.call(a.get(0))}function V(){var t=a.offset().top-e(window).scrollTop()+a.outerHeight();if(t+I.outerHeight()>window.innerHeight){var o=a.offset().top-e(window).scrollTop()-I.outerHeight();o>=0&&(t=o)}var i=a.offset().left-e(window).scrollLeft()-parseInt((I.outerWidth()-a.outerWidth())/2);I.css("left",i+"px").css("top",t+"px")}function Z(){e(window).off("scroll.clockTimePicker");var t=ea(a.val());if(p="",I.css("display","none"),n()?i.stop().animate({opacity:0},300,function(){i.css("display","none")}):a.val(t),!function e(){if(document.activeElement==H.get(0)){var t=document.createElement("input");a.parent().get(0).appendChild(t),t.focus(),a.parent().get(0).removeChild(t)}}(),!y&&!u&&t.match(RegExp("^0+"+r.separator+"00$")))es("");else if(u!=t){if("createEvent"in document){var o=document.createEvent("HTMLEvents");o.initEvent("change",!0,!1),a.get(0).dispatchEvent(o)}else{var o=document.createEventObject();o.eventType="click",a.get(0).fireEvent("onchange",o)}r.onChange.call(a.get(0),t.replace(/^\+/,""),u.replace(/^\+/,"")),u=t}r.onClose.call(a.get(0)),y=!1}function ee(e){"HOUR"!=$&&(p="",L(),e?E.css("display","none"):E.css("zIndex",2).stop().animate({opacity:0,zoom:"80%",left:"10%",top:"10%"},r.modeSwitchSpeed,function(){E.css("display","none")}),D.stop().css("zoom","100%").css("left","0px").css("top","0px").css("display","block").css("opacity",1).css("zIndex",1),$="HOUR",r.onModeSwitch.call(a.get(0),$))}function et(e){"MINUTE"!=$&&(p="",G(),E.stop().css("display","block").css("zoom","80%").css("left","10%").css("top","10%").css("opacity",0).css("zIndex",1),e?E.css("opacity",1).css("zoom","100%").css("left","0px").css("top","0px"):E.animate({opacity:1,zoom:"100%",left:"0px",top:"0px"}),$="MINUTE",r.onModeSwitch.call(a.get(0),$))}function eo(){H.focus(),setTimeout(function(){n()?(e(".clock-timepicker-mobile-time-hours").css("backgroundColor","rgba(255, 255, 255, 0.6)"),e(".clock-timepicker-mobile-time-minutes").css("backgroundColor","inherit")):H.get(0).setSelectionRange(0,el().indexOf(r.separator))},1)}function ei(){H.focus(),setTimeout(function(){n()?(e(".clock-timepicker-mobile-time-hours").css("backgroundColor","inherit"),e(".clock-timepicker-mobile-time-minutes").css("backgroundColor","rgba(255, 255, 255, 0.6)")):H.get(0).setSelectionRange(el().indexOf(r.separator)+1,el().length)},1)}function er(){!r.autosize||n()||(w.html(a.val()),w.css("display","inline-block"),a.css("width",w.outerWidth()+5+parseInt(a.css("padding-left"))+parseInt(a.css("padding-right"))+"px"),w.css("display","none"))}function ea(e){if(""==e)return r.required?r.duration?"0:00":"00:00":e;if(RegExp("^(-|\\+)?([0-9]+)(.([0-9]{1,2})?)?$","i").test(e)){var t=parseInt(RegExp.$2),o=parseInt(RegExp.$4);o||(o=0);var i=!!r.duration&&!!r.durationNegative&&"-"==RegExp.$1;if(t>=24&&!r.duration&&(t%=24),o>=60&&(o%=60),1!=r.precision){var a=Math.floor(o/r.precision);60!=(o=a*r.precision+(1==Math.round((o-a*r.precision)/r.precision)?r.precision:0))||(o=0,24!=++t||r.duration||(t=0))}e=(i?"-":"")+(t<10&&!r.duration?"0":"")+t+r.separator+(RegExp.$3?(o<10?"0":"")+o:"00")}else if(RegExp("^(-|\\+)?.([0-9]{1,2})").test(e)){var o=parseInt(RegExp.$2),i=!!r.duration&&!!r.durationNegative&&"-"==RegExp.$1;o>=60&&(o%=60),e=(i&&o>0?"-":"")+"0"+(r.duration?"":"0")+r.separator+(o<10?"0":"")+o}else e="0"+(r.duration?"":"0")+r.separator+"00";return(r.duration&&r.useDurationPlusSign&&!e.match(/^\-/)&&!e.match(/^0+:00$/)?"+":"")+e}function ec(e){e.parent().find(".clock-timepicker-autosize").remove(),e.parent().find(".clock-timepicker-background").remove(),e.parent().find(".clock-timepicker-popup").remove(),e.unwrap(),e.off("drag.clockTimePicker dragend.clockTimePicker dragover.clockTimePicker dragenter.clockTimePicker dragstart.clockTimePicker dragleave.clockTimePicker drop.clockTimePicker selectstart.clockTimePicker contextmenu.clockTimePicker"),e.off("mousedown.clockTimePicker"),e.off("keyup.clockTimePicker"),e.off("keydown.clockTimePicker"),e.off("mousewheel.clockTimePicker"),e.off("focus.clockTimePicker"),e.attr("data-autocomplete-orig")?(e.attr("autocomplete",e.attr("data-autocomplete-orig")),e.removeAttr("data-autocomplete-orig")):e.removeAttr("autocomplete"),e.attr("data-autocorrect-orig")?(e.attr("autocorrect",e.attr("data-autocorrect-orig")),e.removeAttr("data-autocorrect-orig")):e.removeAttr("autocorrect"),e.attr("data-autocapitalize-orig")?(e.attr("autocapitalize",e.attr("data-autocapitalize-orig")),e.removeAttr("data-autocapitalize-orig")):e.removeAttr("autocapitalize"),e.attr("data-spellcheck-orig")?(e.attr("spellcheck",e.attr("data-spellcheck-orig")),e.removeAttr("data-spellcheck-orig")):e.removeAttr("spellcheck")}function en(e){if(!r.contextmenu||1==e.which)return!function e(t){var o="none"!=I.css("display");if(el()){if(60==r.precision)ee(!o),eo();else{var i=H.css("direction");i||(i="ltr");var a=H.css("text-align");a||(a="left");var c=H.innerWidth(),n=parseFloat(H.css("padding-left")),l=parseFloat(H.css("padding-right")),s=c-n-l;w.css("display","inline-block"),w.html(el());var m=w.innerWidth();w.html(r.separator);var u=w.innerWidth()/2;w.html(el().replace(RegExp(r.separator+"[0-9]+$"),"")),u+=w.innerWidth(),w.css("display","none");var p=c/2;"left"==a||"justify"==a||"ltr"==i&&"start"==a||"rtl"==i&&"end"==a?p=Math.floor(n+u):"center"==a?p=Math.floor(n+(s-m)/2+u):("right"==a||"ltr"==i&&"end"==a||"rtl"==i&&"start"==a)&&(p=Math.floor(n+s-(m-u))),t.offsetX>=p-2&&(o||!r.alwaysSelectHoursFirst)?("HOUR"==$&&r.vibrate&&navigator.vibrate(10),et(!o),ei()):("MINUTE"==$&&r.vibrate&&navigator.vibrate(10),ee(!o),eo())}}else es(ea("00:00")),ee(!o),eo();o||Q()}(e),e.stopImmediatePropagation(),e.stopPropagation(),e.preventDefault(),!1}function el(){return n()?e(".clock-timepicker-mobile-time-hours").html()+r.separator+e(".clock-timepicker-mobile-time-minutes").html():H.val()}function es(t){if(n()){if(t.match(/^(-|\\+)?([0-9]{1,2}).([0-9]{1,2})$/)){var o=RegExp.$1+(r.duration||1!=RegExp.$2.length?"":"0")+RegExp.$2,i=(1==RegExp.$3.length?"0":"")+RegExp.$3;e(".clock-timepicker-mobile-time-hours").html(o),e(".clock-timepicker-mobile-time-minutes").html(i)}}else H.val(t)}});function n(){var e,t=!1;return e=navigator.userAgent||navigator.vendor||window.opera,(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4)))&&(t=!0),t}function l(e,t,o){var i="^(-|\\+)?([0-9]+)(.([0-9]{1,2}))?$";RegExp(i,"i").test(e);var r=60*parseInt(RegExp.$2);RegExp.$4&&!o&&(r+=parseInt(RegExp.$4)),"-"==RegExp.$1&&(r*=-1),RegExp(i,"i").test(t);var a=60*parseInt(RegExp.$2);return RegExp.$4&&!o&&(a+=parseInt(RegExp.$4)),"-"==RegExp.$1&&(a*=-1),r<=a}}}(jQuery);