All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gwt.material.design.addins.client.timepicker.resources.js.timepicker.min.js Maven / Gradle / Ivy

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy