Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

console-debug.js 44KB

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