Merge lp:~michael.nelson/lazr-js/491337-error-style-try-2 into lp:lazr-js

Proposed by Michael Nelson
Status: Merged
Approved by: Brad Crittenden
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~michael.nelson/lazr-js/491337-error-style-try-2
Merge into: lp:lazr-js
Diff against target: 127 lines (+19/-17)
3 files modified
examples/error/minimal_example.html (+7/-6)
src-js/lazrjs/error/error-widget-minimal.js (+6/-7)
src-js/lazrjs/error/tests/error.js (+6/-4)
To merge this branch: bzr merge lp:~michael.nelson/lazr-js/491337-error-style-try-2
Reviewer Review Type Date Requested Status
Brad Crittenden (community) code Approve
Review via email: mp+16423@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Michael Nelson (michael.nelson) wrote :

Summary
=======

Fixes bug 491337 by ensuring that the minimal error widget has its own module, so that the associated css is loaded dynamically loaded at runtime when the module appears in a .use() statement.

To test:

Check the following url before and after merging (in FF or Chromium etc.):

file:///home/michael/canonical/lazr-js-branches/491337-error-style-try-2/examples/error/minimal_example.html

Before merging the error will be not be styled, appearing at the top-left of the window.

Revision history for this message
Michael Nelson (michael.nelson) wrote :

er, try:

firefox examples/error/minimal_example.html

Revision history for this message
Brad Crittenden (bac) wrote :

