AUI.add("aui-char-counter",function(C){var J=C.Lang,K=J.isNumber,B="char-counter",G="counter",I="input",F="maxLength",E="scrollLeft",H="scrollTop";var D=C.Component.create({NAME:B,ATTRS:{counter:{setter:C.one},maxLength:{lazyAdd:false,setter:function(A){return this._setMaxLength(A);},value:Infinity,validator:K},input:{setter:C.one}},EXTENDS:C.Base,prototype:{handler:null,initializer:function(){var A=this;A.bindUI();A.checkLength();},bindUI:function(){var A=this;var L=A.get(I);A.publish("maxLength");A.after("maxLengthChange",A.checkLength);if(L){A.handler=L.on(I,C.bind(A._onInputChange,A));}},syncUI:function(){var A=this;var L=A.get(G);if(L){var M=A.get(I).val();L.html(A.get(F)-M.length);}},destroy:function(){var A=this;if(A.handler){A.handler.detach();}},checkLength:function(){var A=this;var M=A.get(I);var L=A.get(F);if(!M){return false;}var N=M.val();var O=M.get(H);var P=M.get(E);if(N.length>L){M.val(N.substring(0,L));}if(N.length==L){A.fire("maxLength");}M.set(H,O);M.set(E,P);A.syncUI();},_onInputChange:function(L){var A=this;A.checkLength();},_setMaxLength:function(M){var A=this;var L=A.get(I);if(L&&(M<Infinity)){L.set(F,M);}return M;}}});C.CharCounter=D;},"1.0.1",{skinnable:false,requires:["aui-base","aui-event-input"]});