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

webapp.static.plugins.fuelux.fuelux.spinner.min.js Maven / Gradle / Ivy

(function(b,c){var a=function(e,d){this.$element=b(e);this.options=b.extend({},b.fn.spinner.defaults,d);this.$input=this.$element.find(".spinner-input");this.$element.on("keyup",this.$input,b.proxy(this.change,this));if(this.options.hold){this.$element.on("mousedown",".spinner-up",b.proxy(function(){this.startSpin(true)},this));this.$element.on("mouseup",".spinner-up, .spinner-down",b.proxy(this.stopSpin,this));this.$element.on("mouseout",".spinner-up, .spinner-down",b.proxy(this.stopSpin,this));this.$element.on("mousedown",".spinner-down",b.proxy(function(){this.startSpin(false)},this))}else{this.$element.on("click",".spinner-up",b.proxy(function(){this.step(true)},this));this.$element.on("click",".spinner-down",b.proxy(function(){this.step(false)},this))}this.switches={count:1,enabled:true};if(this.options.speed==="medium"){this.switches.speed=300}else{if(this.options.speed==="fast"){this.switches.speed=100}else{this.switches.speed=500}}this.lastValue=null;this.render();if(this.options.disabled){this.disable()}};a.prototype={constructor:a,render:function(){this.$input.val(this.options.value);this.$input.attr("maxlength",(this.options.max+"").split("").length)},change:function(){var d=this.$input.val();if(d/1){this.options.value=d/1}else{d=d.replace(/[^0-9]/g,"");this.$input.val(d);this.options.value=d/1}this.triggerChangedEvent()},stopSpin:function(){clearTimeout(this.switches.timeout);this.switches.count=1;this.triggerChangedEvent()},triggerChangedEvent:function(){var d=this.value();if(d===this.lastValue){return}this.lastValue=d;this.$element.trigger("changed",d);this.$element.trigger("change")},startSpin:function(d){if(!this.options.disabled){var e=this.switches.count;if(e===1){this.step(d);e=1}else{if(e<3){e=1.5}else{if(e<8){e=2.5}else{e=4}}}this.switches.timeout=setTimeout(b.proxy(function(){this.iterator(d)},this),this.switches.speed/e);this.switches.count++}},iterator:function(d){this.step(d);this.startSpin(d)},step:function(e){var g=this.options.value;var f=e?this.options.max:this.options.min;if((e?gf)){var d=g+(e?1:-1)*this.options.step;if(e?d>f:d




© 2015 - 2024 Weber Informatics LLC | Privacy Policy