forked from liferay/yui3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
164 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
{{>console-filters-intro-css}} | ||
|
||
<div class="intro"> | ||
<p>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.</p> | ||
|
||
<p>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.</p> | ||
|
||
<p>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.</p> | ||
</div> | ||
|
||
<div class="example"> | ||
{{>console-filters-intro-markup}} | ||
{{>console-filters-intro-js}} | ||
</div> | ||
|
||
<h3 class="first">Configure the YUI instance for debug mode</h3> | ||
<p>Only the `<em>module</em>-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.</p> | ||
|
||
``` | ||
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) { ... }); | ||
``` | ||
|
||
<h3>Create the Console and plug in ConsoleFilters</h3> | ||
<p>All that's left to do now is plugin in the ConsoleFilters plugin. This can be done in one of a few ways.</p> | ||
``` | ||
// 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'); | ||
``` | ||
|
||
<p>Alternatively, you can attach the ConsoleFilters plugin after instantiation. This version also shows how to apply initial category and source filter states.</p> | ||
``` | ||
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(); | ||
</script> | ||
``` | ||
|
||
<h3>Full Code Listing</h3> | ||
|
||
<h4>Markup</h4> | ||
``` | ||
{{>console-filters-intro-markup}} | ||
``` | ||
|
||
<h4>JavaScript</h4> | ||
``` | ||
{{>console-filters-intro-js}} | ||
``` | ||
|
||
<h4>CSS</h4> | ||
``` | ||
{{>console-filters-intro-css}} | ||
``` | ||
|
Empty file.
17 changes: 17 additions & 0 deletions
17
src/console-filters/docs/partials/console-filters-intro-css.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<style scoped> | ||
#yconsole { | ||
margin: 0 auto 1em; | ||
} | ||
#demo .yui3-console .yui3-console-title { | ||
border: 0 none; | ||
color: #000; | ||
font-size: 13px; | ||
font-weight: bold; | ||
margin: 0; | ||
text-transform: none; | ||
} | ||
#demo .yui3-console .yui3-console-entry-meta { | ||
margin: 0; | ||
} | ||
</style> |
54 changes: 54 additions & 0 deletions
54
src/console-filters/docs/partials/console-filters-intro-js.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<script type="text/javascript"> | ||
// Create a YUI instance and request the console module and its dependencies | ||
YUI().use("console-filters", function (Y) { | ||
// create the console instance | ||
var yconsole = new Y.Console({ | ||
boundingBox: '#yconsole', | ||
height: '400px', | ||
width: '450px', | ||
newestOnTop: false, | ||
style: 'block', | ||
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'); | ||
/* Alternately | ||
var yconsole = new Y.Console({ | ||
boundingBox: '#console', | ||
height: '400px', | ||
width: '450px', | ||
style: 'block', | ||
newestOnTop: false | ||
}).plug(Y.Plugin.ConsoleFilters, { | ||
category: { | ||
error: false | ||
}, | ||
source: { | ||
attribute: false, | ||
widget: false | ||
} | ||
}).render(); | ||
*/ | ||
// Broadcast a log message from a button that uses a custom category and source | ||
Y.on('click', function () { | ||
Y.log('Logging a message to the Console','my_stuff','MyApp'); | ||
},'#log'); | ||
// It is also possible to set the filter's subattributes directly | ||
Y.on('click', function () { | ||
var current = yconsole.filter.get('category.info'); | ||
yconsole.filter.set('category.info', !current); | ||
this.set('text', (current ? 'Show' : 'Hide') + ' info messages'); | ||
},'#toggle_info'); | ||
}); | ||
</script> |
5 changes: 5 additions & 0 deletions
5
src/console-filters/docs/partials/console-filters-intro-markup.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div id="demo" class="yui3-skin-sam"> | ||
<div id="yconsole"></div> | ||
<button id="log" type="button">Log a message</button> | ||
<button id="toggle_info" type="button">Hide info messages</button> | ||
</div> |