/* file: ui.inputNum.js - v1.0.0 | minified on 2011/01/27 with http://jscompress.com/ */ (function($) {var publicMethods={init:function(opt) {return this.each(function() {var $this=$(this),data=$this.data('options'),objects=$this.data('objects'),properties=$this.data('properties'),options={numDec:0,minValue:'none',maxValue:'none',stepValue:1,showSlider:'no',disabled:false,textAlign:'right',btInc:'+',btDec:'-',unitValue:'',change:null};$this.data('options',options);if(!properties) {$this.data('properties',{initialized:false,re:/^\d+$/,value:0,factor:1,isSlider:false,isValid:true,mouseIsOver:false,isSliderCurrentlyVisible:false,inputMargins:0});properties=$this.data('properties');} if(!objects) {objects={container:$('
',{'class':'ui-inputNum',css:{width:'100%'}}).bind('click.inputNum',function() {objects.input.focus();}).bind('mouseenter',function() {properties.mouseIsOver=true;}).bind('mouseleave',function() {properties.mouseIsOver=false;}),input:$('',{type:"text",value:''}).bind('focusout.inputNum',function() {privateMethods.lostFocus($this);}).bind('focus.inputNum',function() {privateMethods.getFocus($this);}).bind('keydown.inputNum',function(event) {return(privateMethods.keyDown($this,event));}).bind('keyup.inputNum',function(event) {privateMethods.keyUp($this,event);}),slider:$('',{css:{display:'none'}}),extraContainer:$('',{'class':'ui-inputNum-extra'}),unit:$('',{html:"",'class':'ui-inputNum-unit',css:{display:'none'}}),btInc:$('',{'class':'ui-inputNum-btInc',tabindex:0}).bind('click',function(event) {privateMethods.incValue($this);}).bind('mousedown',function(){$(this).addClass('ui-inputNum-btInc-active');}).bind('mouseup',function(){$(this).removeClass('ui-inputNum-btInc-active');}),btDec:$('',{'class':'ui-inputNum-btDec',tabindex:0}).bind('click',function(event) {privateMethods.decValue($this);}).bind('mousedown',function(){$(this).addClass('ui-inputNum-btDec-active');}).bind('mouseup',function(){$(this).removeClass('ui-inputNum-btDec-active');})};$this.html('').append(objects.container.append(objects.input).append(objects.extraContainer.append(objects.unit).append(objects.btInc).append(objects.btDec)).append(objects.slider));properties.inputMargins=objects.input.outerWidth(true)-objects.input.width();$this.data('objects',objects);} privateMethods.setOptions($this,opt);});},destroy:function() {return this.each(function() {var $this=$(this),objects=$this.data('objects');objects.input.unbind().remove();objects.btInc.unbind().remove();objects.btDec.unbind().remove();objects.container.unbind().remove();$this.unbind('.inputNum').css({width:'',height:''});});},options:function(value) {return this.each(function() {privateMethods.setOptions($(this),value);});},showSlider:function(value) {if(value!=null) {this.each(function() {privateMethods.setShowSlider($(this),value);});} else {var options=this.data('options');if(options) {return(options.showSlider);} else {return('');}}},minValue:function(value) {if(value!=null) {return this.each(function() {privateMethods.setMinValue($(this),value);});} else {var options=this.data('options');if(options) {return(options.minValue);} else {return('');}}},maxValue:function(value) {if(value!=null) {return this.each(function() {privateMethods.setMaxValue($(this),value);});} else {var options=this.data('options');if(options) {return(options.maxValue);} else {return('');}}},stepValue:function(value) {if(value!=null) {return this.each(function() {privateMethods.setStepValue($(this),value);});} else {var options=this.data('options');if(options) {return(options.stepValue);} else {return('');}}},numDec:function(value) {if(value!=null) {return this.each(function() {privateMethods.setNumDec($(this),value);});} else {var options=this.data('options');if(options) {return(options.numDec);} else {return('');}}},unitValue:function(value) {if(value!=null) {return this.each(function() {privateMethods.setUnitValue($(this),value);});} else {var options=this.data('options');if(options) {return(options.unitValue);} else {return('');}}},disabled:function(value) {if(value!=null) {return this.each(function() {privateMethods.setDisabled($(this),value);});} else {var options=this.data('options');if(options) {return(options.disabled);} else {return('');}}},textAlign:function(value) {if(value!=null) {return this.each(function() {privateMethods.setTextAlign($(this),value);});} else {var options=this.data('options');if(options) {return(options.textAlign);} else {return('');}}},btInc:function(value) {if(value!=null) {return this.each(function() {privateMethods.setBtInc($(this),value);});} else {var options=this.data('options');if(options) {return(options.btInc);} else {return('');}}},btDec:function(value) {if(value!=null) {return this.each(function() {privateMethods.setBtDec($(this),value);});} else {var options=this.data('options');if(options) {return(options.btDec);} else {return('');}}},value:function(value) {if(value!=null) {return this.each(function() {privateMethods.setValue($(this),value,true);});} else {var properties=this.data('properties');return(properties.value);}},isValid:function(value) {if(value!=null) {return this.each(function() {privateMethods.setIsValid($(this),value);});} else {var properties=this.data('properties');return(properties.isValid);}},change:function(value) {if(value!=null&&$.isFunction(value)) {return this.each(function() {privateMethods.setEventChange($(this),value);});} else {var options=this.data('options');if(options) {return(options.change);} else {return(null);}}}};var privateMethods={isValid:function(object,value) {var properties=object.data('properties');return(properties.re.exec(value))},setRE:function(object) {var properties=object.data('properties'),options=object.data('options'),tmpRe="\\d+";if(options.numDec>0) {tmpRe+="(\\.\\d{0,"+options.numDec+"})?";} tmpRe+="$";if(options.minValue=='none'||options.minValue!='none'&&options.minValue<0) {if(options.maxValue!='none'&&options.maxValue<0) {tmpRe="\\-"+tmpRe;} else {tmpRe="(\\-)?"+tmpRe;}} tmpRe="^"+tmpRe;properties.re=new RegExp(tmpRe);},setOptions:function(object,value) {var properties=object.data('properties'),options=object.data('options');if(!$.isPlainObject(value))return(false);properties.initialized=false;privateMethods.setNumDec(object,(value.numDec!=null)?value.numDec:options.numDec);privateMethods.setStepValue(object,(value.stepValue!=null)?value.stepValue:options.stepValue);privateMethods.setMinValue(object,(value.minValue!=null)?value.minValue:options.minValue);privateMethods.setMaxValue(object,(value.maxValue!=null)?value.maxValue:options.maxValue);privateMethods.setValue(object,(value.value!=null)?value.value:options.value,true);privateMethods.setUnitValue(object,(value.unitValue!=null)?value.unitValue:options.unitValue);privateMethods.setShowSlider(object,(value.showSlider!=null)?value.showSlider:options.showSlider);privateMethods.setDisabled(object,(value.disabled!=null)?value.disabled:options.disabled);privateMethods.setBtInc(object,(value.btInc!=null)?value.btInc:options.btInc);privateMethods.setBtDec(object,(value.btDec!=null)?value.btDec:options.btDec);privateMethods.setTextAlign(object,(value.textAlign!=null)?value.textAlign:options.textAlign);privateMethods.setEventChange(object,(value.change!=null)?value.change:options.change);privateMethods.calculateInputWidth(object);properties.initialized=true;},setIsValid:function(object,value) {var objects=object.data('objects'),properties=object.data('properties');if(properties.isValid!=value) {properties.isValid=value;if(properties.isValid) {objects.container.removeClass('ui-error');objects.input.removeClass('ui-error');} else {objects.container.addClass('ui-error');objects.input.addClass('ui-error');}} return(properties.isValid);},setNumDec:function(object,value) {var options=object.data('options'),properties=object.data('properties');if((!properties.initialized||options.numDec!=value)&&value>=0&&value<=15) {options.numDec=value;privateMethods.setRE(object);properties.factor=Math.pow(10,options.numDec);} return(options.numDec);},setStepValue:function(object,value) {var options=object.data('options'),properties=object.data('properties');if((!properties.initialized||options.stepValue!=value)&&value>0&&privateMethods.isValid(object,value)) {options.stepValue=value;} return(options.stepValue);},setShowSlider:function(object,value) {var options=object.data('options'),objects=object.data('objects'),properties=object.data('properties');if((!properties.initialized||options.showSlider!=value)&&(value=='no'||value=='yes'||value=='auto')) {options.showSlider=value;privateMethods.manageSlider(object);} return(options.showSlider);},setMinValue:function(object,value) {var options=object.data('options'),properties=object.data('properties');if((!properties.initialized||options.minValue!=value)&&(value=='none'||privateMethods.isValid(object,value))) {options.minValue=value;if(options.minValue>options.maxValue)options.maxValue=options.minValue;privateMethods.setRE(object);privateMethods.manageSlider(object);} return(options.minValue);},setMaxValue:function(object,value) {var options=object.data('options'),properties=object.data('properties');if((!properties.initialized||options.maxValue!=value)&&(value=='none'||privateMethods.isValid(object,value)&&(options.minValue<=value&&options.minValue!='none'||options.minValue=='none'))) {options.maxValue=value;privateMethods.setRE(object);privateMethods.manageSlider(object);} return(options.maxValue);},setUnitValue:function(object,value) {var options=object.data('options'),objects=object.data('objects'),properties=object.data('properties');if(!properties.initialized||options.unitValue!=value) {options.unitValue=value;objects.unit.html(options.unitValue).css('display',($.trim(value)=='')?'none':'');privateMethods.calculateInputWidth(object);} return(options.unitValue);},setBtInc:function(object,value) {var options=object.data('options'),objects=object.data('objects'),properties=object.data('properties');if(!properties.initialized||options.btInc!=value) {options.btInc=value;objects.btInc.html(options.btInc);} return(options.btInc);},setBtDec:function(object,value) {var options=object.data('options'),objects=object.data('objects'),properties=object.data('properties');if(!properties.initialized||options.btDec!=value) {options.btDec=value;objects.btDec.html(options.btDec);} return(options.btDec);},setDisabled:function(object,value) {var options=object.data('options'),objects=object.data('objects'),properties=object.data('properties');if((!properties.initialized||options.disabled!=value)&&(value==true||value==false)) {options.disabled=value;if(options.disabled) {objects.btDec.attr('disabled',true);objects.btInc.attr('disabled',true);objects.input.attr('disabled',true);} else {objects.input.attr('disabled',false);privateMethods.setButtonsState(object);}} return(options.disabled);},setTextAlign:function(object,value) {var options=object.data('options'),objects=object.data('objects'),properties=object.data('properties');if((!properties.initialized||options.textAlign!=value)&&(value=='left'||value=='right')) {options.textAlign=value;objects.input.css('text-align',options.textAlign);} return(options.textAlign);},setButtonsState:function(object) {var options=object.data('options'),objects=object.data('objects'),properties=object.data('properties');if(options.minValue!='none'&&properties.value-options.stepValue