text: !function(){var t=window.jQuery;k.DEFAULTS={startTime:"",autoclose:!1,vibrate:!0,hour24:!1,orientation:"portrait",cancelText:"CANCEL",okText:"OK"};var i="ontouchstart"in window,o="mousedown"+(i?" touchstart":""),e="mousemove.lolliclock"+(i?" touchmove.lolliclock":""),s="mouseup.lolliclock"+(i?" touchend.lolliclock":""),l=navigator.vibravarte?"vibrate":navigator.webkitVibrate?"webkitVibrate":null,n="http://www.w3.org/2000/svg";function a(t){return document.createElementNS(n,t)}function c(t){return(t<10?"0":"")+t}var h=0;var d=84,r=50,u=70,p=12,m=2*d,v=350,f=['<div id="time-picker" class="clock-overlay">','<div class="lolliclock-popover">','<div class="lolliclock-header">','<div class="lolliclock-time">','<div class="lolliclock-hours lolliclock-primary-text">','<div class="lolliclock-time-old"></div>','<div class="lolliclock-time-new"></div>',"</div>",'<span class="lolliclock-colon">:</span>','<div class="lolliclock-minutes">','<div class="lolliclock-time-old"></div>','<div class="lolliclock-time-new"></div>',"</div>","</div>",'<span class="lolliclock-am-pm"></span>',"</div>",'<div class="popover-content">','<div class="lolliclock-plate">','<div class="lolliclock-canvas"></div>','<div class="lolliclock-dial lolliclock-dial-hours"></div>','<div class="lolliclock-dial lolliclock-dial-minutes lolliclock-dial-out"></div>',"</div>",'<div class="lolliclock-ampm-block">','<div id="lolliclock-btn-am" class="lolliclock-ampm-btn">','<div class="lolliclock-btn-background"></div>','<div class="lolliclock-btn-text">AM</div>',"</div>",'<div style="flex: 1;"></div>','<div id="lolliclock-btn-pm" class="lolliclock-ampm-btn">','<div class="lolliclock-btn-background"></div>','<div class="lolliclock-btn-text">PM</div>',"</div>","</div>","</div>","</div>","</div>"].join("");function k(i,l){var n,k,w=t(f),b=w.find(".lolliclock-popover"),A=w.find(".lolliclock-plate"),C=w.find(".lolliclock-dial-hours"),M=w.find(".lolliclock-dial-minutes"),y="INPUT"===i.prop("tagName"),P=y?i:i.find("input"),T=this;if(this.id=(k=++h+"",(n="lolli")?n+k:k),this.element=i,this.options=l,this.isAppended=!1,this.isShown=!1,this.currentView="hours",this.isInput=y,this.input=P,this.popover=w,this.plate=A,this.hoursView=C,this.minutesView=M,this.header=w.find(".lolliclock-header"),this.spanHours=w.find(".lolliclock-hours"),this.spanMinutes=w.find(".lolliclock-minutes"),this.spanNewTime=w.find(".lolliclock-time-new"),this.spanOldTime=w.find(".lolliclock-time-old"),this.spanAmPm=w.find(".lolliclock-am-pm"),this.amOrPm="PM",this.AmPmButtons=w.find(".lolliclock-ampm-btn"),this.amButton=w.find("#lolliclock-btn-am"),this.pmButton=w.find("#lolliclock-btn-pm"),this.options.hour24&&(this.AmPmButtons.hide(),this.spanAmPm.hide()),w.addClass(this.options.orientation),!l.autoclose){this.popover.css("height","380px");var x=t('<div class="lolliclock-buttons"></div>').appendTo(b);t('<div class="lolliclock-button">'+l.cancelText+"</div>").click(t.proxy(this.hide,this)).appendTo(x),t('<div class="lolliclock-button">'+l.okText+"</div>").click(t.proxy(this.done,this)).appendTo(x),this.closeButtons=w.find(".lolliclock-button")}P.on("focus.lolliclock click.lolliclock",t.proxy(this.show,this));var V,E,B,S=t('<div class="lolliclock-tick"></div>');if(l.hour24){for(V=1;V<13;V++)E=S.clone(),B=V/6*Math.PI,E.css({left:d+Math.sin(B)*r-p,top:d-Math.cos(B)*r-p}),E.html(V),C.append(E);for(V=13;V<=24;V++)E=S.clone(),B=V/6*Math.PI,E.css({left:d+Math.sin(B)*u-p,top:d-Math.cos(B)*u-p}),24===V?E.html("00"):E.html(V),C.append(E)}else for(V=1;V<13;V++)E=S.clone(),B=V/6*Math.PI,E.css({left:d+Math.sin(B)*u-p,top:d-Math.cos(B)*u-p}),E.html(V),C.append(E);for(V=0;V<60;V+=5)E=S.clone(),B=V/30*Math.PI,E.css({left:d+Math.sin(B)*u-p,top:d-Math.cos(B)*u-p}),E.html(c(V)),M.append(E);A.on(o,function(i){var o=A.offset(),n=/^touch/.test(i.type),a=o.left+d,c=o.top+d,h=(n?i.originalEvent.touches[0]:i).pageX-a,m=(n?i.originalEvent.touches[0]:i).pageY-c,f=Math.sqrt(h*h+m*m),k=!1;if(outsideMode=!0,f<u+p&&f>u-p)outsideMode=!0;else{if(!(f>r-p&&f<r+p&&l.hour24&&"hours"===T.currentView))return;outsideMode=!1}i.preventDefault(),t(document.body).addClass("lolliclock-moving"),A.append(T.canvas),T.setHand(h,m,outsideMode),t(document).off(e).on(e,function(t){t.preventDefault();var i=/^touch/.test(t.type),o=(i?t.originalEvent.touches[0]:t).pageX-a,e=(i?t.originalEvent.touches[0]:t).pageY-c;(k||o!==h||e!==m)&&(k=!0,T.setHand(o,e,outsideMode))}),t(document).off(s).on(s,function(i){i.preventDefault();var o=/^touch/.test(i.type),n=(o?i.originalEvent.changedTouches[0]:i).pageX-a,d=(o?i.originalEvent.changedTouches[0]:i).pageY-c;n===h&&d===m&&T.setHand(n,d,outsideMode),"hours"===T.currentView?T.toggleView("minutes",v/2):l.autoclose&&T.done(),A.prepend(N),t(document.body).removeClass("lolliclock-moving"),t(document).off(e),t(document).off(s)})});var N=w.find(".lolliclock-canvas"),H=a("svg");H.setAttribute("class","lolliclock-svg"),H.setAttribute("width",m),H.setAttribute("height",m);var O=a("g");O.setAttribute("transform","translate("+d+","+d+")");var D=a("circle");D.setAttribute("class","lolliclock-bearing"),D.setAttribute("cx",0),D.setAttribute("cy",0),D.setAttribute("r",1.25);var I=a("line");I.setAttribute("x1",0),I.setAttribute("y1",0);var L=a("circle");L.setAttribute("class","lolliclock-canvas-bg"),L.setAttribute("r",p);var X=a("circle");X.setAttribute("class","lolliclock-canvas-fg"),X.setAttribute("r",3.5),O.appendChild(I),O.appendChild(L),O.appendChild(X),O.appendChild(D),H.appendChild(O),N.append(H),this.hand=I,this.bg=L,this.fg=X,this.bearing=D,this.g=O,this.canvas=N,document.querySelector("#"+t(P).attr("id")).addEventListener("pointerdown",function(t){t.target&&t.target.setPointerCapture&&t.target.setPointerCapture(t.pointerId)}),g(this.options.init)}function g(t){t&&"function"==typeof t&&t()}k.prototype.toggle=function(){this[this.isShown?"hide":"show"]()},k.prototype.setOrientation=function(t){this.popover.removeClass(this.options.orientation),this.options.orientation=t,this.popover.addClass(t)},k.prototype.changeAmPm=function(i){i&&i===this.amOrPm&&this.options.hour24||(this.amOrPm="AM"===this.amOrPm?"PM":"AM",this.spanAmPm.html(this.amOrPm),t(this.amButton[0].childNodes[0]).toggleClass("lolliclock-active-button-background","AM"===this.amOrPm),t(this.pmButton[0].childNodes[0]).toggleClass("lolliclock-active-button-background","PM"===this.amOrPm),t(this.amButton[0].childNodes[1]).toggleClass("lolliclock-active-button-text","AM"===this.amOrPm),t(this.pmButton[0].childNodes[1]).toggleClass("lolliclock-active-button-text","PM"===this.amOrPm))},k.prototype.locate=function(){var i=this.element,o=this.popover,e=i.offset().left+(i.outerWidth()-o.width())/2,s=t(window).width()-o.width()-8,l=t(window).height()+t(window).scrollTop()-8-o.height(),n=8+t(window).scrollTop(),a=i.offset().top,c={};c.top=a<n?n:a>l?l:a,c.left=e<8?8:e>s?s:e,o.css(c),o.show()},k.prototype.show=function(){if(!this.isShown){g(this.options.beforeShow);var i,o=this;this.popover.addClass(this.options.orientation),this.isAppended||(t(document.body).append(this.popover),this.isAppended=!0,t(window).on("resize.lolliclock"+this.id,function(){o.isShown&&o.locate()}),t(window).on("scroll.lolliclock",function(){o.isShown&&o.locate()}),this.AmPmButtons.on("click",function(t){o.changeAmPm(t.currentTarget.children[1].innerHTML)}),this.spanMinutes.on("click",function(){o.toggleView("minutes")}),this.spanHours.on("click",function(){o.toggleView("hours")}),this.spanAmPm.on("click",function(){o.changeAmPm()})),o.locate(),this.plate.addClass("animate"),this.header.addClass("animate"),this.popover.addClass("animate"),this.AmPmButtons.addClass("animate"),this.spanNewTime.addClass("animate"),this.spanOldTime.addClass("animate"),!this.options.autoclose&&this.closeButtons.addClass("animate"),this.plate.on("webkitAnimationEnd animationend MSAnimationEnd oanimationend",function(){o.plate.removeClass("animate"),o.header.removeClass("animate"),o.popover.removeClass("animate"),o.AmPmButtons.removeClass("animate"),o.spanNewTime.removeClass("animate"),o.spanOldTime.removeClass("animate"),!o.options.autoclose&&o.closeButtons.removeClass("animate"),o.plate.off("webkitAnimationEnd animationend MSAnimationEnd oanimationend")});var e=this.input.prop("value"),s=this.options.startTime,l=this.input.prop("placeholder");i=e&&a(e)?n(e):"now"===s?new Date:s&&a(s)?n(s):l&&a(l)?n(l):new Date,this.options.hour24?this.hours=i.getHours():(this.hours=i.getHours()%12,this.amOrPm=i.getHours()>11?"AM":"PM"),this.minutes=i.getMinutes(),this.changeAmPm(),o.toggleView("minutes"),o.toggleView("hours"),o.isShown=!0,t(document).on("click.lolliclock."+this.id+" focusin.lolliclock."+this.id,function(i){var e=t(i.target);0===e.closest(o.popover).length&&0===e.closest(o.input).length&&o.done()}),t(document).on("keyup.lolliclock."+this.id,function(t){27===t.keyCode&&o.hide()}),g(this.options.afterShow)}function n(t){var i=t.split(":");if(2===i.length){var o=+i[0],e=i[1].split(" ");if(2===e.length){var s=e[0];return"PM"===e[1]&&(o+=12),new Date(1970,1,1,o,s)}}return new Date("x")}function a(t){return!isNaN(n(t).getTime())}},k.prototype.hide=function(){g(this.options.beforeHide);var i=this;i.popover.addClass("animate-out"),i.plate.addClass("animate-out"),i.header.addClass("animate-out"),i.AmPmButtons.addClass("animate-out"),!i.options.autoclose&&i.closeButtons.addClass("animate-out"),this.popover.on("webkitAnimationEnd animationend MSAnimationEnd oanimationend",function(){t(i.spanHours[0].childNodes[0]).html(""),t(i.spanMinutes[0].childNodes[0]).html(""),i.popover.removeClass("animate-out"),i.plate.removeClass("animate-out"),i.header.removeClass("animate-out"),i.AmPmButtons.removeClass("animate-out"),!i.options.autoclose&&i.closeButtons.removeClass("animate-out"),i.popover.off("webkitAnimationEnd animationend MSAnimationEnd oanimationend"),t(document).off("click.lolliclock."+i.id+" focusin.lolliclock."+i.id),t(document).off("keyup.lolliclock."+i.id),i.popover.hide(),g(i.options.afterHide)}),i.isShown=!1},k.prototype.toggleView=function(i,o){var s="hours"===i,l=s?this.hoursView:this.minutesView,n=s?this.minutesView:this.hoursView;if(this.currentView=i,this.spanHours.toggleClass("lolliclock-primary-text",s),this.spanMinutes.toggleClass("lolliclock-primary-text",!s),n.addClass("lolliclock-dial-out"),l.css("visibility","visible").removeClass("lolliclock-dial-out"),this.resetClock(o),clearTimeout(this.toggleViewTimer),this.toggleViewTimer=setTimeout(function(){n.css("visibility","hidden")},v),s)this.plate.off(e);else{var a=this;this.plate.on(e,function(i){var o=a.plate.offset(),e=o.left+d,s=o.top+d,l=i.pageX-e,n=i.pageY-s,c=Math.sqrt(l*l+n*n);c>u-p&&c<u+p?t(document.body).addClass("lolliclock-clickable"):t(document.body).removeClass("lolliclock-clickable")})}},k.prototype.resetClock=function(t){var i=this.currentView,o=!0,e=this[i];"hours"===i?(unit=Math.PI/6,0!==e&&e<=12&&this.options.hour24&&(o=!1)):unit=Math.PI/30;var s=e*unit,l=Math.sin(s)*r,n=-Math.cos(s)*r,a=this;t?(a.canvas.addClass("lolliclock-canvas-out"),setTimeout(function(){a.canvas.removeClass("lolliclock-canvas-out"),a.setHand(l,n,o)},t)):this.setHand(l,n,o)},k.prototype.setHand=function(i,o,e){var s,n,a,h=Math.atan2(-i,o)+Math.PI,d="hours"===this.currentView,m=Math.PI/(d?6:30);if(e&&this.options.hour24&&d?12===(s=Math.round(h/m))||0===s?s=0:s+=12:s=Math.round(h/m),h=s*m,d)0!==s||this.options.hour24&&e||(s=12),this.fg.style.visibility="hidden";else{var v=s%5==0;this.fg.style.visibility=v?"hidden":"visible",60===s&&(s=0)}this[this.currentView]!==s&&l&&this.options.vibrate&&(this.vibrateTimer||(navigator[l](10),this.vibrateTimer=setTimeout(t.proxy(function(){this.vibrateTimer=null},this),100))),this[this.currentView]=s,d?(n=t(this.spanHours[0].childNodes[0]),a=t(this.spanHours[0].childNodes[1]),this.options.hour24&&(s=c(s))):(n=t(this.spanMinutes[0].childNodes[0]),a=t(this.spanMinutes[0].childNodes[1]),s=c(s)),n.on("webkitAnimationEnd animationend MSAnimationEnd oanimationend",function(){n.html(s),n.removeClass("old-down old-up"),a.removeClass("new-down new-up"),n.off("webkitAnimationEnd animationend MSAnimationEnd oanimationend")}),s<+n.html()?(a.html(n.html()),n.html(s),a.addClass("new-down"),n.addClass("old-down")):(s>+n.html()||!n.html())&&(a.html(s),n.addClass("old-up"),a.addClass("new-up")),this.g.insertBefore(this.hand,this.bearing),this.g.insertBefore(this.bg,this.fg),this.bg.setAttribute("class","lolliclock-canvas-bg");var f=r;e&&(f=u);var k=Math.sin(h)*f,g=-Math.cos(h)*f;this.hand.setAttribute("x2",Math.sin(h)*(f-p)),this.hand.setAttribute("y2",-Math.cos(h)*(f-p)),this.bg.setAttribute("cx",k),this.bg.setAttribute("cy",g),this.fg.setAttribute("cx",k),this.fg.setAttribute("cy",g)},k.prototype.done=function(){g(this.options.beforeDone);var t=this.input.prop("value"),i="";(i=this.options.hour24?c(this.hours)+":"+c(this.minutes):this.hours+":"+c(this.minutes)+" "+this.amOrPm)!==t&&(this.input.prop("value",i),this.input.trigger("input"),this.input.trigger("change")),this.hide()},k.prototype.remove=function(){this.element.removeData("lolliclock"),this.input.off("focus.lolliclock click.lolliclock"),this.isShown&&this.hide(),this.isAppended&&(t(window).off("resize.lolliclock"+this.id),t(window).off("scroll.lolliclock"+this.id),this.popover.remove())},t.fn.lolliclock=function(i){var o=Array.prototype.slice.call(arguments,1);return this.each(function(){var e=t(this),s=e.data("lolliclock");if(s)"function"==typeof s[i]&&s[i].apply(s,o);else{var l=t.extend({},k.DEFAULTS,e.data(),"object"==typeof i&&i);e.data("lolliclock",new k(e,l))}})}}();