b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith/**
3cefe5340bfed84038e5816dbfbe7cec44f0df31Luke Smith * Console creates a visualization for messages logged through calls to a YUI
3cefe5340bfed84038e5816dbfbe7cec44f0df31Luke Smith * instance's <code>Y.log( message, category, source )</code> method. The
3cefe5340bfed84038e5816dbfbe7cec44f0df31Luke Smith * debug versions of YUI modules will include logging statements to offer some
3cefe5340bfed84038e5816dbfbe7cec44f0df31Luke Smith * insight into the steps executed during that module's operation. Including
3cefe5340bfed84038e5816dbfbe7cec44f0df31Luke Smith * log statements in your code will cause those messages to also appear in the
3cefe5340bfed84038e5816dbfbe7cec44f0df31Luke Smith * Console. Use Console to aid in developing your page or application.
3cefe5340bfed84038e5816dbfbe7cec44f0df31Luke Smith *
3cefe5340bfed84038e5816dbfbe7cec44f0df31Luke Smith * Entry categories &quot;info&quot;, &quot;warn&quot;, and &quot;error&quot;
3cefe5340bfed84038e5816dbfbe7cec44f0df31Luke Smith * are also referred to as the log level, and entries are filtered against the
3cefe5340bfed84038e5816dbfbe7cec44f0df31Luke Smith * configured logLevel.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @module console
3cefe5340bfed84038e5816dbfbe7cec44f0df31Luke Smith * @class Console
3cefe5340bfed84038e5816dbfbe7cec44f0df31Luke Smith * @extends Widget
3cefe5340bfed84038e5816dbfbe7cec44f0df31Luke Smith * @param conf {Object} Configuration object (see Configuration attributes)
3cefe5340bfed84038e5816dbfbe7cec44f0df31Luke Smith * @constructor
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smithvar getCN = Y.ClassNameManager.getClassName,
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith CHECKED = 'checked',
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith CLEAR = 'clear',
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith CLICK = 'click',
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith COLLAPSED = 'collapsed',
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith CONSOLE = 'console',
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith CONTENT_BOX = 'contentBox',
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith DISABLED = 'disabled',
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith ENTRY = 'entry',
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith ERROR = 'error',
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith HEIGHT = 'height',
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith INFO = 'info',
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith LAST_TIME = 'lastTime',
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith PAUSE = 'pause',
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith PAUSED = 'paused',
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith RESET = 'reset',
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith START_TIME = 'startTime',
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith TITLE = 'title',
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith WARN = 'warn',
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith DOT = '.',
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith C_BUTTON = getCN(CONSOLE,'button'),
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith C_CHECKBOX = getCN(CONSOLE,'checkbox'),
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith C_CLEAR = getCN(CONSOLE,CLEAR),
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith C_COLLAPSE = getCN(CONSOLE,'collapse'),
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith C_COLLAPSED = getCN(CONSOLE,COLLAPSED),
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith C_CONSOLE_CONTROLS = getCN(CONSOLE,'controls'),
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith C_CONSOLE_HD = getCN(CONSOLE,'hd'),
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith C_CONSOLE_BD = getCN(CONSOLE,'bd'),
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith C_CONSOLE_FT = getCN(CONSOLE,'ft'),
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith C_CONSOLE_TITLE = getCN(CONSOLE,TITLE),
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith C_ENTRY = getCN(CONSOLE,ENTRY),
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith C_ENTRY_CAT = getCN(CONSOLE,ENTRY,'cat'),
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith C_ENTRY_CONTENT = getCN(CONSOLE,ENTRY,'content'),
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith C_ENTRY_META = getCN(CONSOLE,ENTRY,'meta'),
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith C_ENTRY_SRC = getCN(CONSOLE,ENTRY,'src'),
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith C_ENTRY_TIME = getCN(CONSOLE,ENTRY,'time'),
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith C_PAUSE = getCN(CONSOLE,PAUSE),
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith C_PAUSE_LABEL = getCN(CONSOLE,PAUSE,'label'),
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith RE_INLINE_SOURCE = /^(\S+)\s/,
f012d18e08e5c256ec59c1fce1262f86e1d4a75dLuke Smith RE_AMP = /&(?!#?[a-z0-9]+;)/g,
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith RE_GT = />/g,
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith RE_LT = /</g,
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith ESC_AMP = '&#38;',
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith ESC_GT = '&#62;',
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith ESC_LT = '&#60;',
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
abf34f3b3d65331ec654c9980a6d60d7f9701bfeLuke Smith ENTRY_TEMPLATE_STR =
abf34f3b3d65331ec654c9980a6d60d7f9701bfeLuke Smith '<div class="{entry_class} {cat_class} {src_class}">'+
abf34f3b3d65331ec654c9980a6d60d7f9701bfeLuke Smith '<p class="{entry_meta_class}">'+
abf34f3b3d65331ec654c9980a6d60d7f9701bfeLuke Smith '<span class="{entry_src_class}">'+
abf34f3b3d65331ec654c9980a6d60d7f9701bfeLuke Smith '{sourceAndDetail}'+
abf34f3b3d65331ec654c9980a6d60d7f9701bfeLuke Smith '</span>'+
abf34f3b3d65331ec654c9980a6d60d7f9701bfeLuke Smith '<span class="{entry_cat_class}">'+
4ec6c08988d4f78cd72251f55b27f018823a5eeeLuke Smith '{category}</span>'+
abf34f3b3d65331ec654c9980a6d60d7f9701bfeLuke Smith '<span class="{entry_time_class}">'+
abf34f3b3d65331ec654c9980a6d60d7f9701bfeLuke Smith ' {totalTime}ms (+{elapsedTime}) {localTime}'+
abf34f3b3d65331ec654c9980a6d60d7f9701bfeLuke Smith '</span>'+
abf34f3b3d65331ec654c9980a6d60d7f9701bfeLuke Smith '</p>'+
abf34f3b3d65331ec654c9980a6d60d7f9701bfeLuke Smith '<pre class="{entry_content_class}">{message}</pre>'+
abf34f3b3d65331ec654c9980a6d60d7f9701bfeLuke Smith '</div>',
abf34f3b3d65331ec654c9980a6d60d7f9701bfeLuke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith L = Y.Lang,
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith create = Y.Node.create,
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith isNumber = L.isNumber,
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith isString = L.isString,
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith merge = Y.merge,
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith substitute = Y.substitute;
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
9327ef7ad1fee11b0e494b97cc07386565326c03Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smithfunction Console() {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith Console.superclass.constructor.apply(this,arguments);
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith}
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke SmithY.Console = Y.extend(Console, Y.Widget,
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith// Y.Console prototype
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith{
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Category to prefix all event subscriptions to allow for ease of detach
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * during destroy.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @property _evtCat
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type string
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @protected
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith _evtCat : null,
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Reference to the Node instance containing the header contents.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @property _head
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type Node
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @default null
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @protected
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith _head : null,
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Reference to the Node instance that will house the console messages.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @property _body
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type Node
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @default null
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @protected
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith _body : null,
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Reference to the Node instance containing the footer contents.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @property _foot
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type Node
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @default null
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @protected
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith _foot : null,
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Holds the object API returned from <code>Y.later</code> for the print
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * loop interval.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @property _printLoop
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @type Object
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @default null
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @protected
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith _printLoop : null,
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Array of normalized message objects awaiting printing.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @property buffer
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type Array
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @default null
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @protected
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith buffer : null,
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Wrapper for <code>Y.log</code>.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @method log
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @param arg* {MIXED} (all arguments passed through to <code>Y.log</code>)
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @chainable
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith log : function () {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith Y.log.apply(Y,arguments);
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith return this;
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Clear the console of messages and flush the buffer of pending messages.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @method clearConsole
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @chainable
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith clearConsole : function () {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith // TODO: clear event listeners from console contents
970d3605073835415b62245302838340763d086fLuke Smith this._body.empty();
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this._cancelPrintLoop();
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this.buffer = [];
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith return this;
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Clears the console and resets internal timers.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @method reset
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @chainable
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith reset : function () {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this.fire(RESET);
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith return this;
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Collapses the body and footer.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @method collapse
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @chainable
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith collapse : function () {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this.set(COLLAPSED, true);
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith return this;
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Expands the body and footer if collapsed.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @method expand
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @chainable
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith expand : function () {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this.set(COLLAPSED, false);
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith return this;
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Outputs buffered messages to the console UI. This is typically called
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * from a scheduled interval until the buffer is empty (referred to as the
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * print loop). The number of buffered messages output to the Console is
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * limited to the number provided as an argument. If no limit is passed,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * all buffered messages are rendered.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @method printBuffer
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @param limit {Number} (optional) max number of buffered entries to write
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @chainable
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith printBuffer: function (limit) {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith var messages = this.buffer,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith debug = Y.config.debug,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith entries = [],
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith consoleLimit= this.get('consoleLimit'),
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith newestOnTop = this.get('newestOnTop'),
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith anchor = newestOnTop ? this._body.get('firstChild') : null,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith i;
16479f9c396537f36d0d9c5633b24df618eee1e6Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith if (messages.length > consoleLimit) {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith messages.splice(0, messages.length - consoleLimit);
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith }
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith limit = Math.min(messages.length, (limit || messages.length));
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith // turn off logging system
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith Y.config.debug = false;
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith if (!this.get(PAUSED) && this.get('rendered')) {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith for (i = 0; i < limit && messages.length; ++i) {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith entries[i] = this._createEntryHTML(messages.shift());
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith }
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith if (!messages.length) {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this._cancelPrintLoop();
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith }
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith if (entries.length) {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith if (newestOnTop) {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith entries.reverse();
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith }
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this._body.insertBefore(create(entries.join('')), anchor);
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith if (this.get('scrollIntoView')) {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this.scrollToLatest();
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith }
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this._trimOldEntries();
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith }
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith }
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith // restore logging system
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith Y.config.debug = debug;
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith return this;
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
c31ae0e3c3d2726907b1876b5fe81cfd94527d5dLuke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Constructor code. Set up the buffer and entry template, publish
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * internal events, and subscribe to the configured logEvent.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @method initializer
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @protected
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith initializer : function () {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this._evtCat = Y.stamp(this) + '|';
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this.buffer = [];
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this.get('logSource').on(this._evtCat +
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this.get('logEvent'),Y.bind("_onLogEvent",this));
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Transfers a received message to the print loop buffer. Default
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * behavior defined in _defEntryFn.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @event entry
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @param event {Event.Facade} An Event Facade object with the following attribute specific properties added:
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <dl>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <dt>message</dt>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <dd>The message data normalized into an object literal (see _normalizeMessage)</dd>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * </dl>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @preventable _defEntryFn
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this.publish(ENTRY, { defaultFn: this._defEntryFn });
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Triggers the reset behavior via the default logic in _defResetFn.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @event reset
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @param event {Event.Facade} Event Facade object
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @preventable _defResetFn
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this.publish(RESET, { defaultFn: this._defResetFn });
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this.after('rendered', this._schedulePrint);
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
16479f9c396537f36d0d9c5633b24df618eee1e6Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Tears down the instance, flushing event subscriptions and purging the UI.
16479f9c396537f36d0d9c5633b24df618eee1e6Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @method destructor
16479f9c396537f36d0d9c5633b24df618eee1e6Luke Smith * @protected
16479f9c396537f36d0d9c5633b24df618eee1e6Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith destructor : function () {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith var bb = this.get('boundingBox');
16479f9c396537f36d0d9c5633b24df618eee1e6Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this._cancelPrintLoop();
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this.get('logSource').detach(this._evtCat + '*');
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
88c285485a7919c95181acfc6ed882304dc31187Luke Smith bb.purge(true);
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Generate the Console UI.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @method renderUI
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @protected
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith renderUI : function () {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this._initHead();
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this._initBody();
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this._initFoot();
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith // Apply positioning to the bounding box if appropriate
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith var style = this.get('style');
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith if (style !== 'block') {
970d3605073835415b62245302838340763d086fLuke Smith this.get('boundingBox').addClass(this.getClassName(style));
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith }
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Sync the UI state to the current attribute state.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @method syncUI
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith syncUI : function () {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this._uiUpdatePaused(this.get(PAUSED));
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this._uiUpdateCollapsed(this.get(COLLAPSED));
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this._uiSetHeight(this.get(HEIGHT));
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Set up event listeners to wire up the UI to the internal state.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @method bindUI
3cefe5340bfed84038e5816dbfbe7cec44f0df31Luke Smith * @protected
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith bindUI : function () {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this.get(CONTENT_BOX).one('button.'+C_COLLAPSE).
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith on(CLICK,this._onCollapseClick,this);
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this.get(CONTENT_BOX).one('input[type=checkbox].'+C_PAUSE).
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith on(CLICK,this._onPauseClick,this);
5800f4bbed853824dd8797caae32f78bcc9ef09bLuke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this.get(CONTENT_BOX).one('button.'+C_CLEAR).
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith on(CLICK,this._onClearClick,this);
0b911fcfd6406910a95696c8d583a698e6304e5fSatyen Desai
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith // Attribute changes
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this.after(this._evtCat + 'stringsChange',
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this._afterStringsChange);
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this.after(this._evtCat + 'pausedChange',
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this._afterPausedChange);
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this.after(this._evtCat + 'consoleLimitChange',
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this._afterConsoleLimitChange);
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this.after(this._evtCat + 'collapsedChange',
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this._afterCollapsedChange);
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Create the DOM structure for the header elements.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @method _initHead
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @protected
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith _initHead : function () {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith var cb = this.get(CONTENT_BOX),
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith info = merge(Console.CHROME_CLASSES, {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith str_collapse : this.get('strings.collapse'),
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith str_title : this.get('strings.title')
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith });
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this._head = create(substitute(Console.HEADER_TEMPLATE,info));
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith cb.insertBefore(this._head,cb.get('firstChild'));
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Create the DOM structure for the console body&#8212;where messages are
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * rendered.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @method _initBody
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @protected
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith _initBody : function () {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this._body = create(substitute(
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith Console.BODY_TEMPLATE,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith Console.CHROME_CLASSES));
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this.get(CONTENT_BOX).appendChild(this._body);
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Create the DOM structure for the footer elements.
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @method _initFoot
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @protected
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith _initFoot : function () {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith var info = merge(Console.CHROME_CLASSES, {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith id_guid : Y.guid(),
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith str_pause : this.get('strings.pause'),
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith str_clear : this.get('strings.clear')
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith });
5800f4bbed853824dd8797caae32f78bcc9ef09bLuke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this._foot = create(substitute(Console.FOOTER_TEMPLATE,info));
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith this.get(CONTENT_BOX).appendChild(this._foot);
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith },
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Determine if incoming log messages are within the configured logLevel
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * to be buffered for printing.
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @method _isInLogLevel
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @protected
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith _isInLogLevel : function (e) {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith var cat = e.cat, lvl = this.get('logLevel');
8652e2d20f8ea9c9bfe21217ba427cf0d85ada9aLuke Smith
8652e2d20f8ea9c9bfe21217ba427cf0d85ada9aLuke Smith if (lvl !== INFO) {
8652e2d20f8ea9c9bfe21217ba427cf0d85ada9aLuke Smith cat = cat || INFO;
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
8652e2d20f8ea9c9bfe21217ba427cf0d85ada9aLuke Smith if (isString(cat)) {
8652e2d20f8ea9c9bfe21217ba427cf0d85ada9aLuke Smith cat = cat.toLowerCase();
8652e2d20f8ea9c9bfe21217ba427cf0d85ada9aLuke Smith }
8652e2d20f8ea9c9bfe21217ba427cf0d85ada9aLuke Smith
8652e2d20f8ea9c9bfe21217ba427cf0d85ada9aLuke Smith if ((cat === WARN && lvl === ERROR) ||
8652e2d20f8ea9c9bfe21217ba427cf0d85ada9aLuke Smith (cat === INFO && lvl !== INFO)) {
8652e2d20f8ea9c9bfe21217ba427cf0d85ada9aLuke Smith return false;
8652e2d20f8ea9c9bfe21217ba427cf0d85ada9aLuke Smith }
8652e2d20f8ea9c9bfe21217ba427cf0d85ada9aLuke Smith }
8652e2d20f8ea9c9bfe21217ba427cf0d85ada9aLuke Smith
8652e2d20f8ea9c9bfe21217ba427cf0d85ada9aLuke Smith return true;
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * Create a log entry message from the inputs including the following keys:
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * <ul>
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * <li>time - this moment</li>
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * <li>message - leg message</li>
8652e2d20f8ea9c9bfe21217ba427cf0d85ada9aLuke Smith * <li>category - logLevel or custom category for the message</li>
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * <li>source - when provided, the widget or util calling Y.log</li>
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * <li>sourceAndDetail - same as source but can include instance info</li>
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * <li>localTime - readable version of time</li>
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * <li>elapsedTime - ms since last entry</li>
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * <li>totalTime - ms since Console was instantiated or reset</li>
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * </ul>
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
c36390194c43d30adc1059a74fdf9f51a235b8a9Luke Smith * @method _normalizeMessage
4db02d4b38afe802ad625f6c389e106fdc7c26faLuke Smith * @param e {Event} custom event containing the log message
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @return Object the message object
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @protected
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
abdfe7cf11d34f89f17b26e4779bf6079d22a910Adam Moore _normalizeMessage : function (e) {
abdfe7cf11d34f89f17b26e4779bf6079d22a910Adam Moore
4db02d4b38afe802ad625f6c389e106fdc7c26faLuke Smith var msg = e.msg,
4db02d4b38afe802ad625f6c389e106fdc7c26faLuke Smith cat = e.cat,
4db02d4b38afe802ad625f6c389e106fdc7c26faLuke Smith src = e.src,
4db02d4b38afe802ad625f6c389e106fdc7c26faLuke Smith
4db02d4b38afe802ad625f6c389e106fdc7c26faLuke Smith m = {
4db02d4b38afe802ad625f6c389e106fdc7c26faLuke Smith time : new Date(),
4db02d4b38afe802ad625f6c389e106fdc7c26faLuke Smith message : msg,
4db02d4b38afe802ad625f6c389e106fdc7c26faLuke Smith category : cat || this.get('defaultCategory'),
4db02d4b38afe802ad625f6c389e106fdc7c26faLuke Smith sourceAndDetail : src || this.get('defaultSource'),
4db02d4b38afe802ad625f6c389e106fdc7c26faLuke Smith source : null,
4db02d4b38afe802ad625f6c389e106fdc7c26faLuke Smith localTime : null,
4db02d4b38afe802ad625f6c389e106fdc7c26faLuke Smith elapsedTime : null,
4db02d4b38afe802ad625f6c389e106fdc7c26faLuke Smith totalTime : null
4db02d4b38afe802ad625f6c389e106fdc7c26faLuke Smith };
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith // Extract m.source "Foo" from m.sourceAndDetail "Foo bar baz"
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith m.source = RE_INLINE_SOURCE.test(m.sourceAndDetail) ?
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith RegExp.$1 : m.sourceAndDetail;
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith m.localTime = m.time.toLocaleTimeString ?
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith m.time.toLocaleTimeString() : (m.time + '');
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith m.elapsedTime = m.time - this.get(LAST_TIME);
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith m.totalTime = m.time - this.get(START_TIME);
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith this._set(LAST_TIME,m.time);
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith return m;
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
c36390194c43d30adc1059a74fdf9f51a235b8a9Luke Smith * Sets an interval for buffered messages to be output to the console.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @method _schedulePrint
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @protected
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith _schedulePrint : function () {
d7a66fe2de41baa56b41e8b7b254d1f6a50a5135Luke Smith if (!this._printLoop && !this.get(PAUSED) && this.get('rendered')) {
35eeab4975a1c9e62cf466455a59e80ba5e00fb0Luke Smith this._printLoop = Y.later(
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith this.get('printTimeout'),
c31ae0e3c3d2726907b1876b5fe81cfd94527d5dLuke Smith this, this.printBuffer,
c31ae0e3c3d2726907b1876b5fe81cfd94527d5dLuke Smith this.get('printLimit'), true);
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith }
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
c36390194c43d30adc1059a74fdf9f51a235b8a9Luke Smith * Translates message meta into the markup for a console entry.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
12193f069c735c9fa68aa22d6b4a8ff1fc5b83f1Luke Smith * @method _createEntryHTML
35eeab4975a1c9e62cf466455a59e80ba5e00fb0Luke Smith * @param m {Object} object literal containing normalized message metadata
12193f069c735c9fa68aa22d6b4a8ff1fc5b83f1Luke Smith * @return String
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @protected
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
12193f069c735c9fa68aa22d6b4a8ff1fc5b83f1Luke Smith _createEntryHTML : function (m) {
35eeab4975a1c9e62cf466455a59e80ba5e00fb0Luke Smith m = merge(
35eeab4975a1c9e62cf466455a59e80ba5e00fb0Luke Smith this._htmlEscapeMessage(m),
35eeab4975a1c9e62cf466455a59e80ba5e00fb0Luke Smith Console.ENTRY_CLASSES,
35eeab4975a1c9e62cf466455a59e80ba5e00fb0Luke Smith {
35eeab4975a1c9e62cf466455a59e80ba5e00fb0Luke Smith cat_class : this.getClassName(ENTRY,m.category),
35eeab4975a1c9e62cf466455a59e80ba5e00fb0Luke Smith src_class : this.getClassName(ENTRY,m.source)
35eeab4975a1c9e62cf466455a59e80ba5e00fb0Luke Smith });
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
12193f069c735c9fa68aa22d6b4a8ff1fc5b83f1Luke Smith return this.get('entryTemplate').replace(/\{(\w+)\}/g,
12193f069c735c9fa68aa22d6b4a8ff1fc5b83f1Luke Smith function (_,token) {
12193f069c735c9fa68aa22d6b4a8ff1fc5b83f1Luke Smith return token in m ? m[token] : '';
12193f069c735c9fa68aa22d6b4a8ff1fc5b83f1Luke Smith });
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith /**
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith * Scrolls to the most recent entry
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith *
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith * @method scrollToLatest
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith * @chainable
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith */
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith scrollToLatest : function () {
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith var scrollTop = this.get('newestOnTop') ?
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith 0 :
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith this._body.get('scrollHeight');
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith this._body.set('scrollTop', scrollTop);
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * Performs HTML escaping on strings in the message object.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @method _htmlEscapeMessage
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @param m {Object} the normalized message object
f9918f6b658319940d633dd8c9a2c16d05b4c881Luke Smith * @return Object the message object with proper escapement
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @protected
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith _htmlEscapeMessage : function (m) {
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith m.message = this._encodeHTML(m.message);
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith m.source = this._encodeHTML(m.source);
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith m.sourceAndDetail = this._encodeHTML(m.sourceAndDetail);
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith m.category = this._encodeHTML(m.category);
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith return m;
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * Removes the oldest message entries from the UI to maintain the limit
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * specified in the consoleLimit configuration.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @method _trimOldEntries
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @protected
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith _trimOldEntries : function () {
35eeab4975a1c9e62cf466455a59e80ba5e00fb0Luke Smith // Turn off the logging system for the duration of this operation
35eeab4975a1c9e62cf466455a59e80ba5e00fb0Luke Smith // to prevent an infinite loop
35eeab4975a1c9e62cf466455a59e80ba5e00fb0Luke Smith Y.config.debug = false;
35eeab4975a1c9e62cf466455a59e80ba5e00fb0Luke Smith
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith var bd = this._body,
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith limit = this.get('consoleLimit'),
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith debug = Y.config.debug,
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith entries,e,i,l;
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith if (bd) {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith entries = bd.all(DOT+C_ENTRY);
35eeab4975a1c9e62cf466455a59e80ba5e00fb0Luke Smith l = entries.size() - limit;
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
35eeab4975a1c9e62cf466455a59e80ba5e00fb0Luke Smith if (l > 0) {
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith if (this.get('newestOnTop')) {
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith i = limit;
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith l = entries.size();
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith } else {
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith i = 0;
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith }
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith
c31ae0e3c3d2726907b1876b5fe81cfd94527d5dLuke Smith this._body.setStyle('display','none');
c31ae0e3c3d2726907b1876b5fe81cfd94527d5dLuke Smith
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith for (;i < l; ++i) {
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith e = entries.item(i);
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith if (e) {
8951c05b281fd712464388c237e1f0be6b6487a7Luke Smith e.remove();
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith }
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith }
c31ae0e3c3d2726907b1876b5fe81cfd94527d5dLuke Smith
c31ae0e3c3d2726907b1876b5fe81cfd94527d5dLuke Smith this._body.setStyle('display','');
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith }
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith }
35eeab4975a1c9e62cf466455a59e80ba5e00fb0Luke Smith
35eeab4975a1c9e62cf466455a59e80ba5e00fb0Luke Smith Y.config.debug = debug;
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * Returns the input string with ampersands (&amp;), &lt, and &gt; encoded
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * as HTML entities.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @method _encodeHTML
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @param s {String} the raw string
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @return String the encoded string
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @protected
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith _encodeHTML : function (s) {
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith return isString(s) ?
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith s.replace(RE_AMP,ESC_AMP).
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith replace(RE_LT, ESC_LT).
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith replace(RE_GT, ESC_GT) :
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith s;
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * Clears the timeout for printing buffered messages.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
35eeab4975a1c9e62cf466455a59e80ba5e00fb0Luke Smith * @method _cancelPrintLoop
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @protected
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
35eeab4975a1c9e62cf466455a59e80ba5e00fb0Luke Smith _cancelPrintLoop : function () {
35eeab4975a1c9e62cf466455a59e80ba5e00fb0Luke Smith if (this._printLoop) {
35eeab4975a1c9e62cf466455a59e80ba5e00fb0Luke Smith this._printLoop.cancel();
35eeab4975a1c9e62cf466455a59e80ba5e00fb0Luke Smith this._printLoop = null;
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith }
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
08299549a01ea998d0fc3bfbf97c5ff4d351f543Luke Smith /**
08299549a01ea998d0fc3bfbf97c5ff4d351f543Luke Smith * Validates input value for style attribute. Accepts only values 'inline',
08299549a01ea998d0fc3bfbf97c5ff4d351f543Luke Smith * 'block', and 'separate'.
08299549a01ea998d0fc3bfbf97c5ff4d351f543Luke Smith *
08299549a01ea998d0fc3bfbf97c5ff4d351f543Luke Smith * @method _validateStyle
08299549a01ea998d0fc3bfbf97c5ff4d351f543Luke Smith * @param style {String} the proposed value
08299549a01ea998d0fc3bfbf97c5ff4d351f543Luke Smith * @return {Boolean} pass/fail
08299549a01ea998d0fc3bfbf97c5ff4d351f543Luke Smith * @protected
08299549a01ea998d0fc3bfbf97c5ff4d351f543Luke Smith */
08299549a01ea998d0fc3bfbf97c5ff4d351f543Luke Smith _validateStyle : function (style) {
08299549a01ea998d0fc3bfbf97c5ff4d351f543Luke Smith return style === 'inline' || style === 'block' || style === 'separate';
08299549a01ea998d0fc3bfbf97c5ff4d351f543Luke Smith },
08299549a01ea998d0fc3bfbf97c5ff4d351f543Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * Event handler for clicking on the Pause checkbox to update the paused
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * attribute.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @method _onPauseClick
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @param e {Event} DOM event facade for the click event
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @protected
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith _onPauseClick : function (e) {
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith this.set(PAUSED,e.target.get(CHECKED));
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * Event handler for clicking on the Clear button. Pass-through to
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * <code>this.clearConsole()</code>.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @method _onClearClick
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @param e {Event} DOM event facade for the click event
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @protected
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith _onClearClick : function (e) {
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith this.clearConsole();
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith /**
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith * Event handler for clicking on the Collapse/Expand button. Sets the
c36390194c43d30adc1059a74fdf9f51a235b8a9Luke Smith * &quot;collapsed&quot; attribute accordingly.
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith *
c36390194c43d30adc1059a74fdf9f51a235b8a9Luke Smith * @method _onCollapseClick
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith * @param e {Event} DOM event facade for the click event
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith * @protected
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith */
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith _onCollapseClick : function (e) {
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith this.set(COLLAPSED, !this.get(COLLAPSED));
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith },
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith /**
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith * Validator for logSource attribute.
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith *
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith * @method _validateLogSource
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith * @param v {Object} the desired logSource
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith * @return {Boolean} true if the input is an object with an <code>on</code>
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith * method
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith * @protected
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith */
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith _validateLogSource: function (v) {
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith return v && Y.Lang.isFunction(v.on);
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith },
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * Setter method for logLevel attribute. Acceptable values are
c36390194c43d30adc1059a74fdf9f51a235b8a9Luke Smith * &quot;error&quot, &quot;warn&quot, and &quot;info&quot (case
c36390194c43d30adc1059a74fdf9f51a235b8a9Luke Smith * insensitive). Other values are treated as &quot;info&quot;.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @method _setLogLevel
8652e2d20f8ea9c9bfe21217ba427cf0d85ada9aLuke Smith * @param v {String} the desired log level
8652e2d20f8ea9c9bfe21217ba427cf0d85ada9aLuke Smith * @return String One of Console.LOG_LEVEL_INFO, _WARN, or _ERROR
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @protected
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith _setLogLevel : function (v) {
8652e2d20f8ea9c9bfe21217ba427cf0d85ada9aLuke Smith if (isString(v)) {
8652e2d20f8ea9c9bfe21217ba427cf0d85ada9aLuke Smith v = v.toLowerCase();
8652e2d20f8ea9c9bfe21217ba427cf0d85ada9aLuke Smith }
8652e2d20f8ea9c9bfe21217ba427cf0d85ada9aLuke Smith
8652e2d20f8ea9c9bfe21217ba427cf0d85ada9aLuke Smith return (v === WARN || v === ERROR) ? v : INFO;
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith /**
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith * Getter method for useBrowserConsole attribute. Just a pass through to
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith * the YUI instance configuration setting.
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith *
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith * @method _getUseBrowserConsole
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith * @return {Boolean} or null if logSource is not a YUI instance
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith * @protected
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith */
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith _getUseBrowserConsole: function () {
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith var logSource = this.get('logSource');
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith return logSource instanceof YUI ?
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith logSource.config.useBrowserConsole : null;
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith },
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith /**
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith * Setter method for useBrowserConsole attributes. Only functional if the
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith * logSource attribute points to a YUI instance. Passes the value down to
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith * the YUI instance. NOTE: multiple Console instances cannot maintain
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith * independent useBrowserConsole values, since it is just a pass through to
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith * the YUI instance configuration.
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith *
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith * @method _setUseBrowserConsole
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith * @param v {Boolean} false to disable browser console printing (default)
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith * @return {Boolean} true|false if logSource is a YUI instance
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith * @protected
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith */
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith _setUseBrowserConsole: function (v) {
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith var logSource = this.get('logSource');
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith if (logSource instanceof YUI) {
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith v = !!v;
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith logSource.config.useBrowserConsole = v;
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith return v;
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith } else {
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith return Y.Attribute.INVALID_VALUE;
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith }
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith },
6ee0f2f556dcd1d88784ad6f12771d36759017a1Luke Smith
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith /**
970d3605073835415b62245302838340763d086fLuke Smith * Set the height of the Console container. Set the body height to the
970d3605073835415b62245302838340763d086fLuke Smith * difference between the configured height and the calculated heights of
970d3605073835415b62245302838340763d086fLuke Smith * the header and footer.
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith * Overrides Widget.prototype._uiSetHeight.
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith *
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith * @method _uiSetHeight
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith * @param v {String|Number} the new height
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith * @protected
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith */
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith _uiSetHeight : function (v) {
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith Console.superclass._uiSetHeight.apply(this,arguments);
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith if (this._head && this._foot) {
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith var h = this.get('boundingBox').get('offsetHeight') -
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith this._head.get('offsetHeight') -
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith this._foot.get('offsetHeight');
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith this._body.setStyle(HEIGHT,h+'px');
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith }
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith },
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith
ee2325dc6d26d8f385007b70eef20ba8890138e8Satyen Desai /**
ee2325dc6d26d8f385007b70eef20ba8890138e8Satyen Desai * Over-ride default content box sizing to do nothing, since we're sizing
ee2325dc6d26d8f385007b70eef20ba8890138e8Satyen Desai * the body section to fill out height ourselves.
ee2325dc6d26d8f385007b70eef20ba8890138e8Satyen Desai *
ee2325dc6d26d8f385007b70eef20ba8890138e8Satyen Desai * @method _uiSizeCB
ee2325dc6d26d8f385007b70eef20ba8890138e8Satyen Desai * @protected
ee2325dc6d26d8f385007b70eef20ba8890138e8Satyen Desai */
ee2325dc6d26d8f385007b70eef20ba8890138e8Satyen Desai _uiSizeCB : function() {
ee2325dc6d26d8f385007b70eef20ba8890138e8Satyen Desai // Do Nothing. Ideally want to move to Widget-StdMod, which accounts for
ee2325dc6d26d8f385007b70eef20ba8890138e8Satyen Desai // _uiSizeCB
ee2325dc6d26d8f385007b70eef20ba8890138e8Satyen Desai },
ee2325dc6d26d8f385007b70eef20ba8890138e8Satyen Desai
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * Updates the UI if changes are made to any of the strings in the strings
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * attribute.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @method _afterStringsChange
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @param e {Event} Custom event for the attribute change
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @protected
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith _afterStringsChange : function (e) {
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith var prop = e.subAttrName ? e.subAttrName.split(DOT)[1] : null,
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith cb = this.get(CONTENT_BOX),
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith before = e.prevVal,
e4c11ebec5d4604079c3d53d2138ee3f772f91f7Luke Smith after = e.newVal;
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith if ((!prop || prop === TITLE) && before.title !== after.title) {
970d3605073835415b62245302838340763d086fLuke Smith cb.all(DOT+C_CONSOLE_TITLE).setContent(after.title);
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith }
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith if ((!prop || prop === PAUSE) && before.pause !== after.pause) {
970d3605073835415b62245302838340763d086fLuke Smith cb.all(DOT+C_PAUSE_LABEL).setContent(after.pause);
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith }
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith if ((!prop || prop === CLEAR) && before.clear !== after.clear) {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith cb.all(DOT+C_CLEAR).set('value',after.clear);
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith }
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
c36390194c43d30adc1059a74fdf9f51a235b8a9Luke Smith * Updates the UI and schedules or cancels the print loop.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @method _afterPausedChange
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @param e {Event} Custom event for the attribute change
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @protected
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith _afterPausedChange : function (e) {
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith var paused = e.newVal;
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith if (e.src !== Y.Widget.SRC_UI) {
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith this._uiUpdatePaused(paused);
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith }
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith if (!paused) {
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith this._schedulePrint();
35eeab4975a1c9e62cf466455a59e80ba5e00fb0Luke Smith } else if (this._printLoop) {
35eeab4975a1c9e62cf466455a59e80ba5e00fb0Luke Smith this._cancelPrintLoop();
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith }
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith /**
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith * Checks or unchecks the paused checkbox
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith *
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith * @method _uiUpdatePaused
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith * @param on {Boolean} the new checked state
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith * @protected
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith */
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith _uiUpdatePaused : function (on) {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith var node = this._foot.all('input[type=checkbox].'+C_PAUSE);
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith if (node) {
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith node.set(CHECKED,on);
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith }
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith },
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * Calls this._trimOldEntries() in response to changes in the configured
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * consoleLimit attribute.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @method _afterConsoleLimitChange
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @param e {Event} Custom event for the attribute change
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @protected
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith _afterConsoleLimitChange : function () {
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith this._trimOldEntries();
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith /**
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith * Updates the className of the contentBox, which should trigger CSS to
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith * hide or show the body and footer sections depending on the new value.
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith *
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith * @method _afterCollapsedChange
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith * @param e {Event} Custom event for the attribute change
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith * @protected
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith */
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith _afterCollapsedChange : function (e) {
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith this._uiUpdateCollapsed(e.newVal);
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith },
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith /**
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith * Updates the UI to reflect the new Collapsed state
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith *
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith * @method _uiUpdateCollapsed
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith * @param v {Boolean} true for collapsed, false for expanded
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith * @protected
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith */
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith _uiUpdateCollapsed : function (v) {
60f5c306297c0d0dc6d239ee618ee333f4c40746Luke Smith var bb = this.get('boundingBox'),
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith button = bb.all('button.'+C_COLLAPSE),
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith method = v ? 'addClass' : 'removeClass',
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith str = this.get('strings.'+(v ? 'expand' : 'collapse'));
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith
60f5c306297c0d0dc6d239ee618ee333f4c40746Luke Smith bb[method](C_COLLAPSED);
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith if (button) {
970d3605073835415b62245302838340763d086fLuke Smith button.setContent(str);
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith }
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith
60f5c306297c0d0dc6d239ee618ee333f4c40746Luke Smith this._uiSetHeight(v ? this._head.get('offsetHeight'): this.get(HEIGHT));
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith },
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith /**
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith * Makes adjustments to the UI if needed when the Console is hidden or shown
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith *
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith * @method _afterVisibleChange
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith * @param e {Event} the visibleChange event
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith * @protected
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith */
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith _afterVisibleChange : function (e) {
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith Console.superclass._afterVisibleChange.apply(this,arguments);
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith this._uiUpdateFromHideShow(e.newVal);
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith },
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith /**
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith * Recalculates dimensions and updates appropriately when shown
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith *
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith * @method _uiUpdateFromHideShow
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith * @param v {Boolean} true for visible, false for hidden
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith * @protected
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith */
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith _uiUpdateFromHideShow : function (v) {
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith if (v) {
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith this._uiSetHeight(this.get(HEIGHT));
d463aba91a07cde67f9ec9382bce464db5bcc9d3Luke Smith }
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith },
ed51daad3a3ab15255ca10edef69d5f703d69adbLuke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * Responds to log events by normalizing qualifying messages and passing
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * them along through the entry event for buffering etc.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @method _onLogEvent
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @param msg {String} the log message
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @param cat {String} OPTIONAL the category or logLevel of the message
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @param src {String} OPTIONAL the source of the message (e.g. widget name)
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @protected
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
abdfe7cf11d34f89f17b26e4779bf6079d22a910Adam Moore _onLogEvent : function (e) {
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
abdfe7cf11d34f89f17b26e4779bf6079d22a910Adam Moore if (!this.get(DISABLED) && this._isInLogLevel(e)) {
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith var debug = Y.config.debug;
abdfe7cf11d34f89f17b26e4779bf6079d22a910Adam Moore
abdfe7cf11d34f89f17b26e4779bf6079d22a910Adam Moore /* TODO: needed? */
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith Y.config.debug = false;
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith this.fire(ENTRY, {
4db02d4b38afe802ad625f6c389e106fdc7c26faLuke Smith message : this._normalizeMessage(e)
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith });
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith Y.config.debug = debug;
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith }
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * Clears the console, resets the startTime attribute, enables and
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * unpauses the widget.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @method _defResetFn
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @protected
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith _defResetFn : function () {
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith this.clearConsole();
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith this.set(START_TIME,new Date());
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith this.set(DISABLED,false);
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith this.set(PAUSED,false);
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith },
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith /**
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * Buffers incoming message objects and schedules the printing.
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith *
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @method _defEntryFn
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @param e {Event} The Custom event carrying the message in its payload
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith * @protected
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith */
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith _defEntryFn : function (e) {
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith if (e.message) {
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith this.buffer.push(e.message);
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith this._schedulePrint();
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith }
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith }
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith},
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith// Y.Console static properties
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith{
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * The identity of the widget.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith * @property NAME
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type String
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @static
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith NAME : CONSOLE,
b32d148b0052e1f874e9bc9803bef729bf859d97Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Static identifier for logLevel configuration setting to allow all
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * incoming messages to generate Console entries.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith * @property LOG_LEVEL_INFO
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type String
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @static
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith LOG_LEVEL_INFO : INFO,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Static identifier for logLevel configuration setting to allow only
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * incoming messages of logLevel &quot;warn&quot; or &quot;error&quot;
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * to generate Console entries.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith * @property LOG_LEVEL_WARN
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type String
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @static
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith LOG_LEVEL_WARN : WARN,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Static identifier for logLevel configuration setting to allow only
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * incoming messages of logLevel &quot;error&quot; to generate
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Console entries.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith * @property LOG_LEVEL_ERROR
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type String
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @static
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith LOG_LEVEL_ERROR : ERROR,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Map (object) of classNames used to populate the placeholders in the
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Console.ENTRY_TEMPLATE markup when rendering a new Console entry.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <p>By default, the keys contained in the object are:</p>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <ul>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>entry_class</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>entry_meta_class</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>entry_cat_class</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>entry_src_class</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>entry_time_class</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>entry_content_class</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * </ul>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith * @property ENTRY_CLASSES
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type Object
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @static
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith ENTRY_CLASSES : {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith entry_class : C_ENTRY,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith entry_meta_class : C_ENTRY_META,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith entry_cat_class : C_ENTRY_CAT,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith entry_src_class : C_ENTRY_SRC,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith entry_time_class : C_ENTRY_TIME,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith entry_content_class : C_ENTRY_CONTENT
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Map (object) of classNames used to populate the placeholders in the
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Console.HEADER_TEMPLATE, Console.BODY_TEMPLATE, and
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Console.FOOTER_TEMPLATE markup when rendering the Console UI.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <p>By default, the keys contained in the object are:</p>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <ul>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>console_hd_class</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>console_bd_class</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>console_ft_class</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>console_controls_class</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>console_checkbox_class</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>console_pause_class</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>console_pause_label_class</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>console_button_class</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>console_clear_class</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>console_collapse_class</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>console_title_class</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * </ul>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith * @property CHROME_CLASSES
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type Object
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @static
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith CHROME_CLASSES : {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith console_hd_class : C_CONSOLE_HD,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith console_bd_class : C_CONSOLE_BD,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith console_ft_class : C_CONSOLE_FT,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith console_controls_class : C_CONSOLE_CONTROLS,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith console_checkbox_class : C_CHECKBOX,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith console_pause_class : C_PAUSE,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith console_pause_label_class : C_PAUSE_LABEL,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith console_button_class : C_BUTTON,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith console_clear_class : C_CLEAR,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith console_collapse_class : C_COLLAPSE,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith console_title_class : C_CONSOLE_TITLE
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Markup template used to generate the DOM structure for the header
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * section of the Console when it is rendered. The template includes
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * these {placeholder}s:
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <ul>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>console_button_class - contributed by Console.CHROME_CLASSES</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>console_collapse_class - contributed by Console.CHROME_CLASSES</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>console_hd_class - contributed by Console.CHROME_CLASSES</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>console_title_class - contributed by Console.CHROME_CLASSES</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>str_collapse - pulled from attribute strings.collapse</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>str_title - pulled from attribute strings.title</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * </ul>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith * @property HEADER_TEMPLATE
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type String
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @static
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith HEADER_TEMPLATE :
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith '<div class="{console_hd_class}">'+
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith '<h4 class="{console_title_class}">{str_title}</h4>'+
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith '<button type="button" class="'+
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith '{console_button_class} {console_collapse_class}">{str_collapse}'+
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith '</button>'+
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith '</div>',
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Markup template used to generate the DOM structure for the Console body
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * (where the messages are inserted) when it is rendered. The template
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * includes only the {placeholder} &quot;console_bd_class&quot;, which is
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * constributed by Console.CHROME_CLASSES.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith * @property BODY_TEMPLATE
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type String
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @static
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith BODY_TEMPLATE : '<div class="{console_bd_class}"></div>',
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Markup template used to generate the DOM structure for the footer
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * section of the Console when it is rendered. The template includes
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * many of the {placeholder}s from Console.CHROME_CLASSES as well as:
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <ul>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>id_guid - generated unique id, relates the label and checkbox</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>str_pause - pulled from attribute strings.pause</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>str_clear - pulled from attribute strings.clear</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * </ul>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith * @property FOOTER_TEMPLATE
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type String
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @static
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith FOOTER_TEMPLATE :
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith '<div class="{console_ft_class}">'+
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith '<div class="{console_controls_class}">'+
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith '<label for="{id_guid}" class="{console_pause_label_class}">'+
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith '<input type="checkbox" class="{console_checkbox_class} '+
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith '{console_pause_class}" value="1" id="{id_guid}"> '+
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith '{str_pause}</label>' +
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith '<button type="button" class="'+
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith '{console_button_class} {console_clear_class}">{str_clear}'+
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith '</button>'+
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith '</div>'+
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith '</div>',
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Default markup template used to create the DOM structure for Console
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * entries. The markup contains {placeholder}s for content and classes
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * that are replaced via Y.substitute. The default template contains
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * the {placeholder}s identified in Console.ENTRY_CLASSES as well as the
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * following placeholders that will be populated by the log entry data:
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <ul>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>cat_class</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>src_class</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>totalTime</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>elapsedTime</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>localTime</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>sourceAndDetail</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>message</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * </ul>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith * @property ENTRY_TEMPLATE
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type String
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @static
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith ENTRY_TEMPLATE : ENTRY_TEMPLATE_STR,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Static property used to define the default attribute configuration of
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * the Widget.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith * @property ATTRS
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @Type Object
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @static
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith ATTRS : {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Name of the custom event that will communicate log messages.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @attribute logEvent
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type String
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @default "yui:log"
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith logEvent : {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith value : 'yui:log',
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith writeOnce : true,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith validator : isString
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Object that will emit the log events. By default the YUI instance.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * To have a single Console capture events from all YUI instances, set
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * this to the Y.Global object.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @attribute logSource
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type EventTarget
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @default Y
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith logSource : {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith value : Y,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith writeOnce : true,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith validator : function (v) {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith return this._validateLogSource(v);
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith }
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Collection of strings used to label elements in the Console UI.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Default collection contains the following name:value pairs:
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <ul>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>title : &quot;Log Console&quot;</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>pause : &quot;Pause&quot;</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>clear : &quot;Clear&quot;</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>collapse : &quot;Collapse&quot;</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * <li>expand : &quot;Expand&quot;</li>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * </ul>
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @attribute strings
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type Object
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith strings : {
b2cd00278b38b2f4565812f25e8d9b532e013735Satyen Desai valueFn: function() { return Y.Intl.get("console"); }
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Boolean to pause the outputting of new messages to the console.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * When paused, messages will accumulate in the buffer.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @attribute paused
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type boolean
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @default false
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith paused : {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith value : false,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith validator : L.isBoolean
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * If a category is not specified in the Y.log(..) statement, this
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * category will be used. Categories &quot;info&quot;,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * &quot;warn&quot;, and &quot;error&quot; are also called log level.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @attribute defaultCategory
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type String
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @default "info"
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith defaultCategory : {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith value : INFO,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith validator : isString
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * If a source is not specified in the Y.log(..) statement, this
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * source will be used.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @attribute defaultSource
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type String
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @default "global"
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith defaultSource : {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith value : 'global',
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith validator : isString
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Markup template used to create the DOM structure for Console entries.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @attribute entryTemplate
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type String
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @default Console.ENTRY_TEMPLATE
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith entryTemplate : {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith value : ENTRY_TEMPLATE_STR,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith validator : isString
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Minimum entry log level to render into the Console. The initial
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * logLevel value for all Console instances defaults from the
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Y.config.logLevel YUI configuration, or Console.LOG_LEVEL_INFO if
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * that configuration is not set.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Possible values are &quot;info&quot;, &quot;warn&quot;,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * &quot;error&quot; (case insensitive), or their corresponding statics
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Console.LOG_LEVEL_INFO and so on.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @attribute logLevel
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type String
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @default Y.config.logLevel or Console.LOG_LEVEL_INFO
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith logLevel : {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith value : Y.config.logLevel || INFO,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith setter : function (v) {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith return this._setLogLevel(v);
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith }
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Millisecond timeout between iterations of the print loop, moving
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * entries from the buffer to the UI.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @attribute printTimeout
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type Number
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @default 100
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith printTimeout : {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith value : 100,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith validator : isNumber
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Maximum number of entries printed in each iteration of the print
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * loop. This is used to prevent excessive logging locking the page UI.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @attribute printLimit
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type Number
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @default 50
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith printLimit : {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith value : 50,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith validator : isNumber
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Maximum number of Console entries allowed in the Console body at one
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * time. This is used to keep acquired messages from exploding the
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * DOM tree and impacting page performance.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @attribute consoleLimit
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type Number
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @default 300
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith consoleLimit : {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith value : 300,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith validator : isNumber
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * New entries should display at the top of the Console or the bottom?
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @attribute newestOnTop
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type Boolean
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @default true
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith newestOnTop : {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith value : true
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * When new entries are added to the Console UI, should they be
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * scrolled into view?
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @attribute scrollIntoView
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type Boolean
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @default true
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith scrollIntoView : {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith value : true
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * The baseline time for this Console instance, used to measure elapsed
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * time from the moment the console module is <code>use</code>d to the
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * moment each new entry is logged (not rendered).
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * This value is reset by the instance method myConsole.reset().
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @attribute startTime
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type Date
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @default The moment the console module is <code>use</code>d
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith startTime : {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith value : new Date()
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * The precise time the last entry was logged. Used to measure elapsed
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * time between log messages.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @attribute lastTime
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type Date
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @default The moment the console module is <code>use</code>d
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith lastTime : {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith value : new Date(),
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith readOnly: true
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Controls the collapsed state of the Console
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @attribute collapsed
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type Boolean
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @default false
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith collapsed : {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith value : false
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * String with units, or number, representing the height of the Console,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * inclusive of header and footer. If a number is provided, the default
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * unit, defined by Widget's DEF_UNIT, property is used.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @attribute height
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @default "300px"
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type {String | Number}
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith height: {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith value: "300px"
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * String with units, or number, representing the width of the Console.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * If a number is provided, the default unit, defined by Widget's
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * DEF_UNIT, property is used.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @attribute width
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @default "300px"
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type {String | Number}
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith width: {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith value: "300px"
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Pass through to the YUI instance useBrowserConsole configuration.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * By default this is set to false, which will disable logging to the
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * browser console when a Console instance is created. If the
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * logSource is not a YUI instance, this has no effect.
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @attribute useBrowserConsole
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type {Boolean}
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @default false
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith useBrowserConsole : {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith lazyAdd: false,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith value: false,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith getter : function () {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith return this._getUseBrowserConsole();
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith setter : function (v) {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith return this._setUseBrowserConsole(v);
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith }
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith },
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith /**
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * Allows the Console to flow in the document. Available values are
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * 'inline', 'block', and 'separate' (the default).
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith *
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @attribute style
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @type {String}
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith * @default 'separate'
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith */
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith style : {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith value : 'separate',
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith writeOnce : true,
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith validator : function (v) {
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith return this._validateStyle(v);
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith }
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith }
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith }
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith
cde38d5b8e9eb36871c8ed5d690424e27d7c0923Luke Smith});