Thanks for the fix Michael.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'examples/error/minimal_example.html'
--- examples/error/minimal_example.html 2009-11-24 10:59:17 +0000
+++ examples/error/minimal_example.html 2009-12-21 12:04:16 +0000
@@ -25,14 +25,15 @@
25// demonstration has access to the function.25// demonstration has access to the function.
26var display_error;26var display_error;
27YUI(LAZR_YUI_CONFIG).use(27YUI(LAZR_YUI_CONFIG).use(
28 'lazr.error', 'lazr.error-widgets', 'lazr.anim', 'node', 'event',28 'lazr.error', 'lazr.error.minimal-error-widget', 'lazr.anim', 'node',
29 'dump', function(Y) {29 'event', 'dump', function(Y) {
3030
31 var input = Y.one('#input_box');31 var input = Y.one('#input_box');
32 var button = Y.one('#raise_error');32 var button = Y.one('#raise_error');
3333
34 // Set the error widget to the minimal one.34 // Set the error widget to the minimal one.
35 Y.lazr.error.widget = new Y.lazr.error_widgets.MinimalErrorWidget(35 var widget_module = Y.lazr.error.minimal_error_widget;
36 Y.lazr.error.widget = new widget_module.MinimalErrorWidget(
36 {visible: false});37 {visible: false});
37 Y.lazr.error.widget.render();38 Y.lazr.error.widget.render();
3839
@@ -82,15 +83,15 @@
8283
83<h2>Page setup</h2>84<h2>Page setup</h2>
84<p>The following Javascript and CSS files have been included for the85<p>The following Javascript and CSS files have been included for the
85 example on this page:</p> 86 example on this page:</p>
8687
87<h3>Javascript</h3>88<h3>Javascript</h3>
88In addition to the JS inclusions documented on the <a href="index.html">default error example</a>.89In addition to the JS inclusions documented on the <a href="index.html">default error example</a>.
89<pre>90<pre>
90 &lt;script type="text/javascript" src="../../build/error/error-widget-minimal.js"&gt;&lt;/script&gt;</pre>91 &lt;script type="text/javascript" src="../../build/error/error-widget-minimal.js"&gt;&lt;/script&gt;</pre>
9192
92Also the overlay inclusion is not necessary when using the minimal widget 93Also the overlay inclusion is not necessary when using the minimal widget
93(actually, it is still required because the BasicErrorWidget is still 94(actually, it is still required because the BasicErrorWidget is still
94sitting in the error.js file rather than a separate file).95sitting in the error.js file rather than a separate file).
9596
96<h3>CSS</h3>97<h3>CSS</h3>
9798
=== modified file 'src-js/lazrjs/error/error-widget-minimal.js'
--- src-js/lazrjs/error/error-widget-minimal.js 2009-11-24 10:59:17 +0000
+++ src-js/lazrjs/error/error-widget-minimal.js 2009-12-21 12:04:16 +0000
@@ -21,8 +21,8 @@
21 * @module lazr.error21 * @module lazr.error
22 * @namespace lazr.error22 * @namespace lazr.error
23 */23 */
24YUI.add('lazr.error-widgets', function(Y) {24YUI.add('lazr.error.minimal-error-widget', function(Y) {
25Y.namespace('lazr.error_widgets');25Y.namespace('lazr.error.minimal_error_widget');
2626
27/**27/**
28 * This class provides a minimal display of lazr errors, enabling28 * This class provides a minimal display of lazr errors, enabling
@@ -141,7 +141,7 @@
141 // Wrap back to the start if necessary.141 // Wrap back to the start if necessary.
142 var new_index = this._wrap_index(142 var new_index = this._wrap_index(
143 this.get(CURRENT_ERROR_INDEX) + amount);143 this.get(CURRENT_ERROR_INDEX) + amount);
144 this.set(CURRENT_ERROR_INDEX, new_index); 144 this.set(CURRENT_ERROR_INDEX, new_index);
145 },145 },
146146
147147
@@ -171,7 +171,7 @@
171 var content_box = this.get(CONTENT_BOX);171 var content_box = this.get(CONTENT_BOX);
172 var error_nodes = content_box.one('div.error-info ul.errors').get(172 var error_nodes = content_box.one('div.error-info ul.errors').get(
173 'children');173 'children');
174 174
175 error_nodes.removeClass(CURRENT);175 error_nodes.removeClass(CURRENT);
176 var error_index = 0;176 var error_index = 0;
177 var this_widget = this;177 var this_widget = this;
@@ -245,7 +245,7 @@
245245
246 // Swap the new error list in.246 // Swap the new error list in.
247 var content_box = this.get(CONTENT_BOX);247 var content_box = this.get(CONTENT_BOX);
248 248
249 var error_info = content_box.one('div.error-info');249 var error_info = content_box.one('div.error-info');
250 var old_error_list_node = error_info.one('ul.errors');250 var old_error_list_node = error_info.one('ul.errors');
251 error_info.replaceChild(new_error_list_node, old_error_list_node);251 error_info.replaceChild(new_error_list_node, old_error_list_node);
@@ -287,8 +287,7 @@
287 ' </div>',287 ' </div>',
288 '</div>'].join('');288 '</div>'].join('');
289289
290Y.lazr.error_widgets.MinimalErrorWidget = MinimalErrorWidget;290Y.lazr.error.minimal_error_widget.MinimalErrorWidget = MinimalErrorWidget;
291
292}, "0.1", {291}, "0.1", {
293 "skinnable": true,292 "skinnable": true,
294 "requires": ["oop", "event", "widget", "lazr.error"]});293 "requires": ["oop", "event", "widget", "lazr.error"]});
295294
=== modified file 'src-js/lazrjs/error/tests/error.js'
--- src-js/lazrjs/error/tests/error.js 2009-11-30 19:07:28 +0000
+++ src-js/lazrjs/error/tests/error.js 2009-12-21 12:04:16 +0000
@@ -19,8 +19,9 @@
19 base: '../../yui/',19 base: '../../yui/',
20 filter: 'raw',20 filter: 'raw',
21 combine: false21 combine: false
22 }).use('lazr.error', 'lazr.error-widgets', 'lazr.testing.runner', 'node',22 }).use(
23 'event', 'test', 'console', function(Y) {23 'lazr.error', 'lazr.error.minimal-error-widget', 'lazr.testing.runner',
24 'node', 'event', 'test', 'console', function(Y) {
2425
25var suite = new Y.Test.Suite('Lazr-js error Test Suite');26var suite = new Y.Test.Suite('Lazr-js error Test Suite');
2627
@@ -45,7 +46,7 @@
45 var error_message = "Error 1234567890";46 var error_message = "Error 1234567890";
46 Y.Mock.expect(47 Y.Mock.expect(
47 Y.lazr.error.widget, {48 Y.lazr.error.widget, {
48 method: "showError", 49 method: "showError",
49 args: [error_message]});50 args: [error_message]});
50 Y.lazr.error.display_error(error_message);51 Y.lazr.error.display_error(error_message);
51 Y.Mock.verify(Y.lazr.error.widget);52 Y.Mock.verify(Y.lazr.error.widget);
@@ -78,7 +79,8 @@
78 name: 'minimalerrorwidget_tests',79 name: 'minimalerrorwidget_tests',
7980
80 setUp: function() {81 setUp: function() {
81 Y.lazr.error.widget = new Y.lazr.error_widgets.MinimalErrorWidget();82 var widget_module = Y.lazr.error.minimal_error_widget;
83 Y.lazr.error.widget = new widget_module.MinimalErrorWidget();
82 Y.lazr.error.widget.render();84 Y.lazr.error.widget.render();
83 },85 },
8486

Subscribers

People subscribed via source and target branches