zul.inp.Spinner=zk.$extends(zul.inp.NumberInputWidget,{_step:1,_buttonVisible:!0,$define:{step:_zkf=function(){},buttonVisible:function(a){zul.inp.RoundUtl.buttonVisible(this,a)}},inRoundedMold:function(){return!0},intValue:function(){return this.$supers("getValue",arguments)},setConstraint:function(a){if("string"==typeof a&&"["!=a.charAt(0)){var b=new zul.inp.SimpleSpinnerConstraint(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=parseInt(b.raw,10);if(isNaN(c)||b.raw!=""+c&&b.raw!="-"+c)return{error:zk.fmt.Text.format(msgzul.INTEGER_REQUIRED,a)};if(2147483647<c||-2147483648>c)return{error:zk.fmt.Text.format(msgzul.OUT_OF_RANGE+"(\u22122147483648 - 2147483647)")};b.divscale&&(c=Math.round(c/Math.pow(10,b.divscale)));return c},coerceToString_:function(a){var b=this._format;return b?zk.fmt.Number.format(b,
a,this._rounding,this._localizedSymbols):null!=a?""+a:""},onHide:zul.inp.Textbox.onHide,validate:zul.inp.Intbox.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;this._noPreviousValue=""==
a.value;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);c&&c.error||(this._noPreviousValue&&(0<this._min||0>this._max)?(a=c,this._noPreviousValue=!1):a=a?c+this._step:c-this._step,a>Math.pow(2,
31)-1?a=Math.pow(2,31)-1:a<-Math.pow(2,31)&&(a=-Math.pow(2,31)),null!=this._max&&a>this._max?a=c:null!=this._min&&a<this._min&&(a=c),b.value=this.coerceToString_(a),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)},bind_:function(){this.$supers(zul.inp.Spinner,
"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.Spinner,"unbind_",arguments)},getBtnUpIconClass_:function(){return"z-icon-angle-up"},getBtnDownIconClass_:function(){return"z-icon-angle-down"}});
