console-min.js revision 9327ef7ad1fee11b0e494b97cc07386565326c03
YUI.add("console",function(D){var G=D.ClassNameManager.getClassName,AB="console",l="entry",u="reset",A="checked",m="title",F="pause",d="paused",p="clear",P="info",g="warn",i="error",v="innerHTML",o="click",b="contentBox",f="disabled",s="startTime",N="lastTime",H="entryTemplate",t="rendered",W=".",w=G(AB,l),Q=G(AB,F),Z=G(AB,"checkbox"),V=G(AB,"button"),AA=G(AB,p),U=G(AB,F,"label"),S=G(AB,l,"meta"),q=G(AB,l,"cat"),e=G(AB,l,"src"),B=G(AB,l,"time"),X=G(AB,l,"content"),c=G(AB,"hd"),a=G(AB,"bd"),C=G(AB,"ft"),E=G(AB,"controls"),h=G(AB,m),k=/^(\S+)\s/,x=/&/g,K=/</g,r=/>/g,I="&",j="<",R=">",J=D.Lang,O=J.isString,z=J.isNumber,n=D.merge,y=D.substitute,M=D.Node.create;function T(){T.superclass.constructor.apply(this,arguments);}D.mix(T,{NAME:AB,LOG_LEVEL_INFO:30,LOG_LEVEL_WARN:20,LOG_LEVEL_ERROR:10,ENTRY_CLASSES:{entry_class:w,entry_meta_class:S,entry_cat_class:q,entry_src_class:e,entry_time_class:B,entry_content_class:X},CHROME_CLASSES:{console_hd_class:c,console_bd_class:a,console_ft_class:C,console_controls_class:E,console_checkbox_class:Z,console_pause_class:Q,console_pause_label_class:U,console_button_class:V,console_clear_class:AA,console_title_class:h},HEADER_TEMPLATE:'<div class="{console_hd_class}">'+'<h4 class="{console_title_class}">{str_title}</h4>'+"</div>",BODY_TEMPLATE:'<div class="{console_bd_class}"></div>',FOOTER_TEMPLATE:'<div class="{console_ft_class}">'+'<div class="{console_controls_class}">'+'<input type="checkbox" class="{console_checkbox_class} '+'{console_pause_class}" value="1" id="{id_guid}"> '+'<label for="{id_guid}" class="{console_pause_label_class}">'+"{str_pause}</label>"+'<input type="button" class="'+'{console_button_class} {console_clear_class}" '+'value="{str_clear}">'+"</div>"+"</div>",ENTRY_TEMPLATE:'<pre class="{entry_class} {cat_class} {src_class}">'+'<div class="{entry_meta_class}">'+"<p>"+'<span class="{entry_cat_class}">'+"{label}</span>"+'<span class="{entry_time_class}">'+" {totalTime}ms (+{elapsedTime}) {localTime}:"+"</span>"+"</p>"+'<p class="{entry_src_class}">'+"{sourceAndDetail}"+"</p>"+"</div>"+'<p class="{entry_content_class}">{message}</p>'+"</pre>",ATTRS:{logEvent:{value:"yui:log",writeOnce:true,validator:O},strings:{value:{title:"Log Console",pause:"Pause",clear:"Clear"}},paused:{value:false,validator:J.isBoolean},defaultCategory:{value:P,validator:O},defaultSource:{value:"global",validator:O},entryTemplate:{value:"",validator:O},logLevel:{value:D.config.logLevel||30,validator:function(L){return this._validateNewLogLevel(L);},setter:function(L){return this._setLogLevel(L);}},printTimeout:{value:100,validator:z},consoleLimit:{value:500,validator:z},newestOnTop:{value:true},scrollIntoView:{value:true},startTime:{value:new Date()},lastTime:{value:new Date(),readOnly:true}},_logLevels:{}});T._logLevels[P]=T.LOG_LEVEL_INFO;T._logLevels[g]=T.LOG_LEVEL_WARN;T._logLevels[i]=T.LOG_LEVEL_ERROR;T._logLevels[T.LOG_LEVEL_INFO]=T.LOG_LEVEL_INFO;T._logLevels[T.LOG_LEVEL_WARN]=T.LOG_LEVEL_WARN;T._logLevels[T.LOG_LEVEL_ERROR]=T.LOG_LEVEL_ERROR;D.extend(T,D.Widget,{_head:null,_body:null,_foot:null,_timeout:null,buffer:null,log:function(){return D.log.apply(D,arguments);},clearConsole:function(){this._body.set(v,"");this._clearTimeout();this.buffer=[];return this;},reset:function(){this.fire(u);return this;},printBuffer:function(){if(!this.get(d)&&this.get("rendered")){this._clearTimeout();var AC=this.buffer,Y,L;this.buffer=[];for(Y=0,L=AC.length;Y<L;++Y){this.printLogEntry(AC[Y]);}this._trimOldEntries();}return this;},printLogEntry:function(L){L=n(this._htmlEscapeMessage(L),T.ENTRY_CLASSES,{cat_class:this.getClassName(l,L.category),src_class:this.getClassName(l,L.source)});var Y=M(y(this.get("entryTemplate"),L));this._addToConsole(Y);return this;},initializer:function(){this.buffer=[];if(!this.get(H)){this.set(H,T.ENTRY_TEMPLATE);}D.on(this.get("logEvent"),D.bind(this._onLogEvent,this));this.publish(l,{defaultFn:this._defEntryFn});this.publish(u,{defaultFn:this._defResetFn});},renderUI:function(){this._initHead();this._initConsole();this._initFoot();},syncUI:function(){this.set(d,this.get(d));},bindUI:function(){this.get(b).query("input[type=checkbox]."+Q).on(o,this._onPauseClick,this);this.get(b).query("input[type=button]."+AA).on(o,this._onClearClick,this);this.after("stringsChange",this._afterStringsChange);this.after("pausedChange",this._afterPausedChange);this.after("consoleLimitChange",this._afterConsoleLimitChange);},_initHead:function(){var L=this.get(b),Y=n(T.CHROME_CLASSES,{str_title:this.get("strings.title")});this._head=M(y(T.HEADER_TEMPLATE,Y));L.insertBefore(this._head,L.get("firstChild"));},_initConsole:function(){this._body=M(y(T.BODY_TEMPLATE,T.CHROME_CLASSES));this.get(b).appendChild(this._body);},_initFoot:function(){var L=n(T.CHROME_CLASSES,{id_guid:D.guid(),str_pause:this.get("strings.pause"),str_clear:this.get("strings.clear")});this._foot=M(y(T.FOOTER_TEMPLATE,L));this.get(b).appendChild(this._foot);},_isInLogLevel:function(AD,L){var Y=this.get("logLevel"),AC=L===i?T.LOG_LEVEL_ERROR:L===g?T.LOG_LEVEL_WARN:T.LOG_LEVEL_INFO;return Y>=AC;},_normalizeMessage:function(AD,Y,AC){var L={time:new Date(),message:AD,category:Y||this.get("defaultCategory"),sourceAndDetail:AC||this.get("defaultSource"),source:null,label:null,localTime:null,elapsedTime:null,totalTime:null};L.source=k.test(L.sourceAndDetail)?RegExp.$1:L.sourceAndDetail;L.label=L.category;L.localTime=L.time.toLocaleTimeString?L.time.toLocaleTimeString():(L.time+"");L.elapsedTime=L.time-this.get(N);L.totalTime=L.time-this.get(s);this._set(N,L.time);return L;},_schedulePrint:function(){if(!this.get(d)&&!this._timeout){this._timeout=D.later(this.get("printTimeout"),this,this.printBuffer);}},_addToConsole:function(Y){var L=this.get("newestOnTop"),AC=this._body,AD;AC.insertBefore(Y,L?AC.get("firstChild"):null);if(this.get("scrollIntoView")){AD=L?0:AC.get("scrollHeight");AC.set("scrollTop",AD);}},_htmlEscapeMessage:function(L){L=D.clone(L);L.message=this._encodeHTML(L.message);L.label=this._encodeHTML(L.label);
L.source=this._encodeHTML(L.source);L.sourceAndDetail=this._encodeHTML(L.sourceAndDetail);L.category=this._encodeHTML(L.category);return L;},_trimOldEntries:function(){var AD=this._body;if(AD){var L=AD.queryAll(W+w),AC=L?L.size()-this.get("consoleLimit"):0;if(AC>0){if(this.get("newestOnTop")){for(var Y=L.size();AC<Y;AC++){AD.removeChild(L.item(AC));}}else{for(;AC>=0;--AC){AD.removeChild(L.item(AC));}}}}},_encodeHTML:function(L){return O(L)?L.replace(x,I).replace(K,j).replace(r,R):L;},_clearTimeout:function(){if(this._timeout){this._timeout.cancel();this._timeout=null;}},_onPauseClick:function(Y){var L=Y.target.get(A);this.set(d,L,{src:D.Widget.UI_SRC});},_onClearClick:function(L){this.clearConsole();},_setLogLevel:function(L){return T._logLevels[(L+"").toLowerCase()];},_validateNewLogLevel:function(L){return(L+"").toLowerCase() in T._logLevels;},_afterStringsChange:function(AD){var AF=AD.subAttrName?AD.subAttrName.split(W)[1]:null,L=this.get(b),AC=AD.prevVal,AE=AD.newVal,Y;if((!AF||AF===m)&&AC.title!==AE.title){Y=L.query(W+h);if(Y){Y.set(v,AE.title);}}if((!AF||AF===F)&&AC.pause!==AE.pause){Y=L.query(W+U);if(Y){Y.set(v,AE.pause);}}if((!AF||AF===p)&&AC.clear!==AE.clear){Y=L.query(W+AA);if(Y){Y.set("value",AE.clear);}}},_afterPausedChange:function(AC){var L=AC.newVal;if(AC.src!==D.Widget.SRC_UI){var Y=this._foot.queryAll("input[type=checkbox]."+Q);if(Y){Y.set(A,L);}}if(!L){this._schedulePrint();}else{if(this._timeout){clearTimeout(this._timeout);this._timeout=null;}}},_afterConsoleLimitChange:function(){this._trimOldEntries();},_onLogEvent:function(AD,L,AC){if(!this.get(f)&&this._isInLogLevel(AD,L,AC)){var Y=D.config.debug;D.config.debug=false;this.fire(l,{message:this._normalizeMessage.apply(this,arguments)});D.config.debug=Y;}},_defResetFn:function(){this.clearConsole();this.set(s,new Date());this.set(f,false);this.set(d,false);},_defEntryFn:function(L){if(L.message){this.buffer.push(L.message);this._schedulePrint();}}});D.Console=T;},"@VERSION@",{requires:["substitute","widget"]});