diff --git a/src/console-filters/docs/component.json b/src/console-filters/docs/component.json index f56dd11815d..544430977d1 100644 --- a/src/console-filters/docs/component.json +++ b/src/console-filters/docs/component.json @@ -10,7 +10,7 @@ "examples": [ { - "name": "console-filters_intro", + "name": "console-filters-intro", "displayName": "Using the ConsoleFilters Plugin", "description": "Adding the ConsoleFilters plugin to a Console instance for more granular run time log message filtering", "modules": ["console-filters","console"], diff --git a/src/console-filters/docs/console-filters-intro.mustache b/src/console-filters/docs/console-filters-intro.mustache new file mode 100644 index 00000000000..f5f90df0132 --- /dev/null +++ b/src/console-filters/docs/console-filters-intro.mustache @@ -0,0 +1,87 @@ +{{>console-filters-intro-css}} + +
+

This example illustrates how to use and configure the ConsoleFilters plugin for Console. The debug versions of YUI module files are used, so standard YUI debugging messages are broadcast to the Console.

+ +

Use the checkboxes in the Console footer to control which messages are displayed or hidden. Click the "Log a message" button to call `Y.log` using a custom category and source.

+ +

Note how new filter checkboxes are added when a new category or source are received by the Console, for example when clicking on the "Log a message" button.

+
+ +
+ {{>console-filters-intro-markup}} + {{>console-filters-intro-js}} +
+ +

Configure the YUI instance for debug mode

+

Only the `module-debug.js` versions of module files include log statements, so we'll set up our YUI instance's `filter` property to "debug". We'll also reduce the noise somewhat by specifying a `logInclude` list.

+ +``` +YUI({filter: 'debug', + logInclude: { + event: true, + attribute: true, + base: true, + widget: true, + node: true, + MyApp: true // This must be included for the custom source message + }, + timeout: 10000 +}).use("console-filters", function (Y) { ... }); +``` + +

Create the Console and plug in ConsoleFilters

+

All that's left to do now is plugin in the ConsoleFilters plugin. This can be done in one of a few ways.

+``` +// create the console instance +var yconsole = new Y.Console({ + boundingBox: '#console', + height: '400px', + width: '450px', + newestOnTop: false, + plugins: [ Y.Plugin.ConsoleFilters ] +}).render(); + +// unknown categories and sources are allowed. +yconsole.filter.hideCategory('error'); + +// hide and show methods support N arguments. +yconsole.filter.hideSource('attribute','widget'); +``` + +

Alternatively, you can attach the ConsoleFilters plugin after instantiation. This version also shows how to apply initial category and source filter states.

+``` +var yconsole = new Y.Console({ + boundingBox: '#console', + height: '400px', + width: '450px', + newestOnTop: false +}).plug(Y.Plugin.ConsoleFilters, { + category: { + error: false + }, + source: { + attribute: false, + widget: false + } +}).render(); + +``` + +

Full Code Listing

+ +

Markup

+``` +{{>console-filters-intro-markup}} +``` + +

JavaScript

+``` +{{>console-filters-intro-js}} +``` + +

CSS

+``` +{{>console-filters-intro-css}} +``` + diff --git a/src/console-filters/docs/index.mustache b/src/console-filters/docs/index.mustache old mode 100755 new mode 100644 diff --git a/src/console-filters/docs/partials/console-filters-intro-css.mustache b/src/console-filters/docs/partials/console-filters-intro-css.mustache new file mode 100644 index 00000000000..b25aaca885d --- /dev/null +++ b/src/console-filters/docs/partials/console-filters-intro-css.mustache @@ -0,0 +1,17 @@ + diff --git a/src/console-filters/docs/partials/console-filters-intro-js.mustache b/src/console-filters/docs/partials/console-filters-intro-js.mustache new file mode 100644 index 00000000000..0744d7cd5dc --- /dev/null +++ b/src/console-filters/docs/partials/console-filters-intro-js.mustache @@ -0,0 +1,54 @@ + diff --git a/src/console-filters/docs/partials/console-filters-intro-markup.mustache b/src/console-filters/docs/partials/console-filters-intro-markup.mustache new file mode 100644 index 00000000000..7dfa0328db7 --- /dev/null +++ b/src/console-filters/docs/partials/console-filters-intro-markup.mustache @@ -0,0 +1,5 @@ +
+
+ + +