1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
<title>Lazr-js examples: error</title>
7
<link rel="stylesheet" type="text/css" href="../../build/cssreset/reset-min.css"></link>
8
<link rel="stylesheet" type="text/css" href="../../build/cssfonts/fonts-min.css"></link>
9
<link rel="stylesheet" type="text/css" href="../../build/cssbase/base-min.css"></link>
11
<script type="text/javascript" src="../../build/yui/yui-min.js"></script>
12
<script type="text/javascript" src="../../build/lazr/lazr-meta.js"></script>
13
<script type="text/javascript">
14
var LAZR_YUI_CONFIG = {
17
modules: LAZR_MODULES,
21
<script type="text/javascript">
23
// We create a global variable here to reference our display_error
24
// method only so that the call to setTimeout() below used for
25
// demonstration has access to the function.
27
YUI(LAZR_YUI_CONFIG).use(
28
'lazr.error', 'lazr.anim', 'node', 'event',
31
var input = Y.one('#input_box');
32
var button = Y.one('#raise_error');
34
var add_delayed_errors = function() {
35
display_error = Y.lazr.error.display_error;
37
'display_error("A subsequent error 1", "#input_box")',
40
'display_error("A subsequent error 2", "#input_box")',
43
'display_error("A subsequent error 3", "#input_box")',
47
// Ensure the error displays when the button is clicked.
48
button.on('click', function(){
49
Y.lazr.error.display_error(input.get('value'), '#input_box');
50
add_delayed_errors(input.get('value'));
53
// And display the error by default when the page loads.
54
Y.lazr.error.display_error(input.get('value'), '#input_box');
55
add_delayed_errors(input.get('value'));
62
<body class="yui3-skin-sam">
64
<h1>Using Lazr error</h1>
65
<p>The Lazr error helper allows generic error handling for site-wide issues
66
such as ajax-related errors, via the
67
<code>lazr.error.display_error()</code> method.</p>
71
<p>Enter your error here: <input type="text" id="input_box" value="Your error"/>
72
<button id="raise_error">Raise error</button></p>
74
<p>A second error should appear in the error widget after 3 seconds.</p>
77
<p>The following Javascript and CSS files have been included for the
78
example on this page (Note: error overlay currently extends
79
overlay - we should invert this):</p>
83
<script type="text/javascript" src="../../build/yui/yui-min.js"></script>
84
<script type="text/javascript" src="../../build/lazr/lazr-meta.js"></script>
88
<p>There is no setup necessary for the error overlay. When
89
calling display_error() you simply pass the error message
90
that should be displayed.</p>
92
Y.lazr.error.display_error("Your error message.");
95
<h3>Passing an optional node to flash</h3>
96
<p>You can optionally pass a node (or a selector) that should be
97
brought to the viewers attention. This node will be flashed red
98
before the error is displayed.
101
Y.lazr.error.display_error("Your error message.", '#input_box');