console-min.js revision 145fddab811fa63e280b6dd283c1ef7d8ad732f8
YUI.add("console",function(D){var H=D.ClassNameManager.getClassName,AB="console",l="entry",u="reset",A="checked",m="title",F="pause",d="paused",q="clear",P="info",g="warn",i="error",v="innerHTML",p="click",b="contentBox",f="disabled",t="startTime",N="lastTime",W=".",w=H(AB,l),Q=H(AB,F),Z=H(AB,"checkbox"),V=H(AB,"button"),AA=H(AB,q),U=H(AB,F,"label"),S=H(AB,l,"meta"),r=H(AB,l,"cat"),e=H(AB,l,"src"),B=H(AB,l,"time"),X=H(AB,l,"content"),c=H(AB,"hd"),a=H(AB,"bd"),C=H(AB,"ft"),E=H(AB,"controls"),h=H(AB,m),k=/^(\S+)\s/,x=/&/g,K=/</g,s=/>/g,I="&#38;",j="&#60;",R="&#62;",J=D.Lang,O=J.isString,z=J.isNumber,n=J.isObject,o=D.merge,y=D.substitute,M=D.Node.create,G='<pre class="{entry_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>";function T(){T.superclass.constructor.apply(this,arguments);}D.mix(T,{NAME:AB,LOG_LEVEL_INFO:3,LOG_LEVEL_WARN:2,LOG_LEVEL_ERROR:1,ENTRY_CLASSES:{entry_class:w,entry_meta_class:S,entry_cat_class:r,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},HEAD_TEMPLATE:'<div class="{console_hd_class}">'+'<h4 class="{console_title_class}">{str_title}</h4>'+"</div>",CONSOLE_TEMPLATE:'<div class="{console_bd_class}"></div>',FOOT_TEMPLATE:'<div class="{console_ft_class}">'+'<div class="{console_controls_class}">'+'<input type="checkbox" class="{console_checkbox_class} '+'{console_pause_class}" value="1"> '+'<label class="{console_pause_label_class}">'+"{str_pause}</label>"+'<input type="button" class="'+'{console_button_class} {console_clear_class}" '+'value="{str_clear}">'+"</div>"+"</div>",ATTRS:{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:G,validator:O},logLevel:{value:D.config.logLevel,validator:function(L){return this._validateLogLevel(L);},set: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}}});D.extend(T,D.Widget,{_title:null,_console:null,_foot:null,_timeout:null,buffer:null,log:function(){return D.log.apply(D,arguments);},clearConsole:function(){this._console.set(v,"");this._clearTimeout();this.buffer=[];return this;},reset:function(){this.fire(u);return this;},printBuffer:function(){var Y=D.config.debug;D.config.debug=false;if(!this.get(d)&&this.get("rendered")){this._clearTimeout();var AD=this.buffer,AC,L;this.buffer=[];for(AC=0,L=AD.length;AC<L;++AC){this.printLogEntry(AD[AC]);}this._trimOldEntries();}D.config.debug=Y;return this;},printLogEntry:function(L){L=o(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(L){this.buffer=[];D.on("yui:log",D.bind(this._onYUILog,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(p,this._onPauseClick,this);this.get(b).query("input[type=button]."+AA).on(p,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=o(T.CHROME_CLASSES,{str_title:this.get("strings.title")});L.insertBefore(M(y(T.HEAD_TEMPLATE,Y)),L.get("firstChild")||null);},_initConsole:function(){this._console=this.get(b).insertBefore(M(y(T.CONSOLE_TEMPLATE,T.CHROME_CLASSES)),this._foot||null);},_initFoot:function(){var L=o(T.CHROME_CLASSES,{str_pause:this.get("strings.pause"),str_clear:this.get("strings.clear")});this._foot=M(y(T.FOOT_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(t);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._console.insertBefore(Y,L?this._console.get("firstChild"):null);if(this.get("scrollIntoView")){AC=L?0:this._console.get("scrollHeight");this._console.set("scrollTop",AC);}},_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(){if(this._console){var L=this._console.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++){this._console.removeChild(L.item(AC));}}else{for(;
AC>=0;--AC){this._console.removeChild(L.item(AC));}}}}},_encodeHTML:function(L){return O(L)?L.replace(x,I).replace(K,j).replace(s,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){if(O(L)){L=L.toLowerCase();L=L===i?T.LOG_LEVEL_ERROR:L===g?T.LOG_LEVEL_WARN:T.LOG_LEVEL_INFO;}else{if(!z(L)){L=T.LOG_LEVEL_INFO;}}return L;},_validateLogLevel:function(L){return L===T.LOG_LEVEL_INFO||L===T.LOG_LEVEL_WARN||L===T.LOG_LEVEL_ERROR;},_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===q)&&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();},_onYUILog: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(t,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"]});