template.js.plugins.jquery.ui.spinner.min.js Maven / Gradle / Ivy
/*
*jQuery UI Spinner 1.21
*
*Copyright (c) 2009-2010 Brant Burnett
*Copyright (c) 2010 Johannes Geppert http://www.jgeppert.com
*Dual licensed under the MIT or GPL Version 2 licenses.
*/
(function(g,h){var i="ui-state-active",s="ui-state-hover",e="ui-state-disabled",k=g.ui.keyCode,m=k.UP,n=k.DOWN,r=k.RIGHT,f=k.LEFT,j=k.PAGE_UP,p=k.PAGE_DOWN,q=k.HOME,d=k.END,l=g.browser.msie,c=g.browser.mozilla?"DOMMouseScroll":"mousewheel",o=".uispinner",a=[m,n,r,f,j,p,q,d,k.BACKSPACE,k.DELETE,k.TAB],b;g.widget("ui.spinner",{options:{min:null,max:null,allowNull:false,group:"",point:".",prefix:"",suffix:"",places:null,defaultStep:1,largeStep:10,mouseWheel:true,increment:"slow",className:null,showOn:"always",width:16,upIconClass:"ui-icon-triangle-1-n",downIconClass:"ui-icon-triangle-1-s",format:function(w,v){var u=this,x=/(\d+)(\d{3})/,t=((isNaN(w)?0:Math.abs(w)).toFixed(v))+"";for(t=t.replace(".",u.point);x.test(t)&&u.group;t=t.replace(x,"$1"+u.group+"$2")){}return(w<0?"-":"")+u.prefix+t+u.suffix},parse:function(u){var t=this;if(t.group=="."){u=u.replace(".","")}if(t.point!="."){u=u.replace(t.point,".")}return parseFloat(u.replace(/[^0-9\-\.]/g,""))}},_create:function(){var u=this,t=u.element,v=t.attr("type");if(!t.is("input")||((v!="text")&&(v!="number"))){console.error("Invalid target for ui.spinner");return}u._procOptions(true);u._createButtons(t);if(!t.is(":enabled")){u.disable()}},_createButtons:function(E){function D(W){return W=="auto"?0:parseInt(W,10)}var H=this,x=H.options,v=x.className,N=x.width,y=x.showOn,C=g.support.boxModel,I=E.outerHeight(),R=H.oMargin=D(E.css("margin-right")),A=H.wrapper=E.css({width:(H.oWidth=(C?E.width():E.outerWidth()))-N,marginRight:R+N,textAlign:"right"}).after('').next(),L=H.btnContainer=g('="0")&&(Y<="9")||(Y=="-")){return false}if(((H.places>0)&&(Y==X.point))||(Y==X.group)){return false}return true}function T(X){if(F){if(X===B){return}clearTimeout(F)}function W(){F=0;X()}B=X;F=setTimeout(W,100)}},_procOptions:function(A){var B=this,y=B.element,C=B.options,w=C.min,x=C.max,v=C.step,t=C.places,u=-1,z;if(C.increment=="slow"){C.increment=[{count:1,mult:1,delay:250},{count:3,mult:1,delay:100},{count:0,mult:1,delay:50}]}else{if(C.increment=="fast"){C.increment=[{count:1,mult:1,delay:250},{count:19,mult:1,delay:100},{count:80,mult:1,delay:20},{count:100,mult:10,delay:20},{count:0,mult:100,delay:20}]}}if((w===null)&&((z=y.attr("min"))!==null)){w=parseFloat(z)}if((x===null)&&((z=y.attr("max"))!==null)){x=parseFloat(z)}if(!v&&((z=y.attr("step"))!==null)){if(z!="any"){v=parseFloat(z);C.largeStep*=v}}C.step=v=v||C.defaultStep;if((t===null)&&((z=v+"").indexOf(".")!=-1)){t=z.length-z.indexOf(".")-1}B.places=t;if((x!==null)&&(w!==null)){if(w>x){w=x}u=Math.max(Math.max(u,C.format(x,t,y).length),C.format(w,t,y).length)}if(A){B.inputMaxLength=y[0].maxLength}z=B.inputMaxLength;if(z>0){u=u>0?Math.min(z,u):z;z=Math.pow(10,u)-1;if((x===null)||(x>z)){x=z}z=-(z+1)/10+1;if((w===null)||(w0){y.attr("maxlength",u)}C.min=w;C.max=x;B._change();y.unbind(c+o);if(C.mouseWheel){y.bind(c+o,B._mouseWheel)}},_mouseWheel:function(u){var t=g.data(this,"spinner");if(!t.options.disabled&&t.focused&&(b===t)){t._change();t._doSpin(((u.wheelDelta||-u.detail)>0?1:-1)*t.options.step);return false}},_setTimer:function(v,u,x){function w(){t._spin(u,x)}var t=this;t._stopSpin();t.timer=setInterval(w,v)},_stopSpin:function(){if(this.timer){clearInterval(this.timer);this.timer=0}},_startSpin:function(w,x){var u=this,v=u.options,t=v.increment;u._change();u._doSpin(w*(x?u.options.largeStep:u.options.step));if(t&&t.length>0){u.counter=0;u.incCounter=0;u._setTimer(t[0].delay,w,x)}},_spin:function(v,w){var u=this,t=u.options.increment,x=t[u.incCounter];u._doSpin(v*x.mult*(w?u.options.largeStep:u.options.step));u.counter++;if((u.counter>x.count)&&(u.incCounter0?t.options.min:t.options.max)||0}t._setValue(v+u)},_parseValue:function(){var t=this.element.val();return t?this.options.parse(t,this.element):null},_validate:function(w){var u=this.options,v=u.min,t=u.max;if((w===null)&&!u.allowNull){w=this.curvalue!==null?this.curvalue:v||t||0}if((t!==null)&&(w>t)){return t}else{if((v!==null)&&(w
'),w,u,Q,V,F,B,G,P,J,O,z=E[0].dir=="rtl";if(v){A.addClass(v)}A.append(L.css({height:I,left:-N-R,top:(E.offset().top-A.offset().top)+"px"}));Q=H.buttons=L.find(".ui-spinner-button");Q.css({width:N-(C?Q.outerWidth()-Q.width():0),height:I/2-(C?Q.outerHeight()-Q.height():0)});w=Q[0];u=Q[1];V=Q.find(".ui-icon");V.css({marginLeft:(Q.innerWidth()-V.width())/2,marginTop:(Q.innerHeight()-V.height())/2});L.width(Q.outerWidth());if(y!="always"){L.css("opacity",0)}if(y=="hover"||y=="both"){Q.add(E).bind("mouseenter"+o,function(){T(function(){G=true;if(!H.focused||(y=="hover")){H.showButtons()}})}).bind("mouseleave"+o,function K(){T(function(){G=false;if(!H.focused||(y=="hover")){H.hideButtons()}})})}function U(){if(!x.disabled){var W=H.element[0],X=(this===w?1:-1);W.focus();W.select();g(this).addClass(i);O=true;H._startSpin(X)}return false}function S(){if(O){g(this).removeClass(i);H._stopSpin();O=false}return false}Q.hover(function(){H.buttons.removeClass(s);if(!x.disabled){g(this).addClass(s)}},function(){g(this).removeClass(s)}).mousedown(U).mouseup(S).mouseout(S);if(l){Q.dblclick(function(){if(!x.disabled){H._change();H._doSpin((this===w?1:-1)*x.step)}return false}).bind("selectstart",function(){return false})}E.bind("keydown"+o,function(aa){var X,Y,W,Z=aa.keyCode;if(aa.ctrl||aa.alt){return true}if(t(Z)){J=true}if(P){return false}switch(Z){case m:case j:X=1;Y=Z==j;break;case n:case p:X=-1;Y=Z==p;break;case r:case f:X=(Z==r)^z?1:-1;break;case q:W=H.options.min;if(W!==null){H._setValue(W)}return false;case d:W=H.options.max;W=H.options.max;if(W!==null){H._setValue(W)}return false}if(X){if(!P&&!x.disabled){keyDir=X;g(X>0?w:u).addClass(i);P=true;H._startSpin(X,Y)}return false}}).bind("keyup"+o,function(W){if(W.ctrl||W.alt){return true}if(t(k)){J=false}switch(W.keyCode){case m:case r:case j:case n:case f:case p:Q.removeClass(i);H._stopSpin();P=false;return false}}).bind("change"+o,function(){H._change()}).bind("focus"+o,function(){function W(){H.element.select()}if(l){W()}else{setTimeout(W,0)}H.focused=true;b=H;if(!G&&(y=="focus"||y=="both")){H.showButtons()}}).bind("blur"+o,function(){H.focused=false;if(!G&&(y=="focus"||y=="both")){H.hideButtons()}});function t(X){for(var W=0;W
© 2015 - 2024 Weber Informatics LLC | Privacy Policy