$.fn.SpinButton=function(cfg){"use strict";function coord(el,prop){for(var c=el[prop],b=document.body;(el=el.offsetParent)&&el!==b;)$.browser.msie&&"relative"===el.currentStyle.position||(c+=el[prop]);return c}return this.each(function(){this.repeating=!1,this.spinCfg={min:cfg&&!isNaN(parseFloat(cfg.min))?Number(cfg.min):null,max:cfg&&!isNaN(parseFloat(cfg.max))?Number(cfg.max):null,step:cfg&&cfg.step?Number(cfg.step):1,stepfunc:!(!cfg||!cfg.stepfunc)&&cfg.stepfunc,page:cfg&&cfg.page?Number(cfg.page):10,upClass:cfg&&cfg.upClass?cfg.upClass:"up",downClass:cfg&&cfg.downClass?cfg.downClass:"down",reset:cfg&&cfg.reset?cfg.reset:this.value,delay:cfg&&cfg.delay?Number(cfg.delay):500,interval:cfg&&cfg.interval?Number(cfg.interval):100,_btn_width:20,_direction:null,_delay:null,_repeat:null,callback:cfg&&cfg.callback?cfg.callback:null},this.spinCfg.smallStep=cfg&&cfg.smallStep?cfg.smallStep:this.spinCfg.step/2,this.adjustValue=function(i){var v;v=isNaN(this.value)?this.spinCfg.reset:$.isFunction(this.spinCfg.stepfunc)?this.spinCfg.stepfunc(this,i):Number((Number(this.value)+Number(i)).toFixed(5)),null!==this.spinCfg.min&&(v=Math.max(v,this.spinCfg.min)),null!==this.spinCfg.max&&(v=Math.min(v,this.spinCfg.max)),this.value=v,$.isFunction(this.spinCfg.callback)&&this.spinCfg.callback(this)},$(this).addClass(cfg&&cfg.spinClass?cfg.spinClass:"spin-button").mousemove(function(e){var x=e.pageX||e.x,y=e.pageY||e.y,el=e.target||e.srcElement,scale=svgEditor.tool_scale||1,height=$(el).height()/2,direction=x>coord(el,"offsetLeft")+el.offsetWidth*scale-this.spinCfg._btn_width?y=120?this.adjustValue(this.spinCfg.step):e.wheelDelta<=-120&&this.adjustValue(-this.spinCfg.step),e.preventDefault()}).change(function(e){this.adjustValue(0)}),this.addEventListener&&this.addEventListener("DOMMouseScroll",function(e){e.detail>0?this.adjustValue(-this.spinCfg.step):e.detail<0&&this.adjustValue(this.spinCfg.step),e.preventDefault()},!1)})};