(function(){function h(a,b){a=""+a;b=a.indexOf(b);return 0>b?0:a.length-b-1}function l(a,b){var c=a._localizedSymbols?a._localizedSymbols.DECIMAL:zk.DECIMAL,d=h(a._step,c);b=h(b||a._value,c);a._fixedDigits=Math.max(d,b)}zul.inp.Doublespinner=zk.$extends(zul.inp.NumberInputWidget,{_step:1,_buttonVisible:!0,$define:{step:function(a){l(this)},buttonVisible:function(a){zul.inp.RoundUtl.buttonVisible(this,a)}},inRoundedMold:function(){return!0},doubleValue:function(){return this.$supers("getValue",arguments)},
setConstraint:function(a){if("string"==typeof a&&"["!=a.charAt(0)){var b=new zul.inp.SimpleDoubleSpinnerConstraint(a);this._min=b._min;this._max=b._max;this.$supers("setConstraint",[b])}else this.$supers("setConstraint",arguments)},coerceFromString_:function(a){if(!a)return null;var b=zk.fmt.Number.unformat(this._format,a,!1,this._localizedSymbols),c=b.raw,d=parseFloat(c),e=""+d,f=e.indexOf("."),g=c.indexOf(".");if(isNaN(d)||0>e.indexOf("e")){0==g&&(c="0"+c,++g);0<=g&&c.substring(c.substring(g+1))&&
0>f&&(f=e.length,e+=".");var h=c.length,k=e.length;if(0<=f&&f<g)for(k-=f,h-=g,f=g-f;0<f--;)e="0"+e;if(k<h)for(f=h-k;0<f--;)e+="0";if(isNaN(d)||c!=e&&c!="-"+e&&0>c.indexOf("e"))return isNaN(d)||c==e?{error:zk.fmt.Text.format(msgzul.NUMBER_REQUIRED,a)}:{error:zk.fmt.Text.format(msgzul.ILLEGAL_VALUE)}}b.divscale&&(d/=Math.pow(10,b.divscale));l(this,d);return d},coerceToString_:function(a){var b=this._format,c=this._localizedSymbols?this._localizedSymbols.DECIMAL:zk.DECIMAL;if("number"===typeof a&&0==
a%1){var d=1;this._step&&(decimal=(this._step+"").split(".")[1])&&(d=decimal.length);a=parseFloat(a).toFixed(d)}return null==a?"":b?zk.fmt.Number.format(b,parseFloat(a),this._rounding,this._localizedSymbols):"."==c?""+a:(""+a).replace(".",c)},onHide:zul.inp.Textbox.onHide,validate:zul.inp.Doublebox.validate,doKeyDown_:function(a){var b=this.getInputNode();if(!b.disabled&&!b.readOnly){switch(a.keyCode){case 38:this.checkValue();this._increase(!0);a.stop();return;case 40:this.checkValue();this._increase(!1);
a.stop();return}this.$supers("doKeyDown_",arguments)}},_ondropbtnup:function(a){this.domUnlisten_(document.body,"onZMouseup","_ondropbtnup");this._stopAutoIncProc();this._currentbtn=null},_btnDown:function(a){if(this._buttonVisible&&!this._disabled){var b=this.$n("btn");zk.dragging||(this._currentbtn&&this._ondropbtnup(a),this.domListen_(document.body,"onZMouseup","_ondropbtnup"),this._currentbtn=b);this.checkValue();var c=zk(b).revisedOffset();a.pageY-c[1]<b.offsetHeight/2?(this._increase(!0),this._startAutoIncProc(!0)):
(this._increase(!1),this._startAutoIncProc(!1));a.stop()}},checkValue:function(){var a=this.getInputNode(),b=this._min,c=this._max;a.value||(a.value=b&&c?0>=b&&0<=c?0:b:b?0>=b?0:b:c?0<=c?0:c:0)},_btnUp:function(a){if(this._buttonVisible&&!this._disabled&&!zk.dragging){this._onChanging();this._stopAutoIncProc();a=this.getInputNode();if(11>zk.ie){var b=a.value.length;zk(a).setSelectionRange(b,b)}a.focus()}},_increase:function(a){var b=this.getInputNode(),c=this.coerceFromString_(b.value);if(!c||!c.error){var d=
Math.max(h(c),this._fixedDigits),e=c,f=this._step;if(d){var g=Math.pow(10,d);e=Math.round(e*g);f=Math.round(f*g)}a=a?e+f:e-f;d&&(a/=g);d=a;d>Math.pow(2,63)-1?d=Math.pow(2,63)-1:d<-Math.pow(2,63)&&(d=-Math.pow(2,63));null!=this._max&&d>this._max?d=c:null!=this._min&&d<this._min&&(d=c);b.value=this.coerceToString_(d);this._onChanging()}},_clearValue:function(){this.getInputNode().value=this._defRawVal="";return!0},_startAutoIncProc:function(a){var b=this;this.timerId&&clearInterval(this.timerId);this.timerId=
setInterval(function(){b._increase(a)},200);jq(this.$n("btn-"+(a?"up":"down"))).addClass(this.$s("active"))},_stopAutoIncProc:function(){this.timerId&&clearTimeout(this.timerId);this.timerId=null;jq("."+this.$s("icon"),this.$n("btn")).removeClass(this.$s("active"))},doFocus_:function(a){this.$supers("doFocus_",arguments);zul.inp.RoundUtl.doFocus_(this)},doBlur_:function(a){this.$supers("doBlur_",arguments);zul.inp.RoundUtl.doBlur_(this)},afterKeyDown_:function(a,b){!b&&this._inplace&&jq(this.$n()).toggleClass(this.getInplaceCSS(),
13==a.keyCode?null:!1);return this.$supers("afterKeyDown_",arguments)},getAllowedKeys_:function(){var a=this._localizedSymbols;return this.$supers("getAllowedKeys_",arguments)+(a?a:zk).DECIMAL+"e"},bind_:function(){this.$supers(zul.inp.Doublespinner,"bind_",arguments);var a;(a=this.$n("btn"))&&this.domListen_(a,"onZMouseDown","_btnDown").domListen_(a,"onZMouseUp","_btnUp");zWatch.listen({onSize:this})},unbind_:function(){this.timerId&&(clearTimeout(this.timerId),this.timerId=null);zWatch.unlisten({onSize:this});
var a=this.$n("btn");a&&this.domUnlisten_(a,"onZMouseDown","_btnDown").domUnlisten_(a,"onZMouseUp","_btnUp");this.$supers(zul.inp.Doublespinner,"unbind_",arguments)},getBtnUpIconClass_:function(){return"z-icon-angle-up"},getBtnDownIconClass_:function(){return"z-icon-angle-down"}})})();
