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
1=== modified file 'examples/error/minimal_example.html'
2--- examples/error/minimal_example.html 2009-11-24 10:59:17 +0000
3+++ examples/error/minimal_example.html 2009-12-21 12:04:16 +0000
4@@ -25,14 +25,15 @@
5 // demonstration has access to the function.
6 var display_error;
7 YUI(LAZR_YUI_CONFIG).use(
8- 'lazr.error', 'lazr.error-widgets', 'lazr.anim', 'node', 'event',
9- 'dump', function(Y) {
10+ 'lazr.error', 'lazr.error.minimal-error-widget', 'lazr.anim', 'node',
11+ 'event', 'dump', function(Y) {
12
13 var input = Y.one('#input_box');
14 var button = Y.one('#raise_error');
15
16 // Set the error widget to the minimal one.
17- Y.lazr.error.widget = new Y.lazr.error_widgets.MinimalErrorWidget(
18+ var widget_module = Y.lazr.error.minimal_error_widget;
19+ Y.lazr.error.widget = new widget_module.MinimalErrorWidget(
20 {visible: false});
21 Y.lazr.error.widget.render();
22
23@@ -82,15 +83,15 @@
24
25 <h2>Page setup</h2>
26 <p>The following Javascript and CSS files have been included for the
27- example on this page:</p>
28+ example on this page:</p>
29
30 <h3>Javascript</h3>
31 In addition to the JS inclusions documented on the <a href="index.html">default error example</a>.
32 <pre>
33 &lt;script type="text/javascript" src="../../build/error/error-widget-minimal.js"&gt;&lt;/script&gt;</pre>
34
35-Also the overlay inclusion is not necessary when using the minimal widget
36-(actually, it is still required because the BasicErrorWidget is still
37+Also the overlay inclusion is not necessary when using the minimal widget
38+(actually, it is still required because the BasicErrorWidget is still
39 sitting in the error.js file rather than a separate file).
40
41 <h3>CSS</h3>
42
43=== modified file 'src-js/lazrjs/error/error-widget-minimal.js'
44--- src-js/lazrjs/error/error-widget-minimal.js 2009-11-24 10:59:17 +0000
45+++ src-js/lazrjs/error/error-widget-minimal.js 2009-12-21 12:04:16 +0000
46@@ -21,8 +21,8 @@
47 * @module lazr.error
48 * @namespace lazr.error
49 */
50-YUI.add('lazr.error-widgets', function(Y) {
51-Y.namespace('lazr.error_widgets');
52+YUI.add('lazr.error.minimal-error-widget', function(Y) {
53+Y.namespace('lazr.error.minimal_error_widget');
54
55 /**
56 * This class provides a minimal display of lazr errors, enabling
57@@ -141,7 +141,7 @@
58 // Wrap back to the start if necessary.
59 var new_index = this._wrap_index(
60 this.get(CURRENT_ERROR_INDEX) + amount);
61- this.set(CURRENT_ERROR_INDEX, new_index);
62+ this.set(CURRENT_ERROR_INDEX, new_index);
63 },
64
65
66@@ -171,7 +171,7 @@
67 var content_box = this.get(CONTENT_BOX);
68 var error_nodes = content_box.one('div.error-info ul.errors').get(
69 'children');
70-
71+
72 error_nodes.removeClass(CURRENT);
73 var error_index = 0;
74 var this_widget = this;
75@@ -245,7 +245,7 @@
76
77 // Swap the new error list in.
78 var content_box = this.get(CONTENT_BOX);
79-
80+
81 var error_info = content_box.one('div.error-info');
82 var old_error_list_node = error_info.one('ul.errors');
83 error_info.replaceChild(new_error_list_node, old_error_list_node);
84@@ -287,8 +287,7 @@
85 ' </div>',
86 '</div>'].join('');
87
88-Y.lazr.error_widgets.MinimalErrorWidget = MinimalErrorWidget;
89-
90+Y.lazr.error.minimal_error_widget.MinimalErrorWidget = MinimalErrorWidget;
91 }, "0.1", {
92 "skinnable": true,
93 "requires": ["oop", "event", "widget", "lazr.error"]});
94
95=== modified file 'src-js/lazrjs/error/tests/error.js'
96--- src-js/lazrjs/error/tests/error.js 2009-11-30 19:07:28 +0000
97+++ src-js/lazrjs/error/tests/error.js 2009-12-21 12:04:16 +0000
98@@ -19,8 +19,9 @@
99 base: '../../yui/',
100 filter: 'raw',
101 combine: false
102- }).use('lazr.error', 'lazr.error-widgets', 'lazr.testing.runner', 'node',
103- 'event', 'test', 'console', function(Y) {
104+ }).use(
105+ 'lazr.error', 'lazr.error.minimal-error-widget', 'lazr.testing.runner',
106+ 'node', 'event', 'test', 'console', function(Y) {
107
108 var suite = new Y.Test.Suite('Lazr-js error Test Suite');
109
110@@ -45,7 +46,7 @@
111 var error_message = "Error 1234567890";
112 Y.Mock.expect(
113 Y.lazr.error.widget, {
114- method: "showError",
115+ method: "showError",
116 args: [error_message]});
117 Y.lazr.error.display_error(error_message);
118 Y.Mock.verify(Y.lazr.error.widget);
119@@ -78,7 +79,8 @@
120 name: 'minimalerrorwidget_tests',
121
122 setUp: function() {
123- Y.lazr.error.widget = new Y.lazr.error_widgets.MinimalErrorWidget();
124+ var widget_module = Y.lazr.error.minimal_error_widget;
125+ Y.lazr.error.widget = new widget_module.MinimalErrorWidget();
126 Y.lazr.error.widget.render();
127 },
128

Subscribers

People subscribed via source and target branches