New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jquery-clockpicker

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jquery-clockpicker - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

2

bower.json

@@ -39,3 +39,3 @@ {

},
"version": "0.0.6"
"version": "0.0.7"
}

@@ -916,3 +916,3 @@ /*!

_updateInput: function() {
if (this.hours && this.minutes) {
if (this.hasOwnProperty('hours') && this.hasOwnProperty('minutes')) {
var last = this.input.prop('value'),

@@ -919,0 +919,0 @@ value = leadingZero(this.hours) + ':' + leadingZero(this.minutes);

@@ -7,2 +7,2 @@ /*!

*/
!function(){function t(t){return document.createElementNS(p,t)}function i(t){return(10>t?"0":"")+t}function e(t){var i=++q+"";return t?t+i:i}function s(t){return t>11?"PM":"AM"}function o(){}function c(s,o){function c(t,i){var e=p.offset(),s=/^touch/.test(t.type),c=e.left+w,a=e.top+w,h=(s?t.originalEvent.touches[0]:t).pageX-c,k=(s?t.originalEvent.touches[0]:t).pageY-a,m=Math.sqrt(h*h+k*k),f=!1;if(!i||!(T-A>m||m>T+A)){t.preventDefault();var b=setTimeout(function(){r.addClass("jqclockpicker-moving")},200);u&&p.append(q.canvas),q.setHand(h,k,!i,!0),l.off(d).on(d,function(t){t.preventDefault();var i=/^touch/.test(t.type),e=(i?t.originalEvent.touches[0]:t).pageX-c,s=(i?t.originalEvent.touches[0]:t).pageY-a;(f||e!==h||s!==k)&&(f=!0,q.setHand(e,s,!1,!0))}),l.off(v).on(v,function(t){l.off(v),t.preventDefault();var e=!1,s=!1;"hours"===q.currentView?(n(q.options.beforeHourSelect),e=!0):(n(q.options.beforeMinuteSelect),s=!0);var u=/^touch/.test(t.type),m=(u?t.originalEvent.changedTouches[0]:t).pageX-c,j=(u?t.originalEvent.changedTouches[0]:t).pageY-a;(i||f)&&m===h&&j===k&&q.setHand(m,j),"hours"===q.currentView?q.toggleView("minutes",C/2):o.autoClose&&(q.minutesView.addClass("jqclockpicker-dial-out"),setTimeout(function(){q.done()},C/2)),p.prepend(B),clearTimeout(b),r.removeClass("jqclockpicker-moving"),l.off(d),e&&n(q.options.afterHourSelect),s&&n(q.options.afterMinuteSelect)})}}var h=a(o.template),p=h.find(".jqclockpicker-plate"),k=h.find(".jqclockpicker-hours"),m=h.find(".jqclockpicker-minutes"),b=h.find(".jqclockpicker-am-pm-block"),j="INPUT"===s.prop("tagName"),g=j?s:s.find("input"),q=this;if(this.id=e("jqcp"),this.element=s,this.options=o,this.isAppended=!1,this.isShown=!1,this.currentView="hours",this.isInput=j,this.input=g,this.template=h,this.plate=p,this.hoursView=k,this.minutesView=m,this.amPmBlock=b,this.hoursLabel=h.find(".jqclockpicker-hours-label"),this.minutesLabel=h.find(".jqclockpicker-minutes-label"),this.spanAmPm=h.find(".jqclockpicker-span-am-pm"),this.amOrPm="PM",this.lastVal,"12h"===o.format){var P=['<div class="jqclockpicker-am-button jqclockpicker-clickable">AM</div>','<div class="jqclockpicker-pm-button jqclockpicker-clickable">PM</div>'].join(""),V=a(P);this.amPmBlock.on("click",".jqclockpicker-am-button",function(){q.amOrPm="AM",q.amPmBlock.find(".jqclockpicker-am-button").addClass("jqclockpicker-active"),q.amPmBlock.find(".jqclockpicker-pm-button").removeClass("jqclockpicker-active"),q._checkTimeLimits()}),this.amPmBlock.on("click",".jqclockpicker-pm-button",function(){q.amOrPm="PM",q.amPmBlock.find(".jqclockpicker-pm-button").addClass("jqclockpicker-active"),q.amPmBlock.find(".jqclockpicker-am-button").removeClass("jqclockpicker-active"),q._checkTimeLimits()}),V.appendTo(this.amPmBlock)}if(!o.autoClose){if(o.appendActions){var S=['<div class="jqclockpicker-footer">','<div class="jqclockpicker-actions">','<button type="button" class="jqclockpicker-cancel-button jqclockpicker-button jqclockpicker-clickable">'+o.cancelText+"</button>",'<button type="button" class="jqclockpicker-ok-button jqclockpicker-button jqclockpicker-clickable">'+o.okText+"</button>","</div>","</div>"].join("");a(S).appendTo(h)}h.on("click",".jqclockpicker-ok-button",a.proxy(this.done,this)),h.on("click",".jqclockpicker-cancel-button",a.proxy(this.hide,this))}h.addClass("jqclockpicker-position-"+o.position),h.addClass("jqclockpicker-align-"+o.alignment),this.hoursLabel.click(a.proxy(this.toggleView,this,"hours")),this.minutesLabel.click(a.proxy(this.toggleView,this,"minutes")),g.on("focus.jqclockpicker click.jqclockpicker",a.proxy(this.show,this)),g.on("keyup",a.proxy(this._doKeyUp,this)),g.on("blur",a.proxy(function(){this.options.autoClose&&this._updateInput()},this));var _,L,H,x,O=a('<div class="jqclockpicker-tick"></div>');if("12h"===o.format)for(_=1;13>_;_+=1)L=O.clone(),H=_/6*Math.PI,x=T,L.css("font-size","115%"),L.css({left:w+Math.sin(H)*x-A,top:w-Math.cos(H)*x-A}),L.html(0===_?"00":_),k.append(L),L.on(f,c);else for(_=0;24>_;_+=1){L=O.clone(),H=_/6*Math.PI;var I=_>0&&13>_;x=I?M:T,L.css({left:w+Math.sin(H)*x-A,top:w-Math.cos(H)*x-A}),I&&L.css("font-size","115%"),L.html(0===_?"00":_),k.append(L),L.on(f,c)}for(_=0;60>_;_+=5)L=O.clone(),H=_/30*Math.PI,L.css({left:w+Math.sin(H)*T-A,top:w-Math.cos(H)*T-A}),L.css("font-size","115%"),L.html(i(_)),m.append(L),L.on(f,c);if(p.on(f,function(t){0===a(t.target).closest(".jqclockpicker-tick").length&&c(t,!0)}),u){var B=h.find(".jqclockpicker-canvas"),D=t("svg");D.setAttribute("class","jqclockpicker-svg"),D.setAttribute("width",y),D.setAttribute("height",y);var E=t("g");E.setAttribute("transform","translate("+w+","+w+")");var U=t("circle");U.setAttribute("class","jqclockpicker-canvas-bearing"),U.setAttribute("cx",0),U.setAttribute("cy",0),U.setAttribute("r",2);var z=t("line");z.setAttribute("x1",0),z.setAttribute("y1",0);var F=t("circle");F.setAttribute("class","jqclockpicker-canvas-bg"),F.setAttribute("r",A);var N=t("circle");N.setAttribute("class","jqclockpicker-canvas-fg"),N.setAttribute("r",3.5),E.appendChild(z),E.appendChild(N),E.appendChild(F),E.appendChild(U),D.appendChild(E),B.append(D),this.hand=z,this.bg=F,this.fg=N,this.bearing=U,this.g=E,this.canvas=B}n(this.options.init)}function n(t){t&&"function"==typeof t&&t()}var r,a=window.jQuery,h=a(window),l=a(document),p="http://www.w3.org/2000/svg",u="SVGAngle"in window&&function(){var t,i=document.createElement("div");return i.innerHTML="<svg/>",t=(i.firstChild&&i.firstChild.namespaceURI)==p,i.innerHTML="",t}(),k=function(){var t=document.createElement("div").style;return"transition"in t||"WebkitTransition"in t||"MozTransition"in t||"msTransition"in t||"OTransition"in t}(),m="ontouchstart"in window,f="mousedown"+(m?" touchstart":""),d="mousemove.jqclockpicker"+(m?" touchmove.jqclockpicker":""),v="mouseup.jqclockpicker"+(m?" touchend.jqclockpicker":""),b=navigator.vibrate?"vibrate":navigator.webkitVibrate?"webkitVibrate":null,j=['<div class="jqclockpicker-container">','<div class="jqclockpicker-header">','<div class="jqclockpicker-time">','<span class="jqclockpicker-hours-label jqclockpicker-clickable"></span>','<span class="jqclockpicker-label-separator">:</span>','<span class="jqclockpicker-minutes-label jqclockpicker-clickable"></span>',"</div>",'<div class="jqclockpicker-am-pm-block"></div>',"</div>",'<div class="jqclockpicker-body">','<div class="jqclockpicker-plate">','<div class="jqclockpicker-canvas"></div>','<div class="jqclockpicker-dial jqclockpicker-hours"></div>','<div class="jqclockpicker-dial jqclockpicker-minutes jqclockpicker-dial-out"></div>',"</div>","</div>","</div>"].join(""),g=function(t,i,e){this.hours=t||0,this.minutes=i||0,this.amOrPm=e||"AM"};c.DEFAULTS={autoClose:!0,appendActions:!0,format:"24h",okText:"OK",cancelText:"Cancel",defaultTime:"",timeFromNow:0,minTime:null,vibrate:!0,position:"bottom",alignment:"left",template:j,beforeShow:o,afterShow:o,beforeHide:o,afterHide:o,beforeShowHours:o,afterShowHours:o,beforeShowMinutes:o,afterShowMinutes:o,beforeHourSelect:o,afterHourSelect:o,beforeMinuteSelect:o,afterMinuteSelect:o,beforeDone:o,afterDone:o};var q=0,w=100,T=83,M=60,A=13,y=2*w,C=k?350:1;a.extend(c.prototype,{toggle:function(){this[this.isShown?"hide":"show"]()},locate:function(){var t=this.element,i=this.template,e=t.offset(),s=t.outerWidth(),o=t.outerHeight(),c=this.options.position,n=this.options.alignment,r={};switch(i.show(),c){case"bottom":r.top=e.top+o;break;case"right":r.left=e.left+s;break;case"top":r.top=e.top-i.outerHeight();break;case"left":r.left=e.left-i.outerWidth()}switch(n){case"left":r.left=e.left;break;case"right":r.left=e.left+s-i.outerWidth()}i.css(r)},show:function(t){if(!this.isShown){n(this.options.beforeShow);var i=this;this.isAppended||(r=a(document.body).append(this.template),h.on("resize.jqclockpicker"+this.id,function(){i.isShown&&i.locate()}),this.isAppended=!0);var e=this.input.prop("value")||this.options.defaultTime||"",s=this._parseTime(e,this.options.timeFromNow);this._setTime(s),this._updateLabels(),this.toggleView("hours"),this.locate(),this.isShown=!0,l.on("click.jqclockpicker."+this.id+" focusin.jqclockpicker."+this.id,function(t){var e=a(t.target);0===e.closest(i.template).length&&0===e.closest(i.input).length&&i.hide()}),l.on("keyup.jqclockpicker."+this.id,function(t){27===t.keyCode&&i.hide()}),n(this.options.afterShow)}},setTime:function(t){this._setTime(this._parseTime(t))},hide:function(){n(this.options.beforeHide),this.isShown=!1,l.off("click.jqclockpicker."+this.id+" focusin.jqclockpicker."+this.id),l.off("keyup.jqclockpicker."+this.id),this.template.hide(),n(this.options.afterHide)},toggleView:function(t,i){var e=!1,s=!1;"hours"===t&&(n(this.options.beforeShowHours),e=!0),"minutes"===t&&(n(this.options.beforeShowMinutes),s=!0);var o="hours"===t,c=o?this.hoursView:this.minutesView,r=o?this.minutesView:this.hoursView;this.currentView=t,this._checkTimeLimits(),this.hoursLabel.toggleClass("jqclockpicker-active",o),this.minutesLabel.toggleClass("jqclockpicker-active",!o),r.addClass("jqclockpicker-dial-out"),c.css("visibility","visible").removeClass("jqclockpicker-dial-out"),this.resetClock(i),clearTimeout(this.toggleViewTimer),this.toggleViewTimer=setTimeout(function(){r.css("visibility","hidden")},C),e&&n(this.options.afterShowHours),s&&n(this.options.afterShowMinutes)},resetClock:function(t){var i=this.currentView,e=this[i],s="hours"===i,o=Math.PI/(s?6:30),c=e*o,n=s&&e>0&&13>e?M:T,r=Math.sin(c)*n,a=-Math.cos(c)*n,h=this;u&&t?(h.canvas.addClass("jqclockpicker-canvas-out"),setTimeout(function(){h.canvas.removeClass("jqclockpicker-canvas-out"),h.setHand(r,a)},t)):this.setHand(r,a)},setHand:function(t,e,s,o){var c,n=Math.atan2(t,-e),r="hours"===this.currentView,h=Math.PI/(r||s?6:30),l=Math.sqrt(t*t+e*e),p=this.options,k=r&&(T+M)/2>l,m=k?M:T;"12h"===p.format&&(m=T),0>n&&(n=2*Math.PI+n),c=Math.round(n/h),n=c*h,"12h"===p.format?r?0===c&&(c=12):(s&&(c*=5),60===c&&(c=0)):r?(12===c&&(c=0),c=k?0===c?12:c:0===c?0:c+12):(s&&(c*=5),60===c&&(c=0));var f=this._parseTime(this.options.minTime);if(r){if(c<f.hours)return}else{var d=this.hours;if("12h"===this.options.format&&"PM"===this.amOrPm&&(d+=12),d<=f.hours&&c<f.minutes)return}if(this[this.currentView]!==c&&b&&this.options.vibrate&&(this.vibrateTimer||(navigator[b](10),this.vibrateTimer=setTimeout(a.proxy(function(){this.vibrateTimer=null},this),100))),this[this.currentView]=c,this[r?"hoursLabel":"minutesLabel"].html(i(c)),this[r?"hoursView":"minutesView"].find(".jqclockpicker-tick").each(function(){var t=a(this);t.toggleClass("jqclockpicker-tick-active",c===+t.html())}),u){var v=Math.sin(n)*m,j=-Math.cos(n)*m,g=Math.sin(n)*(m-this.bg.getAttribute("r")),q=-Math.cos(n)*(m-this.bg.getAttribute("r"));return this.hand.setAttribute("x2",g),this.hand.setAttribute("y2",q),this.bg.setAttribute("cx",v),this.bg.setAttribute("cy",j),this.fg.setAttribute("visibility","hidden"),this.bg.setAttribute("class","jqclockpicker-canvas-bg"),!r&&c%5&&(this.fg.setAttribute("cx",v),this.fg.setAttribute("cy",j),this.fg.setAttribute("visibility","visible")),o?this.g.insertBefore(this.hand,this.bearing):this.g.insertBefore(this.hand,this.bg),!0}},done:function(){n(this.options.beforeDone),this.hide(),this._updateInput(),this.options.autoClose&&this.input.trigger("blur"),n(this.options.afterDone)},remove:function(){this.element.removeData("jqclockpicker"),this.input.off("focus.jqclockpicker click.jqclockpicker").off("keyup",this._doKeyUp),this.isShown&&this.hide(),this.isAppended&&(h.off("resize.jqclockpicker"+this.id),this.template.remove())},_updateLabels:function(){this.hoursLabel.html(i(this.hours)),this.minutesLabel.html(i(this.minutes)),"12h"===this.options.format&&("AM"===this.amOrPm?(this.amPmBlock.find(".jqclockpicker-am-button").addClass("jqclockpicker-active"),this.amPmBlock.find(".jqclockpicker-pm-button").removeClass("jqclockpicker-active")):(this.amPmBlock.find(".jqclockpicker-pm-button").addClass("jqclockpicker-active"),this.amPmBlock.find(".jqclockpicker-am-button").removeClass("jqclockpicker-active")))},_parseTime:function(t,i){var e,o,c,n=(t+"").replace(/^\s\s*/,"").replace(/\s\s*$/,"");if("now"===n){var r=new Date(+new Date+(i||0));e=r.getHours(),o=r.getMinutes(),c=s(this.hours)}else{var a=(t+"").replace(/^\s\s*/,"").replace(/\s\s*$/,"").toUpperCase(),h=a.match(/^([0-9]|0[0-9]|1[0-9]|2[0-3])(?::)?(?:(?::)([0-5][0-9])\s*(AM|PM)?)?$/);h?(e=h[1]?+h[1]:0,o=h[2]?+h[2]:0,c=h[3]||null):(e=0,o=0)}return new g(e,o,c)},_setTime:function(t){this.hours=t.hours,this.minutes=t.minutes,this.amOrPm=t.amOrPm,this._checkTimeLimits(),this._updateLabels(),this.resetClock()},_checkTimeLimits:function(){this._checkMinTime()},_checkMinTime:function(){var t=this,i=this._parseTime(this.options.minTime),e=this.hours;"12h"===t.options.format&&"PM"===t.amOrPm&&(e+=12),(e<i.hours||e==i.hours&&this.minutes<i.minutes)&&(this.hours=i.hours,this.minutes=i.minutes);var s="hours"==this.currentView;if(s)this[s?"hoursView":"minutesView"].find(".jqclockpicker-tick").each(function(){var e=a(this),s=parseInt(e.html());"12h"===t.options.format&&"PM"===t.amOrPm&&(s+=12),e.toggleClass("disabled",s<i.hours)});else{var e=this.hours;"12h"===t.options.format&&"PM"===t.amOrPm&&(e+=12),e<=i.hours?this[s?"hoursView":"minutesView"].find(".jqclockpicker-tick").each(function(){var t=a(this);t.toggleClass("disabled",t.html()<i.minutes)}):this.minutesView.find(".jqclockpicker-tick").removeClass("disabled")}},_updateInput:function(){if(this.hours&&this.minutes){var t=this.input.prop("value"),e=i(this.hours)+":"+i(this.minutes);"12h"===this.options.format&&(e+=this.amOrPm),this.input.prop("value",e),this.lastVal=this.input.prop("value"),e!==t&&(this.input.trigger("change"),this.input.triggerHandler("change"),this.isInput||this.element.trigger("change"))}},_doKeyUp:function(t){return this.input.val()!==this.lastVal&&this.setTime(this.input.val()),!0},_setOption:function(t,i){t in c.DEFAULTS&&("default"===i?this.options[t]=c.DEFAULTS[t]:this.options[t]=i,this._checkTimeLimits(),this._updateInput())}}),a.fn.jqclockpicker=function(t){var i=Array.prototype.slice.call(arguments,1);return this.each(function(){var e=a(this),s=e.data("jqclockpicker");if(s)"option"===t&&2===i.length&&"string"==typeof i[1]?s._setOption.apply(s,i):"function"==typeof s[t]&&s[t].apply(s,i);else{var o=a.extend({},c.DEFAULTS,e.data(),"object"==typeof t&&t);e.data("jqclockpicker",new c(e,o))}})}}();
!function(){function t(t){return document.createElementNS(p,t)}function i(t){return(10>t?"0":"")+t}function e(t){var i=++q+"";return t?t+i:i}function s(t){return t>11?"PM":"AM"}function o(){}function c(s,o){function c(t,i){var e=p.offset(),s=/^touch/.test(t.type),c=e.left+w,a=e.top+w,h=(s?t.originalEvent.touches[0]:t).pageX-c,k=(s?t.originalEvent.touches[0]:t).pageY-a,m=Math.sqrt(h*h+k*k),f=!1;if(!i||!(T-y>m||m>T+y)){t.preventDefault();var b=setTimeout(function(){r.addClass("jqclockpicker-moving")},200);u&&p.append(q.canvas),q.setHand(h,k,!i,!0),l.off(d).on(d,function(t){t.preventDefault();var i=/^touch/.test(t.type),e=(i?t.originalEvent.touches[0]:t).pageX-c,s=(i?t.originalEvent.touches[0]:t).pageY-a;(f||e!==h||s!==k)&&(f=!0,q.setHand(e,s,!1,!0))}),l.off(v).on(v,function(t){l.off(v),t.preventDefault();var e=!1,s=!1;"hours"===q.currentView?(n(q.options.beforeHourSelect),e=!0):(n(q.options.beforeMinuteSelect),s=!0);var u=/^touch/.test(t.type),m=(u?t.originalEvent.changedTouches[0]:t).pageX-c,j=(u?t.originalEvent.changedTouches[0]:t).pageY-a;(i||f)&&m===h&&j===k&&q.setHand(m,j),"hours"===q.currentView?q.toggleView("minutes",P/2):o.autoClose&&(q.minutesView.addClass("jqclockpicker-dial-out"),setTimeout(function(){q.done()},P/2)),p.prepend(B),clearTimeout(b),r.removeClass("jqclockpicker-moving"),l.off(d),e&&n(q.options.afterHourSelect),s&&n(q.options.afterMinuteSelect)})}}var h=a(o.template),p=h.find(".jqclockpicker-plate"),k=h.find(".jqclockpicker-hours"),m=h.find(".jqclockpicker-minutes"),b=h.find(".jqclockpicker-am-pm-block"),j="INPUT"===s.prop("tagName"),g=j?s:s.find("input"),q=this;if(this.id=e("jqcp"),this.element=s,this.options=o,this.isAppended=!1,this.isShown=!1,this.currentView="hours",this.isInput=j,this.input=g,this.template=h,this.plate=p,this.hoursView=k,this.minutesView=m,this.amPmBlock=b,this.hoursLabel=h.find(".jqclockpicker-hours-label"),this.minutesLabel=h.find(".jqclockpicker-minutes-label"),this.spanAmPm=h.find(".jqclockpicker-span-am-pm"),this.amOrPm="PM",this.lastVal,"12h"===o.format){var C=['<div class="jqclockpicker-am-button jqclockpicker-clickable">AM</div>','<div class="jqclockpicker-pm-button jqclockpicker-clickable">PM</div>'].join(""),V=a(C);this.amPmBlock.on("click",".jqclockpicker-am-button",function(){q.amOrPm="AM",q.amPmBlock.find(".jqclockpicker-am-button").addClass("jqclockpicker-active"),q.amPmBlock.find(".jqclockpicker-pm-button").removeClass("jqclockpicker-active"),q._checkTimeLimits()}),this.amPmBlock.on("click",".jqclockpicker-pm-button",function(){q.amOrPm="PM",q.amPmBlock.find(".jqclockpicker-pm-button").addClass("jqclockpicker-active"),q.amPmBlock.find(".jqclockpicker-am-button").removeClass("jqclockpicker-active"),q._checkTimeLimits()}),V.appendTo(this.amPmBlock)}if(!o.autoClose){if(o.appendActions){var S=['<div class="jqclockpicker-footer">','<div class="jqclockpicker-actions">','<button type="button" class="jqclockpicker-cancel-button jqclockpicker-button jqclockpicker-clickable">'+o.cancelText+"</button>",'<button type="button" class="jqclockpicker-ok-button jqclockpicker-button jqclockpicker-clickable">'+o.okText+"</button>","</div>","</div>"].join("");a(S).appendTo(h)}h.on("click",".jqclockpicker-ok-button",a.proxy(this.done,this)),h.on("click",".jqclockpicker-cancel-button",a.proxy(this.hide,this))}h.addClass("jqclockpicker-position-"+o.position),h.addClass("jqclockpicker-align-"+o.alignment),this.hoursLabel.click(a.proxy(this.toggleView,this,"hours")),this.minutesLabel.click(a.proxy(this.toggleView,this,"minutes")),g.on("focus.jqclockpicker click.jqclockpicker",a.proxy(this.show,this)),g.on("keyup",a.proxy(this._doKeyUp,this)),g.on("blur",a.proxy(function(){this.options.autoClose&&this._updateInput()},this));var _,L,H,x,O=a('<div class="jqclockpicker-tick"></div>');if("12h"===o.format)for(_=1;13>_;_+=1)L=O.clone(),H=_/6*Math.PI,x=T,L.css("font-size","115%"),L.css({left:w+Math.sin(H)*x-y,top:w-Math.cos(H)*x-y}),L.html(0===_?"00":_),k.append(L),L.on(f,c);else for(_=0;24>_;_+=1){L=O.clone(),H=_/6*Math.PI;var I=_>0&&13>_;x=I?M:T,L.css({left:w+Math.sin(H)*x-y,top:w-Math.cos(H)*x-y}),I&&L.css("font-size","115%"),L.html(0===_?"00":_),k.append(L),L.on(f,c)}for(_=0;60>_;_+=5)L=O.clone(),H=_/30*Math.PI,L.css({left:w+Math.sin(H)*T-y,top:w-Math.cos(H)*T-y}),L.css("font-size","115%"),L.html(i(_)),m.append(L),L.on(f,c);if(p.on(f,function(t){0===a(t.target).closest(".jqclockpicker-tick").length&&c(t,!0)}),u){var B=h.find(".jqclockpicker-canvas"),D=t("svg");D.setAttribute("class","jqclockpicker-svg"),D.setAttribute("width",A),D.setAttribute("height",A);var E=t("g");E.setAttribute("transform","translate("+w+","+w+")");var U=t("circle");U.setAttribute("class","jqclockpicker-canvas-bearing"),U.setAttribute("cx",0),U.setAttribute("cy",0),U.setAttribute("r",2);var z=t("line");z.setAttribute("x1",0),z.setAttribute("y1",0);var F=t("circle");F.setAttribute("class","jqclockpicker-canvas-bg"),F.setAttribute("r",y);var N=t("circle");N.setAttribute("class","jqclockpicker-canvas-fg"),N.setAttribute("r",3.5),E.appendChild(z),E.appendChild(N),E.appendChild(F),E.appendChild(U),D.appendChild(E),B.append(D),this.hand=z,this.bg=F,this.fg=N,this.bearing=U,this.g=E,this.canvas=B}n(this.options.init)}function n(t){t&&"function"==typeof t&&t()}var r,a=window.jQuery,h=a(window),l=a(document),p="http://www.w3.org/2000/svg",u="SVGAngle"in window&&function(){var t,i=document.createElement("div");return i.innerHTML="<svg/>",t=(i.firstChild&&i.firstChild.namespaceURI)==p,i.innerHTML="",t}(),k=function(){var t=document.createElement("div").style;return"transition"in t||"WebkitTransition"in t||"MozTransition"in t||"msTransition"in t||"OTransition"in t}(),m="ontouchstart"in window,f="mousedown"+(m?" touchstart":""),d="mousemove.jqclockpicker"+(m?" touchmove.jqclockpicker":""),v="mouseup.jqclockpicker"+(m?" touchend.jqclockpicker":""),b=navigator.vibrate?"vibrate":navigator.webkitVibrate?"webkitVibrate":null,j=['<div class="jqclockpicker-container">','<div class="jqclockpicker-header">','<div class="jqclockpicker-time">','<span class="jqclockpicker-hours-label jqclockpicker-clickable"></span>','<span class="jqclockpicker-label-separator">:</span>','<span class="jqclockpicker-minutes-label jqclockpicker-clickable"></span>',"</div>",'<div class="jqclockpicker-am-pm-block"></div>',"</div>",'<div class="jqclockpicker-body">','<div class="jqclockpicker-plate">','<div class="jqclockpicker-canvas"></div>','<div class="jqclockpicker-dial jqclockpicker-hours"></div>','<div class="jqclockpicker-dial jqclockpicker-minutes jqclockpicker-dial-out"></div>',"</div>","</div>","</div>"].join(""),g=function(t,i,e){this.hours=t||0,this.minutes=i||0,this.amOrPm=e||"AM"};c.DEFAULTS={autoClose:!0,appendActions:!0,format:"24h",okText:"OK",cancelText:"Cancel",defaultTime:"",timeFromNow:0,minTime:null,vibrate:!0,position:"bottom",alignment:"left",template:j,beforeShow:o,afterShow:o,beforeHide:o,afterHide:o,beforeShowHours:o,afterShowHours:o,beforeShowMinutes:o,afterShowMinutes:o,beforeHourSelect:o,afterHourSelect:o,beforeMinuteSelect:o,afterMinuteSelect:o,beforeDone:o,afterDone:o};var q=0,w=100,T=83,M=60,y=13,A=2*w,P=k?350:1;a.extend(c.prototype,{toggle:function(){this[this.isShown?"hide":"show"]()},locate:function(){var t=this.element,i=this.template,e=t.offset(),s=t.outerWidth(),o=t.outerHeight(),c=this.options.position,n=this.options.alignment,r={};switch(i.show(),c){case"bottom":r.top=e.top+o;break;case"right":r.left=e.left+s;break;case"top":r.top=e.top-i.outerHeight();break;case"left":r.left=e.left-i.outerWidth()}switch(n){case"left":r.left=e.left;break;case"right":r.left=e.left+s-i.outerWidth()}i.css(r)},show:function(t){if(!this.isShown){n(this.options.beforeShow);var i=this;this.isAppended||(r=a(document.body).append(this.template),h.on("resize.jqclockpicker"+this.id,function(){i.isShown&&i.locate()}),this.isAppended=!0);var e=this.input.prop("value")||this.options.defaultTime||"",s=this._parseTime(e,this.options.timeFromNow);this._setTime(s),this._updateLabels(),this.toggleView("hours"),this.locate(),this.isShown=!0,l.on("click.jqclockpicker."+this.id+" focusin.jqclockpicker."+this.id,function(t){var e=a(t.target);0===e.closest(i.template).length&&0===e.closest(i.input).length&&i.hide()}),l.on("keyup.jqclockpicker."+this.id,function(t){27===t.keyCode&&i.hide()}),n(this.options.afterShow)}},setTime:function(t){this._setTime(this._parseTime(t))},hide:function(){n(this.options.beforeHide),this.isShown=!1,l.off("click.jqclockpicker."+this.id+" focusin.jqclockpicker."+this.id),l.off("keyup.jqclockpicker."+this.id),this.template.hide(),n(this.options.afterHide)},toggleView:function(t,i){var e=!1,s=!1;"hours"===t&&(n(this.options.beforeShowHours),e=!0),"minutes"===t&&(n(this.options.beforeShowMinutes),s=!0);var o="hours"===t,c=o?this.hoursView:this.minutesView,r=o?this.minutesView:this.hoursView;this.currentView=t,this._checkTimeLimits(),this.hoursLabel.toggleClass("jqclockpicker-active",o),this.minutesLabel.toggleClass("jqclockpicker-active",!o),r.addClass("jqclockpicker-dial-out"),c.css("visibility","visible").removeClass("jqclockpicker-dial-out"),this.resetClock(i),clearTimeout(this.toggleViewTimer),this.toggleViewTimer=setTimeout(function(){r.css("visibility","hidden")},P),e&&n(this.options.afterShowHours),s&&n(this.options.afterShowMinutes)},resetClock:function(t){var i=this.currentView,e=this[i],s="hours"===i,o=Math.PI/(s?6:30),c=e*o,n=s&&e>0&&13>e?M:T,r=Math.sin(c)*n,a=-Math.cos(c)*n,h=this;u&&t?(h.canvas.addClass("jqclockpicker-canvas-out"),setTimeout(function(){h.canvas.removeClass("jqclockpicker-canvas-out"),h.setHand(r,a)},t)):this.setHand(r,a)},setHand:function(t,e,s,o){var c,n=Math.atan2(t,-e),r="hours"===this.currentView,h=Math.PI/(r||s?6:30),l=Math.sqrt(t*t+e*e),p=this.options,k=r&&(T+M)/2>l,m=k?M:T;"12h"===p.format&&(m=T),0>n&&(n=2*Math.PI+n),c=Math.round(n/h),n=c*h,"12h"===p.format?r?0===c&&(c=12):(s&&(c*=5),60===c&&(c=0)):r?(12===c&&(c=0),c=k?0===c?12:c:0===c?0:c+12):(s&&(c*=5),60===c&&(c=0));var f=this._parseTime(this.options.minTime);if(r){if(c<f.hours)return}else{var d=this.hours;if("12h"===this.options.format&&"PM"===this.amOrPm&&(d+=12),d<=f.hours&&c<f.minutes)return}if(this[this.currentView]!==c&&b&&this.options.vibrate&&(this.vibrateTimer||(navigator[b](10),this.vibrateTimer=setTimeout(a.proxy(function(){this.vibrateTimer=null},this),100))),this[this.currentView]=c,this[r?"hoursLabel":"minutesLabel"].html(i(c)),this[r?"hoursView":"minutesView"].find(".jqclockpicker-tick").each(function(){var t=a(this);t.toggleClass("jqclockpicker-tick-active",c===+t.html())}),u){var v=Math.sin(n)*m,j=-Math.cos(n)*m,g=Math.sin(n)*(m-this.bg.getAttribute("r")),q=-Math.cos(n)*(m-this.bg.getAttribute("r"));return this.hand.setAttribute("x2",g),this.hand.setAttribute("y2",q),this.bg.setAttribute("cx",v),this.bg.setAttribute("cy",j),this.fg.setAttribute("visibility","hidden"),this.bg.setAttribute("class","jqclockpicker-canvas-bg"),!r&&c%5&&(this.fg.setAttribute("cx",v),this.fg.setAttribute("cy",j),this.fg.setAttribute("visibility","visible")),o?this.g.insertBefore(this.hand,this.bearing):this.g.insertBefore(this.hand,this.bg),!0}},done:function(){n(this.options.beforeDone),this.hide(),this._updateInput(),this.options.autoClose&&this.input.trigger("blur"),n(this.options.afterDone)},remove:function(){this.element.removeData("jqclockpicker"),this.input.off("focus.jqclockpicker click.jqclockpicker").off("keyup",this._doKeyUp),this.isShown&&this.hide(),this.isAppended&&(h.off("resize.jqclockpicker"+this.id),this.template.remove())},_updateLabels:function(){this.hoursLabel.html(i(this.hours)),this.minutesLabel.html(i(this.minutes)),"12h"===this.options.format&&("AM"===this.amOrPm?(this.amPmBlock.find(".jqclockpicker-am-button").addClass("jqclockpicker-active"),this.amPmBlock.find(".jqclockpicker-pm-button").removeClass("jqclockpicker-active")):(this.amPmBlock.find(".jqclockpicker-pm-button").addClass("jqclockpicker-active"),this.amPmBlock.find(".jqclockpicker-am-button").removeClass("jqclockpicker-active")))},_parseTime:function(t,i){var e,o,c,n=(t+"").replace(/^\s\s*/,"").replace(/\s\s*$/,"");if("now"===n){var r=new Date(+new Date+(i||0));e=r.getHours(),o=r.getMinutes(),c=s(this.hours)}else{var a=(t+"").replace(/^\s\s*/,"").replace(/\s\s*$/,"").toUpperCase(),h=a.match(/^([0-9]|0[0-9]|1[0-9]|2[0-3])(?::)?(?:(?::)([0-5][0-9])\s*(AM|PM)?)?$/);h?(e=h[1]?+h[1]:0,o=h[2]?+h[2]:0,c=h[3]||null):(e=0,o=0)}return new g(e,o,c)},_setTime:function(t){this.hours=t.hours,this.minutes=t.minutes,this.amOrPm=t.amOrPm,this._checkTimeLimits(),this._updateLabels(),this.resetClock()},_checkTimeLimits:function(){this._checkMinTime()},_checkMinTime:function(){var t=this,i=this._parseTime(this.options.minTime),e=this.hours;"12h"===t.options.format&&"PM"===t.amOrPm&&(e+=12),(e<i.hours||e==i.hours&&this.minutes<i.minutes)&&(this.hours=i.hours,this.minutes=i.minutes);var s="hours"==this.currentView;if(s)this[s?"hoursView":"minutesView"].find(".jqclockpicker-tick").each(function(){var e=a(this),s=parseInt(e.html());"12h"===t.options.format&&"PM"===t.amOrPm&&(s+=12),e.toggleClass("disabled",s<i.hours)});else{var e=this.hours;"12h"===t.options.format&&"PM"===t.amOrPm&&(e+=12),e<=i.hours?this[s?"hoursView":"minutesView"].find(".jqclockpicker-tick").each(function(){var t=a(this);t.toggleClass("disabled",t.html()<i.minutes)}):this.minutesView.find(".jqclockpicker-tick").removeClass("disabled")}},_updateInput:function(){if(this.hasOwnProperty("hours")&&this.hasOwnProperty("minutes")){var t=this.input.prop("value"),e=i(this.hours)+":"+i(this.minutes);"12h"===this.options.format&&(e+=this.amOrPm),this.input.prop("value",e),this.lastVal=this.input.prop("value"),e!==t&&(this.input.trigger("change"),this.input.triggerHandler("change"),this.isInput||this.element.trigger("change"))}},_doKeyUp:function(t){return this.input.val()!==this.lastVal&&this.setTime(this.input.val()),!0},_setOption:function(t,i){t in c.DEFAULTS&&("default"===i?this.options[t]=c.DEFAULTS[t]:this.options[t]=i,this._checkTimeLimits(),this._updateInput())}}),a.fn.jqclockpicker=function(t){var i=Array.prototype.slice.call(arguments,1);return this.each(function(){var e=a(this),s=e.data("jqclockpicker");if(s)"option"===t&&2===i.length&&"string"==typeof i[1]?s._setOption.apply(s,i):"function"==typeof s[t]&&s[t].apply(s,i);else{var o=a.extend({},c.DEFAULTS,e.data(),"object"==typeof t&&t);e.data("jqclockpicker",new c(e,o))}})}}();
{
"name": "jquery-clockpicker",
"version": "0.0.6",
"version": "0.0.7",
"description": "Time picker based on android material for jQuery",

@@ -5,0 +5,0 @@ "repository": {

@@ -916,3 +916,3 @@ /*!

_updateInput: function() {
if (this.hours && this.minutes) {
if (this.hasOwnProperty('hours') && this.hasOwnProperty('minutes')) {
var last = this.input.prop('value'),

@@ -919,0 +919,0 @@ value = leadingZero(this.hours) + ':' + leadingZero(this.minutes);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc