/*
 * libura V2.0R1.0
 * http://www.desknets.com/
 * Copyright (C)2010 NEOJAPAN,Inc. All Rights Reserved.
 * 本製品は日本国著作権法および国際条約により保護されています。 
 * 本製品の全部または一部を無断で複製したり、無断で複製物を頒 
 * 布すると著作権の侵害となりますのでご注意ください。 
 */
(function(){if(!neo.core.readyNamespace("neo.jQuery.fn.neoTextCounter")){return}var a;a=new neo.core.Class({properties:{_getElText:function(){return this._elText},_setElText:function(b){this._elText=b},_elText:null,_getElCount:function(){return this._elCount},_setElCount:function(b){this._elCount=b},_elCount:null,_getElLength:function(){return this._elLength||this._initElLength()},_initElLength:function(){return this._elLength=this._getElCount().find("span.neo-textcount-length")},_elLength:null,_maxLength:null,_lastLength:null,_tmObserve:null,__constructor:function(d,c,b){this._setElText(d);this._setElCount(c);this._maxLength=b;a.showcase.set(this._getElText(),this);this._initialize()},_initialize:function(){this._bindActions();this._update()},_bindActions:function(){var b=this._getElText();b.focus(a.onFocus).blur(a.onBlur)},startObserve:function(){this.observe()},observe:function(){this._update();var b=this;var c=function(){return b.observe()};this._tmObserve=setTimeout(c,1)},_update:function(){var d=this._getElText().val().split(/\r\n|\r|\n/);var c=d.join("  ");var b=c.length;if(this._lastLength==b){return}this._updateLow(b)},_updateLow:function(b){var c=this._getElLength();c.text(b);if(b>this._maxLength){this._getElCount().addClass(a.CLS_OVERFLOW)}else{this._getElCount().removeClass(a.CLS_OVERFLOW)}this._lastLength=b},stopObserve:function(){clearTimeout(this._tmObserve)}},classProperties:{CLS_OVERFLOW:"neo-textcount-overflow",showcase:new neo.core.Showcase("neo-textcount"),onFocus:function(d){var c=this;var e=c.getAttribute("neo-textcount");if(!e||e==""){return}var b=a.showcase.get(e);if(!b){return}b.startObserve()},onBlur:function(d){var c=this;var e=c.getAttribute("neo-textcount");if(!e||e==""){return}var b=a.showcase.get(e);if(!b){return}b.stopObserve()}}});$.fn.neoTextCounter=function(c,d,b){return this.each(function(){new a($(this),c,d,b)})}})();
