(function(){var h=11>zk.ie?function(){return!0}:zk.opera?function(a){return 32==a||46<a}:function(a){return 32<=a},k=zk.ie?function(a){setTimeout(function(){a==zk.currentFocus&&zjq.fixInput(a.getInputNode())},0)}:zk.$void,f=windowY=0;zul.inp.RoundUtl={syncWidth:function(a,b,c){var d=a.$n();(a._inplace||d.style.width)&&(c||zk(d).isRealVisible())&&d.style.width&&(c=d.offsetWidth,b=b?b.offsetWidth:0,a.getInputNode().style.width=jq.px0(c-b))},buttonVisible:function(a,b){var c=a.$n("btn");c&&(b=b?"removeClass":
"addClass",jq(c)[b](a.$s("disabled")),jq(a.getInputNode())[b](a.$s("rightedge")),a.onSize())},doFocus_:function(a){a._inplace&&(null!=a._inplaceTimerId&&(clearTimeout(a._inplaceTimerId),a._inplaceTimerId=null),a.onSize())},doBlur_:function(a){if(a._inplace){var b=a.$n();null!=a._inplaceTimerId&&(clearTimeout(a._inplaceTimerId),a._inplaceTimerId=null);a._inplaceTimerId=setTimeout(function(){a.desktop&&jq(a.$n()).addClass(a.getInplaceCSS())},a._inplaceTimeout);a.onSize();a.getHflex()||(b.style.width=
a.getWidth()||"")}},onSize:function(a){var b=a.getWidth();a.getHflex()||b&&-1==b.indexOf("%")||(a.getInputNode().style.width="");this.syncWidth(a,a.$n("btn"),!0)}};var g=zul.inp.InputWidget=zk.$extends(zul.Widget,{_maxlength:0,_cols:0,_type:"text",_placeholder:null,_inplaceTimerId:null,_inplaceTimeout:150,_inplaceIgnore:!1,$define:{name:function(a){var b=this.getInputNode();b&&(b.name=a)},disabled:function(a){var b=this.getInputNode();b&&(a=(b.disabled=a)?"addClass":"removeClass",jq(this.$n())[a](this.$s("disabled")))},
readonly:function(a){var b=this.getInputNode();if(b){k(this);var c=a?"addClass":"removeClass";b.readOnly=a;jq(this.$n())[c](this.$s("readonly"))}},cols:function(a){var b=this.getInputNode();b&&(this.isMultiline()?b.cols=a:b.size=a)},maxlength:function(a){var b=this.getInputNode();b&&!this.isMultiline()&&(b.maxLength=a)},tabindex:function(a){var b=this.getInputNode();b&&(null==a?b.removeAttribute("tabindex"):b.tabIndex=a)},inplace:function(a){this.rerender()},placeholder:function(a){this.rerender()},
instant:null,errorboxSclass:null,errorboxIconSclass:null},getInplaceCSS:function(){return this._inplace?this.$s("inplace"):""},select:function(a,b){var c=this.getInputNode();zk.currentFocus!=c&&this.focus_();null==a&&null==b?c.select():zk(c).setSelectionRange(a,b)},getType:function(){return this._type},isMultiline:function(){return!1},inRoundedMold:function(){return!0},getText:function(){return this.coerceToString_(this.getValue())},setText:function(a){this.setValue(this.coerceFromString_(a))},getValue:function(){return this._value},
setValue:function(a,b){if(b)this.clearErrorMessage(null!=this.cst);else{var c=this._validate(a);a=c.value}this.$class._clearOnChanging(this);!(c&&c.error||!b&&this._equalValue(this._value,a))&&(this._value=a,b=this.getInputNode())&&(this._defRawVal=this._lastChg=b.value=this.coerceToString_(a))},set_value:function(a,b){this.setValue(this.unmarshall_(a),b)},getInputNode:_zkf=function(){return this.$n("real")||this.$n()},getTextNode:_zkf,domAttrs_:function(a){var b=this.$supers("domAttrs_",arguments);
a&&a.text||(b+=this.textAttrs_());return b},textAttrs_:function(){var a="";if(this.isMultiline()){var b=this._cols;0<b&&(a+=' cols="'+b+'"')}else a+=' value="'+this._areaText()+'"',a+=' type="'+this.getType()+'"',b=this._cols,0<b&&(a+=' size="'+b+'"'),b=this._maxlength,0<b&&(a+=' maxlength="'+b+'"');b=this._tabindex;void 0!=b&&(a+=' tabindex="'+b+'"');(b=this._name)&&(a+=' name="'+b+'"');this._disabled&&(a+=' disabled="disabled"');this._readonly&&(a+=' readonly="readonly"');this._placeholder&&(a+=
' placeholder="'+zUtl.encodeXML(this._placeholder)+'"');(b=jq.filterTextStyle(this.domStyle_({width:!0,height:!0,top:!0,left:!0})))&&(a+=' style="'+b+'"');return a},_onChanging:function(a){this.$class._onChanging.call(this,a)},_areaText:function(){return zUtl.encodeXML(this.coerceToString_(this._value))},setConstraint:function(a){"string"==typeof a&&"["!=a.charAt(0)?this._cst=new zul.inp.SimpleConstraint(a):this._cst=a;this._cst&&(this._reVald=!0)},getConstraint:function(){return this._cst},doFocus_:function(a){this.$supers("doFocus_",
arguments);this._lastChg=this.getInputNode().value;if(a.domTarget.tagName&&(this._inplace&&(jq(this.$n()).removeClass(this.getInplaceCSS()),null!=this._inplaceTimerId&&(clearTimeout(this._inplaceTimerId),this._inplaceTimerId=null)),this._errbox)){var b=this,c=b._cst&&b._cst._pos;setTimeout(function(){b._errbox&&b._errbox.open(b,null,c||b._errbox._defaultPos,{dodgeRef:!c})})}},doBlur_:function(a){this.$class._stopOnChanging(this,!0);!zk.alerting&&this.shallUpdate_(zk.currentFocus)&&(this.updateChange_(),
this.$supers("doBlur_",arguments));if(this._inplace&&(this.$class._clearInplaceTimeout(this),!this._inplaceIgnore)){var b=this;b._inplaceTimerId=setTimeout(function(){b.desktop&&jq(b.$n()).addClass(b.getInplaceCSS())},b._inplaceTimeout)}if(zk.ios&&jq(this.$n()).data("fixscrollposition")){var c=window.pageYOffset;window.pageXOffset==f&&c==windowY||window.scrollTo(f,windowY)}this._lastKeyDown=null},_doTouch:zk.ios?function(a){f=window.pageXOffset;windowY=window.pageYOffset}:zk.$void,_doSelect:function(a){if(this.isListen("onSelection")){a=
this.getInputNode();var b=zk(a).getSelectionRange(),c=b[0];b=b[1];this.fire("onSelection",{start:c,end:b,selected:a.value.substring(c,b)})}},shallUpdate_:function(a){return!a||!zUtl.isAncestor(this,a)},getErrorMesssage:function(){return this.getErrorMessage()},getErrorMessage:function(){return this._errmsg},setErrorMessage:function(a){this.clearErrorMessage(!0,!0);this._markError(a,null,!0)},clearErrorMessage:function(a,b){var c=this._errbox;c&&(this._errbox=null,c.destroy());b||(this._errmsg=null,
jq(this.getInputNode()).removeClass(this.$s("invalid")));a&&(this._reVald=!0)},coerceFromString_:function(a){return a},coerceToString_:function(a){return a||""},_markError:function(a,b,c){this._errmsg=a;if(this.desktop){jq(this.getInputNode()).addClass(this.$s("invalid"));var d=this._cst,e;"[c"!=d&&(d&&(e=d.showCustomError)&&(e=e.call(d,this,a)),e||(this._errbox=this.showError_(a)));c||this.fire("onError",{value:b,message:a})}},validate_:function(a){var b;if(b=this._cst){if("string"==typeof b)return!1;
a=b.validate(this,a);return!a&&b.serverValidate?!1:a}},_validate:function(a){zul.inp.validating=!0;try{var b=a,c;if(("string"==typeof b||null==b)&&(b=this.coerceFromString_(b))&&((c=b.error)||b.server)){this.clearErrorMessage(!0);if(b.server||"[c"==this._cst)return this._reVald=!1,{rawValue:a||"",server:!0};this._markError(c,b);return b}if(this.desktop){var d=this._errmsg;this.clearErrorMessage(!0);c=this.validate_(b);if(!1===c)return this._reVald=!1,{value:b,server:!0};if(c)return this._markError(c,
b),{error:c};this._reVald=!1;d&&this.fire("onError",{value:b})}else this._errmsg=null;return{value:b}}finally{zul.inp.validating=!1}},_shallIgnore:function(a,b){if(a.keyCode||a.charCode){if(!zk.mac||!a.metaKey){var c=11>zk.ie||zk.opera?a.keyCode:a.charCode;if(!a.altKey&&!a.ctrlKey&&h(c)&&0>b.indexOf(String.fromCharCode(c)))return a.stop(),!0}}else if(c=(c=a.domEvent.originalEvent.clipboardData.getData("text"))?c:window.clipboardData.getData("text"),b=b.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),!(new RegExp("^["+
b+"]+$")).test(c))return a.stop(),!0},showError_:function(a){a=new zul.inp.Errorbox(this,a);a.show();return a},onShow:function(){this.__ebox&&(this.setFloating_(!0),this.__ebox.show())},_equalValue:function(a,b){return a==b||this.marshall_(a)==this.marshall_(b)},marshall_:function(a){return a},unmarshall_:function(a){return a},updateChange_:function(){if(zul.inp.validating)return!1;var a=this.getInputNode(),b=a.value;if(!this._reVald&&b==this._defRawVal)return!1;var c=this._errmsg,d=this._validate(b);
if(!d.error||d.server){var e;if(null!=d.rawValue)var f={rawValue:d.rawValue};else!d.error&&(b=this.coerceToString_(d.value),a.value!==b&&(a.value=b),this._reVald=!1,e=c||!this._equalValue(d.value,this._value))&&(this._value=d.value,this._defRawVal=b);(e||d.server)&&this.fire("onChange",this.$class._onChangeData(this,null!=f?f:{value:this.marshall_(d.value)}),d.server?{toServer:!0}:null,90)}return!0},fireOnChange:function(a){this.fire("onChange",this.$class._onChangeData(this,{value:this.marshall_(this.getValue())}),
a)},_resetForm:function(){var a=this.getInputNode();if(a.value!=a.defaultValue){var b=this;setTimeout(function(){b.updateChange_()},0)}},focus_:function(a){zk.ie11_&&!a&&(a=0);zk(this.getInputNode()).focus(a);return!0},domClass_:function(a){var b=this.$supers("domClass_",arguments);a&&a.zclass||!this._disabled||(b+=" "+this.$s("disabled"));a&&a.input||!this._inplace||(b+=" "+this.getInplaceCSS());a&&a.zclass||!this._readonly||(b+=" "+this.$s("readonly"));return b},bind_:function(){this.$supers(g,
"bind_",arguments);var a=this.getInputNode();this._lastChg=this._defRawVal=a.value;this.domListen_(a,"onFocus","doFocus_").domListen_(a,"onBlur","doBlur_").domListen_(a,"onSelect");if(zk.ie10_||zk.ie11_){var b=this;setTimeout(function(){b.domListen_(a,"onInput","doInput_")},100)}else this.domListen_(a,"onInput","doInput_");zk.ios&&this.domListen_(a,"onTouchStart","_doTouch");(a=a.form)&&jq(a).bind("reset",this.proxy(this._resetForm));zWatch.listen({onShow:this})},unbind_:function(){zWatch.unlisten({onShow:this});
this.$class._stopOnChanging(this);this.clearErrorMessage(!0);var a=this.getInputNode();this.domUnlisten_(a,"onFocus","doFocus_").domUnlisten_(a,"onBlur","doBlur_").domUnlisten_(a,"onSelect").domUnlisten_(a,"onInput","doInput_");zk.ios&&this.domUnlisten_(a,"onTouchStart","_doTouch");(a=a.form)&&jq(a).unbind("reset",this.proxy(this._resetForm));this.$supers(g,"unbind_",arguments)},doInput_:function(a){var b=this;setTimeout(function(){!b||zk.chrome||b._lastKeyDown||zk.currentFocus==b||b.doBlur_(a)},
10)},resetSize_:function(a){var b;this.$n()!=(b=this.getInputNode())&&(b.style["w"==a?"width":"height"]="");this.$supers("resetSize_",arguments)},doKeyDown_:function(a){var b=a.keyCode;this._lastKeyDown=b;if(this._readonly&&8==b&&a.target==this)a.stop();else if(9!=b||a.altKey||a.ctrlKey||a.shiftKey||!this._tabbable)this.$class._stopOnChanging(this),this.$supers("doKeyDown_",arguments);else{b=this.getInputNode();var c=zk(b),d=c.getSelectionRange(),e=b.value;e=e.substring(0,d[0])+"\t"+e.substring(d[1]);
b.value=e;e=d[0]+1;c.setSelectionRange(e,e);a.stop()}},doKeyUp_:function(){if(this.isMultiline()){var a=this._maxlength;if(0<a){var b=this.getInputNode(),c=b.value;c!=this._defRawVal&&c.length>a&&(b.value=c.substring(0,a))}}(this.isListen("onChanging")||this._instant)&&this.$class._startOnChanging(this);this.$supers("doKeyUp_",arguments)},afterKeyDown_:function(a,b){if(!b&&this._inplace)if(this._multiline||13!=a.keyCode)jq(this.getInputNode()).removeClass(this.getInplaceCSS());else{var c=jq(this.getInputNode()),
d=this.getInplaceCSS();c.toggleClass(d).hasClass(d)&&c.zk.setSelectionRange(0,c[0].value.length)}if(13!=a.keyCode||!this.isMultiline())return this.$supers("afterKeyDown_",arguments)},beforeCtrlKeys_:function(a){this.updateChange_()},shallIgnoreClick_:function(a){return this.isDisabled()},setInsertedText:function(a){if(a){var b=this.getInputNode();if(b){var c=zk(b);zk.currentFocus!=b&&c.focus();b=c.getSelectionRange()[0];var d=this.getText();c=d.substring(0,b);d=d.substring(b);b+=a.length;this.setText(c+
a+d);this.select(b,b);this.fireOnChange()}}}},{onChangingDelay:350,onChangingForced:!0,_isInView:function(a){a=a.getInputNode();return zk(a).isRealScrollIntoView(!0)},_onChanging:function(a){if(this.desktop){var b=this.getInputNode();b=this.valueEnter_||b.value;if(this._lastChg!=b){this._lastChg=b;var c=this.valueSel_;this.valueSel_=null;this.isListen("onChanging")&&this.fire("onChanging",zul.inp.InputWidget._onChangeData(this,{value:b},c==b),{ignorable:1,rtags:{onChanging:1}},a||5);this._instant&&
this.updateChange_()}}},_onChangeData:function(a,b,c){b.start=zk(a.getInputNode()).getSelectionRange()[0];c&&(b.bySelectBack=!0);return b},_startOnChanging:function(a){var b=zul.inp.InputWidget;b._stopOnChanging(a);a._tidChg=setTimeout(a.proxy(b._onChanging),b.onChangingDelay)},_stopOnChanging:function(a,b){a._tidChg&&(clearTimeout(a._tidChg),a._tidChg=null);b&&(b=zul.inp.InputWidget,(b.onChangingForced&&a.isListen("onChanging")||a._instant)&&b._onChanging.call(a,-1),b._clearOnChanging(a))},_clearOnChanging:function(a){a.valueEnter_=
a.valueSel_=null},_clearInplaceTimeout:function(a){a._inplaceTimerId&&(clearTimeout(a._inplaceTimerId),a._inplaceTimerId=null)}});zul.inp.InputCtrl={isPreservedFocus:function(a){return!0},isPreservedMouseMove:function(a){return!0},isIgnoredDragForErrorbox:function(a,b,c){a=a.control.$n("c");return c.domTarget==a&&jq(a).hasClass("z-errbox-close-over")}}})();
