src/cm/media/js/lib/yui/yui_3.0.0b1/build/console/console-debug.js
changeset 0 40c8f766c9b8
equal deleted inserted replaced
-1:000000000000 0:40c8f766c9b8
       
     1 /*
       
     2 Copyright (c) 2009, Yahoo! Inc. All rights reserved.
       
     3 Code licensed under the BSD License:
       
     4 http://developer.yahoo.net/yui/license.txt
       
     5 version: 3.0.0b1
       
     6 build: 1163
       
     7 */
       
     8 YUI.add('console', function(Y) {
       
     9 
       
    10 /**
       
    11  * Console creates a visualization for messages logged through calls to a YUI
       
    12  * instance's <code>Y.log( message, category, source )</code> method.  The
       
    13  * debug versions of YUI modules will include logging statements to offer some
       
    14  * insight into the steps executed during that module's operation.  Including
       
    15  * log statements in your code will cause those messages to also appear in the
       
    16  * Console.  Use Console to aid in developing your page or application.
       
    17  *
       
    18  * Entry categories &quot;info&quot;, &quot;warn&quot;, and &quot;error&quot;
       
    19  * are also referred to as the log level, and entries are filtered against the
       
    20  * configured logLevel.
       
    21  *
       
    22  * @module console
       
    23  * @class Console
       
    24  * @extends Widget
       
    25  * @param conf {Object} Configuration object (see Configuration attributes)
       
    26  * @constructor
       
    27  */
       
    28 
       
    29 var getCN = Y.ClassNameManager.getClassName,
       
    30     CHECKED        = 'checked',
       
    31     CLEAR          = 'clear',
       
    32     CLICK          = 'click',
       
    33     COLLAPSED      = 'collapsed',
       
    34     CONSOLE        = 'console',
       
    35     CONTENT_BOX    = 'contentBox',
       
    36     DISABLED       = 'disabled',
       
    37     ENTRY          = 'entry',
       
    38     ENTRY_TEMPLATE = 'entryTemplate',
       
    39     ERROR          = 'error',
       
    40     HEIGHT         = 'height',
       
    41     INFO           = 'info',
       
    42     INNER_HTML     = 'innerHTML',
       
    43     LAST_TIME      = 'lastTime',
       
    44     PAUSE          = 'pause',
       
    45     PAUSED         = 'paused',
       
    46     RESET          = 'reset',
       
    47     START_TIME     = 'startTime',
       
    48     TITLE          = 'title',
       
    49     WARN           = 'warn',
       
    50 
       
    51     DOT = '.',
       
    52 
       
    53     C_BUTTON           = getCN(CONSOLE,'button'),
       
    54     C_CHECKBOX         = getCN(CONSOLE,'checkbox'),
       
    55     C_CLEAR            = getCN(CONSOLE,CLEAR),
       
    56     C_COLLAPSE         = getCN(CONSOLE,'collapse'),
       
    57     C_COLLAPSED        = getCN(CONSOLE,COLLAPSED),
       
    58     C_CONSOLE_CONTROLS = getCN(CONSOLE,'controls'),
       
    59     C_CONSOLE_HD       = getCN(CONSOLE,'hd'),
       
    60     C_CONSOLE_BD       = getCN(CONSOLE,'bd'),
       
    61     C_CONSOLE_FT       = getCN(CONSOLE,'ft'),
       
    62     C_CONSOLE_TITLE    = getCN(CONSOLE,TITLE),
       
    63     C_ENTRY            = getCN(CONSOLE,ENTRY),
       
    64     C_ENTRY_CAT        = getCN(CONSOLE,ENTRY,'cat'),
       
    65     C_ENTRY_CONTENT    = getCN(CONSOLE,ENTRY,'content'),
       
    66     C_ENTRY_META       = getCN(CONSOLE,ENTRY,'meta'),
       
    67     C_ENTRY_SRC        = getCN(CONSOLE,ENTRY,'src'),
       
    68     C_ENTRY_TIME       = getCN(CONSOLE,ENTRY,'time'),
       
    69     C_PAUSE            = getCN(CONSOLE,PAUSE),
       
    70     C_PAUSE_LABEL      = getCN(CONSOLE,PAUSE,'label'),
       
    71 
       
    72     RE_INLINE_SOURCE = /^(\S+)\s/,
       
    73     RE_AMP = /&/g,
       
    74     RE_GT  = />/g,
       
    75     RE_LT  = /</g,
       
    76 
       
    77     ESC_AMP = '&#38;',
       
    78     ESC_GT  = '&#62;',
       
    79     ESC_LT  = '&#60;',
       
    80     
       
    81     L = Y.Lang,
       
    82     create     = Y.Node.create,
       
    83     isNumber   = L.isNumber,
       
    84     isString   = L.isString,
       
    85     merge      = Y.merge,
       
    86     substitute = Y.substitute;
       
    87     
       
    88 
       
    89 function Console() {
       
    90     Console.superclass.constructor.apply(this,arguments);
       
    91 }
       
    92 
       
    93 Y.mix(Console, {
       
    94 
       
    95     /**
       
    96      * The identity of the widget.
       
    97      *
       
    98      * @property Console.NAME
       
    99      * @type String
       
   100      * @static
       
   101      */
       
   102     NAME : CONSOLE,
       
   103 
       
   104     /**
       
   105      * Static identifier for logLevel configuration setting to allow all
       
   106      * incoming messages to generate Console entries.
       
   107      *
       
   108      * @property Console.LOG_LEVEL_INFO
       
   109      * @type String
       
   110      * @static
       
   111      */
       
   112     LOG_LEVEL_INFO  : INFO,
       
   113 
       
   114     /**
       
   115      * Static identifier for logLevel configuration setting to allow only
       
   116      * incoming messages of logLevel &quot;warn&quot; or &quot;error&quot;
       
   117      * to generate Console entries.
       
   118      *
       
   119      * @property Console.LOG_LEVEL_WARN
       
   120      * @type String
       
   121      * @static
       
   122      */
       
   123     LOG_LEVEL_WARN  : WARN,
       
   124 
       
   125     /**
       
   126      * Static identifier for logLevel configuration setting to allow only
       
   127      * incoming messages of logLevel &quot;error&quot; to generate
       
   128      * Console entries.
       
   129      *
       
   130      * @property Console.LOG_LEVEL_ERROR
       
   131      * @type String
       
   132      * @static
       
   133      */
       
   134     LOG_LEVEL_ERROR : ERROR,
       
   135 
       
   136     /**
       
   137      * Map (object) of classNames used to populate the placeholders in the
       
   138      * Console.ENTRY_TEMPLATE markup when rendering a new Console entry.
       
   139      *
       
   140      * <p>By default, the keys contained in the object are:</p>
       
   141      * <ul>
       
   142      *    <li>entry_class</li>
       
   143      *    <li>entry_meta_class</li>
       
   144      *    <li>entry_cat_class</li>
       
   145      *    <li>entry_src_class</li>
       
   146      *    <li>entry_time_class</li>
       
   147      *    <li>entry_content_class</li>
       
   148      * </ul>
       
   149      *
       
   150      * @property Console.ENTRY_CLASSES
       
   151      * @type Object
       
   152      * @static
       
   153      */
       
   154     ENTRY_CLASSES   : {
       
   155         entry_class         : C_ENTRY,
       
   156         entry_meta_class    : C_ENTRY_META,
       
   157         entry_cat_class     : C_ENTRY_CAT,
       
   158         entry_src_class     : C_ENTRY_SRC,
       
   159         entry_time_class    : C_ENTRY_TIME,
       
   160         entry_content_class : C_ENTRY_CONTENT
       
   161     },
       
   162 
       
   163     /**
       
   164      * Map (object) of classNames used to populate the placeholders in the
       
   165      * Console.HEADER_TEMPLATE, Console.BODY_TEMPLATE, and
       
   166      * Console.FOOTER_TEMPLATE markup when rendering the Console UI.
       
   167      *
       
   168      * <p>By default, the keys contained in the object are:</p>
       
   169      * <ul>
       
   170      *   <li>console_hd_class</li>
       
   171      *   <li>console_bd_class</li>
       
   172      *   <li>console_ft_class</li>
       
   173      *   <li>console_controls_class</li>
       
   174      *   <li>console_checkbox_class</li>
       
   175      *   <li>console_pause_class</li>
       
   176      *   <li>console_pause_label_class</li>
       
   177      *   <li>console_button_class</li>
       
   178      *   <li>console_clear_class</li>
       
   179      *   <li>console_collapse_class</li>
       
   180      *   <li>console_title_class</li>
       
   181      * </ul>
       
   182      *
       
   183      * @property Console.CHROME_CLASSES
       
   184      * @type Object
       
   185      * @static
       
   186      */
       
   187     CHROME_CLASSES  : {
       
   188         console_hd_class       : C_CONSOLE_HD,
       
   189         console_bd_class       : C_CONSOLE_BD,
       
   190         console_ft_class       : C_CONSOLE_FT,
       
   191         console_controls_class : C_CONSOLE_CONTROLS,
       
   192         console_checkbox_class : C_CHECKBOX,
       
   193         console_pause_class    : C_PAUSE,
       
   194         console_pause_label_class : C_PAUSE_LABEL,
       
   195         console_button_class   : C_BUTTON,
       
   196         console_clear_class    : C_CLEAR,
       
   197         console_collapse_class : C_COLLAPSE,
       
   198         console_title_class    : C_CONSOLE_TITLE
       
   199     },
       
   200 
       
   201     /**
       
   202      * Markup template used to generate the DOM structure for the header
       
   203      * section of the Console when it is rendered.  The template includes
       
   204      * these {placeholder}s:
       
   205      *
       
   206      * <ul>
       
   207      *   <li>console_button_class - contributed by Console.CHROME_CLASSES</li>
       
   208      *   <li>console_collapse_class - contributed by Console.CHROME_CLASSES</li>
       
   209      *   <li>console_hd_class - contributed by Console.CHROME_CLASSES</li>
       
   210      *   <li>console_title_class - contributed by Console.CHROME_CLASSES</li>
       
   211      *   <li>str_collapse - pulled from attribute strings.collapse</li>
       
   212      *   <li>str_title - pulled from attribute strings.title</li>
       
   213      * </ul>
       
   214      *
       
   215      * @property Console.HEADER_TEMPLATE
       
   216      * @type String
       
   217      * @static
       
   218      */
       
   219     HEADER_TEMPLATE :
       
   220         '<div class="{console_hd_class}">'+
       
   221             '<h4 class="{console_title_class}">{str_title}</h4>'+
       
   222             '<button type="button" class="'+
       
   223                 '{console_button_class} {console_collapse_class}">{str_collapse}'+
       
   224             '</button>'+
       
   225         '</div>',
       
   226 
       
   227     /**
       
   228      * Markup template used to generate the DOM structure for the Console body
       
   229      * (where the messages are inserted) when it is rendered.  The template
       
   230      * includes only the {placeholder} &quot;console_bd_class&quot;, which is
       
   231      * constributed by Console.CHROME_CLASSES.
       
   232      *
       
   233      * @property Console.BODY_TEMPLATE
       
   234      * @type String
       
   235      * @static
       
   236      */
       
   237     BODY_TEMPLATE : '<div class="{console_bd_class}"></div>',
       
   238 
       
   239     /**
       
   240      * Markup template used to generate the DOM structure for the footer
       
   241      * section of the Console when it is rendered.  The template includes
       
   242      * many of the {placeholder}s from Console.CHROME_CLASSES as well as:
       
   243      *
       
   244      * <ul>
       
   245      *   <li>id_guid - generated unique id, relates the label and checkbox</li>
       
   246      *   <li>str_pause - pulled from attribute strings.pause</li>
       
   247      *   <li>str_clear - pulled from attribute strings.clear</li>
       
   248      * </ul>
       
   249      *
       
   250      * @property Console.FOOTER_TEMPLATE
       
   251      * @type String
       
   252      * @static
       
   253      */
       
   254     FOOTER_TEMPLATE :
       
   255         '<div class="{console_ft_class}">'+
       
   256             '<div class="{console_controls_class}">'+
       
   257                 '<label for="{id_guid}" class="{console_pause_label_class}">'+
       
   258                     '<input type="checkbox" class="{console_checkbox_class} '+
       
   259                         '{console_pause_class}" value="1" id="{id_guid}"> '+
       
   260                     '{str_pause}</label>' +
       
   261                 '<button type="button" class="'+
       
   262                     '{console_button_class} {console_clear_class}">{str_clear}'+
       
   263                 '</button>'+
       
   264             '</div>'+
       
   265         '</div>',
       
   266 
       
   267     /**
       
   268      * Default markup template used to create the DOM structure for Console
       
   269      * entries. The markup contains {placeholder}s for content and classes
       
   270      * that are replaced via Y.substitute.  The default template contains
       
   271      * the {placeholder}s identified in Console.ENTRY_CLASSES as well as the
       
   272      * following placeholders that will be populated by the log entry data:
       
   273      *
       
   274      * <ul>
       
   275      *   <li>cat_class</li>
       
   276      *   <li>src_class</li>
       
   277      *   <li>label</li>
       
   278      *   <li>totalTime</li>
       
   279      *   <li>elapsedTime</li>
       
   280      *   <li>localTime</li>
       
   281      *   <li>sourceAndDetail</li>
       
   282      *   <li>message</li>
       
   283      * </ul>
       
   284      *
       
   285      * @property Console.ENTRY_TEMPLATE
       
   286      * @type String
       
   287      * @static
       
   288      */
       
   289     ENTRY_TEMPLATE :
       
   290         '<div class="{entry_class} {cat_class} {src_class}">'+
       
   291             '<p class="{entry_meta_class}">'+
       
   292                 '<span class="{entry_src_class}">'+
       
   293                     '{sourceAndDetail}'+
       
   294                 '</span>'+
       
   295                 '<span class="{entry_cat_class}">'+
       
   296                     '{label}</span>'+
       
   297                 '<span class="{entry_time_class}">'+
       
   298                     ' {totalTime}ms (+{elapsedTime}) {localTime}'+
       
   299                 '</span>'+
       
   300             '</p>'+
       
   301             '<pre class="{entry_content_class}">{message}</pre>'+
       
   302         '</div>',
       
   303 
       
   304     /**
       
   305      * Static property used to define the default attribute configuration of
       
   306      * the Widget.
       
   307      *
       
   308      * @property Console.ATTRS
       
   309      * @Type Object
       
   310      * @static
       
   311      */
       
   312     ATTRS : {
       
   313 
       
   314         /**
       
   315          * Name of the custom event that will communicate log messages.
       
   316          *
       
   317          * @attribute logEvent
       
   318          * @type String
       
   319          * @default "yui:log"
       
   320          */
       
   321         logEvent : {
       
   322             value : 'yui:log',
       
   323             writeOnce : true,
       
   324             validator : isString
       
   325         },
       
   326 
       
   327         /**
       
   328          * Object that will emit the log events.  By default the YUI instance.
       
   329          * To have a single Console capture events from all YUI instances, set
       
   330          * this to the Y.Global object.
       
   331          *
       
   332          * @attribute logSource
       
   333          * @type EventTarget
       
   334          * @default Y
       
   335          */
       
   336         logSource : {
       
   337             value : Y,
       
   338             writeOnce : true,
       
   339             validator : function (v) {
       
   340                 return v && Y.Lang.isFunction(v.on);
       
   341             }
       
   342         },
       
   343 
       
   344         /**
       
   345          * Collection of strings used to label elements in the Console UI.
       
   346          * Default collection contains the following name:value pairs:
       
   347          *
       
   348          * <ul>
       
   349          *   <li>title : &quot;Log Console&quot;</li>
       
   350          *   <li>pause : &quot;Pause&quot;</li>
       
   351          *   <li>clear : &quot;Clear&quot;</li>
       
   352          *   <li>collapse : &quot;Collapse&quot;</li>
       
   353          *   <li>expand : &quot;Expand&quot;</li>
       
   354          * </ul>
       
   355          *
       
   356          * @attribute strings
       
   357          * @type Object
       
   358          */
       
   359         strings : {
       
   360             value : {
       
   361                 title : "Log Console",
       
   362                 pause : "Pause",
       
   363                 clear : "Clear",
       
   364                 collapse : "Collapse",
       
   365                 expand   : "Expand"
       
   366             }
       
   367         },
       
   368 
       
   369         /**
       
   370          * Boolean to pause the outputting of new messages to the console.
       
   371          * When paused, messages will accumulate in the buffer.
       
   372          *
       
   373          * @attribute paused
       
   374          * @type boolean
       
   375          * @default false
       
   376          */
       
   377         paused : {
       
   378             value : false,
       
   379             validator : L.isBoolean
       
   380         },
       
   381 
       
   382         /**
       
   383          * If a category is not specified in the Y.log(..) statement, this
       
   384          * category will be used. Categories &quot;info&quot;,
       
   385          * &quot;warn&quot;, and &quot;error&quot; are also called log level.
       
   386          *
       
   387          * @attribute defaultCategory
       
   388          * @type String
       
   389          * @default "info"
       
   390          */
       
   391         defaultCategory : {
       
   392             value : INFO,
       
   393             validator : isString
       
   394         },
       
   395 
       
   396         /**
       
   397          * If a source is not specified in the Y.log(..) statement, this
       
   398          * source will be used.
       
   399          *
       
   400          * @attribute defaultSource
       
   401          * @type String
       
   402          * @default "global"
       
   403          */
       
   404         defaultSource   : {
       
   405             value : 'global',
       
   406             validator : isString
       
   407         },
       
   408 
       
   409         /**
       
   410          * Markup template used to create the DOM structure for Console entries.
       
   411          *
       
   412          * @attribute entryTemplate
       
   413          * @type String
       
   414          * @default (see Console.ENTRY_TEMPLATE)
       
   415          */
       
   416         entryTemplate : {
       
   417             value : '',
       
   418             validator : isString
       
   419         },
       
   420 
       
   421         /**
       
   422          * Minimum entry log level to render into the Console.  The initial
       
   423          * logLevel value for all Console instances defaults from the
       
   424          * Y.config.logLevel YUI configuration, or Console.LOG_LEVEL_INFO if
       
   425          * that configuration is not set.
       
   426          *
       
   427          * Possible values are &quot;info&quot;, &quot;warn&quot;,
       
   428          * &quot;error&quot; (case insensitive), or their corresponding statics
       
   429          * Console.LOG_LEVEL_INFO and so on.
       
   430          *
       
   431          * @attribute logLevel
       
   432          * @type String
       
   433          * @default Y.config.logLevel or Console.LOG_LEVEL_INFO
       
   434          */
       
   435         logLevel : {
       
   436             value : Y.config.logLevel || INFO,
       
   437             setter : function (v) {
       
   438                 return this._setLogLevel(v);
       
   439             }
       
   440         },
       
   441 
       
   442         /**
       
   443          * Millisecond timeout between iterations of the print loop, moving
       
   444          * entries from the buffer to the UI.
       
   445          *
       
   446          * @attribute printTimeout
       
   447          * @type Number
       
   448          * @default 100
       
   449          */
       
   450         printTimeout : {
       
   451             value : 100,
       
   452             validator : isNumber
       
   453         },
       
   454 
       
   455         /**
       
   456          * Maximum number of entries printed in each iteration of the print
       
   457          * loop. This is used to prevent excessive logging locking the page UI.
       
   458          *
       
   459          * @attribute printLimit
       
   460          * @type Number
       
   461          * @default 50
       
   462          */
       
   463         printLimit : {
       
   464             value : 50,
       
   465             validator : isNumber
       
   466         },
       
   467 
       
   468         /**
       
   469          * Maximum number of Console entries allowed in the Console body at one
       
   470          * time.  This is used to keep acquired messages from exploding the
       
   471          * DOM tree and impacting page performance.
       
   472          *
       
   473          * @attribute consoleLimit
       
   474          * @type Number
       
   475          * @default 300
       
   476          */
       
   477         consoleLimit : {
       
   478             value : 300,
       
   479             validator : isNumber
       
   480         },
       
   481 
       
   482         /**
       
   483          * New entries should display at the top of the Console or the bottom?
       
   484          *
       
   485          * @attribute newestOnTop
       
   486          * @type Boolean
       
   487          * @default true
       
   488          */
       
   489         newestOnTop : {
       
   490             value : true
       
   491         },
       
   492 
       
   493         /**
       
   494          * When new entries are added to the Console UI, should they be
       
   495          * scrolled into view?
       
   496          *
       
   497          * @attribute scrollIntoView
       
   498          * @type Boolean
       
   499          * @default true
       
   500          */
       
   501         scrollIntoView : {
       
   502             value : true
       
   503         },
       
   504 
       
   505         /**
       
   506          * The baseline time for this Console instance, used to measure elapsed
       
   507          * time from the moment the console module is <code>use</code>d to the
       
   508          * moment each new entry is logged (not rendered).
       
   509          *
       
   510          * This value is reset by the instance method myConsole.reset().
       
   511          *
       
   512          * @attribute startTime
       
   513          * @type Date
       
   514          * @default The moment the console module is <code>use</code>d
       
   515          */
       
   516         startTime : {
       
   517             value : new Date()
       
   518         },
       
   519 
       
   520         /**
       
   521          * The precise time the last entry was logged.  Used to measure elapsed
       
   522          * time between log messages.
       
   523          *
       
   524          * @attribute lastTime
       
   525          * @type Date
       
   526          * @default The moment the console module is <code>use</code>d
       
   527          */
       
   528         lastTime : {
       
   529             value : new Date(),
       
   530             readOnly: true
       
   531         },
       
   532 
       
   533         /**
       
   534          * Controls the collapsed state of the Console
       
   535          *
       
   536          * @attribute collapsed
       
   537          * @type Boolean
       
   538          * @default false
       
   539          */
       
   540         collapsed : {
       
   541             value : false
       
   542         },
       
   543 
       
   544         /**
       
   545         * String with units, or number, representing the height of the Console,
       
   546         * inclusive of header and footer. If a number is provided, the default
       
   547         * unit, defined by Widget's DEF_UNIT, property is used.
       
   548         *
       
   549         * @attribute height
       
   550         * @default "300px"
       
   551         * @type {String | Number}
       
   552         */
       
   553         height: {
       
   554             value: "300px"
       
   555         },
       
   556 
       
   557         /**
       
   558         * String with units, or number, representing the width of the Console.
       
   559         * If a number is provided, the default unit, defined by Widget's
       
   560         * DEF_UNIT, property is used.
       
   561         *
       
   562         * @attribute width
       
   563         * @default "300px"
       
   564         * @type {String | Number}
       
   565         */
       
   566         width: {
       
   567             value: "300px"
       
   568         }
       
   569     }
       
   570 
       
   571 });
       
   572 
       
   573 Y.extend(Console,Y.Widget,{
       
   574 
       
   575     /**
       
   576      * Category to prefix all event subscriptions to allow for ease of detach
       
   577      * during destroy.
       
   578      *
       
   579      * @property _evtCat
       
   580      * @type string
       
   581      * @protected
       
   582      */
       
   583     _evtCat : null,
       
   584 
       
   585     /**
       
   586      * Reference to the Node instance containing the header contents.
       
   587      *
       
   588      * @property _head
       
   589      * @type Node
       
   590      * @default null
       
   591      * @protected
       
   592      */
       
   593     _head    : null,
       
   594 
       
   595     /**
       
   596      * Reference to the Node instance that will house the console messages.
       
   597      *
       
   598      * @property _body
       
   599      * @type Node
       
   600      * @default null
       
   601      * @protected
       
   602      */
       
   603     _body    : null,
       
   604 
       
   605     /**
       
   606      * Reference to the Node instance containing the footer contents.
       
   607      *
       
   608      * @property _foot
       
   609      * @type Node
       
   610      * @default null
       
   611      * @protected
       
   612      */
       
   613     _foot    : null,
       
   614 
       
   615     /**
       
   616      * Holds the object API returned from <code>Y.later</code> for the print
       
   617      * loop interval.
       
   618      *
       
   619      * @property _printLoop
       
   620      * @type Object
       
   621      * @default null
       
   622      * @protected
       
   623      */
       
   624     _printLoop : null,
       
   625 
       
   626     /**
       
   627      * Array of normalized message objects awaiting printing.
       
   628      *
       
   629      * @property buffer
       
   630      * @type Array
       
   631      * @default null
       
   632      * @protected
       
   633      */
       
   634     buffer   : null,
       
   635 
       
   636     /**
       
   637      * Wrapper for <code>Y.log</code>.
       
   638      *
       
   639      * @method log
       
   640      * @param arg* {MIXED} (all arguments passed through to <code>Y.log</code>)
       
   641      */
       
   642     log : function () {
       
   643         return Y.log.apply(Y,arguments);
       
   644     },
       
   645 
       
   646     /**
       
   647      * Clear the console of messages and flush the buffer of pending messages.
       
   648      *
       
   649      * @method clearConsole
       
   650      * @chainable
       
   651      */
       
   652     clearConsole : function () {
       
   653         // TODO: clear event listeners from console contents
       
   654         this._body.set(INNER_HTML,'');
       
   655 
       
   656         this._cancelPrintLoop();
       
   657 
       
   658         this.buffer = [];
       
   659 
       
   660         return this;
       
   661     },
       
   662 
       
   663     /**
       
   664      * Clears the console and resets internal timers.
       
   665      *
       
   666      * @method reset
       
   667      * @chainable
       
   668      */
       
   669     reset : function () {
       
   670         this.fire(RESET);
       
   671         
       
   672         return this;
       
   673     },
       
   674 
       
   675     /**
       
   676      * Collapses the body and footer.
       
   677      *
       
   678      * @method collapse
       
   679      */
       
   680     collapse : function () {
       
   681         this.set(COLLAPSED, true);
       
   682     },
       
   683 
       
   684     /**
       
   685      * Expands the body and footer if collapsed.
       
   686      *
       
   687      * @method expand
       
   688      */
       
   689     expand : function () {
       
   690         this.set(COLLAPSED, false);
       
   691     },
       
   692 
       
   693     /**
       
   694      * Outputs buffered messages to the console UI.  This is typically called
       
   695      * from a scheduled interval until the buffer is empty (referred to as the
       
   696      * print loop).  The number of buffered messages output to the Console is
       
   697      * limited to the number provided as an argument.  If no limit is passed,
       
   698      * all buffered messages are rendered.
       
   699      * 
       
   700      * @method printBuffer
       
   701      * @param limit {Number} (optional) max number of buffered entries to write
       
   702      * @chainable
       
   703      */
       
   704     printBuffer: function (limit) {
       
   705         var messages    = this.buffer,
       
   706             debug       = Y.config.debug,
       
   707             entries     = [],
       
   708             consoleLimit= this.get('consoleLimit'),
       
   709             newestOnTop = this.get('newestOnTop'),
       
   710             anchor      = newestOnTop ? this._body.get('firstChild') : null,
       
   711             i;
       
   712 
       
   713         if (messages.length > consoleLimit) {
       
   714             messages.splice(0, messages.length - consoleLimit);
       
   715         }
       
   716 
       
   717         limit = Math.min(messages.length, (limit || messages.length));
       
   718         
       
   719         // turn off logging system
       
   720         Y.config.debug = false;
       
   721 
       
   722         if (!this.get(PAUSED) && this.get('rendered')) {
       
   723 
       
   724             for (i = 0; i < limit && messages.length; ++i) {
       
   725                 entries[i] = this._createEntryHTML(messages.shift());
       
   726             }
       
   727 
       
   728             if (!messages.length) {
       
   729                 this._cancelPrintLoop();
       
   730             }
       
   731 
       
   732             if (newestOnTop) {
       
   733                 entries.reverse();
       
   734             }
       
   735 
       
   736             this._body.insertBefore(create(entries.join('')), anchor);
       
   737 
       
   738             if (this.get('scrollIntoView')) {
       
   739                 this.scrollToLatest();
       
   740             }
       
   741 
       
   742             this._trimOldEntries();
       
   743 
       
   744         }
       
   745 
       
   746         // restore logging system
       
   747         Y.config.debug = debug;
       
   748 
       
   749         return this;
       
   750     },
       
   751 
       
   752     
       
   753     /**
       
   754      * Constructor code.  Set up the buffer and entry template, publish
       
   755      * internal events, and subscribe to the configured logEvent.
       
   756      * 
       
   757      * @method initializer
       
   758      * @protected
       
   759      */
       
   760     initializer : function () {
       
   761         this._evtCat = Y.stamp(this) + '|';
       
   762 
       
   763         this.buffer = [];
       
   764 
       
   765         if (!this.get(ENTRY_TEMPLATE)) {
       
   766             this.set(ENTRY_TEMPLATE,Console.ENTRY_TEMPLATE);
       
   767         }
       
   768 
       
   769         this.get('logSource').on(this._evtCat +
       
   770             this.get('logEvent'),Y.bind("_onLogEvent",this));
       
   771 
       
   772         /**
       
   773          * Transfers a received message to the print loop buffer.  Default
       
   774          * behavior defined in _defEntryFn.
       
   775          *
       
   776          * @event entry
       
   777          * @param event {Event.Facade} An Event Facade object with the following attribute specific properties added:
       
   778          *  <dl>
       
   779          *      <dt>message</dt>
       
   780          *          <dd>The message data normalized into an object literal (see _normalizeMessage)</dd>
       
   781          *  </dl>
       
   782          * @preventable _defEntryFn
       
   783          */
       
   784         this.publish(ENTRY, { defaultFn: this._defEntryFn });
       
   785 
       
   786         /**
       
   787          * Triggers the reset behavior via the default logic in _defResetFn.
       
   788          *
       
   789          * @event reset
       
   790          * @param event {Event.Facade} Event Facade object
       
   791          * @preventable _defResetFn
       
   792          */
       
   793         this.publish(RESET, { defaultFn: this._defResetFn });
       
   794 
       
   795         this.after('rendered', this._schedulePrint);
       
   796     },
       
   797 
       
   798     /**
       
   799      * Tears down the instance, flushing event subscriptions and purging the UI.
       
   800      *
       
   801      * @method destructor
       
   802      * @protected
       
   803      */
       
   804     destructor : function () {
       
   805         var bb = this.get('boundingBox');
       
   806 
       
   807         this._cancelPrintLoop();
       
   808 
       
   809         this.get('logSource').detach(this._evtCat + '*');
       
   810         
       
   811         Y.Event.purgeElement(bb, true);
       
   812 
       
   813         bb.set('innerHTML','');
       
   814     },
       
   815 
       
   816     /**
       
   817      * Generate the Console UI.
       
   818      *
       
   819      * @method renderUI
       
   820      * @protected
       
   821      */
       
   822     renderUI : function () {
       
   823         this._initHead();
       
   824         this._initBody();
       
   825         this._initFoot();
       
   826     },
       
   827 
       
   828     /**
       
   829      * Sync the UI state to the current attribute state.
       
   830      *
       
   831      * @method syncUI
       
   832      */
       
   833     syncUI : function () {
       
   834         this._uiUpdatePaused(this.get(PAUSED));
       
   835         this._uiUpdateCollapsed(this.get(COLLAPSED));
       
   836         this._uiSetHeight(this.get(HEIGHT));
       
   837     },
       
   838 
       
   839     /**
       
   840      * Set up event listeners to wire up the UI to the internal state.
       
   841      *
       
   842      * @method bindUI
       
   843      * @protected
       
   844      */
       
   845     bindUI : function () {
       
   846         this.get(CONTENT_BOX).query('button.'+C_COLLAPSE).
       
   847             on(CLICK,this._onCollapseClick,this);
       
   848 
       
   849         this.get(CONTENT_BOX).query('input[type=checkbox].'+C_PAUSE).
       
   850             on(CLICK,this._onPauseClick,this);
       
   851 
       
   852         this.get(CONTENT_BOX).query('button.'+C_CLEAR).
       
   853             on(CLICK,this._onClearClick,this);
       
   854         
       
   855         // Attribute changes
       
   856         this.after(this._evtCat + 'stringsChange',
       
   857             this._afterStringsChange);
       
   858         this.after(this._evtCat + 'pausedChange',
       
   859             this._afterPausedChange);
       
   860         this.after(this._evtCat + 'consoleLimitChange',
       
   861             this._afterConsoleLimitChange);
       
   862         this.after(this._evtCat + 'collapsedChange',
       
   863             this._afterCollapsedChange);
       
   864     },
       
   865 
       
   866     
       
   867     /**
       
   868      * Create the DOM structure for the header elements.
       
   869      *
       
   870      * @method _initHead
       
   871      * @protected
       
   872      */
       
   873     _initHead : function () {
       
   874         var cb   = this.get(CONTENT_BOX),
       
   875             info = merge(Console.CHROME_CLASSES, {
       
   876                         str_collapse : this.get('strings.collapse'),
       
   877                         str_title : this.get('strings.title')
       
   878                     });
       
   879 
       
   880         this._head = create(substitute(Console.HEADER_TEMPLATE,info));
       
   881 
       
   882         cb.insertBefore(this._head,cb.get('firstChild'));
       
   883     },
       
   884 
       
   885     /**
       
   886      * Create the DOM structure for the console body&#8212;where messages are
       
   887      * rendered.
       
   888      *
       
   889      * @method _initBody
       
   890      * @protected
       
   891      */
       
   892     _initBody : function () {
       
   893         this._body = create(substitute(
       
   894                             Console.BODY_TEMPLATE,
       
   895                             Console.CHROME_CLASSES));
       
   896 
       
   897         this.get(CONTENT_BOX).appendChild(this._body);
       
   898     },
       
   899 
       
   900     /**
       
   901      * Create the DOM structure for the footer elements.
       
   902      *
       
   903      * @method _initFoot
       
   904      * @protected
       
   905      */
       
   906     _initFoot : function () {
       
   907         var info = merge(Console.CHROME_CLASSES, {
       
   908                 id_guid   : Y.guid(),
       
   909                 str_pause : this.get('strings.pause'),
       
   910                 str_clear : this.get('strings.clear')
       
   911             });
       
   912 
       
   913         this._foot = create(substitute(Console.FOOTER_TEMPLATE,info));
       
   914 
       
   915         this.get(CONTENT_BOX).appendChild(this._foot);
       
   916     },
       
   917 
       
   918     /**
       
   919      * Determine if incoming log messages are within the configured logLevel
       
   920      * to be buffered for printing.
       
   921      *
       
   922      * @method _isInLogLevel
       
   923      * @protected
       
   924      */
       
   925     _isInLogLevel : function (e) {
       
   926         var cat = e.cat, lvl = this.get('logLevel');
       
   927 
       
   928         if (lvl !== INFO) {
       
   929             cat = cat || INFO;
       
   930 
       
   931             if (isString(cat)) {
       
   932                 cat = cat.toLowerCase();
       
   933             }
       
   934 
       
   935             if ((cat === WARN && lvl === ERROR) ||
       
   936                 (cat === INFO && lvl !== INFO)) {
       
   937                 return false;
       
   938             }
       
   939         }
       
   940 
       
   941         return true;
       
   942     },
       
   943 
       
   944     /**
       
   945      * Create a log entry message from the inputs including the following keys:
       
   946      * <ul>
       
   947      *     <li>time - this moment</li>
       
   948      *     <li>message - leg message</li>
       
   949      *     <li>category - logLevel or custom category for the message</li>
       
   950      *     <li>source - when provided, the widget or util calling Y.log</li>
       
   951      *     <li>sourceAndDetail - same as source but can include instance info</li>
       
   952      *     <li>label - logLevel/category label for the entry</li>
       
   953      *     <li>localTime - readable version of time</li>
       
   954      *     <li>elapsedTime - ms since last entry</li>
       
   955      *     <li>totalTime - ms since Console was instantiated or reset</li>
       
   956      * </ul>
       
   957      *
       
   958      * @method _normalizeMessage
       
   959      * @param e {Event} custom event containing the log message
       
   960      * @return Object the message object
       
   961      * @protected
       
   962      */
       
   963     _normalizeMessage : function (e) {
       
   964 
       
   965         var msg = e.msg,
       
   966             cat = e.cat,
       
   967             src = e.src,
       
   968 
       
   969             m = {
       
   970                 time            : new Date(),
       
   971                 message         : msg,
       
   972                 category        : cat || this.get('defaultCategory'),
       
   973                 sourceAndDetail : src || this.get('defaultSource'),
       
   974                 source          : null,
       
   975                 label           : null,
       
   976                 localTime       : null,
       
   977                 elapsedTime     : null,
       
   978                 totalTime       : null
       
   979             };
       
   980 
       
   981         // Extract m.source "Foo" from m.sourceAndDetail "Foo bar baz"
       
   982         m.source          = RE_INLINE_SOURCE.test(m.sourceAndDetail) ?
       
   983                                 RegExp.$1 : m.sourceAndDetail;
       
   984         m.label           = m.category;
       
   985         m.localTime       = m.time.toLocaleTimeString ? 
       
   986                             m.time.toLocaleTimeString() : (m.time + '');
       
   987         m.elapsedTime     = m.time - this.get(LAST_TIME);
       
   988         m.totalTime       = m.time - this.get(START_TIME);
       
   989 
       
   990         this._set(LAST_TIME,m.time);
       
   991 
       
   992         return m;
       
   993     },
       
   994 
       
   995     /**
       
   996      * Sets an interval for buffered messages to be output to the console.
       
   997      *
       
   998      * @method _schedulePrint
       
   999      * @protected
       
  1000      */
       
  1001     _schedulePrint : function () {
       
  1002         if (!this._printLoop && !this.get(PAUSED) && this.get('rendered')) {
       
  1003             this._printLoop = Y.later(
       
  1004                                 this.get('printTimeout'),
       
  1005                                 this, this.printBuffer,
       
  1006                                 this.get('printLimit'), true);
       
  1007         }
       
  1008     },
       
  1009 
       
  1010     /**
       
  1011      * Translates message meta into the markup for a console entry.
       
  1012      *
       
  1013      * @method _createEntryHTML
       
  1014      * @param m {Object} object literal containing normalized message metadata
       
  1015      * @return String
       
  1016      * @protected
       
  1017      */
       
  1018     _createEntryHTML : function (m) {
       
  1019         m = merge(
       
  1020                 this._htmlEscapeMessage(m),
       
  1021                 Console.ENTRY_CLASSES,
       
  1022                 {
       
  1023                     cat_class : this.getClassName(ENTRY,m.category),
       
  1024                     src_class : this.getClassName(ENTRY,m.source)
       
  1025                 });
       
  1026 
       
  1027         return this.get('entryTemplate').replace(/\{(\w+)\}/g,
       
  1028             function (_,token) {
       
  1029                 return token in m ? m[token] : '';
       
  1030             });
       
  1031     },
       
  1032 
       
  1033     /**
       
  1034      * Scrolls to the most recent entry
       
  1035      *
       
  1036      * @method scrollToLatest
       
  1037      * @chainable
       
  1038      */
       
  1039     scrollToLatest : function () {
       
  1040         var scrollTop = this.get('newestOnTop') ?
       
  1041                             0 :
       
  1042                             this._body.get('scrollHeight');
       
  1043 
       
  1044         this._body.set('scrollTop', scrollTop);
       
  1045     },
       
  1046 
       
  1047     /**
       
  1048      * Performs HTML escaping on strings in the message object.
       
  1049      *
       
  1050      * @method _htmlEscapeMessage
       
  1051      * @param m {Object} the normalized message object
       
  1052      * @return Object a clone of the message object with proper escapement
       
  1053      * @protected
       
  1054      */
       
  1055     _htmlEscapeMessage : function (m) {
       
  1056         m = Y.clone(m);
       
  1057         m.message         = this._encodeHTML(m.message);
       
  1058         m.label           = this._encodeHTML(m.label);
       
  1059         m.source          = this._encodeHTML(m.source);
       
  1060         m.sourceAndDetail = this._encodeHTML(m.sourceAndDetail);
       
  1061         m.category        = this._encodeHTML(m.category);
       
  1062 
       
  1063         return m;
       
  1064     },
       
  1065 
       
  1066     /**
       
  1067      * Removes the oldest message entries from the UI to maintain the limit
       
  1068      * specified in the consoleLimit configuration.
       
  1069      *
       
  1070      * @method _trimOldEntries
       
  1071      * @protected
       
  1072      */
       
  1073     _trimOldEntries : function () {
       
  1074         // Turn off the logging system for the duration of this operation
       
  1075         // to prevent an infinite loop
       
  1076         Y.config.debug = false;
       
  1077 
       
  1078         var bd = this._body,
       
  1079             limit = this.get('consoleLimit'),
       
  1080             debug = Y.config.debug,
       
  1081             entries,e,i,l;
       
  1082 
       
  1083         if (bd) {
       
  1084             entries = bd.queryAll(DOT+C_ENTRY);
       
  1085             l = entries.size() - limit;
       
  1086 
       
  1087             if (l > 0) {
       
  1088                 if (this.get('newestOnTop')) {
       
  1089                     i = limit;
       
  1090                     l = entries.size();
       
  1091                 } else {
       
  1092                     i = 0;
       
  1093                 }
       
  1094 
       
  1095                 this._body.setStyle('display','none');
       
  1096 
       
  1097                 for (;i < l; ++i) {
       
  1098                     e = entries.item(i);
       
  1099                     if (e) {
       
  1100                         e.get('parentNode').removeChild(e);
       
  1101                     }
       
  1102                 }
       
  1103 
       
  1104                 this._body.setStyle('display','');
       
  1105             }
       
  1106 
       
  1107         }
       
  1108 
       
  1109         Y.config.debug = debug;
       
  1110     },
       
  1111 
       
  1112     /**
       
  1113      * Returns the input string with ampersands (&amp;), &lt, and &gt; encoded
       
  1114      * as HTML entities.
       
  1115      *
       
  1116      * @method _encodeHTML
       
  1117      * @param s {String} the raw string
       
  1118      * @return String the encoded string
       
  1119      * @protected
       
  1120      */
       
  1121     _encodeHTML : function (s) {
       
  1122         return isString(s) ?
       
  1123             s.replace(RE_AMP,ESC_AMP).
       
  1124               replace(RE_LT, ESC_LT).
       
  1125               replace(RE_GT, ESC_GT) :
       
  1126             s;
       
  1127     },
       
  1128 
       
  1129     /**
       
  1130      * Clears the timeout for printing buffered messages.
       
  1131      *
       
  1132      * @method _cancelPrintLoop
       
  1133      * @protected
       
  1134      */
       
  1135     _cancelPrintLoop : function () {
       
  1136         if (this._printLoop) {
       
  1137             this._printLoop.cancel();
       
  1138             this._printLoop = null;
       
  1139         }
       
  1140     },
       
  1141 
       
  1142     /**
       
  1143      * Event handler for clicking on the Pause checkbox to update the paused
       
  1144      * attribute.
       
  1145      *
       
  1146      * @method _onPauseClick
       
  1147      * @param e {Event} DOM event facade for the click event
       
  1148      * @protected
       
  1149      */
       
  1150     _onPauseClick : function (e) {
       
  1151         this.set(PAUSED,e.target.get(CHECKED));
       
  1152     },
       
  1153 
       
  1154     /**
       
  1155      * Event handler for clicking on the Clear button.  Pass-through to
       
  1156      * <code>this.clearConsole()</code>.
       
  1157      *
       
  1158      * @method _onClearClick
       
  1159      * @param e {Event} DOM event facade for the click event
       
  1160      * @protected
       
  1161      */
       
  1162     _onClearClick : function (e) {
       
  1163         this.clearConsole();
       
  1164     },
       
  1165 
       
  1166     /**
       
  1167      * Event handler for clicking on the Collapse/Expand button. Sets the
       
  1168      * &quot;collapsed&quot; attribute accordingly.
       
  1169      *
       
  1170      * @method _onCollapseClick
       
  1171      * @param e {Event} DOM event facade for the click event
       
  1172      * @protected
       
  1173      */
       
  1174     _onCollapseClick : function (e) {
       
  1175         this.set(COLLAPSED, !this.get(COLLAPSED));
       
  1176     },
       
  1177 
       
  1178 
       
  1179     /**
       
  1180      * Setter method for logLevel attribute.  Acceptable values are
       
  1181      * &quot;error&quot, &quot;warn&quot, and &quot;info&quot (case
       
  1182      * insensitive).  Other values are treated as &quot;info&quot;.
       
  1183      *
       
  1184      * @method _setLogLevel
       
  1185      * @param v {String} the desired log level
       
  1186      * @return String One of Console.LOG_LEVEL_INFO, _WARN, or _ERROR
       
  1187      * @protected
       
  1188      */
       
  1189     _setLogLevel : function (v) {
       
  1190         if (isString(v)) {
       
  1191             v = v.toLowerCase();
       
  1192         }
       
  1193         
       
  1194         return (v === WARN || v === ERROR) ? v : INFO;
       
  1195     },
       
  1196 
       
  1197     /**
       
  1198      * Set the height of the Console container.  Set the body height to the difference between the configured height and the calculated heights of the header and footer.
       
  1199      * Overrides Widget.prototype._uiSetHeight.
       
  1200      *
       
  1201      * @method _uiSetHeight
       
  1202      * @param v {String|Number} the new height
       
  1203      * @protected
       
  1204      */
       
  1205     _uiSetHeight : function (v) {
       
  1206         Console.superclass._uiSetHeight.apply(this,arguments);
       
  1207 
       
  1208         if (this._head && this._foot) {
       
  1209             var h = this.get('boundingBox').get('offsetHeight') -
       
  1210                     this._head.get('offsetHeight') -
       
  1211                     this._foot.get('offsetHeight');
       
  1212 
       
  1213             this._body.setStyle(HEIGHT,h+'px');
       
  1214         }
       
  1215     },
       
  1216 
       
  1217     /**
       
  1218      * Updates the UI if changes are made to any of the strings in the strings
       
  1219      * attribute.
       
  1220      *
       
  1221      * @method _afterStringsChange
       
  1222      * @param e {Event} Custom event for the attribute change
       
  1223      * @protected
       
  1224      */
       
  1225     _afterStringsChange : function (e) {
       
  1226         var prop   = e.subAttrName ? e.subAttrName.split(DOT)[1] : null,
       
  1227             cb     = this.get(CONTENT_BOX),
       
  1228             before = e.prevVal,
       
  1229             after  = e.newVal,
       
  1230             el;
       
  1231 
       
  1232         if ((!prop || prop === TITLE) && before.title !== after.title) {
       
  1233             el = cb.query(DOT+C_CONSOLE_TITLE);
       
  1234             if (el) {
       
  1235                 el.set(INNER_HTML,after.title);
       
  1236             }
       
  1237         }
       
  1238 
       
  1239         if ((!prop || prop === PAUSE) && before.pause !== after.pause) {
       
  1240             el = cb.query(DOT+C_PAUSE_LABEL);
       
  1241             if (el) {
       
  1242                 el.set(INNER_HTML,after.pause);
       
  1243             }
       
  1244         }
       
  1245 
       
  1246         if ((!prop || prop === CLEAR) && before.clear !== after.clear) {
       
  1247             el = cb.query(DOT+C_CLEAR);
       
  1248             if (el) {
       
  1249                 el.set('value',after.clear);
       
  1250             }
       
  1251         }
       
  1252     },
       
  1253 
       
  1254     /**
       
  1255      * Updates the UI and schedules or cancels the print loop.
       
  1256      *
       
  1257      * @method _afterPausedChange
       
  1258      * @param e {Event} Custom event for the attribute change
       
  1259      * @protected
       
  1260      */
       
  1261     _afterPausedChange : function (e) {
       
  1262         var paused = e.newVal;
       
  1263 
       
  1264         if (e.src !== Y.Widget.SRC_UI) {
       
  1265             this._uiUpdatePaused(paused);
       
  1266         }
       
  1267 
       
  1268         if (!paused) {
       
  1269             this._schedulePrint();
       
  1270         } else if (this._printLoop) {
       
  1271             this._cancelPrintLoop();
       
  1272         }
       
  1273     },
       
  1274 
       
  1275     /**
       
  1276      * Checks or unchecks the paused checkbox
       
  1277      *
       
  1278      * @method _uiUpdatePaused
       
  1279      * @param on {Boolean} the new checked state
       
  1280      * @protected
       
  1281      */
       
  1282     _uiUpdatePaused : function (on) {
       
  1283         var node = this._foot.queryAll('input[type=checkbox].'+C_PAUSE);
       
  1284 
       
  1285         if (node) {
       
  1286             node.set(CHECKED,on);
       
  1287         }
       
  1288     },
       
  1289 
       
  1290     /**
       
  1291      * Calls this._trimOldEntries() in response to changes in the configured
       
  1292      * consoleLimit attribute.
       
  1293      * 
       
  1294      * @method _afterConsoleLimitChange
       
  1295      * @param e {Event} Custom event for the attribute change
       
  1296      * @protected
       
  1297      */
       
  1298     _afterConsoleLimitChange : function () {
       
  1299         this._trimOldEntries();
       
  1300     },
       
  1301 
       
  1302 
       
  1303     /**
       
  1304      * Updates the className of the contentBox, which should trigger CSS to
       
  1305      * hide or show the body and footer sections depending on the new value.
       
  1306      *
       
  1307      * @method _afterCollapsedChange
       
  1308      * @param e {Event} Custom event for the attribute change
       
  1309      * @protected
       
  1310      */
       
  1311     _afterCollapsedChange : function (e) {
       
  1312         this._uiUpdateCollapsed(e.newVal);
       
  1313     },
       
  1314 
       
  1315     /**
       
  1316      * Updates the UI to reflect the new Collapsed state
       
  1317      *
       
  1318      * @method _uiUpdateCollapsed
       
  1319      * @param v {Boolean} true for collapsed, false for expanded
       
  1320      * @protected
       
  1321      */
       
  1322     _uiUpdateCollapsed : function (v) {
       
  1323         var cb     = this.get(CONTENT_BOX),
       
  1324             button = cb.queryAll('button.'+C_COLLAPSE),
       
  1325             method = v ? 'addClass' : 'removeClass',
       
  1326             str    = this.get('strings.'+(v ? 'expand' : 'collapse'));
       
  1327 
       
  1328         cb[method](C_COLLAPSED);
       
  1329 
       
  1330         if (button) {
       
  1331             button.set('innerHTML',str);
       
  1332         }
       
  1333 
       
  1334         if (!v) {
       
  1335             this._uiSetHeight(this.get(HEIGHT));
       
  1336         }
       
  1337     },
       
  1338 
       
  1339     /**
       
  1340      * Makes adjustments to the UI if needed when the Console is hidden or shown
       
  1341      *
       
  1342      * @method _afterVisibleChange
       
  1343      * @param e {Event} the visibleChange event
       
  1344      * @protected
       
  1345      */
       
  1346     _afterVisibleChange : function (e) {
       
  1347         Console.superclass._afterVisibleChange.apply(this,arguments);
       
  1348 
       
  1349         this._uiUpdateFromHideShow(e.newVal);
       
  1350     },
       
  1351 
       
  1352     /**
       
  1353      * Recalculates dimensions and updates appropriately when shown
       
  1354      *
       
  1355      * @method _uiUpdateFromHideShow
       
  1356      * @param v {Boolean} true for visible, false for hidden
       
  1357      * @protected
       
  1358      */
       
  1359     _uiUpdateFromHideShow : function (v) {
       
  1360         if (v) {
       
  1361             this._uiSetHeight(this.get(HEIGHT));
       
  1362         }
       
  1363     },
       
  1364 
       
  1365     /**
       
  1366      * Responds to log events by normalizing qualifying messages and passing
       
  1367      * them along through the entry event for buffering etc.
       
  1368      * 
       
  1369      * @method _onLogEvent
       
  1370      * @param msg {String} the log message
       
  1371      * @param cat {String} OPTIONAL the category or logLevel of the message
       
  1372      * @param src {String} OPTIONAL the source of the message (e.g. widget name)
       
  1373      * @protected
       
  1374      */
       
  1375     _onLogEvent : function (e) {
       
  1376 
       
  1377         if (!this.get(DISABLED) && this._isInLogLevel(e)) {
       
  1378 
       
  1379             var debug = Y.config.debug;
       
  1380 
       
  1381             /* TODO: needed? */
       
  1382             Y.config.debug = false;
       
  1383 
       
  1384             this.fire(ENTRY, {
       
  1385                 message : this._normalizeMessage(e)
       
  1386             });
       
  1387 
       
  1388             Y.config.debug = debug;
       
  1389         }
       
  1390     },
       
  1391 
       
  1392     /**
       
  1393      * Clears the console, resets the startTime attribute, enables and
       
  1394      * unpauses the widget.
       
  1395      *
       
  1396      * @method _defResetFn
       
  1397      * @protected
       
  1398      */
       
  1399     _defResetFn : function () {
       
  1400         this.clearConsole();
       
  1401         this.set(START_TIME,new Date());
       
  1402         this.set(DISABLED,false);
       
  1403         this.set(PAUSED,false);
       
  1404     },
       
  1405 
       
  1406     /**
       
  1407      * Buffers incoming message objects and schedules the printing.
       
  1408      *
       
  1409      * @method _defEntryFn
       
  1410      * @param e {Event} The Custom event carrying the message in its payload
       
  1411      * @protected
       
  1412      */
       
  1413     _defEntryFn : function (e) {
       
  1414         if (e.message) {
       
  1415             this.buffer.push(e.message);
       
  1416             this._schedulePrint();
       
  1417         }
       
  1418     }
       
  1419 
       
  1420 });
       
  1421 
       
  1422 Y.Console = Console;
       
  1423 
       
  1424 
       
  1425 }, '3.0.0b1' ,{requires:['substitute','widget']});