Merge lp:~sidnei/lazr-js/yui-3.0.0-redux into lp:lazr-js
- yui-3.0.0-redux
- Merge into toolchain
Status: | Merged |
---|---|
Approved by: | Edwin Grubbs |
Approved revision: | 154 |
Merged at revision: | not available |
Proposed branch: | lp:~sidnei/lazr-js/yui-3.0.0-redux |
Merge into: | lp:lazr-js |
Diff against target: |
159000 lines 0 files modified
|
To merge this branch: | bzr merge lp:~sidnei/lazr-js/yui-3.0.0-redux |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Edwin Grubbs (community) | code | Approve | |
Review via email: mp+13743@code.launchpad.net |
Commit message
Update to YUI 3.0.0.
Description of the change
Sidnei da Silva (sidnei) wrote : | # |
Sidnei da Silva (sidnei) wrote : | # |
Since the branch is large due to the inclusion of YUI 3.0.0, I've made a smaller incremental diff from the base branch (lp:~sidnei/lazr-js/jstestdriver-support).
Edwin Grubbs (edwin-grubbs) wrote : | # |
Hi Sidnei,
I'm glad I didn't have to do all this work. Thanks. I have quite a few
questions, so I'm marking this
needs-fixing
-Edwin
>=== modified file 'examples/
>--- examples/
>+++ new 2009-10-21 17:31:07.000000000 -0500
> var multiline_text = new Y.EditableText({
>- contentBox: '#edit-
>- multiline: true,
>- buttons: 'top'
>+ contentBox: '#multiline_text',
>+ multi_line: true,
>+ size: 70
> });
> multiline_
>
>- // Add the 2 second delay to the underlying editor widget.
>- multiline_
Why was this removed?
>+ // XXX remove this when done writing the *error CSS stuff.
>+ // editor.
>+ // editor.
Why were these comments added?
> });
> </script>
>
>=== modified file 'src-js/
>--- src-js/
>+++ src-js/
>@@ -4,7 +4,7 @@
> base: '../../
> filter: 'raw',
> combine: false
>- }).use(
>+ }).use(
Line too long.
> // Local aliases
> var Assert = Y.Assert,
>
>=== modified file 'src-js/
>--- src-js/
>+++ src-js/
>@@ -1,11 +1,11 @@
> /* Copyright (c) 2008, Canonical Ltd. All rights reserved. */
>
> YUI({
>- base: '../../
>+ base: '../../
> filter: 'raw',
> combine: false
> }).use(
>- 'lazr.testing.
>+ 'lazr.testing.
> 'console', function(Y) {
>
> var Assert = Y.Assert; // For easy access to isTrue(), etc.
>@@ -20,6 +20,17 @@
> Y.Event.
> }
>
>+/* Helper function to cleanup and destroy a form overlay instance */
>+function cleanup_
>+ if (form_overlay.
>+ var bb = form_overlay.
>+ bb.get(
>+ }
>+
>+ // Kill the widget itself.
>+ form_overlay.
>+}
>+
> /* Helper function that creates a new form overlay instance. */
> function make_form_
> var form_overlay = new Y.lazr.
>@@ -52,17 +63,7 @@
>
> tearDown: function() {
> window.
>- this.cleanUp(
>- },
>-
>- cleanUp: function(
>- if (form_overlay.
>- var bb = form_overlay.
>- ...
- 144. By Sidnei da Silva
-
- Merge from jstestdriver-
support - 145. By Sidnei da Silva
-
- Sort
- 146. By Sidnei da Silva
-
- Revert unwanted change to examples.
- Use proper AOP on Picker like on FormOverlay
- Kill some now meaningless comments (after above changes)
- Wrap some long lines - 147. By Sidnei da Silva
-
- Fix some long lines
Sidnei da Silva (sidnei) wrote : | # |
>>=== modified file 'examples/
>>--- examples/
>>- // Add the 2 second delay to the underlying editor widget.
>>- multiline_
>
> Why was this removed?
Uhm, that's something that came from Maris' branch. Since it doesn't
make sense to me either, re-adding it.
>>+ // XXX remove this when done writing the *error CSS stuff.
>>+ // editor.
>>+ // editor.
>
> Why were these comments added?
Same as above. Since it doesn't make sense to me, removing it.
>>=== modified file 'widgets.conf'
>>--- widgets.conf 2009-10-20 13:11:56 +0000
>>+++ widgets.conf 2009-10-21 22:29:49 +0000
>>@@ -5,37 +5,53 @@
>
>
> How is this file generated? There appear to be a bunch of diffs
> from entries just moving to different spots. If this is generated by
> a script, it would be nice to have it sort the list, so that future
> diffs show only real changes.
It's manually generated, though it would make sense to have a script
generate it. I will keep that in mind for the future.
In the meantime, I've sorted the file.
As for the long-lines and indentation, all fixed.
I also changed the Picker widget to use the AOP approach like was done
for FormOverlay, and all tests pass. Incremental diff below.
=== modified file 'examples/
--- examples/
+++ examples/
@@ -421,9 +421,8 @@
});
multiline_
- // XXX remove this when done writing the *error CSS stuff.
- // editor.
- // editor.
+ // Add the 2 second delay to the underlying editor widget.
+ multiline_
});
</script>
=== modified file 'src-js/
--- src-js/
+++ src-js/
@@ -4,7 +4,8 @@
base: '../../
filter: 'raw',
combine: false
- }).use(
'widget-stack', 'console', function(Y) {
+ }).use(
+ 'event', 'widget-stack', 'console', function(Y) {
// Local aliases
var Assert = Y.Assert,
=== modified file 'src-js/
--- src-js/
+++ src-js/
@@ -75,28 +75,19 @@
},
- // This fails because YUI adds an extra div for some reason.
- // If and when this is fixed, and this passes, we'll need to
- // update test_form_
- // _should: {
- // fail: {test_bodyConte
- // },
-
- test_bodyConten
+ test_body_
- 148. By Sidnei da Silva
-
- Fix comments
- 149. By Sidnei da Silva
-
- Fix some examples, though not all
- 150. By Sidnei da Silva
-
- Need to unplug the NodeMenuNav before plugging it, otherwise the descendants are all wrong.
- 151. By Sidnei da Silva
-
- AOP-ize more. Fix a bug with the zIndex of the PrettyOverlay
- 152. By Sidnei da Silva
-
- Merge from jstestdriver-
support - 153. By Sidnei da Silva
-
- Remove custom 'show()' method and use a handler on visibleChange instead.
- 154. By Sidnei da Silva
-
- Fix example
Edwin Grubbs (edwin-grubbs) wrote : | # |
Hi Sidnei,
Thanks for the fixes, and thanks for the explanations of some of the changes that the new version of YUI brings.
merge-approved
-Edwin
- 155. By Sidnei da Silva
-
- Merge from parent branch
Preview Diff
1 | === modified file 'buildout.cfg' | |||
2 | --- buildout.cfg 2009-10-27 08:59:24 +0000 | |||
3 | +++ buildout.cfg 2009-10-30 17:01:13 +0000 | |||
4 | @@ -2,6 +2,7 @@ | |||
5 | 2 | develop = . | 2 | develop = . |
6 | 3 | parts = | 3 | parts = |
7 | 4 | scripts | 4 | scripts |
8 | 5 | test | ||
9 | 5 | 6 | ||
10 | 6 | unzip = true | 7 | unzip = true |
11 | 7 | eggs-directory = eggs | 8 | eggs-directory = eggs |
12 | @@ -27,6 +28,16 @@ | |||
13 | 27 | [versions] | 28 | [versions] |
14 | 28 | # Alphabetical, case-insensitive, please! :-) | 29 | # Alphabetical, case-insensitive, please! :-) |
15 | 29 | bzr = 2.0.0 | 30 | bzr = 2.0.0 |
16 | 31 | lazr.testing = 0.1.1 | ||
17 | 32 | mocker = 0.10.1 | ||
18 | 30 | setuptools = 0.6c9 | 33 | setuptools = 0.6c9 |
19 | 31 | zc.buildout = 1.4.1 | 34 | zc.buildout = 1.4.1 |
20 | 32 | zc.recipe.egg = 1.2.2 | 35 | zc.recipe.egg = 1.2.2 |
21 | 36 | zc.recipe.testrunner = 1.2.0 | ||
22 | 37 | zope.exceptions = 3.5.2 | ||
23 | 38 | zope.interface = 3.5.1 | ||
24 | 39 | zope.testing = 3.8.1 | ||
25 | 40 | |||
26 | 41 | [test] | ||
27 | 42 | recipe = zc.recipe.testrunner | ||
28 | 43 | eggs = lazr-js | ||
29 | 33 | 44 | ||
30 | === modified file 'examples/activator/index.html' | |||
31 | --- examples/activator/index.html 2009-04-22 02:42:02 +0000 | |||
32 | +++ examples/activator/index.html 2009-10-30 17:01:13 +0000 | |||
33 | @@ -3,7 +3,7 @@ | |||
34 | 3 | <html> | 3 | <html> |
35 | 4 | <head> | 4 | <head> |
36 | 5 | <title>Lazr-js examples: Activator</title> | 5 | <title>Lazr-js examples: Activator</title> |
38 | 6 | <script type="text/javascript" src="../../lib/yui/current/build/yui/yui.js"></script> | 6 | <script type="text/javascript" src="../../build/yui/current/build/yui/yui.js"></script> |
39 | 7 | <script type="text/javascript" src="../../build/anim/anim.js"></script> | 7 | <script type="text/javascript" src="../../build/anim/anim.js"></script> |
40 | 8 | <script type="text/javascript" src="../../build/lazr/lazr.js"></script> | 8 | <script type="text/javascript" src="../../build/lazr/lazr.js"></script> |
41 | 9 | <script type="text/javascript" src="../../build/activator/activator.js"></script> | 9 | <script type="text/javascript" src="../../build/activator/activator.js"></script> |
42 | @@ -11,7 +11,7 @@ | |||
43 | 11 | <script id="example-script" type="text/javascript"> | 11 | <script id="example-script" type="text/javascript"> |
44 | 12 | 12 | ||
45 | 13 | YUI({ | 13 | YUI({ |
47 | 14 | base: '../../lib/yui/current/build/', | 14 | base: '../../build/yui/current/build/', |
48 | 15 | filter: 'raw' | 15 | filter: 'raw' |
49 | 16 | }).use('node', 'lazr.activator', function(Y) { | 16 | }).use('node', 'lazr.activator', function(Y) { |
50 | 17 | 17 | ||
51 | @@ -96,9 +96,9 @@ | |||
52 | 96 | We need to include individual css files because some of them have | 96 | We need to include individual css files because some of them have |
53 | 97 | relative paths to images. | 97 | relative paths to images. |
54 | 98 | --> | 98 | --> |
58 | 99 | <link rel="stylesheet" type="text/css" href="../../lib/yui/current/build/cssreset/reset.css" /> | 99 | <link rel="stylesheet" type="text/css" href="../../build/yui/current/build/cssreset/reset.css" /> |
59 | 100 | <link rel="stylesheet" type="text/css" href="../../lib/yui/current/build/cssfonts/fonts.css" /> | 100 | <link rel="stylesheet" type="text/css" href="../../build/yui/current/build/cssfonts/fonts.css" /> |
60 | 101 | <link rel="stylesheet" type="text/css" href="../../lib/yui/current/build/cssbase/base.css" /> | 101 | <link rel="stylesheet" type="text/css" href="../../build/yui/current/build/cssbase/base.css" /> |
61 | 102 | 102 | ||
62 | 103 | <link type="text/css" rel="stylesheet" href="../../build/lazr-sam.css"></link> | 103 | <link type="text/css" rel="stylesheet" href="../../build/lazr-sam.css"></link> |
63 | 104 | <link type="text/css" rel="stylesheet" href="../../build/lazr/assets/skins/sam/lazr.css"></link> | 104 | <link type="text/css" rel="stylesheet" href="../../build/lazr/assets/skins/sam/lazr.css"></link> |
64 | 105 | 105 | ||
65 | === modified file 'examples/anim/index.html' | |||
66 | --- examples/anim/index.html 2009-03-12 02:55:06 +0000 | |||
67 | +++ examples/anim/index.html 2009-10-30 17:01:13 +0000 | |||
68 | @@ -3,14 +3,14 @@ | |||
69 | 3 | <html> | 3 | <html> |
70 | 4 | <head> | 4 | <head> |
71 | 5 | <title>Lazr-js examples: anim</title> | 5 | <title>Lazr-js examples: anim</title> |
80 | 6 | <script type="text/javascript" src="../../lib/yui/current/build/yui/yui-min.js"></script> | 6 | <script type="text/javascript" src="../../build/yui/current/build/yui/yui-min.js"></script> |
81 | 7 | <script type="text/javascript" src="../../lib/yui/current/build/oop/oop-min.js"></script> | 7 | <script type="text/javascript" src="../../build/yui/current/build/oop/oop-min.js"></script> |
82 | 8 | <script type="text/javascript" src="../../lib/yui/current/build/event/event-min.js"></script> | 8 | <script type="text/javascript" src="../../build/yui/current/build/event/event-min.js"></script> |
83 | 9 | <script type="text/javascript" src="../../lib/yui/current/build/attribute/attribute-min.js"></script> | 9 | <script type="text/javascript" src="../../build/yui/current/build/attribute/attribute-min.js"></script> |
84 | 10 | <script type="text/javascript" src="../../lib/yui/current/build/base/base-min.js"></script> | 10 | <script type="text/javascript" src="../../build/yui/current/build/base/base-min.js"></script> |
85 | 11 | <script type="text/javascript" src="../../lib/yui/current/build/dom/dom-min.js"></script> | 11 | <script type="text/javascript" src="../../build/yui/current/build/dom/dom-min.js"></script> |
86 | 12 | <script type="text/javascript" src="../../lib/yui/current/build/node/node-min.js"></script> | 12 | <script type="text/javascript" src="../../build/yui/current/build/node/node-min.js"></script> |
87 | 13 | <script type="text/javascript" src="../../lib/yui/current/build/anim/anim-min.js"></script> | 13 | <script type="text/javascript" src="../../build/yui/current/build/anim/anim-min.js"></script> |
88 | 14 | 14 | ||
89 | 15 | <script type="text/javascript" src="../../build/anim/anim.js"></script> | 15 | <script type="text/javascript" src="../../build/anim/anim.js"></script> |
90 | 16 | <script type="text/javascript"> | 16 | <script type="text/javascript"> |
91 | 17 | 17 | ||
92 | === modified file 'examples/autocomplete/index.html' | |||
93 | --- examples/autocomplete/index.html 2009-04-22 19:02:42 +0000 | |||
94 | +++ examples/autocomplete/index.html 2009-10-30 17:01:13 +0000 | |||
95 | @@ -4,20 +4,20 @@ | |||
96 | 4 | <head> | 4 | <head> |
97 | 5 | <title>Lazr-js examples: autocomplete</title> | 5 | <title>Lazr-js examples: autocomplete</title> |
98 | 6 | 6 | ||
109 | 7 | <link type="text/css" rel="stylesheet" href="../../lib/yui/current/build/cssreset/reset.css"></link> | 7 | <link type="text/css" rel="stylesheet" href="../../build/yui/current/build/cssreset/reset.css"></link> |
110 | 8 | <link type="text/css" rel="stylesheet" href="../../lib/yui/current/build/cssfonts/fonts.css"></link> | 8 | <link type="text/css" rel="stylesheet" href="../../build/yui/current/build/cssfonts/fonts.css"></link> |
111 | 9 | <link type="text/css" rel="stylesheet" href="../../lib/yui/current/build/cssbase/base.css"></link> | 9 | <link type="text/css" rel="stylesheet" href="../../build/yui/current/build/cssbase/base.css"></link> |
112 | 10 | 10 | ||
113 | 11 | 11 | ||
114 | 12 | <script type="text/javascript" src="../../lib/yui/current/build/yui/yui.js"></script> | 12 | <script type="text/javascript" src="../../build/yui/current/build/yui/yui.js"></script> |
115 | 13 | <script type="text/javascript" src="../../lib/yui/current/build/widget/widget-position-debug.js"></script> | 13 | <script type="text/javascript" src="../../build/yui/current/build/widget/widget-position-debug.js"></script> |
116 | 14 | <script type="text/javascript" src="../../lib/yui/current/build/widget/widget-position-ext-debug.js"></script> | 14 | <script type="text/javascript" src="../../build/yui/current/build/widget/widget-position-ext-debug.js"></script> |
117 | 15 | <script type="text/javascript" src="../../lib/lazr/build/lazr.js"></script> | 15 | <script type="text/javascript" src="../../build/lazr/lazr.js"></script> |
118 | 16 | <script type="text/javascript" src="../../lib/lazr/build/autocomplete/autocomplete.js"></script> | 16 | <script type="text/javascript" src="../../build/autocomplete/autocomplete.js"></script> |
119 | 17 | <script type="text/javascript"> | 17 | <script type="text/javascript"> |
120 | 18 | 18 | ||
121 | 19 | var LP = YUI({ | 19 | var LP = YUI({ |
123 | 20 | base: '../../lib/yui/current/build/', | 20 | base: '../../build/yui/current/build/', |
124 | 21 | filter: 'raw' | 21 | filter: 'raw' |
125 | 22 | }); | 22 | }); |
126 | 23 | 23 | ||
127 | @@ -241,9 +241,9 @@ | |||
128 | 241 | We need to include individual css files because some of them have | 241 | We need to include individual css files because some of them have |
129 | 242 | relative paths to images. | 242 | relative paths to images. |
130 | 243 | --> | 243 | --> |
134 | 244 | <link type="text/css" rel="stylesheet" href="../../lib/lazr/build/lazr-sam.css"></link> | 244 | <link type="text/css" rel="stylesheet" href="../../build/lazr-sam.css"></link> |
135 | 245 | <link type="text/css" rel="stylesheet" href="../../lib/lazr/build/lazr/assets/skins/sam/lazr.css"></link> | 245 | <link type="text/css" rel="stylesheet" href="../../build/lazr/assets/skins/sam/lazr.css"></link> |
136 | 246 | <link type="text/css" rel="stylesheet" href="../../lib/lazr/build/autocomplete/assets/skins/sam/autocomplete.css"></link> | 246 | <link type="text/css" rel="stylesheet" href="../../build/autocomplete/assets/skins/sam/autocomplete.css"></link> |
137 | 247 | 247 | ||
138 | 248 | <style type="text/css"> | 248 | <style type="text/css"> |
139 | 249 | #example { | 249 | #example { |
140 | 250 | 250 | ||
141 | === modified file 'examples/choiceedit/index.html' | |||
142 | --- examples/choiceedit/index.html 2009-07-30 22:55:42 +0000 | |||
143 | +++ examples/choiceedit/index.html 2009-10-30 17:01:13 +0000 | |||
144 | @@ -2,150 +2,27 @@ | |||
145 | 2 | <html> | 2 | <html> |
146 | 3 | <head> | 3 | <head> |
147 | 4 | <title>Lazr-js examples: Choice editing</title> | 4 | <title>Lazr-js examples: Choice editing</title> |
150 | 5 | <script type="text/javascript" src="../../lib/yui/3.0.0pr2/build/yui/yui.js"></script> | 5 | <script type="text/javascript" src="../../build/yui/current/build/yui/yui.js"></script> |
151 | 6 | <script type="text/javascript" src="../../lib/lazr/build/lazr.js"></script> | 6 | <script type="text/javascript" src="../../build/lazr/lazr.js"></script> |
152 | 7 | <script type="text/javascript" src="../../build/anim/anim.js"></script> | ||
153 | 8 | <script type="text/javascript" src="../../build/overlay/overlay.js"></script> | ||
154 | 7 | 9 | ||
155 | 8 | <!-- | 10 | <!-- |
156 | 9 | We need to include individual css files because some of them have | 11 | We need to include individual css files because some of them have |
157 | 10 | relative paths to images. | 12 | relative paths to images. |
158 | 11 | --> | 13 | --> |
296 | 12 | <link type="text/css" rel="stylesheet" href="../../lib/lazr/build/lazr-sam.css"></link> | 14 | <link type="text/css" rel="stylesheet" href="../../build/lazr-sam.css"></link> |
297 | 13 | <link type="text/css" rel="stylesheet" href="../../lib/lazr/build/lazr/assets/skins/sam/lazr.css"></link> | 15 | <link type="text/css" rel="stylesheet" href="../../build/lazr/assets/skins/sam/lazr.css"></link> |
298 | 14 | <link type="text/css" rel="stylesheet" href="../../lib/lazr/build/inlineedit/assets/skins/sam/editor.css"></link> | 16 | <link type="text/css" rel="stylesheet" href="../../build/inlineedit/assets/skins/sam/editor.css"></link> |
299 | 15 | 17 | ||
300 | 16 | <script type="text/javascript" src="../../lib/lazr/build/choiceedit/choiceedit.js"></script> | 18 | <script type="text/javascript" src="../../build/choiceedit/choiceedit.js"></script> |
301 | 17 | <script> | 19 | |
302 | 18 | YUI({ | 20 | <link type="text/css" rel="stylesheet" |
303 | 19 | base: '../../lib/yui/3.0.0pr2/build/', | 21 | href="../../build/overlay/assets/pretty-overlay-core.css"> |
304 | 20 | filter: 'raw' | 22 | <link type="text/css" rel="stylesheet" |
305 | 21 | }).use('node', 'event', 'widget', 'plugin', 'overlay', 'lazr.choiceedit', function(Y) { | 23 | href="../../build/overlay/assets/skins/sam/pretty-overlay-skin.css"> |
306 | 22 | 24 | <link type="text/css" rel="stylesheet" | |
307 | 23 | // Add a delay between the start and end of the inline editor widget's | 25 | href="../../build/choiceedit/assets/choiceedit-core.css"> |
171 | 24 | // "save" event. | ||
172 | 25 | var DelayedSavePlugin = function(config) { | ||
173 | 26 | DelayedSavePlugin.superclass.constructor.apply(this, arguments); | ||
174 | 27 | }; | ||
175 | 28 | |||
176 | 29 | DelayedSavePlugin.NAME = 'delayedsave'; | ||
177 | 30 | DelayedSavePlugin.NS = 'fx'; | ||
178 | 31 | |||
179 | 32 | DelayedSavePlugin.ATTRS = { | ||
180 | 33 | /* | ||
181 | 34 | * Default duration of the 'saving' delay, in milliseconds. | ||
182 | 35 | */ | ||
183 | 36 | duration: { | ||
184 | 37 | value: 2000 | ||
185 | 38 | } | ||
186 | 39 | }; | ||
187 | 40 | |||
188 | 41 | Y.extend(DelayedSavePlugin, Y.Plugin, { | ||
189 | 42 | |||
190 | 43 | initializer: function(config) { | ||
191 | 44 | // Save a reference to the original _saveData() method before | ||
192 | 45 | // we wrap it up. | ||
193 | 46 | this.original_save = config.owner._saveData; | ||
194 | 47 | |||
195 | 48 | // We want to run our delayed-save code before the original | ||
196 | 49 | // 'save' method. Using doBefore() means that unplugging our | ||
197 | 50 | // code will leave the original widget in a clean state. | ||
198 | 51 | this.doBefore("_saveData", this._altSave); | ||
199 | 52 | }, | ||
200 | 53 | |||
201 | 54 | destructor: function() {}, | ||
202 | 55 | |||
203 | 56 | /* | ||
204 | 57 | * Our own _altSave() method, used to override the owner's default | ||
205 | 58 | * behaviour. This method will only be called if the editor's input | ||
206 | 59 | * is valid. | ||
207 | 60 | */ | ||
208 | 61 | _altSave: function() { | ||
209 | 62 | var owner = this._owner, | ||
210 | 63 | delay = this.get('duration'); | ||
211 | 64 | |||
212 | 65 | Y.log("Running alternative _saveData()", 'info'); | ||
213 | 66 | |||
214 | 67 | // Set the UI 'waiting' status. | ||
215 | 68 | owner._uiSetWaiting(); | ||
216 | 69 | |||
217 | 70 | // Introduce a configurable delay around the owner's _saveData() | ||
218 | 71 | // method. | ||
219 | 72 | Y.later(delay, this, function() { | ||
220 | 73 | |||
221 | 74 | Y.log("Running original 'save' method.", 'info'); | ||
222 | 75 | this.original_save.apply(owner, arguments[0]); | ||
223 | 76 | |||
224 | 77 | // Make sure we clear the 'waiting' status. | ||
225 | 78 | owner._uiClearWaiting(); | ||
226 | 79 | |||
227 | 80 | }, arguments); | ||
228 | 81 | |||
229 | 82 | // Make sure we prevent the default _devSave() method from | ||
230 | 83 | // running. | ||
231 | 84 | return new Y.Do.Halt(); | ||
232 | 85 | } | ||
233 | 86 | }); | ||
234 | 87 | |||
235 | 88 | |||
236 | 89 | var choice_edit = new Y.ChoiceSource({ | ||
237 | 90 | contentBox: '#status', | ||
238 | 91 | value: 'incomplete', | ||
239 | 92 | title: 'Change status to', | ||
240 | 93 | items: [ | ||
241 | 94 | { name: 'New', value: 'new', style: '', | ||
242 | 95 | help: '', disabled: false }, | ||
243 | 96 | { name: 'Invalid', value: 'invalid', style: '', | ||
244 | 97 | help: '', disabled: true }, | ||
245 | 98 | { name: 'Incomplete', value: 'incomplete', style: '', | ||
246 | 99 | help: '', disabled: false }, | ||
247 | 100 | { name: 'Fix Released', value: 'fixreleased', style: '', | ||
248 | 101 | help: '', disabled: false }, | ||
249 | 102 | { name: 'Fix Committed', value: 'fixcommitted', style: '', | ||
250 | 103 | help: '', disabled: true }, | ||
251 | 104 | { name: 'In Progress', value: 'inprogress', style: '', | ||
252 | 105 | help: '', disabled: false } | ||
253 | 106 | ] | ||
254 | 107 | }); | ||
255 | 108 | |||
256 | 109 | // Add the 2 second delay to the underlying editor widget. | ||
257 | 110 | choice_edit.plug({fn:DelayedSavePlugin}); | ||
258 | 111 | |||
259 | 112 | choice_edit.render(); | ||
260 | 113 | |||
261 | 114 | |||
262 | 115 | var null_choice_edit = new Y.NullChoiceSource({ | ||
263 | 116 | contentBox: '#nullchoiceedit', | ||
264 | 117 | value: null, | ||
265 | 118 | title: 'Choose something', | ||
266 | 119 | items: [ | ||
267 | 120 | { name: 'Chico', value: 'chico', style: '', | ||
268 | 121 | help: '', disabled: false }, | ||
269 | 122 | { name: 'Harpo', value: 'harpo', style: '', | ||
270 | 123 | help: '', disabled: false }, | ||
271 | 124 | { name: 'Groucho', value: 'groucho', style: '', | ||
272 | 125 | help: '', disabled: false }, | ||
273 | 126 | { name: 'Gummo', value: 'gummo', style: '', | ||
274 | 127 | help: '', disabled: false }, | ||
275 | 128 | { name: 'Zeppo', value: 'zeppo', style: '', | ||
276 | 129 | help: '', disabled: false }, | ||
277 | 130 | { name: 'Not funny!', value: null, style: '', | ||
278 | 131 | help: '', disabled: false } | ||
279 | 132 | ] | ||
280 | 133 | }); | ||
281 | 134 | |||
282 | 135 | // Add the 2 second delay to the underlying editor widget. | ||
283 | 136 | null_choice_edit.plug({fn:DelayedSavePlugin}); | ||
284 | 137 | |||
285 | 138 | null_choice_edit.render(); | ||
286 | 139 | }) | ||
287 | 140 | |||
288 | 141 | </script> | ||
289 | 142 | |||
290 | 143 | <link type="text/css" rel="stylesheet" | ||
291 | 144 | href="../../lib/lazr/build/overlay/assets/pretty-overlay-core.css"> | ||
292 | 145 | <link type="text/css" rel="stylesheet" | ||
293 | 146 | href="../../lib/lazr/build/overlay/assets/skins/sam/pretty-overlay-skin.css"> | ||
294 | 147 | <link type="text/css" rel="stylesheet" | ||
295 | 148 | href="../../lib/lazr/build/choiceedit/assets/choiceedit-core.css"> | ||
308 | 149 | </head> | 26 | </head> |
309 | 150 | <body class="yui-skin-sam"> | 27 | <body class="yui-skin-sam"> |
310 | 151 | 28 | ||
311 | @@ -159,15 +36,15 @@ | |||
312 | 159 | 36 | ||
313 | 160 | <h2>Required include dependencies</h2> | 37 | <h2>Required include dependencies</h2> |
314 | 161 | <pre> | 38 | <pre> |
318 | 162 | <script type="text/javascript" src="../../lib/yui/3.0.0pr2/build/yui/yui.js"></script> | 39 | <script type="text/javascript" src="../../build/yui/current/build/yui/yui.js"></script> |
319 | 163 | <script type="text/javascript" src="../../lib/lazr/build/choiceedit/choiceedit.js"></script> | 40 | <script type="text/javascript" src="../../build/choiceedit/choiceedit.js"></script> |
320 | 164 | <script type="text/javascript" src="../../lib/lazr/build/anim/anim.js"></script> | 41 | <script type="text/javascript" src="../../build/anim/anim.js"></script> |
321 | 165 | 42 | ||
322 | 166 | <!-- overlay required files --> | 43 | <!-- overlay required files --> |
325 | 167 | <link type="text/css" rel="stylesheet" href="../../lib/lazr/build/overlay/assets/pretty-overlay-core.css"></link> | 44 | <link type="text/css" rel="stylesheet" href="../../build/overlay/assets/pretty-overlay-core.css"></link> |
326 | 168 | <link type="text/css" rel="stylesheet" href="../../lib/lazr/build/overlay/assets/skins/sam/pretty-overlay-skin.css"></link> | 45 | <link type="text/css" rel="stylesheet" href="../../build/overlay/assets/skins/sam/pretty-overlay-skin.css"></link> |
327 | 169 | <!-- choiceedit required files --> | 46 | <!-- choiceedit required files --> |
329 | 170 | <link type="text/css" rel="stylesheet" href="../../lib/lazr/build/choiceedit/assets/choiceedit-core.css"></link> | 47 | <link type="text/css" rel="stylesheet" href="../../build/choiceedit/assets/choiceedit-core.css"></link> |
330 | 171 | 48 | ||
331 | 172 | </pre> | 49 | </pre> |
332 | 173 | 50 | ||
333 | @@ -297,5 +174,131 @@ | |||
334 | 297 | </p> | 174 | </p> |
335 | 298 | </pre> | 175 | </pre> |
336 | 299 | 176 | ||
337 | 177 | <script> | ||
338 | 178 | YUI({ | ||
339 | 179 | base: '../../build/yui/current/build/', | ||
340 | 180 | filter: 'raw' | ||
341 | 181 | }).use('node', 'event', 'widget', 'plugin', 'overlay', 'lazr.choiceedit', function(Y) { | ||
342 | 182 | |||
343 | 183 | // Add a delay between the start and end of the inline editor widget's | ||
344 | 184 | // "save" event. | ||
345 | 185 | var DelayedSavePlugin = function(config) { | ||
346 | 186 | DelayedSavePlugin.superclass.constructor.apply(this, arguments); | ||
347 | 187 | }; | ||
348 | 188 | |||
349 | 189 | DelayedSavePlugin.NAME = 'delayedsave'; | ||
350 | 190 | DelayedSavePlugin.NS = 'fx'; | ||
351 | 191 | |||
352 | 192 | DelayedSavePlugin.ATTRS = { | ||
353 | 193 | /* | ||
354 | 194 | * Default duration of the 'saving' delay, in milliseconds. | ||
355 | 195 | */ | ||
356 | 196 | duration: { | ||
357 | 197 | value: 2000 | ||
358 | 198 | } | ||
359 | 199 | }; | ||
360 | 200 | |||
361 | 201 | Y.extend(DelayedSavePlugin, Y.Plugin.Base, { | ||
362 | 202 | |||
363 | 203 | initializer: function(config) { | ||
364 | 204 | // Save a reference to the original _saveData() method before | ||
365 | 205 | // we wrap it up. | ||
366 | 206 | this.original_save = config.host._saveData; | ||
367 | 207 | |||
368 | 208 | // We want to run our delayed-save code before the original | ||
369 | 209 | // 'save' method. Using doBefore() means that unplugging our | ||
370 | 210 | // code will leave the original widget in a clean state. | ||
371 | 211 | this.doBefore("_saveData", this._altSave); | ||
372 | 212 | }, | ||
373 | 213 | |||
374 | 214 | destructor: function() {}, | ||
375 | 215 | |||
376 | 216 | /* | ||
377 | 217 | * Our own _altSave() method, used to override the host's default | ||
378 | 218 | * behaviour. This method will only be called if the editor's input | ||
379 | 219 | * is valid. | ||
380 | 220 | */ | ||
381 | 221 | _altSave: function() { | ||
382 | 222 | var host = this.get('host'), | ||
383 | 223 | delay = this.get('duration'); | ||
384 | 224 | |||
385 | 225 | Y.log("Running alternative _saveData()", 'info'); | ||
386 | 226 | |||
387 | 227 | // Set the UI 'waiting' status. | ||
388 | 228 | host._uiSetWaiting(); | ||
389 | 229 | |||
390 | 230 | // Introduce a configurable delay around the host's _saveData() | ||
391 | 231 | // method. | ||
392 | 232 | Y.later(delay, this, function() { | ||
393 | 233 | |||
394 | 234 | Y.log("Running original 'save' method.", 'info'); | ||
395 | 235 | this.original_save.apply(host, arguments); | ||
396 | 236 | |||
397 | 237 | // Make sure we clear the 'waiting' status. | ||
398 | 238 | host._uiClearWaiting(); | ||
399 | 239 | |||
400 | 240 | }, arguments); | ||
401 | 241 | |||
402 | 242 | // Make sure we prevent the default _devSave() method from | ||
403 | 243 | // running. | ||
404 | 244 | return new Y.Do.Halt(); | ||
405 | 245 | } | ||
406 | 246 | }); | ||
407 | 247 | |||
408 | 248 | |||
409 | 249 | var choice_edit = new Y.ChoiceSource({ | ||
410 | 250 | contentBox: '#status', | ||
411 | 251 | value: 'incomplete', | ||
412 | 252 | title: 'Change status to', | ||
413 | 253 | items: [ | ||
414 | 254 | { name: 'New', value: 'new', style: '', | ||
415 | 255 | help: '', disabled: false }, | ||
416 | 256 | { name: 'Invalid', value: 'invalid', style: '', | ||
417 | 257 | help: '', disabled: true }, | ||
418 | 258 | { name: 'Incomplete', value: 'incomplete', style: '', | ||
419 | 259 | help: '', disabled: false }, | ||
420 | 260 | { name: 'Fix Released', value: 'fixreleased', style: '', | ||
421 | 261 | help: '', disabled: false }, | ||
422 | 262 | { name: 'Fix Committed', value: 'fixcommitted', style: '', | ||
423 | 263 | help: '', disabled: true }, | ||
424 | 264 | { name: 'In Progress', value: 'inprogress', style: '', | ||
425 | 265 | help: '', disabled: false } | ||
426 | 266 | ] | ||
427 | 267 | }); | ||
428 | 268 | |||
429 | 269 | // Add the 2 second delay to the underlying editor widget. | ||
430 | 270 | choice_edit.plug({fn:DelayedSavePlugin}); | ||
431 | 271 | |||
432 | 272 | choice_edit.render(); | ||
433 | 273 | |||
434 | 274 | |||
435 | 275 | var null_choice_edit = new Y.NullChoiceSource({ | ||
436 | 276 | contentBox: '#nullchoiceedit', | ||
437 | 277 | value: null, | ||
438 | 278 | title: 'Choose something', | ||
439 | 279 | items: [ | ||
440 | 280 | { name: 'Chico', value: 'chico', style: '', | ||
441 | 281 | help: '', disabled: false }, | ||
442 | 282 | { name: 'Harpo', value: 'harpo', style: '', | ||
443 | 283 | help: '', disabled: false }, | ||
444 | 284 | { name: 'Groucho', value: 'groucho', style: '', | ||
445 | 285 | help: '', disabled: false }, | ||
446 | 286 | { name: 'Gummo', value: 'gummo', style: '', | ||
447 | 287 | help: '', disabled: false }, | ||
448 | 288 | { name: 'Zeppo', value: 'zeppo', style: '', | ||
449 | 289 | help: '', disabled: false }, | ||
450 | 290 | { name: 'Not funny!', value: null, style: '', | ||
451 | 291 | help: '', disabled: false } | ||
452 | 292 | ] | ||
453 | 293 | }); | ||
454 | 294 | |||
455 | 295 | // Add the 2 second delay to the underlying editor widget. | ||
456 | 296 | null_choice_edit.plug({fn:DelayedSavePlugin}); | ||
457 | 297 | |||
458 | 298 | null_choice_edit.render(); | ||
459 | 299 | }) | ||
460 | 300 | |||
461 | 301 | </script> | ||
462 | 302 | |||
463 | 300 | </body> | 303 | </body> |
464 | 301 | </html> | 304 | </html> |
465 | 302 | 305 | ||
466 | === modified file 'examples/effects/index.html' | |||
467 | --- examples/effects/index.html 2009-07-21 02:14:12 +0000 | |||
468 | +++ examples/effects/index.html 2009-10-30 17:01:13 +0000 | |||
469 | @@ -4,21 +4,21 @@ | |||
470 | 4 | <head> | 4 | <head> |
471 | 5 | <title>Lazr-js examples: lazr.effects</title> | 5 | <title>Lazr-js examples: lazr.effects</title> |
472 | 6 | 6 | ||
476 | 7 | <link type="text/css" rel="stylesheet" href="../../lib/yui/current/build/cssreset/reset.css"></link> | 7 | <link type="text/css" rel="stylesheet" href="../../build/yui/current/build/cssreset/reset.css"></link> |
477 | 8 | <link type="text/css" rel="stylesheet" href="../../lib/yui/current/build/cssfonts/fonts.css"></link> | 8 | <link type="text/css" rel="stylesheet" href="../../build/yui/current/build/cssfonts/fonts.css"></link> |
478 | 9 | <link type="text/css" rel="stylesheet" href="../../lib/yui/current/build/cssbase/base.css"></link> | 9 | <link type="text/css" rel="stylesheet" href="../../build/yui/current/build/cssbase/base.css"></link> |
479 | 10 | 10 | ||
483 | 11 | <script type="text/javascript" src="../../lib/yui/current/build/yui/yui.js"></script> | 11 | <script type="text/javascript" src="../../build/yui/current/build/yui/yui.js"></script> |
484 | 12 | <script type="text/javascript" src="../../lib/lazr/build/lazr.js"></script> | 12 | <script type="text/javascript" src="../../build/lazr.js"></script> |
485 | 13 | <script type="text/javascript" src="../../lib/lazr/build/effects/effects.js"></script> | 13 | <script type="text/javascript" src="../../build/effects/effects.js"></script> |
486 | 14 | 14 | ||
487 | 15 | <!-- | 15 | <!-- |
488 | 16 | We need to include individual css files because some of them have | 16 | We need to include individual css files because some of them have |
489 | 17 | relative paths to images. | 17 | relative paths to images. |
490 | 18 | --> | 18 | --> |
494 | 19 | <link type="text/css" rel="stylesheet" href="../../lib/lazr/build/lazr-sam.css"></link> | 19 | <link type="text/css" rel="stylesheet" href="../../build/lazr-sam.css"></link> |
495 | 20 | <link type="text/css" rel="stylesheet" href="../../lib/lazr/build/lazr/assets/skins/sam/lazr.css"></link> | 20 | <link type="text/css" rel="stylesheet" href="../../build/lazr/assets/skins/sam/lazr.css"></link> |
496 | 21 | <link type="text/css" rel="stylesheet" href="../../lib/lazr/build/effects/assets/skins/sam/effects.css"></link> | 21 | <link type="text/css" rel="stylesheet" href="../../build/effects/assets/skins/sam/effects.css"></link> |
497 | 22 | 22 | ||
498 | 23 | <style type="text/css"> | 23 | <style type="text/css"> |
499 | 24 | .example { | 24 | .example { |
500 | @@ -192,7 +192,7 @@ | |||
501 | 192 | <script type="text/javascript"> | 192 | <script type="text/javascript"> |
502 | 193 | 193 | ||
503 | 194 | YUI({ | 194 | YUI({ |
505 | 195 | base: '../../lib/yui/current/build/', | 195 | base: '../../build/yui/current/build/', |
506 | 196 | filter: 'raw' | 196 | filter: 'raw' |
507 | 197 | }).use('node', 'event', 'lazr.effects', function(Y) { | 197 | }).use('node', 'event', 'lazr.effects', function(Y) { |
508 | 198 | 198 | ||
509 | 199 | 199 | ||
510 | === modified file 'examples/formoverlay/index.html' | |||
511 | --- examples/formoverlay/index.html 2009-05-15 07:38:48 +0000 | |||
512 | +++ examples/formoverlay/index.html 2009-10-30 17:01:13 +0000 | |||
513 | @@ -5,21 +5,22 @@ | |||
514 | 5 | <title>LAZR JS Examples: lazr.formoverlay</title> | 5 | <title>LAZR JS Examples: lazr.formoverlay</title> |
515 | 6 | <meta http-equiv="content-type" content="text/html;charset=utf-8" /> | 6 | <meta http-equiv="content-type" content="text/html;charset=utf-8" /> |
516 | 7 | 7 | ||
520 | 8 | <script type="text/javascript" src="../../lib/yui/3.0.0pr2/build/yui/yui.js"></script> | 8 | <script type="text/javascript" src="../../build/yui/current/build/yui/yui.js"></script> |
521 | 9 | <script type="text/javascript" src="../../lib/lazr/build/overlay/overlay.js"></script> | 9 | <script type="text/javascript" src="../../build/lazr/lazr.js"></script> |
522 | 10 | <script type="text/javascript" src="../../lib/lazr/build/formoverlay/formoverlay.js"></script> | 10 | <script type="text/javascript" src="../../build/overlay/overlay.js"></script> |
523 | 11 | <script type="text/javascript" src="../../build/formoverlay/formoverlay.js"></script> | ||
524 | 11 | 12 | ||
531 | 12 | <link rel="stylesheet" href="../../lib/yui/3.0.0pr2/build/cssreset/reset.css"/> | 13 | <link rel="stylesheet" href="../../build/yui/current/build/cssreset/reset.css"/> |
532 | 13 | <link rel="stylesheet" href="../../lib/yui/3.0.0pr2/build/cssfonts/fonts.css"/> | 14 | <link rel="stylesheet" href="../../build/yui/current/build/cssfonts/fonts.css"/> |
533 | 14 | <link rel="stylesheet" href="../../lib/yui/3.0.0pr2/build/cssbase/base.css"/> | 15 | <link rel="stylesheet" href="../../build/yui/current/build/cssbase/base.css"/> |
534 | 15 | <link rel="stylesheet" href="../../lib/lazr/build/overlay/assets/pretty-overlay-core.css"/> | 16 | <link rel="stylesheet" href="../../build/overlay/assets/pretty-overlay-core.css"/> |
535 | 16 | <link rel="stylesheet" href="../../lib/lazr/build/overlay/assets/skins/sam/pretty-overlay-skin.css"/> | 17 | <link rel="stylesheet" href="../../build/overlay/assets/skins/sam/pretty-overlay-skin.css"/> |
536 | 17 | <link rel="stylesheet" href="../../lib/lazr/build/formoverlay/assets/formoverlay.css"/> | 18 | <link rel="stylesheet" href="../../build/formoverlay/assets/formoverlay.css"/> |
537 | 18 | 19 | ||
538 | 19 | <script type="text/javascript"> | 20 | <script type="text/javascript"> |
539 | 20 | 21 | ||
540 | 21 | YUI({ | 22 | YUI({ |
542 | 22 | base: "../../lib/yui/3.0.0pr2/build/", | 23 | base: "../../build/yui/current/build/", |
543 | 23 | filter: 'raw', | 24 | filter: 'raw', |
544 | 24 | }).use('lazr.formoverlay', 'node', 'event', 'dump', function(Y) { | 25 | }).use('lazr.formoverlay', 'node', 'event', 'dump', function(Y) { |
545 | 25 | 26 | ||
546 | @@ -93,7 +94,9 @@ | |||
547 | 93 | }); | 94 | }); |
548 | 94 | formoverlay.render(); | 95 | formoverlay.render(); |
549 | 95 | 96 | ||
551 | 96 | Y.on("domready", function(){ formoverlay.show()}); | 97 | Y.on("domready", function(){ |
552 | 98 | formoverlay.show(); | ||
553 | 99 | }); | ||
554 | 97 | 100 | ||
555 | 98 | Y.on('click', function(e) { | 101 | Y.on('click', function(e) { |
556 | 99 | Y.log("Showing overlay", "info"); | 102 | Y.log("Showing overlay", "info"); |
557 | @@ -123,16 +126,16 @@ | |||
558 | 123 | 126 | ||
559 | 124 | <h3>Javascript</h3> | 127 | <h3>Javascript</h3> |
560 | 125 | <pre> | 128 | <pre> |
564 | 126 | <script type="text/javascript" src="../../lib/yui/3.0.0pr2/build/yui/yui.js"></script> | 129 | <script type="text/javascript" src="../../build/yui/current/build/yui/yui.js"></script> |
565 | 127 | <script type="text/javascript" src="../../lib/lazr/build/overlay/overlay.js"></script> | 130 | <script type="text/javascript" src="../../build/overlay/overlay.js"></script> |
566 | 128 | <script type="text/javascript" src="../../lib/lazr/build/formoverlay/formoverlay.js"></script> | 131 | <script type="text/javascript" src="../../build/formoverlay/formoverlay.js"></script> |
567 | 129 | </pre> | 132 | </pre> |
568 | 130 | 133 | ||
569 | 131 | <h3>CSS</h3> | 134 | <h3>CSS</h3> |
570 | 132 | <pre> | 135 | <pre> |
574 | 133 | <link rel="stylesheet" href="../../lib/lazr/build/overlay/assets/pretty-overlay-core.css" /> | 136 | <link rel="stylesheet" href="../../build/overlay/assets/pretty-overlay-core.css" /> |
575 | 134 | <link rel="stylesheet" href="../../lib/lazr/build/overlay/assets/skins/sam/pretty-overlay-skin.css" /> | 137 | <link rel="stylesheet" href="../../build/overlay/assets/skins/sam/pretty-overlay-skin.css" /> |
576 | 135 | <link rel="stylesheet" href="../../lib/lazr/build/formoverlay/assets/formoverlay.css" /> | 138 | <link rel="stylesheet" href="../../build/formoverlay/assets/formoverlay.css" /> |
577 | 136 | </pre> | 139 | </pre> |
578 | 137 | 140 | ||
579 | 138 | <h2>Widget Setup</h2> | 141 | <h2>Widget Setup</h2> |
580 | 139 | 142 | ||
581 | === modified file 'examples/inlineeditor/index.html' | |||
582 | --- examples/inlineeditor/index.html 2009-10-22 02:04:44 +0000 | |||
583 | +++ examples/inlineeditor/index.html 2009-10-30 17:01:13 +0000 | |||
584 | @@ -3,117 +3,19 @@ | |||
585 | 3 | <html> | 3 | <html> |
586 | 4 | <head> | 4 | <head> |
587 | 5 | <title>Lazr-js examples: In-line text editing</title> | 5 | <title>Lazr-js examples: In-line text editing</title> |
690 | 6 | <script type="text/javascript" src="../../lib/yui/3.0.0pr2/build/yui/yui.js"></script> | 6 | <script type="text/javascript" src="../../build/yui/current/build/yui/yui.js"></script> |
691 | 7 | <script type="text/javascript" src="../../lib/lazr/build/lazr.js"></script> | 7 | <script type="text/javascript" src="../../build/lazr/lazr.js"></script> |
692 | 8 | <script type="text/javascript" src="../../lib/lazr/build/inlineedit/editor.js"></script> | 8 | <script type="text/javascript" src="../../build/anim/anim.js"></script> |
693 | 9 | <script type="text/javascript"> | 9 | <script type="text/javascript" src="../../build/inlineedit/editor.js"></script> |
592 | 10 | |||
593 | 11 | YUI({ | ||
594 | 12 | base: '../../lib/yui/3.0.0pr2/build/', | ||
595 | 13 | filter: 'raw' | ||
596 | 14 | }).use('node', 'event', 'plugin', 'lazr.editor', function(Y) { | ||
597 | 15 | |||
598 | 16 | // Add a delay between the start and end of the inline editor widget's | ||
599 | 17 | // "save" event. | ||
600 | 18 | var DelayedSavePlugin = function(config) { | ||
601 | 19 | DelayedSavePlugin.superclass.constructor.apply(this, arguments); | ||
602 | 20 | }; | ||
603 | 21 | |||
604 | 22 | DelayedSavePlugin.NAME = 'delayedsave'; | ||
605 | 23 | DelayedSavePlugin.NS = 'fx'; | ||
606 | 24 | |||
607 | 25 | DelayedSavePlugin.ATTRS = { | ||
608 | 26 | /* | ||
609 | 27 | * Default duration of the 'saving' delay, in milliseconds. | ||
610 | 28 | */ | ||
611 | 29 | duration: { | ||
612 | 30 | value: 2000 | ||
613 | 31 | } | ||
614 | 32 | }; | ||
615 | 33 | |||
616 | 34 | Y.extend(DelayedSavePlugin, Y.Plugin, { | ||
617 | 35 | |||
618 | 36 | initializer: function(config) { | ||
619 | 37 | // Save a reference to the original _saveData() method before | ||
620 | 38 | // we wrap it up. | ||
621 | 39 | this.original_save = config.owner._saveData; | ||
622 | 40 | |||
623 | 41 | // We want to run our delayed-save code before the original | ||
624 | 42 | // 'save' method. Using doBefore() means that unplugging our | ||
625 | 43 | // code will leave the original widget in a clean state. | ||
626 | 44 | this.doBefore("_saveData", this._altSave); | ||
627 | 45 | }, | ||
628 | 46 | |||
629 | 47 | destructor: function() {}, | ||
630 | 48 | |||
631 | 49 | /* | ||
632 | 50 | * Our own _altSave() method, used to override the owner's default | ||
633 | 51 | * behaviour. This method will only be called if the editor's input | ||
634 | 52 | * is valid. | ||
635 | 53 | */ | ||
636 | 54 | _altSave: function() { | ||
637 | 55 | var owner = this._owner, | ||
638 | 56 | delay = this.get('duration'); | ||
639 | 57 | |||
640 | 58 | Y.log("Running alternative _saveData()", 'info'); | ||
641 | 59 | |||
642 | 60 | // Set the UI 'waiting' status. | ||
643 | 61 | owner._uiSetWaiting(); | ||
644 | 62 | |||
645 | 63 | // Introduce a configurable delay around the owner's _saveData() | ||
646 | 64 | // method. | ||
647 | 65 | Y.later(delay, this, function() { | ||
648 | 66 | |||
649 | 67 | Y.log("Running original 'save' method.", 'info'); | ||
650 | 68 | this.original_save.apply(owner, arguments[0]); | ||
651 | 69 | |||
652 | 70 | // Make sure we clear the 'waiting' status. | ||
653 | 71 | owner._uiClearWaiting(); | ||
654 | 72 | |||
655 | 73 | }, arguments); | ||
656 | 74 | |||
657 | 75 | // Make sure we prevent the default _devSave() method from | ||
658 | 76 | // running. | ||
659 | 77 | return new Y.Do.Halt(); | ||
660 | 78 | } | ||
661 | 79 | }); | ||
662 | 80 | |||
663 | 81 | var editable_text = new Y.EditableText({ | ||
664 | 82 | contentBox: '#editable_text' | ||
665 | 83 | }); | ||
666 | 84 | |||
667 | 85 | editable_text.render(); | ||
668 | 86 | |||
669 | 87 | // Add the 2 second delay to the underlying editor widget. | ||
670 | 88 | editable_text.editor.plug({fn:DelayedSavePlugin}); | ||
671 | 89 | |||
672 | 90 | // Hook up the "allow empty" button. | ||
673 | 91 | Y.on('click', function(ev) { | ||
674 | 92 | var accept_empty = !editor.get('accept_empty'); | ||
675 | 93 | Y.log("Allowing empty editor input: " + accept_empty, 'info'); | ||
676 | 94 | editor.set('accept_empty', accept_empty); | ||
677 | 95 | }, 'input[name=accept_empty]'); | ||
678 | 96 | |||
679 | 97 | var multiline_text = new Y.EditableText({ | ||
680 | 98 | contentBox: '#edit-test-description', | ||
681 | 99 | multiline: true, | ||
682 | 100 | buttons: 'top' | ||
683 | 101 | }); | ||
684 | 102 | multiline_text.render(); | ||
685 | 103 | |||
686 | 104 | // Add the 2 second delay to the underlying editor widget. | ||
687 | 105 | multiline_text.editor.plug({fn:DelayedSavePlugin}); | ||
688 | 106 | }); | ||
689 | 107 | </script> | ||
694 | 108 | 10 | ||
695 | 109 | <!-- | 11 | <!-- |
696 | 110 | We need to include individual css files because some of them have | 12 | We need to include individual css files because some of them have |
697 | 111 | relative paths to images. | 13 | relative paths to images. |
698 | 112 | --> | 14 | --> |
703 | 113 | <link type="text/css" rel="stylesheet" href="../../lib/lazr/build/lazr-sam.css"></link> | 15 | <link type="text/css" rel="stylesheet" href="../../build/lazr-sam.css"></link> |
704 | 114 | <link type="text/css" rel="stylesheet" href="../../lib/lazr/build/lazr/assets/skins/sam/lazr.css"></link> | 16 | <link type="text/css" rel="stylesheet" href="../../build/lazr/assets/skins/sam/lazr.css"></link> |
705 | 115 | <link type="text/css" rel="stylesheet" href="../../lib/lazr/build/inlineedit/assets/skins/sam/editor.css"></link> | 17 | <link type="text/css" rel="stylesheet" href="../../build/inlineedit/assets/skins/sam/editor.css"></link> |
706 | 116 | <link rel="stylesheet" type="text/css" href="../../src/inlineedit/assets/skins/sam/editor-skin.css" /> | 18 | <link rel="stylesheet" type="text/css" href="../../build/inlineedit/assets/skins/sam/editor-skin.css" /> |
707 | 117 | <style> | 19 | <style> |
708 | 118 | #example { | 20 | #example { |
709 | 119 | margin-left: 20px; | 21 | margin-left: 20px; |
710 | @@ -163,11 +65,11 @@ | |||
711 | 163 | <p><strong>Don't forget to include the widget's CSS files!</strong></p> | 65 | <p><strong>Don't forget to include the widget's CSS files!</strong></p> |
712 | 164 | 66 | ||
713 | 165 | <pre> | 67 | <pre> |
717 | 166 | <script type="text/javascript" src="../../lib/yui/3.0.0pr2/build/yui/yui.js"></script> | 68 | <script type="text/javascript" src="../../build/yui/3.0.0pr2/build/yui/yui.js"></script> |
718 | 167 | <script type="text/javascript" src="../../lib/lazr/build/inlineedit/editor.js"></script> | 69 | <script type="text/javascript" src="../../build/inlineedit/editor.js"></script> |
719 | 168 | <script type="text/javascript" src="../../lib/lazr/build/anim/anim.js"></script> | 70 | <script type="text/javascript" src="../../build/anim/anim.js"></script> |
720 | 169 | 71 | ||
722 | 170 | <link type="text/css" rel="stylesheet" href="../../lib/lazr/build/inlineedit/assets/skins/sam/editor.css"></link> | 72 | <link type="text/css" rel="stylesheet" href="../../build/inlineedit/assets/skins/sam/editor.css"></link> |
723 | 171 | </pre> | 73 | </pre> |
724 | 172 | 74 | ||
725 | 173 | <pre> | 75 | <pre> |
726 | @@ -425,5 +327,106 @@ | |||
727 | 425 | </li> | 327 | </li> |
728 | 426 | </ul> | 328 | </ul> |
729 | 427 | 329 | ||
730 | 330 | <script type="text/javascript"> | ||
731 | 331 | |||
732 | 332 | YUI({ | ||
733 | 333 | base: '../../build/yui/current/build/', | ||
734 | 334 | filter: 'raw' | ||
735 | 335 | }).use('node', 'event', 'plugin', 'lazr.editor', function(Y) { | ||
736 | 336 | |||
737 | 337 | // Add a delay between the start and end of the inline editor widget's | ||
738 | 338 | // "save" event. | ||
739 | 339 | var DelayedSavePlugin = function(config) { | ||
740 | 340 | DelayedSavePlugin.superclass.constructor.apply(this, arguments); | ||
741 | 341 | }; | ||
742 | 342 | |||
743 | 343 | DelayedSavePlugin.NAME = 'delayedsave'; | ||
744 | 344 | DelayedSavePlugin.NS = 'fx'; | ||
745 | 345 | |||
746 | 346 | DelayedSavePlugin.ATTRS = { | ||
747 | 347 | /* | ||
748 | 348 | * Default duration of the 'saving' delay, in milliseconds. | ||
749 | 349 | */ | ||
750 | 350 | duration: { | ||
751 | 351 | value: 2000 | ||
752 | 352 | } | ||
753 | 353 | }; | ||
754 | 354 | |||
755 | 355 | Y.extend(DelayedSavePlugin, Y.Plugin.Base, { | ||
756 | 356 | |||
757 | 357 | initializer: function(config) { | ||
758 | 358 | // Save a reference to the original _saveData() method before | ||
759 | 359 | // we wrap it up. | ||
760 | 360 | this.original_save = config.host._saveData; | ||
761 | 361 | |||
762 | 362 | // We want to run our delayed-save code before the original | ||
763 | 363 | // 'save' method. Using doBefore() means that unplugging our | ||
764 | 364 | // code will leave the original widget in a clean state. | ||
765 | 365 | this.doBefore("_saveData", this._altSave); | ||
766 | 366 | }, | ||
767 | 367 | |||
768 | 368 | destructor: function() {}, | ||
769 | 369 | |||
770 | 370 | /* | ||
771 | 371 | * Our own _altSave() method, used to override the host's default | ||
772 | 372 | * behaviour. This method will only be called if the editor's input | ||
773 | 373 | * is valid. | ||
774 | 374 | */ | ||
775 | 375 | _altSave: function() { | ||
776 | 376 | var host = this.get('host'), | ||
777 | 377 | delay = this.get('duration'); | ||
778 | 378 | |||
779 | 379 | Y.log("Running alternative _saveData()", 'info'); | ||
780 | 380 | |||
781 | 381 | // Set the UI 'waiting' status. | ||
782 | 382 | host._uiSetWaiting(); | ||
783 | 383 | |||
784 | 384 | // Introduce a configurable delay around the host's _saveData() | ||
785 | 385 | // method. | ||
786 | 386 | Y.later(delay, this, function() { | ||
787 | 387 | |||
788 | 388 | Y.log("Running original 'save' method.", 'info'); | ||
789 | 389 | this.original_save.apply(host, arguments); | ||
790 | 390 | |||
791 | 391 | // Make sure we clear the 'waiting' status. | ||
792 | 392 | host._uiClearWaiting(); | ||
793 | 393 | |||
794 | 394 | }, arguments); | ||
795 | 395 | |||
796 | 396 | // Make sure we prevent the default _devSave() method from | ||
797 | 397 | // running. | ||
798 | 398 | return new Y.Do.Halt(); | ||
799 | 399 | } | ||
800 | 400 | }); | ||
801 | 401 | |||
802 | 402 | var editable_text = new Y.EditableText({ | ||
803 | 403 | contentBox: '#editable_text' | ||
804 | 404 | }); | ||
805 | 405 | |||
806 | 406 | editable_text.render(); | ||
807 | 407 | |||
808 | 408 | // Add the 2 second delay to the underlying editor widget. | ||
809 | 409 | editable_text.editor.plug({fn:DelayedSavePlugin}); | ||
810 | 410 | |||
811 | 411 | // Hook up the "allow empty" button. | ||
812 | 412 | Y.on('click', function(ev) { | ||
813 | 413 | var accept_empty = !editable_text.get('accept_empty'); | ||
814 | 414 | Y.log("Allowing empty editor input: " + accept_empty, 'info'); | ||
815 | 415 | editable_text.set('accept_empty', accept_empty); | ||
816 | 416 | }, 'input[name=accept_empty]'); | ||
817 | 417 | |||
818 | 418 | var multiline_text = new Y.EditableText({ | ||
819 | 419 | contentBox: '#edit-test-description', | ||
820 | 420 | multiline: true, | ||
821 | 421 | buttons: 'top', | ||
822 | 422 | }); | ||
823 | 423 | multiline_text.render(); | ||
824 | 424 | |||
825 | 425 | // Add the 2 second delay to the underlying editor widget. | ||
826 | 426 | multiline_text.editor.plug({fn:DelayedSavePlugin}); | ||
827 | 427 | |||
828 | 428 | }); | ||
829 | 429 | </script> | ||
830 | 430 | |||
831 | 428 | </body> | 431 | </body> |
832 | 429 | </html> | 432 | </html> |
833 | 430 | 433 | ||
834 | === modified file 'examples/lazr/index.html' | |||
835 | --- examples/lazr/index.html 2009-03-05 01:50:43 +0000 | |||
836 | +++ examples/lazr/index.html 2009-10-30 17:01:13 +0000 | |||
837 | @@ -5,13 +5,13 @@ | |||
838 | 5 | <title>LAZR JS Examples: lazr.base</title> | 5 | <title>LAZR JS Examples: lazr.base</title> |
839 | 6 | <meta http-equiv="content-type" content="text/html;charset=utf-8" /> | 6 | <meta http-equiv="content-type" content="text/html;charset=utf-8" /> |
840 | 7 | 7 | ||
842 | 8 | <script type="text/javascript" src="../../lib/yui/current/build/yui/yui.js"></script> | 8 | <script type="text/javascript" src="../../build/yui/current/build/yui/yui.js"></script> |
843 | 9 | <script type="text/javascript" src="../../build/lazr/lazr.js"></script> | 9 | <script type="text/javascript" src="../../build/lazr/lazr.js"></script> |
844 | 10 | 10 | ||
845 | 11 | <script type="text/javascript"> | 11 | <script type="text/javascript"> |
846 | 12 | 12 | ||
847 | 13 | YUI({ | 13 | YUI({ |
849 | 14 | base: "../../lib/yui/current/build/", | 14 | base: "../../build/yui/current/build/", |
850 | 15 | filter: 'raw', | 15 | filter: 'raw', |
851 | 16 | }).use('node', 'lazr.base', function(Y) { | 16 | }).use('node', 'lazr.base', function(Y) { |
852 | 17 | 17 | ||
853 | @@ -72,7 +72,7 @@ | |||
854 | 72 | <p>The common usage:</p> | 72 | <p>The common usage:</p> |
855 | 73 | 73 | ||
856 | 74 | <pre> | 74 | <pre> |
858 | 75 | <script type="text/javascript" src="../../lib/yui/current/build/yui/yui.js"></script> | 75 | <script type="text/javascript" src="../../build/yui/current/build/yui/yui.js"></script> |
859 | 76 | <script type="text/javascript" src="../../build/lazr/lazr.js"></script> | 76 | <script type="text/javascript" src="../../build/lazr/lazr.js"></script> |
860 | 77 | <script type="text/javascript" src="../../build/lazr/assets/skins/sam/lazr-skin.css"></script> | 77 | <script type="text/javascript" src="../../build/lazr/assets/skins/sam/lazr-skin.css"></script> |
861 | 78 | </pre> | 78 | </pre> |
862 | 79 | 79 | ||
863 | === modified file 'examples/overlay/index.html' | |||
864 | --- examples/overlay/index.html 2009-02-21 18:21:14 +0000 | |||
865 | +++ examples/overlay/index.html 2009-10-30 17:01:13 +0000 | |||
866 | @@ -5,12 +5,12 @@ | |||
867 | 5 | <title>LAZR JS Examples: lazr.overlay</title> | 5 | <title>LAZR JS Examples: lazr.overlay</title> |
868 | 6 | <meta http-equiv="content-type" content="text/html;charset=utf-8" /> | 6 | <meta http-equiv="content-type" content="text/html;charset=utf-8" /> |
869 | 7 | 7 | ||
871 | 8 | <script type="text/javascript" src="../../lib/yui/current/build/yui/yui.js"></script> | 8 | <script type="text/javascript" src="../../build/yui/current/build/yui/yui.js"></script> |
872 | 9 | <script type="text/javascript" src="../../build/overlay/overlay.js"></script> | 9 | <script type="text/javascript" src="../../build/overlay/overlay.js"></script> |
873 | 10 | 10 | ||
877 | 11 | <link rel="stylesheet" type="text/css" href="../../lib/yui/current/build/cssreset/reset.css" /> | 11 | <link rel="stylesheet" type="text/css" href="../../build/yui/current/build/cssreset/reset.css" /> |
878 | 12 | <link rel="stylesheet" type="text/css" href="../../lib/yui/current/build/cssfonts/fonts.css" /> | 12 | <link rel="stylesheet" type="text/css" href="../../build/yui/current/build/cssfonts/fonts.css" /> |
879 | 13 | <link rel="stylesheet" type="text/css" href="../../lib/yui/current/build/cssbase/base.css" /> | 13 | <link rel="stylesheet" type="text/css" href="../../build/yui/current/build/cssbase/base.css" /> |
880 | 14 | 14 | ||
881 | 15 | <link rel="stylesheet" type="text/css" href="../../build/overlay/assets/pretty-overlay-core.css" /> | 15 | <link rel="stylesheet" type="text/css" href="../../build/overlay/assets/pretty-overlay-core.css" /> |
882 | 16 | <link rel="stylesheet" type="text/css" href="../../build/overlay/assets/skins/sam/pretty-overlay-skin.css" /> | 16 | <link rel="stylesheet" type="text/css" href="../../build/overlay/assets/skins/sam/pretty-overlay-skin.css" /> |
883 | @@ -109,7 +109,7 @@ | |||
884 | 109 | 109 | ||
885 | 110 | <script type="text/javascript"> | 110 | <script type="text/javascript"> |
886 | 111 | YUI({ | 111 | YUI({ |
888 | 112 | base: '../../lib/yui/current/build/', | 112 | base: '../../build/yui/current/build/', |
889 | 113 | filter: "raw", | 113 | filter: "raw", |
890 | 114 | combine: false | 114 | combine: false |
891 | 115 | }).use('lazr.overlay', function(Y) { | 115 | }).use('lazr.overlay', function(Y) { |
892 | 116 | 116 | ||
893 | === modified file 'examples/picker/index.html' | |||
894 | --- examples/picker/index.html 2009-05-07 16:27:01 +0000 | |||
895 | +++ examples/picker/index.html 2009-10-30 17:01:13 +0000 | |||
896 | @@ -3,7 +3,7 @@ | |||
897 | 3 | <html> | 3 | <html> |
898 | 4 | <head> | 4 | <head> |
899 | 5 | <title>Lazr-js examples: Picker widget</title> | 5 | <title>Lazr-js examples: Picker widget</title> |
901 | 6 | <script type="text/javascript" src="../../lib/yui/current/build/yui/yui.js"></script> | 6 | <script type="text/javascript" src="../../build/yui/current/build/yui/yui.js"></script> |
902 | 7 | <script type="text/javascript" src="../../build/anim/anim.js"></script> | 7 | <script type="text/javascript" src="../../build/anim/anim.js"></script> |
903 | 8 | <script type="text/javascript" src="../../build/lazr/lazr.js"></script> | 8 | <script type="text/javascript" src="../../build/lazr/lazr.js"></script> |
904 | 9 | <script type="text/javascript" src="../../build/overlay/overlay.js"></script> | 9 | <script type="text/javascript" src="../../build/overlay/overlay.js"></script> |
905 | @@ -12,7 +12,7 @@ | |||
906 | 12 | <script type="text/javascript"> | 12 | <script type="text/javascript"> |
907 | 13 | 13 | ||
908 | 14 | YUI({ | 14 | YUI({ |
910 | 15 | base: '../../lib/yui/current/build/', | 15 | base: '../../build/yui/current/build/', |
911 | 16 | filter: 'raw' | 16 | filter: 'raw' |
912 | 17 | }).use('lazr.picker', 'dump', function(Y) { | 17 | }).use('lazr.picker', 'dump', function(Y) { |
913 | 18 | // Parse the content of the textarea in the data structure | 18 | // Parse the content of the textarea in the data structure |
914 | @@ -160,9 +160,9 @@ | |||
915 | 160 | }); | 160 | }); |
916 | 161 | </script> | 161 | </script> |
917 | 162 | 162 | ||
921 | 163 | <link rel="stylesheet" type="text/css" href="../../lib/yui/current/build/cssreset/reset.css" /> | 163 | <link rel="stylesheet" type="text/css" href="../../build/yui/current/build/cssreset/reset.css" /> |
922 | 164 | <link rel="stylesheet" type="text/css" href="../../lib/yui/current/build/cssfonts/fonts.css" /> | 164 | <link rel="stylesheet" type="text/css" href="../../build/yui/current/build/cssfonts/fonts.css" /> |
923 | 165 | <link rel="stylesheet" type="text/css" href="../../lib/yui/current/build/cssbase/base.css" /> | 165 | <link rel="stylesheet" type="text/css" href="../../build/yui/current/build/cssbase/base.css" /> |
924 | 166 | 166 | ||
925 | 167 | <link rel="stylesheet" type="text/css" href="../../build/overlay/assets/skins/sam/pretty-overlay.css" /> | 167 | <link rel="stylesheet" type="text/css" href="../../build/overlay/assets/skins/sam/pretty-overlay.css" /> |
926 | 168 | <link type="text/css" rel="stylesheet" href="../../build/lazr/assets/skins/sam/lazr.css" /> | 168 | <link type="text/css" rel="stylesheet" href="../../build/lazr/assets/skins/sam/lazr.css" /> |
927 | 169 | 169 | ||
928 | === modified file 'setup.py' | |||
929 | --- setup.py 2009-10-28 19:04:25 +0000 | |||
930 | +++ setup.py 2009-10-30 17:01:13 +0000 | |||
931 | @@ -26,6 +26,7 @@ | |||
932 | 26 | license='GPL v3', | 26 | license='GPL v3', |
933 | 27 | install_requires=[ | 27 | install_requires=[ |
934 | 28 | 'bzr', | 28 | 'bzr', |
935 | 29 | 'lazr.testing', | ||
936 | 29 | 'setuptools', | 30 | 'setuptools', |
937 | 30 | ], | 31 | ], |
938 | 31 | url='https://launchpad.net/lazr-js', | 32 | url='https://launchpad.net/lazr-js', |
939 | 32 | 33 | ||
940 | === modified file 'src-js/lazrjs/activator/tests/activator.html' | |||
941 | --- src-js/lazrjs/activator/tests/activator.html 2009-03-13 15:54:02 +0000 | |||
942 | +++ src-js/lazrjs/activator/tests/activator.html 2009-10-30 17:01:13 +0000 | |||
943 | @@ -5,30 +5,24 @@ | |||
944 | 5 | <title>Activator</title> | 5 | <title>Activator</title> |
945 | 6 | 6 | ||
946 | 7 | <!-- YUI 3.0 Setup --> | 7 | <!-- YUI 3.0 Setup --> |
951 | 8 | <script type="text/javascript" src="../../../lib/yui/current/build/yui/yui.js"></script> | 8 | <script type="text/javascript" src="../../yui/current/build/yui/yui.js"></script> |
952 | 9 | <link rel="stylesheet" href="../../../lib/yui/current/build/cssreset/reset.css"/> | 9 | <link rel="stylesheet" href="../../yui/current/build/cssreset/reset.css"/> |
953 | 10 | <link rel="stylesheet" href="../../../lib/yui/current/build/cssfonts/fonts.css"/> | 10 | <link rel="stylesheet" href="../../yui/current/build/cssfonts/fonts.css"/> |
954 | 11 | <link rel="stylesheet" href="../../../lib/yui/current/build/cssbase/base.css"/> | 11 | <link rel="stylesheet" href="../../yui/current/build/cssbase/base.css"/> |
955 | 12 | 12 | ||
956 | 13 | <!-- The module under test --> | 13 | <!-- The module under test --> |
960 | 14 | <script type="text/javascript" src="../../../build/activator/activator.js"></script> | 14 | <script type="text/javascript" src="../../activator/activator.js"></script> |
961 | 15 | <script type="text/javascript" src="../../../build/anim/anim.js"></script> | 15 | <script type="text/javascript" src="../../anim/anim.js"></script> |
962 | 16 | <script type="text/javascript" src="../../../build/lazr/lazr.js"></script> | 16 | <script type="text/javascript" src="../../lazr/lazr.js"></script> |
963 | 17 | <script type="text/javascript" src="../../testing/testing.js"></script> | ||
964 | 17 | 18 | ||
965 | 18 | <!-- The test suite --> | 19 | <!-- The test suite --> |
966 | 19 | <script type="text/javascript" src="activator.js"></script> | 20 | <script type="text/javascript" src="activator.js"></script> |
967 | 20 | 21 | ||
969 | 21 | <link rel="stylesheet" href="../../../src/testing/assets/testlogger.css"/> | 22 | <link rel="stylesheet" href="../../testing/assets/testlogger.css"/> |
970 | 22 | </head> | 23 | </head> |
971 | 23 | <body class="yui-skin-sam"> | 24 | <body class="yui-skin-sam"> |
972 | 24 | 25 | ||
973 | 25 | <div id="workspace" | ||
974 | 26 | style="border: 1px solid blue; | ||
975 | 27 | width: 20em; | ||
976 | 28 | margin: 1em; | ||
977 | 29 | padding: 1em"> | ||
978 | 30 | </div> | ||
979 | 31 | |||
980 | 32 | <div id="log"></div> | 26 | <div id="log"></div> |
981 | 33 | </body> | 27 | </body> |
982 | 34 | </html> | 28 | </html> |
983 | 35 | 29 | ||
984 | === modified file 'src-js/lazrjs/activator/tests/activator.js' | |||
985 | --- src-js/lazrjs/activator/tests/activator.js 2009-04-22 02:42:02 +0000 | |||
986 | +++ src-js/lazrjs/activator/tests/activator.js 2009-10-30 17:01:13 +0000 | |||
987 | @@ -1,10 +1,11 @@ | |||
988 | 1 | /* Copyright (c) 2009, Canonical Ltd. All rights reserved. */ | 1 | /* Copyright (c) 2009, Canonical Ltd. All rights reserved. */ |
989 | 2 | 2 | ||
990 | 3 | YUI({ | 3 | YUI({ |
992 | 4 | base: '../../../lib/yui/current/build/', | 4 | base: '../../yui/current/build/', |
993 | 5 | filter: 'raw', | 5 | filter: 'raw', |
994 | 6 | combine: false | 6 | combine: false |
996 | 7 | }).use('lazr.activator', 'node', 'event', 'yuitest', 'console', function(Y) { | 7 | }).use('lazr.activator', 'lazr.testing.runner', 'node', |
997 | 8 | 'event', 'event-simulate', 'console', function(Y) { | ||
998 | 8 | 9 | ||
999 | 9 | var Assert = Y.Assert; // For easy access to isTrue(), etc. | 10 | var Assert = Y.Assert; // For easy access to isTrue(), etc. |
1000 | 10 | 11 | ||
1001 | @@ -37,6 +38,16 @@ | |||
1002 | 37 | 38 | ||
1003 | 38 | setUp: function() { | 39 | setUp: function() { |
1004 | 39 | this.workspace = Y.get('#workspace'); | 40 | this.workspace = Y.get('#workspace'); |
1005 | 41 | if (!this.workspace){ | ||
1006 | 42 | Y.get(document.body).appendChild(Y.Node.create( | ||
1007 | 43 | '<div id="workspace" ' + | ||
1008 | 44 | 'style="border: 1px solid blue; ' + | ||
1009 | 45 | 'width: 20em; ' + | ||
1010 | 46 | 'margin: 1em; ' + | ||
1011 | 47 | 'padding: 1em">'+ | ||
1012 | 48 | '</div>')); | ||
1013 | 49 | this.workspace = Y.get('#workspace'); | ||
1014 | 50 | } | ||
1015 | 40 | this.workspace.appendChild(Y.Node.create( | 51 | this.workspace.appendChild(Y.Node.create( |
1016 | 41 | '<div id="example-1">' + | 52 | '<div id="example-1">' + |
1017 | 42 | '<span class="yui-activator-data-box">' + | 53 | '<span class="yui-activator-data-box">' + |
1018 | @@ -233,15 +244,7 @@ | |||
1019 | 233 | } | 244 | } |
1020 | 234 | })); | 245 | })); |
1021 | 235 | 246 | ||
1032 | 236 | Y.Test.Runner.add(suite); | 247 | Y.lazr.testing.Runner.add(suite); |
1033 | 237 | 248 | Y.lazr.testing.Runner.run(); | |
1024 | 238 | var yconsole = new Y.Console({ | ||
1025 | 239 | newestOnTop: false | ||
1026 | 240 | }); | ||
1027 | 241 | yconsole.render('#log'); | ||
1028 | 242 | |||
1029 | 243 | Y.on('domready', function() { | ||
1030 | 244 | Y.Test.Runner.run(); | ||
1031 | 245 | }); | ||
1034 | 246 | 249 | ||
1035 | 247 | }); | 250 | }); |
1036 | 248 | 251 | ||
1037 | === modified file 'src-js/lazrjs/autocomplete/autocomplete.js' | |||
1038 | --- src-js/lazrjs/autocomplete/autocomplete.js 2009-07-16 19:35:57 +0000 | |||
1039 | +++ src-js/lazrjs/autocomplete/autocomplete.js 2009-10-30 17:01:14 +0000 | |||
1040 | @@ -1,19 +1,4 @@ | |||
1057 | 1 | /* | 1 | /* Copyright (c) 2009, Canonical Ltd. All rights reserved. */ |
1042 | 2 | Copyright (c) 2009, Canonical Ltd. All rights reserved. | ||
1043 | 3 | |||
1044 | 4 | This program is free software: you can redistribute it and/or modify | ||
1045 | 5 | it under the terms of the GNU Affero General Public License as published by | ||
1046 | 6 | the Free Software Foundation, either version 3 of the License, or | ||
1047 | 7 | (at your option) any later version. | ||
1048 | 8 | |||
1049 | 9 | This program is distributed in the hope that it will be useful, | ||
1050 | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1051 | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1052 | 12 | GNU Affero General Public License for more details. | ||
1053 | 13 | |||
1054 | 14 | You should have received a copy of the GNU Affero General Public License | ||
1055 | 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1056 | 16 | */ | ||
1058 | 17 | 2 | ||
1059 | 18 | YUI.add('lazr.autocomplete', function(Y) { | 3 | YUI.add('lazr.autocomplete', function(Y) { |
1060 | 19 | 4 | ||
1061 | @@ -51,7 +36,7 @@ | |||
1062 | 51 | 36 | ||
1063 | 52 | // We need a base class on which to build our autocomplete widget, so we will | 37 | // We need a base class on which to build our autocomplete widget, so we will |
1064 | 53 | // make that class capable of positioning itself, too. | 38 | // make that class capable of positioning itself, too. |
1066 | 54 | var AutoCompleteBase = Y.Base.build(Y.Widget, [Y.WidgetStack]); | 39 | var AutoCompleteBase = Y.Base.build("AutoCompleteBase", Y.Widget, [Y.WidgetStack]); |
1067 | 55 | 40 | ||
1068 | 56 | 41 | ||
1069 | 57 | /** | 42 | /** |
1070 | @@ -119,7 +104,7 @@ | |||
1071 | 119 | */ | 104 | */ |
1072 | 120 | input: { | 105 | input: { |
1073 | 121 | value: null, | 106 | value: null, |
1075 | 122 | set: function(val) { | 107 | setter: function(val) { |
1076 | 123 | return this._setInput(val); | 108 | return this._setInput(val); |
1077 | 124 | } | 109 | } |
1078 | 125 | }, | 110 | }, |
1079 | @@ -254,6 +239,8 @@ | |||
1080 | 254 | 239 | ||
1081 | 255 | var cbox = this.get(CONTENT_BOX); | 240 | var cbox = this.get(CONTENT_BOX); |
1082 | 256 | 241 | ||
1083 | 242 | this.get(BOUNDING_BOX).unplug(Y.Plugin.NodeMenuNav); | ||
1084 | 243 | |||
1085 | 257 | if (this._completions) { | 244 | if (this._completions) { |
1086 | 258 | cbox.replaceChild(list, this._completions); | 245 | cbox.replaceChild(list, this._completions); |
1087 | 259 | } else { | 246 | } else { |
1088 | @@ -261,7 +248,7 @@ | |||
1089 | 261 | } | 248 | } |
1090 | 262 | 249 | ||
1091 | 263 | // Re-plug the MenuNav, so it updates the menu options. | 250 | // Re-plug the MenuNav, so it updates the menu options. |
1093 | 264 | this.get(BOUNDING_BOX).plug(Y.plugin.NodeMenuNav); | 251 | this.get(BOUNDING_BOX).plug(Y.Plugin.NodeMenuNav); |
1094 | 265 | 252 | ||
1095 | 266 | // Highlight the first item. | 253 | // Highlight the first item. |
1096 | 267 | this._selectItem(0, false); | 254 | this._selectItem(0, false); |
1097 | @@ -601,7 +588,7 @@ | |||
1098 | 601 | // It is ugly to have to check protected members of the menu | 588 | // It is ugly to have to check protected members of the menu |
1099 | 602 | // like this, but the 'currently selected item' should | 589 | // like this, but the 'currently selected item' should |
1100 | 603 | // really be public, don't you think? | 590 | // really be public, don't you think? |
1102 | 604 | var menu = this.get(BOUNDING_BOX).MenuNav; | 591 | var menu = this.get(BOUNDING_BOX).menuNav; |
1103 | 605 | if (menu) { | 592 | if (menu) { |
1104 | 606 | return menu._activeItem ? menu._activeItem : null; | 593 | return menu._activeItem ? menu._activeItem : null; |
1105 | 607 | } | 594 | } |
1106 | @@ -620,11 +607,12 @@ | |||
1107 | 620 | * be found. | 607 | * be found. |
1108 | 621 | */ | 608 | */ |
1109 | 622 | _selectItem: function(index, set_focus) { | 609 | _selectItem: function(index, set_focus) { |
1111 | 623 | var menu = this.get(BOUNDING_BOX).MenuNav; | 610 | var menu = this.get(BOUNDING_BOX).menuNav; |
1112 | 624 | 611 | ||
1113 | 625 | // More ugliness, looking at protected object members that should | 612 | // More ugliness, looking at protected object members that should |
1114 | 626 | // be made public. | 613 | // be made public. |
1116 | 627 | var item = menu ? menu._firstItem : null; | 614 | var firstItem = menu._rootMenu.all('.yui-menuitem').item(0) |
1117 | 615 | var item = menu ? firstItem : null; | ||
1118 | 628 | if (!menu || !item) { | 616 | if (!menu || !item) { |
1119 | 629 | return null; | 617 | return null; |
1120 | 630 | } | 618 | } |
1121 | @@ -636,11 +624,14 @@ | |||
1122 | 636 | } | 624 | } |
1123 | 637 | } | 625 | } |
1124 | 638 | 626 | ||
1125 | 639 | menu._setActiveItem(item); | ||
1126 | 640 | if (set_focus) { | 627 | if (set_focus) { |
1127 | 641 | // We need an anchor to focus on, because some browsers (IE, ahem) | 628 | // We need an anchor to focus on, because some browsers (IE, ahem) |
1128 | 642 | // don't like focusing non-anchor things. | 629 | // don't like focusing non-anchor things. |
1129 | 643 | var anchor = item.query('a'); | 630 | var anchor = item.query('a'); |
1130 | 631 | |||
1131 | 632 | menu._focusManager.set("activeDescendant", anchor); | ||
1132 | 633 | menu._focusItem(item); | ||
1133 | 634 | |||
1134 | 644 | if (anchor) { | 635 | if (anchor) { |
1135 | 645 | // Use a 5ms timer to give the browser rendering engine some | 636 | // Use a 5ms timer to give the browser rendering engine some |
1136 | 646 | // time to catch up to the JS call, and prevent a race | 637 | // time to catch up to the JS call, and prevent a race |
1137 | @@ -648,6 +639,7 @@ | |||
1138 | 648 | Y.later(5, anchor, anchor.focus); | 639 | Y.later(5, anchor, anchor.focus); |
1139 | 649 | } | 640 | } |
1140 | 650 | } | 641 | } |
1141 | 642 | menu._setActiveItem(item); | ||
1142 | 651 | return item; | 643 | return item; |
1143 | 652 | }, | 644 | }, |
1144 | 653 | 645 | ||
1145 | @@ -722,7 +714,7 @@ | |||
1146 | 722 | }, | 714 | }, |
1147 | 723 | 715 | ||
1148 | 724 | /** | 716 | /** |
1150 | 725 | * Handle presses of keys like Tab ane Enter | 717 | * Handle presses of keys like Tab and Enter |
1151 | 726 | * | 718 | * |
1152 | 727 | * @method _onInputKeydown | 719 | * @method _onInputKeydown |
1153 | 728 | * @protected | 720 | * @protected |
1154 | @@ -797,11 +789,4 @@ | |||
1155 | 797 | }; | 789 | }; |
1156 | 798 | 790 | ||
1157 | 799 | 791 | ||
1166 | 800 | }, null, { | 792 | }, '0.1', {requires:['oop', 'base', 'event', 'widget', 'widget-stack', 'node-menunav']}); |
1159 | 801 | requires:[ | ||
1160 | 802 | 'oop', | ||
1161 | 803 | 'base', | ||
1162 | 804 | 'widget', | ||
1163 | 805 | 'widget-stack', | ||
1164 | 806 | 'node-menunav' | ||
1165 | 807 | ]}); | ||
1167 | 808 | 793 | ||
1168 | === renamed file 'src-js/lazrjs/autocomplete/tests/test.js' => 'src-js/lazrjs/autocomplete/tests/autocomplete.js' | |||
1169 | --- src-js/lazrjs/autocomplete/tests/test.js 2009-03-27 04:38:14 +0000 | |||
1170 | +++ src-js/lazrjs/autocomplete/tests/autocomplete.js 2009-10-30 17:01:14 +0000 | |||
1171 | @@ -1,33 +1,17 @@ | |||
1188 | 1 | /* | 1 | /* Copyright (c) 2009, Canonical Ltd. All rights reserved. */ |
1173 | 2 | Copyright (c) 2009, Canonical Ltd. All rights reserved. | ||
1174 | 3 | |||
1175 | 4 | This program is free software: you can redistribute it and/or modify | ||
1176 | 5 | it under the terms of the GNU Affero General Public License as published by | ||
1177 | 6 | the Free Software Foundation, either version 3 of the License, or | ||
1178 | 7 | (at your option) any later version. | ||
1179 | 8 | |||
1180 | 9 | This program is distributed in the hope that it will be useful, | ||
1181 | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1182 | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1183 | 12 | GNU Affero General Public License for more details. | ||
1184 | 13 | |||
1185 | 14 | You should have received a copy of the GNU Affero General Public License | ||
1186 | 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1187 | 16 | */ | ||
1189 | 17 | 2 | ||
1190 | 18 | YUI({ | 3 | YUI({ |
1192 | 19 | base: '../../../lib/yui/current/build/', | 4 | base: '../../yui/current/build/', |
1193 | 20 | filter: 'raw', | 5 | filter: 'raw', |
1194 | 21 | combine: false | 6 | combine: false |
1197 | 22 | }).use('lazr.autocomplete', 'node', 'event', 'yuitest', 'console', function(Y) { | 7 | }).use('lazr.autocomplete', 'lazr.testing.runner', |
1198 | 23 | 8 | 'node', 'event', 'console', function(Y) { | |
1199 | 24 | 9 | ||
1200 | 25 | /***************************** | 10 | /***************************** |
1201 | 26 | * | 11 | * |
1202 | 27 | * Helper methods and aliases | 12 | * Helper methods and aliases |
1203 | 28 | * | 13 | * |
1204 | 29 | */ | 14 | */ |
1205 | 30 | |||
1206 | 31 | var Assert = Y.Assert; | 15 | var Assert = Y.Assert; |
1207 | 32 | 16 | ||
1208 | 33 | /* Helper function to clean up a dynamically added widget instance. */ | 17 | /* Helper function to clean up a dynamically added widget instance. */ |
1209 | @@ -584,16 +568,7 @@ | |||
1210 | 584 | } | 568 | } |
1211 | 585 | })); | 569 | })); |
1212 | 586 | 570 | ||
1224 | 587 | 571 | Y.lazr.testing.Runner.add(suite); | |
1225 | 588 | Y.Test.Runner.add(suite); | 572 | Y.lazr.testing.Runner.run(); |
1215 | 589 | |||
1216 | 590 | var yconsole = new Y.Console({ | ||
1217 | 591 | newestOnTop: false | ||
1218 | 592 | }); | ||
1219 | 593 | yconsole.render('#log'); | ||
1220 | 594 | |||
1221 | 595 | Y.on('domready', function() { | ||
1222 | 596 | Y.Test.Runner.run(); | ||
1223 | 597 | }); | ||
1226 | 598 | 573 | ||
1227 | 599 | }); | 574 | }); |
1228 | 600 | 575 | ||
1229 | === modified file 'src-js/lazrjs/autocomplete/tests/index.html' | |||
1230 | --- src-js/lazrjs/autocomplete/tests/index.html 2009-03-18 00:42:42 +0000 | |||
1231 | +++ src-js/lazrjs/autocomplete/tests/index.html 2009-10-30 17:01:14 +0000 | |||
1232 | @@ -5,18 +5,19 @@ | |||
1233 | 5 | <title>autocomplete unit tests</title> | 5 | <title>autocomplete unit tests</title> |
1234 | 6 | 6 | ||
1235 | 7 | <!-- YUI 3.0 Setup --> | 7 | <!-- YUI 3.0 Setup --> |
1240 | 8 | <script type="text/javascript" src="../../../lib/yui/current/build/yui/yui.js"></script> | 8 | <script type="text/javascript" src="../../yui/current/build/yui/yui.js"></script> |
1241 | 9 | <link rel="stylesheet" href="../../../lib/yui/current/build/cssreset/reset.css"/> | 9 | <link rel="stylesheet" href="../../yui/current/build/cssreset/reset.css"/> |
1242 | 10 | <link rel="stylesheet" href="../../../lib/yui/current/build/cssfonts/fonts.css"/> | 10 | <link rel="stylesheet" href="../../yui/current/build/cssfonts/fonts.css"/> |
1243 | 11 | <link rel="stylesheet" href="../../../lib/yui/current/build/cssbase/base.css"/> | 11 | <link rel="stylesheet" href="../../yui/current/build/cssbase/base.css"/> |
1244 | 12 | 12 | ||
1246 | 13 | <link rel="stylesheet" href="../../../src/testing/assets/testlogger.css"/> | 13 | <link rel="stylesheet" href="../../testing/assets/testlogger.css"/> |
1247 | 14 | <script type="text/javascript" src="../../testing/testing.js"></script> | ||
1248 | 14 | 15 | ||
1249 | 15 | <!-- The module under test --> | 16 | <!-- The module under test --> |
1250 | 16 | <script type="text/javascript" src="../autocomplete.js"></script> | 17 | <script type="text/javascript" src="../autocomplete.js"></script> |
1251 | 17 | 18 | ||
1252 | 18 | <!-- The test suite --> | 19 | <!-- The test suite --> |
1254 | 19 | <script type="text/javascript" src="test.js"></script> | 20 | <script type="text/javascript" src="autocomplete.js"></script> |
1255 | 20 | 21 | ||
1256 | 21 | </head> | 22 | </head> |
1257 | 22 | <body class="yui-skin-sam"> | 23 | <body class="yui-skin-sam"> |
1258 | 23 | 24 | ||
1259 | === modified file 'src-js/lazrjs/choiceedit/choiceedit.js' | |||
1260 | --- src-js/lazrjs/choiceedit/choiceedit.js 2009-08-21 14:06:19 +0000 | |||
1261 | +++ src-js/lazrjs/choiceedit/choiceedit.js 2009-10-30 17:01:14 +0000 | |||
1262 | @@ -20,6 +20,9 @@ | |||
1263 | 20 | C_ADDICON = 'addicon', | 20 | C_ADDICON = 'addicon', |
1264 | 21 | SAVE = 'save', | 21 | SAVE = 'save', |
1265 | 22 | LEFT_MOUSE_BUTTON = 1, | 22 | LEFT_MOUSE_BUTTON = 1, |
1266 | 23 | RENDERUI = "renderUI", | ||
1267 | 24 | BINDUI = "bindUI", | ||
1268 | 25 | SYNCUI = "syncUI", | ||
1269 | 23 | NOTHING = new Object(); | 26 | NOTHING = new Object(); |
1270 | 24 | 27 | ||
1271 | 25 | /** | 28 | /** |
1272 | @@ -33,6 +36,8 @@ | |||
1273 | 33 | 36 | ||
1274 | 34 | var ChoiceSource = function() { | 37 | var ChoiceSource = function() { |
1275 | 35 | ChoiceSource.superclass.constructor.apply(this, arguments); | 38 | ChoiceSource.superclass.constructor.apply(this, arguments); |
1276 | 39 | Y.after(this._bindUIChoiceSource, this, BINDUI); | ||
1277 | 40 | Y.after(this._syncUIChoiceSource, this, SYNCUI); | ||
1278 | 36 | }; | 41 | }; |
1279 | 37 | 42 | ||
1280 | 38 | ChoiceSource.NAME = CHOICESOURCE; | 43 | ChoiceSource.NAME = CHOICESOURCE; |
1281 | @@ -94,7 +99,7 @@ | |||
1282 | 94 | */ | 99 | */ |
1283 | 95 | value_location: { | 100 | value_location: { |
1284 | 96 | value: null, | 101 | value: null, |
1286 | 97 | set: function(v) { | 102 | setter: function(v) { |
1287 | 98 | return Y.get(v); | 103 | return Y.get(v); |
1288 | 99 | } | 104 | } |
1289 | 100 | }, | 105 | }, |
1290 | @@ -110,7 +115,7 @@ | |||
1291 | 110 | */ | 115 | */ |
1292 | 111 | editicon: { | 116 | editicon: { |
1293 | 112 | value: null, | 117 | value: null, |
1295 | 113 | set: function(v) { | 118 | setter: function(v) { |
1296 | 114 | return Y.get(v); | 119 | return Y.get(v); |
1297 | 115 | } | 120 | } |
1298 | 116 | }, | 121 | }, |
1299 | @@ -123,14 +128,14 @@ | |||
1300 | 123 | * @type Node | 128 | * @type Node |
1301 | 124 | */ | 129 | */ |
1302 | 125 | actionicon: { | 130 | actionicon: { |
1304 | 126 | get: function() { | 131 | getter: function() { |
1305 | 127 | return this.get('editicon'); | 132 | return this.get('editicon'); |
1306 | 128 | } | 133 | } |
1307 | 129 | }, | 134 | }, |
1308 | 130 | 135 | ||
1309 | 131 | elementToFlash: { | 136 | elementToFlash: { |
1310 | 132 | value: null, | 137 | value: null, |
1312 | 133 | set: function(v) { | 138 | setter: function(v) { |
1313 | 134 | return Y.get(v); | 139 | return Y.get(v); |
1314 | 135 | } | 140 | } |
1315 | 136 | }, | 141 | }, |
1316 | @@ -138,7 +143,7 @@ | |||
1317 | 138 | backgroundColor: { | 143 | backgroundColor: { |
1318 | 139 | value: null | 144 | value: null |
1319 | 140 | }, | 145 | }, |
1321 | 141 | 146 | ||
1322 | 142 | clickable_content: { | 147 | clickable_content: { |
1323 | 143 | value: true | 148 | value: true |
1324 | 144 | } | 149 | } |
1325 | @@ -160,10 +165,15 @@ | |||
1326 | 160 | 165 | ||
1327 | 161 | /** | 166 | /** |
1328 | 162 | * bind UI events | 167 | * bind UI events |
1329 | 168 | * <p> | ||
1330 | 169 | * This method is invoked after bindUI is invoked for the Widget class | ||
1331 | 170 | * using YUI's aop infrastructure. | ||
1332 | 171 | * </p> | ||
1333 | 163 | * | 172 | * |
1335 | 164 | * @method bindUI | 173 | * @method _bindUIChoiceSource |
1336 | 174 | * @protected | ||
1337 | 165 | */ | 175 | */ |
1339 | 166 | bindUI: function() { | 176 | _bindUIChoiceSource: function() { |
1340 | 167 | var that = this; | 177 | var that = this; |
1341 | 168 | if (this.get('clickable_content')) { | 178 | if (this.get('clickable_content')) { |
1342 | 169 | var clickable_element = this.get('contentBox'); | 179 | var clickable_element = this.get('contentBox'); |
1343 | @@ -188,10 +198,15 @@ | |||
1344 | 188 | 198 | ||
1345 | 189 | /** | 199 | /** |
1346 | 190 | * Update in-page HTML with current value of the field | 200 | * Update in-page HTML with current value of the field |
1347 | 201 | * <p> | ||
1348 | 202 | * This method is invoked after syncUI is invoked for the Widget class | ||
1349 | 203 | * using YUI's aop infrastructure. | ||
1350 | 204 | * </p> | ||
1351 | 191 | * | 205 | * |
1353 | 192 | * @method syncUI | 206 | * @method _syncUIChoiceSource |
1354 | 207 | * @protected | ||
1355 | 193 | */ | 208 | */ |
1357 | 194 | syncUI: function() { | 209 | _syncUIChoiceSource: function() { |
1358 | 195 | var items = this.get("items"); | 210 | var items = this.get("items"); |
1359 | 196 | var value = this.get("value"); | 211 | var value = this.get("value"); |
1360 | 197 | var node = this.get("value_location"); | 212 | var node = this.get("value_location"); |
1361 | @@ -411,14 +426,21 @@ | |||
1362 | 411 | */ | 426 | */ |
1363 | 412 | this.publish("valueChosen"); | 427 | this.publish("valueChosen"); |
1364 | 413 | this.after("renderedChange", this._positionCorrectly); | 428 | this.after("renderedChange", this._positionCorrectly); |
1365 | 429 | Y.after(this._renderUIChoiceList, this, RENDERUI); | ||
1366 | 430 | Y.after(this._bindUIChoiceList, this, BINDUI); | ||
1367 | 414 | }, | 431 | }, |
1368 | 415 | 432 | ||
1369 | 416 | /** | 433 | /** |
1370 | 417 | * Render the popup menu | 434 | * Render the popup menu |
1371 | 435 | * <p> | ||
1372 | 436 | * This method is invoked after renderUI is invoked for the Widget class | ||
1373 | 437 | * using YUI's aop infrastructure. | ||
1374 | 438 | * </p> | ||
1375 | 418 | * | 439 | * |
1377 | 419 | * @method renderUI | 440 | * @method _renderUIChoiceList |
1378 | 441 | * @protected | ||
1379 | 420 | */ | 442 | */ |
1381 | 421 | renderUI: function() { | 443 | _renderUIChoiceList: function() { |
1382 | 422 | this.set("align", { | 444 | this.set("align", { |
1383 | 423 | node: this.get("value_location"), | 445 | node: this.get("value_location"), |
1384 | 424 | points:[Y.WidgetPositionExt.TL, Y.WidgetPositionExt.TL] | 446 | points:[Y.WidgetPositionExt.TL, Y.WidgetPositionExt.TL] |
1385 | @@ -448,26 +470,26 @@ | |||
1386 | 448 | } | 470 | } |
1387 | 449 | display_items_list.appendChild(li); | 471 | display_items_list.appendChild(li); |
1388 | 450 | } | 472 | } |
1390 | 451 | this.set("bodyContent", display_items_list); | 473 | |
1391 | 474 | this.setStdModContent(Y.WidgetStdMod.BODY, display_items_list, Y.WidgetStdMod.REPLACE); | ||
1392 | 452 | this.move(-10000, 0); | 475 | this.move(-10000, 0); |
1393 | 453 | }, | 476 | }, |
1394 | 454 | 477 | ||
1395 | 455 | /** | 478 | /** |
1396 | 456 | * Bind UI events | 479 | * Bind UI events |
1397 | 480 | * <p> | ||
1398 | 481 | * This method is invoked after bindUI is invoked for the Widget class | ||
1399 | 482 | * using YUI's aop infrastructure. | ||
1400 | 483 | * </p> | ||
1401 | 457 | * | 484 | * |
1403 | 458 | * @method bindUI | 485 | * @method _bindUIChoiceList |
1404 | 486 | * @protected | ||
1405 | 459 | */ | 487 | */ |
1410 | 460 | bindUI: function() { | 488 | _bindUIChoiceList: function() { |
1407 | 461 | // We need to call the superclass's bindUI because it does things. | ||
1408 | 462 | ChoiceList.superclass.bindUI.apply(this); | ||
1409 | 463 | |||
1411 | 464 | var display_items_list = this.get("display_items_list"); | 489 | var display_items_list = this.get("display_items_list"); |
1412 | 465 | var that = this; | 490 | var that = this; |
1418 | 466 | display_items_list.on("click", function(e) { | 491 | Y.delegate("click", function(e) { |
1419 | 467 | var target = e.target; | 492 | var target = e.currentTarget; |
1415 | 468 | while (target.get("nodeName").toLowerCase() != "a") { | ||
1416 | 469 | target = target.get("parentNode"); | ||
1417 | 470 | } | ||
1420 | 471 | var value = target._value; | 493 | var value = target._value; |
1421 | 472 | var items = that.get("items"); | 494 | var items = that.get("items"); |
1422 | 473 | for (var i=0; i<items.length; i++) { | 495 | for (var i=0; i<items.length; i++) { |
1423 | @@ -478,7 +500,7 @@ | |||
1424 | 478 | break; | 500 | break; |
1425 | 479 | } | 501 | } |
1426 | 480 | } | 502 | } |
1428 | 481 | }); | 503 | }, display_items_list, "li a"); |
1429 | 482 | }, | 504 | }, |
1430 | 483 | 505 | ||
1431 | 484 | /** | 506 | /** |
1432 | @@ -581,7 +603,7 @@ | |||
1433 | 581 | * @attribute actionicon | 603 | * @attribute actionicon |
1434 | 582 | */ | 604 | */ |
1435 | 583 | actionicon: { | 605 | actionicon: { |
1437 | 584 | get: function() { | 606 | getter: function() { |
1438 | 585 | if (Y.Lang.isValue(this.get('value'))) { | 607 | if (Y.Lang.isValue(this.get('value'))) { |
1439 | 586 | return this.get('editicon'); | 608 | return this.get('editicon'); |
1440 | 587 | } else { | 609 | } else { |
1441 | @@ -598,7 +620,7 @@ | |||
1442 | 598 | */ | 620 | */ |
1443 | 599 | items: { | 621 | items: { |
1444 | 600 | value: [], | 622 | value: [], |
1446 | 601 | get: function(v) { | 623 | getter: function(v) { |
1447 | 602 | if (!Y.Lang.isValue(this.get("value"))) { | 624 | if (!Y.Lang.isValue(this.get("value"))) { |
1448 | 603 | v = Y.Array(v).filter(function(item) { | 625 | v = Y.Array(v).filter(function(item) { |
1449 | 604 | return (Y.Lang.isValue(item.value)); | 626 | return (Y.Lang.isValue(item.value)); |
1450 | @@ -619,7 +641,7 @@ | |||
1451 | 619 | } | 641 | } |
1452 | 620 | return v; | 642 | return v; |
1453 | 621 | }, | 643 | }, |
1455 | 622 | clone : Y.Attribute.CLONE.DEEP | 644 | clone : "deep" |
1456 | 623 | } | 645 | } |
1457 | 624 | } | 646 | } |
1458 | 625 | 647 | ||
1459 | @@ -647,6 +669,7 @@ | |||
1460 | 647 | 669 | ||
1461 | 648 | Y.NullChoiceSource = NullChoiceSource; | 670 | Y.NullChoiceSource = NullChoiceSource; |
1462 | 649 | 671 | ||
1465 | 650 | },'0.2', {requires: | 672 | },'0.2', {requires: ['oop', 'event', 'event-delegate', 'node', |
1466 | 651 | ['oop', 'event', 'node', 'widget', 'overlay', 'lazr.overlay', 'lazr.anim', 'lazr.base']}); | 673 | 'widget', 'widget-stdmod', 'overlay', |
1467 | 674 | 'lazr.overlay', 'lazr.anim', 'lazr.base']}); | ||
1468 | 652 | 675 | ||
1469 | 653 | 676 | ||
1470 | === modified file 'src-js/lazrjs/choiceedit/tests/choiceedit.html' | |||
1471 | --- src-js/lazrjs/choiceedit/tests/choiceedit.html 2009-02-20 14:15:34 +0000 | |||
1472 | +++ src-js/lazrjs/choiceedit/tests/choiceedit.html 2009-10-30 17:01:14 +0000 | |||
1473 | @@ -4,17 +4,19 @@ | |||
1474 | 4 | <title>Status Editor</title> | 4 | <title>Status Editor</title> |
1475 | 5 | 5 | ||
1476 | 6 | <!-- YUI 3.0 Setup --> | 6 | <!-- YUI 3.0 Setup --> |
1481 | 7 | <script type="text/javascript" src="../../../lib/yui/3.0.0pr2/build/yui/yui.js"></script> | 7 | <script type="text/javascript" src="../../yui/current/build/yui/yui.js"></script> |
1482 | 8 | <link rel="stylesheet" href="../../../lib/yui/3.0.0pr2/build/cssreset/reset.css"/> | 8 | <link rel="stylesheet" href="../../yui/current/build/cssreset/reset.css"/> |
1483 | 9 | <link rel="stylesheet" href="../../../lib/yui/3.0.0pr2/build/cssfonts/fonts.css"/> | 9 | <link rel="stylesheet" href="../../yui/current/build/cssfonts/fonts.css"/> |
1484 | 10 | <link rel="stylesheet" href="../../../lib/yui/3.0.0pr2/build/cssbase/base.css"/> | 10 | <link rel="stylesheet" href="../../yui/current/build/cssbase/base.css"/> |
1485 | 11 | 11 | ||
1486 | 12 | <!-- Dependency --> | 12 | <!-- Dependency --> |
1489 | 13 | <script type="text/javascript" src="../../../lib/lazr/build/lazr.js"></script> | 13 | <script type="text/javascript" src="../../lazr/lazr.js"></script> |
1490 | 14 | <script type="text/javascript" src="../../../lib/lazr/build/overlay/overlay.js"></script> | 14 | <script type="text/javascript" src="../../anim/anim.js"></script> |
1491 | 15 | <script type="text/javascript" src="../../testing/testing.js"></script> | ||
1492 | 16 | <script type="text/javascript" src="../../overlay/overlay.js"></script> | ||
1493 | 15 | 17 | ||
1494 | 16 | <!-- The module under test --> | 18 | <!-- The module under test --> |
1496 | 17 | <script type="text/javascript" src="../../../lib/lazr/build/choiceedit/choiceedit.js"></script> | 19 | <script type="text/javascript" src="../../choiceedit/choiceedit.js"></script> |
1497 | 18 | 20 | ||
1498 | 19 | <!-- The test suite --> | 21 | <!-- The test suite --> |
1499 | 20 | <script type="text/javascript" src="choiceedit.js"></script> | 22 | <script type="text/javascript" src="choiceedit.js"></script> |
1500 | 21 | 23 | ||
1501 | === modified file 'src-js/lazrjs/choiceedit/tests/choiceedit.js' | |||
1502 | --- src-js/lazrjs/choiceedit/tests/choiceedit.js 2009-08-21 14:06:19 +0000 | |||
1503 | +++ src-js/lazrjs/choiceedit/tests/choiceedit.js 2009-10-30 17:01:14 +0000 | |||
1504 | @@ -1,10 +1,11 @@ | |||
1505 | 1 | /* Copyright (c) 2008, Canonical Ltd. All rights reserved. */ | 1 | /* Copyright (c) 2008, Canonical Ltd. All rights reserved. */ |
1506 | 2 | 2 | ||
1507 | 3 | YUI({ | 3 | YUI({ |
1509 | 4 | base: '../../../lib/yui/current/build/', | 4 | base: '../../yui/current/build/', |
1510 | 5 | filter: 'raw', | 5 | filter: 'raw', |
1511 | 6 | combine: false | 6 | combine: false |
1513 | 7 | }).use('lazr.choiceedit', 'node', 'event', 'yuitest', 'widget-stack', 'console', function(Y) { | 7 | }).use('lazr.choiceedit', 'lazr.testing.runner', 'node', |
1514 | 8 | 'event', 'widget-stack', 'console', function(Y) { | ||
1515 | 8 | 9 | ||
1516 | 9 | // Local aliases | 10 | // Local aliases |
1517 | 10 | var Assert = Y.Assert, | 11 | var Assert = Y.Assert, |
1518 | @@ -525,15 +526,7 @@ | |||
1519 | 525 | } | 526 | } |
1520 | 526 | })); | 527 | })); |
1521 | 527 | 528 | ||
1532 | 528 | Y.Test.Runner.add(suite); | 529 | Y.lazr.testing.Runner.add(suite); |
1533 | 529 | 530 | Y.lazr.testing.Runner.run(); | |
1524 | 530 | var yconsole = new Y.Console({ | ||
1525 | 531 | newestOnTop: false | ||
1526 | 532 | }); | ||
1527 | 533 | yconsole.render('#log'); | ||
1528 | 534 | |||
1529 | 535 | Y.on('domready', function() { | ||
1530 | 536 | Y.Test.Runner.run(); | ||
1531 | 537 | }); | ||
1534 | 538 | 531 | ||
1535 | 539 | }); | 532 | }); |
1536 | 540 | 533 | ||
1537 | === modified file 'src-js/lazrjs/formoverlay/formoverlay.js' | |||
1538 | --- src-js/lazrjs/formoverlay/formoverlay.js 2009-08-13 13:08:36 +0000 | |||
1539 | +++ src-js/lazrjs/formoverlay/formoverlay.js 2009-10-30 17:01:14 +0000 | |||
1540 | @@ -8,6 +8,13 @@ | |||
1541 | 8 | * @module lazr.formoverlay | 8 | * @module lazr.formoverlay |
1542 | 9 | */ | 9 | */ |
1543 | 10 | 10 | ||
1544 | 11 | |||
1545 | 12 | var getCN = Y.ClassNameManager.getClassName, | ||
1546 | 13 | NAME = 'lazr-formoverlay', | ||
1547 | 14 | CONTENT_BOX = 'contentBox', | ||
1548 | 15 | RENDERUI = "renderUI", | ||
1549 | 16 | BINDUI = "bindUI"; | ||
1550 | 17 | |||
1551 | 11 | /** | 18 | /** |
1552 | 12 | * The FormOverlay class builds on the lazr.PrettyOverlay class | 19 | * The FormOverlay class builds on the lazr.PrettyOverlay class |
1553 | 13 | * to display form content and extract form data for the callsite. | 20 | * to display form content and extract form data for the callsite. |
1554 | @@ -17,11 +24,12 @@ | |||
1555 | 17 | */ | 24 | */ |
1556 | 18 | function FormOverlay(config) { | 25 | function FormOverlay(config) { |
1557 | 19 | FormOverlay.superclass.constructor.apply(this, arguments); | 26 | FormOverlay.superclass.constructor.apply(this, arguments); |
1558 | 27 | |||
1559 | 28 | Y.after(this._renderUIFormOverlay, this, RENDERUI); | ||
1560 | 29 | Y.after(this._bindUIFormOverlay, this, BINDUI); | ||
1561 | 30 | |||
1562 | 20 | } | 31 | } |
1563 | 21 | 32 | ||
1564 | 22 | var getCN = Y.ClassNameManager.getClassName; | ||
1565 | 23 | var NAME = 'lazr-formoverlay'; | ||
1566 | 24 | |||
1567 | 25 | FormOverlay.NAME = NAME; | 33 | FormOverlay.NAME = NAME; |
1568 | 26 | 34 | ||
1569 | 27 | /** | 35 | /** |
1570 | @@ -184,16 +192,19 @@ | |||
1571 | 184 | 192 | ||
1572 | 185 | /** | 193 | /** |
1573 | 186 | * Create the nodes for the form and add them to the contentBody. | 194 | * Create the nodes for the form and add them to the contentBody. |
1574 | 195 | * <p> | ||
1575 | 196 | * This method is invoked after renderUI is invoked for the Widget class | ||
1576 | 197 | * using YUI's aop infrastructure. | ||
1577 | 198 | * </p> | ||
1578 | 187 | * | 199 | * |
1580 | 188 | * @method renderUI | 200 | * @method _renderUIFormOverlay |
1581 | 201 | * @protected | ||
1582 | 189 | */ | 202 | */ |
1586 | 190 | renderUI: function(){ | 203 | _renderUIFormOverlay: function(){ |
1584 | 191 | FormOverlay.superclass.renderUI.apply(this); | ||
1585 | 192 | |||
1587 | 193 | // Create a node that will contain the form header: | 204 | // Create a node that will contain the form header: |
1588 | 194 | this.form_header_node = Y.Node.create( | 205 | this.form_header_node = Y.Node.create( |
1589 | 195 | FormOverlay.FORM_HEADER_TEMPLATE); | 206 | FormOverlay.FORM_HEADER_TEMPLATE); |
1591 | 196 | 207 | ||
1592 | 197 | // Create a form node that will contain the form content: | 208 | // Create a form node that will contain the form content: |
1593 | 198 | this.form_node = Y.Node.create(FormOverlay.FORM_TEMPLATE); | 209 | this.form_node = Y.Node.create(FormOverlay.FORM_TEMPLATE); |
1594 | 199 | 210 | ||
1595 | @@ -216,51 +227,43 @@ | |||
1596 | 216 | this.error_node = Y.Node.create(FormOverlay.ERROR_TEMPLATE); | 227 | this.error_node = Y.Node.create(FormOverlay.ERROR_TEMPLATE); |
1597 | 217 | 228 | ||
1598 | 218 | this._setFormContent(); | 229 | this._setFormContent(); |
1599 | 219 | |||
1600 | 220 | }, | 230 | }, |
1601 | 221 | 231 | ||
1602 | 222 | /** | 232 | /** |
1603 | 223 | * Bind the submit button to the _onFormSubmit() method. | 233 | * Bind the submit button to the _onFormSubmit() method. |
1604 | 234 | * <p> | ||
1605 | 235 | * This method is invoked after bindUI is invoked for the Widget class | ||
1606 | 236 | * using YUI's aop infrastructure. | ||
1607 | 237 | * </p> | ||
1608 | 224 | * | 238 | * |
1609 | 225 | * @method bindUI | 239 | * @method bindUI |
1610 | 240 | * @protected | ||
1611 | 226 | */ | 241 | */ |
1619 | 227 | bindUI: function(){ | 242 | _bindUIFormOverlay: function(){ |
1620 | 228 | this.constructor.superclass.bindUI.call(this); | 243 | Y.on("submit", |
1621 | 229 | 244 | Y.bind(this._onFormSubmit, this), | |
1622 | 230 | Y.on( | 245 | this.form_node); |
1616 | 231 | "submit", | ||
1617 | 232 | Y.bind(this._onFormSubmit, this), | ||
1618 | 233 | this.form_node); | ||
1623 | 234 | 246 | ||
1624 | 235 | // Setup the cancel button to hide the formoverlay. | 247 | // Setup the cancel button to hide the formoverlay. |
1653 | 236 | Y.on( | 248 | Y.on("click", |
1654 | 237 | "click", | 249 | Y.bind(function(e){ this.hide();}, this), |
1655 | 238 | Y.bind(function(e){ this.hide();}, this), | 250 | this.get("form_cancel_button")); |
1656 | 239 | this.get("form_cancel_button")); | 251 | |
1657 | 240 | }, | 252 | this.on("visibleChange", function(e) { |
1658 | 241 | 253 | // If the 'centered' configuration attribute is set to true, | |
1659 | 242 | /** | 254 | // then we should always re-center relative to the current |
1660 | 243 | * Show the widget by setting the "visible" attribute to "true". | 255 | // viewport when shown: |
1661 | 244 | * | 256 | if (e.newVal) { |
1662 | 245 | * Overridden here to ensure that the focus is given to the first | 257 | if (this.get('centered')){ |
1663 | 246 | * input element whenever the FormOverlay is shown. | 258 | this.centered(); |
1664 | 247 | * | 259 | } |
1665 | 248 | * @method show | 260 | |
1666 | 249 | */ | 261 | var form_elem = Y.Node.getDOMNode(this.form_node); |
1667 | 250 | show: function(){ | 262 | if (form_elem.elements.length > 0) { |
1668 | 251 | // If the 'centered' configuration attribute is set to true, | 263 | Y.get(form_elem.elements[0]).focus(); |
1669 | 252 | // then we should always re-center relative to the current | 264 | } |
1670 | 253 | // viewport when shown: | 265 | } |
1671 | 254 | if (this.get('centered')){ | 266 | }); |
1644 | 255 | this.centered(); | ||
1645 | 256 | } | ||
1646 | 257 | |||
1647 | 258 | this.constructor.superclass.show.call(this); | ||
1648 | 259 | |||
1649 | 260 | var form_elem = Y.Node.getDOMNode(this.form_node); | ||
1650 | 261 | if (form_elem.elements.length > 0) { | ||
1651 | 262 | form_elem.elements[0].focus(); | ||
1652 | 263 | } | ||
1672 | 264 | }, | 267 | }, |
1673 | 265 | 268 | ||
1674 | 266 | /** | 269 | /** |
1675 | @@ -274,6 +277,7 @@ | |||
1676 | 274 | this.form_header_node.set('innerHTML', | 277 | this.form_header_node.set('innerHTML', |
1677 | 275 | this.get('form_header')); | 278 | this.get('form_header')); |
1678 | 276 | 279 | ||
1679 | 280 | |||
1680 | 277 | // Add the form content to the form node. | 281 | // Add the form content to the form node. |
1681 | 278 | // The form_content can be a string of HTML (as is useful when | 282 | // The form_content can be a string of HTML (as is useful when |
1682 | 279 | // it is obtained via AJAX) or a form node (as is useful if the | 283 | // it is obtained via AJAX) or a form node (as is useful if the |
1683 | @@ -300,7 +304,7 @@ | |||
1684 | 300 | body_node.appendChild(this.form_header_node); | 304 | body_node.appendChild(this.form_header_node); |
1685 | 301 | body_node.appendChild(this.form_node); | 305 | body_node.appendChild(this.form_node); |
1686 | 302 | 306 | ||
1688 | 303 | this.set("bodyContent", body_node); | 307 | this.setStdModContent(Y.WidgetStdMod.BODY, body_node, Y.WidgetStdMod.REPLACE); |
1689 | 304 | }, | 308 | }, |
1690 | 305 | 309 | ||
1691 | 306 | /** | 310 | /** |
1692 | 307 | 311 | ||
1693 | === modified file 'src-js/lazrjs/formoverlay/tests/formoverlay.html' | |||
1694 | --- src-js/lazrjs/formoverlay/tests/formoverlay.html 2009-08-13 08:54:56 +0000 | |||
1695 | +++ src-js/lazrjs/formoverlay/tests/formoverlay.html 2009-10-30 17:01:14 +0000 | |||
1696 | @@ -4,50 +4,26 @@ | |||
1697 | 4 | <title>Form Overlay</title> | 4 | <title>Form Overlay</title> |
1698 | 5 | 5 | ||
1699 | 6 | <!-- YUI 3.0 Setup --> | 6 | <!-- YUI 3.0 Setup --> |
1704 | 7 | <script type="text/javascript" src="../../../lib/yui/3.0.0pr2/build/yui/yui.js"></script> | 7 | <script type="text/javascript" src="../../yui/current/build/yui/yui.js"></script> |
1705 | 8 | <link rel="stylesheet" href="../../../lib/yui/3.0.0pr2/build/cssreset/reset.css"/> | 8 | <link rel="stylesheet" href="../../yui/current/build/cssreset/reset.css"/> |
1706 | 9 | <link rel="stylesheet" href="../../../lib/yui/3.0.0pr2/build/cssfonts/fonts.css"/> | 9 | <link rel="stylesheet" href="../../yui/current/build/cssfonts/fonts.css"/> |
1707 | 10 | <link rel="stylesheet" href="../../../lib/yui/3.0.0pr2/build/cssbase/base.css"/> | 10 | <link rel="stylesheet" href="../../yui/current/build/cssbase/base.css"/> |
1708 | 11 | <link rel="stylesheet" href="../../testing/assets/testlogger.css"/> | ||
1709 | 11 | 12 | ||
1710 | 12 | <!-- dependent modules from lazr--> | 13 | <!-- dependent modules from lazr--> |
1713 | 13 | <script type="text/javascript" src="../../../lib/lazr/build/lazr/lazr.js"></script> | 14 | <script type="text/javascript" src="../../lazr/lazr.js"></script> |
1714 | 14 | <script type="text/javascript" src="../../../lib/lazr/build/overlay/overlay.js"></script> | 15 | <script type="text/javascript" src="../../overlay/overlay.js"></script> |
1715 | 16 | <script type="text/javascript" src="../../testing/testing.js"></script> | ||
1716 | 15 | 17 | ||
1717 | 16 | <!-- The module under test --> | 18 | <!-- The module under test --> |
1719 | 17 | <script type="text/javascript" src="../../../lib/lazr/build/formoverlay/formoverlay.js"></script> | 19 | <script type="text/javascript" src="../../formoverlay/formoverlay.js"></script> |
1720 | 18 | 20 | ||
1721 | 19 | <!-- Testing helpers --> | 21 | <!-- Testing helpers --> |
1723 | 20 | <script type="text/javascript" src="../../../lib/lazr/build/testing/mockio.js"></script> | 22 | <script type="text/javascript" src="../../testing/mockio.js"></script> |
1724 | 21 | 23 | ||
1725 | 22 | <!-- The test suite --> | 24 | <!-- The test suite --> |
1726 | 23 | <script type="text/javascript" src="formoverlay.js"></script> | 25 | <script type="text/javascript" src="formoverlay.js"></script> |
1727 | 24 | 26 | ||
1728 | 25 | <style> | ||
1729 | 26 | /* Taken and customized from testlogger.css */ | ||
1730 | 27 | #log .yui-console-content { width:44em } | ||
1731 | 28 | #log .yui-console .yui-console-bd { height:30em } | ||
1732 | 29 | #log .yui-console .yui-console-controls { display:none; } | ||
1733 | 30 | #log .yui-console .yui-console-hd { display:none; } | ||
1734 | 31 | #log .yui-console .yui-console-ft { position:absolute;top:0em; } | ||
1735 | 32 | |||
1736 | 33 | #log .yui-console-entry-src { display:none; } | ||
1737 | 34 | |||
1738 | 35 | #log .yui-console-entry-pass .yui-console-entry-cat { | ||
1739 | 36 | background-color: green; | ||
1740 | 37 | font-weight: bold; | ||
1741 | 38 | color: white; | ||
1742 | 39 | } | ||
1743 | 40 | #log .yui-console-entry-fail .yui-console-entry-cat { | ||
1744 | 41 | background-color: red; | ||
1745 | 42 | font-weight: bold; | ||
1746 | 43 | color: white; | ||
1747 | 44 | } | ||
1748 | 45 | #log .yui-console-entry-ignore .yui-console-entry-cat { | ||
1749 | 46 | background-color: #666; | ||
1750 | 47 | font-weight: bold; | ||
1751 | 48 | color: white; | ||
1752 | 49 | } | ||
1753 | 50 | </style> | ||
1754 | 51 | </head> | 27 | </head> |
1755 | 52 | <body class="yui-skin-sam"> | 28 | <body class="yui-skin-sam"> |
1756 | 53 | <div id="form_overlay_example"> | 29 | <div id="form_overlay_example"> |
1757 | 54 | 30 | ||
1758 | === modified file 'src-js/lazrjs/formoverlay/tests/formoverlay.js' | |||
1759 | --- src-js/lazrjs/formoverlay/tests/formoverlay.js 2009-08-13 13:08:36 +0000 | |||
1760 | +++ src-js/lazrjs/formoverlay/tests/formoverlay.js 2009-10-30 17:01:14 +0000 | |||
1761 | @@ -1,11 +1,12 @@ | |||
1762 | 1 | /* Copyright (c) 2008, Canonical Ltd. All rights reserved. */ | 1 | /* Copyright (c) 2008, Canonical Ltd. All rights reserved. */ |
1763 | 2 | 2 | ||
1764 | 3 | YUI({ | 3 | YUI({ |
1766 | 4 | base: '../../../lib/yui/3.0.0pr2/build/', | 4 | base: '../../yui/current/build/', |
1767 | 5 | filter: 'raw', | 5 | filter: 'raw', |
1768 | 6 | combine: false | 6 | combine: false |
1771 | 7 | }).use('lazr.formoverlay', 'lazr.testing', 'node', 'event', 'yuitest', | 7 | }).use('lazr.formoverlay', 'lazr.testing.runner', |
1772 | 8 | 'dump', 'console', function(Y) { | 8 | 'lazr.testing.mockio', 'node', 'event', 'dump', |
1773 | 9 | 'console', function(Y) { | ||
1774 | 9 | 10 | ||
1775 | 10 | var Assert = Y.Assert; // For easy access to isTrue(), etc. | 11 | var Assert = Y.Assert; // For easy access to isTrue(), etc. |
1776 | 11 | 12 | ||
1777 | @@ -19,6 +20,17 @@ | |||
1778 | 19 | Y.Event.simulate(rawnode, evtype, options); | 20 | Y.Event.simulate(rawnode, evtype, options); |
1779 | 20 | } | 21 | } |
1780 | 21 | 22 | ||
1781 | 23 | /* Helper function to cleanup and destroy a form overlay instance */ | ||
1782 | 24 | function cleanup_form_overlay(form_overlay) { | ||
1783 | 25 | if (form_overlay.get('rendered')) { | ||
1784 | 26 | var bb = form_overlay.get('boundingBox'); | ||
1785 | 27 | bb.get('parentNode').removeChild(bb); | ||
1786 | 28 | } | ||
1787 | 29 | |||
1788 | 30 | // Kill the widget itself. | ||
1789 | 31 | form_overlay.destroy(); | ||
1790 | 32 | } | ||
1791 | 33 | |||
1792 | 22 | /* Helper function that creates a new form overlay instance. */ | 34 | /* Helper function that creates a new form overlay instance. */ |
1793 | 23 | function make_form_overlay(cfg) { | 35 | function make_form_overlay(cfg) { |
1794 | 24 | var form_overlay = new Y.lazr.FormOverlay(cfg); | 36 | var form_overlay = new Y.lazr.FormOverlay(cfg); |
1795 | @@ -44,21 +56,14 @@ | |||
1796 | 44 | }); | 56 | }); |
1797 | 45 | 57 | ||
1798 | 46 | // Ensure window size is constant for tests | 58 | // Ensure window size is constant for tests |
1800 | 47 | window.resizeTo(800, 600); | 59 | this.width = window.top.outerWidth; |
1801 | 60 | this.height = window.top.outerHeight; | ||
1802 | 61 | window.top.resizeTo(800, 600); | ||
1803 | 48 | }, | 62 | }, |
1804 | 49 | 63 | ||
1805 | 50 | tearDown: function() { | 64 | tearDown: function() { |
1817 | 51 | this.cleanUp(this.form_overlay); | 65 | window.top.resizeTo(this.width, this.height); |
1818 | 52 | }, | 66 | cleanup_form_overlay(this.form_overlay); |
1808 | 53 | |||
1809 | 54 | cleanUp: function(form_overlay) { | ||
1810 | 55 | if (form_overlay.get('rendered')) { | ||
1811 | 56 | var bb = form_overlay.get('boundingBox'); | ||
1812 | 57 | bb.get('parentNode').removeChild(bb); | ||
1813 | 58 | } | ||
1814 | 59 | |||
1815 | 60 | // Kill the widget itself. | ||
1816 | 61 | form_overlay.destroy(); | ||
1819 | 62 | }, | 67 | }, |
1820 | 63 | 68 | ||
1821 | 64 | test_form_overlay_can_be_instantiated: function() { | 69 | test_form_overlay_can_be_instantiated: function() { |
1822 | @@ -67,45 +72,36 @@ | |||
1823 | 67 | Y.lazr.FormOverlay, | 72 | Y.lazr.FormOverlay, |
1824 | 68 | overlay, | 73 | overlay, |
1825 | 69 | "Form overlay could not be instantiated."); | 74 | "Form overlay could not be instantiated."); |
1836 | 70 | }, | 75 | cleanup_form_overlay(overlay); |
1837 | 71 | 76 | }, | |
1838 | 72 | // This fails because YUI adds an extra div for some reason. | 77 | |
1839 | 73 | // If and when this is fixed, and this passes, we'll need to | 78 | test_body_content_is_single_node: function() { |
1830 | 74 | // update test_form_content_in_bodyContent below. | ||
1831 | 75 | _should: { | ||
1832 | 76 | fail: {test_bodyContent_is_single_node: true} | ||
1833 | 77 | }, | ||
1834 | 78 | |||
1835 | 79 | test_bodyContent_is_single_node: function() { | ||
1840 | 80 | Assert.areEqual( | 79 | Assert.areEqual( |
1841 | 81 | 1, | 80 | 1, |
1844 | 82 | this.form_overlay.get("bodyContent").size(), | 81 | this.form_overlay.getStdModNode("body").size(), |
1845 | 83 | "The bodyContent should be a single node, not a node list."); | 82 | "The body content should be a single node, not a node list."); |
1846 | 84 | }, | 83 | }, |
1847 | 85 | 84 | ||
1850 | 86 | test_form_content_in_bodyContent: function() { | 85 | test_form_content_in_body_content: function() { |
1851 | 87 | // The form_content should be included in the bodyContent of the | 86 | // The form_content should be included in the body of the |
1852 | 88 | // overlay during initialization. | 87 | // overlay during initialization. |
1854 | 89 | var body_content = this.form_overlay.get("bodyContent"); | 88 | var body_content = this.form_overlay.getStdModNode("body"); |
1855 | 90 | 89 | ||
1856 | 91 | // Ensure the body_content contains our form node. | 90 | // Ensure the body_content contains our form node. |
1857 | 92 | // Note: see failing test_bodyContent_is_single_node above for why | ||
1858 | 93 | // an index is used here. | ||
1859 | 94 | Assert.isTrue( | 91 | Assert.isTrue( |
1861 | 95 | body_content.contains(this.form_overlay.form_node)[1], | 92 | body_content.contains(this.form_overlay.form_node), |
1862 | 96 | "The form node is part of the body content."); | 93 | "The form node is part of the body content."); |
1863 | 97 | 94 | ||
1864 | 98 | // And then make sure that the user-supplied form_content is | 95 | // And then make sure that the user-supplied form_content is |
1865 | 99 | // included in the form node: | 96 | // included in the form node: |
1866 | 100 | Assert.areNotEqual( | 97 | Assert.areNotEqual( |
1868 | 101 | body_content.get("innerHTML")[1].search( | 98 | body_content.get("innerHTML").search( |
1869 | 102 | this.form_overlay.get("form_content"))); | 99 | this.form_overlay.get("form_content"))); |
1870 | 103 | }, | 100 | }, |
1871 | 104 | 101 | ||
1872 | 105 | test_first_input_has_focus: function() { | 102 | test_first_input_has_focus: function() { |
1873 | 106 | // The first input element in the form content should have | 103 | // The first input element in the form content should have |
1874 | 107 | // focus. | 104 | // focus. |
1875 | 108 | |||
1876 | 109 | var first_input = this.form_overlay.form_node.query('#field1'); | 105 | var first_input = this.form_overlay.form_node.query('#field1'); |
1877 | 110 | 106 | ||
1878 | 111 | // Hide the overlay and ensure that the first input does not | 107 | // Hide the overlay and ensure that the first input does not |
1879 | @@ -125,26 +121,23 @@ | |||
1880 | 125 | }); | 121 | }); |
1881 | 126 | }; | 122 | }; |
1882 | 127 | 123 | ||
1884 | 128 | Y.on('focus', onFocus, first_input); | 124 | first_input.on('focus', onFocus); |
1885 | 129 | 125 | ||
1886 | 130 | this.form_overlay.show(); | 126 | this.form_overlay.show(); |
1887 | 131 | 127 | ||
1888 | 132 | this.wait(5000); | 128 | this.wait(5000); |
1889 | 133 | }, | 129 | }, |
1890 | 134 | 130 | ||
1897 | 135 | test_form_submit_in_bodyContent: function() { | 131 | test_form_submit_in_body_content: function() { |
1898 | 136 | // The bodyContent should include the submit button. | 132 | // The body content should include the submit button. |
1899 | 137 | 133 | var body_content = this.form_overlay.getStdModNode("body"); | |
1894 | 138 | var body_content = this.form_overlay.get("bodyContent"); | ||
1895 | 139 | // Note: see failing test_bodyContent_is_single_node above for why | ||
1896 | 140 | // an index is used here. | ||
1900 | 141 | Assert.isTrue( | 134 | Assert.isTrue( |
1901 | 142 | body_content.contains( | 135 | body_content.contains( |
1904 | 143 | this.form_overlay.get("form_submit_button"))[1], | 136 | this.form_overlay.get("form_submit_button")), |
1905 | 144 | "The bodyContent includes the form_submit_button."); | 137 | "The body content includes the form_submit_button."); |
1906 | 145 | }, | 138 | }, |
1907 | 146 | 139 | ||
1909 | 147 | test_users_submit_button_in_bodyContent: function() { | 140 | test_users_submit_button_in_body_content: function() { |
1910 | 148 | // If a user supplies a custom submit button, it should be included | 141 | // If a user supplies a custom submit button, it should be included |
1911 | 149 | // in the form instead of the default one. | 142 | // in the form instead of the default one. |
1912 | 150 | var submit_button = Y.Node.create( | 143 | var submit_button = Y.Node.create( |
1913 | @@ -161,22 +154,19 @@ | |||
1914 | 161 | form_overlay.form_node.contains(submit_button), | 154 | form_overlay.form_node.contains(submit_button), |
1915 | 162 | "The form should include the users submit button."); | 155 | "The form should include the users submit button."); |
1916 | 163 | 156 | ||
1918 | 164 | this.cleanUp(form_overlay); | 157 | cleanup_form_overlay(form_overlay); |
1919 | 165 | }, | 158 | }, |
1920 | 166 | 159 | ||
1927 | 167 | test_form_cancel_in_bodyContent: function() { | 160 | test_form_cancel_in_body_content: function() { |
1928 | 168 | // The bodyContent should include the cancel button. | 161 | // The body content should include the cancel button. |
1929 | 169 | 162 | var body_content = this.form_overlay.getStdModNode("body"); | |
1924 | 170 | var body_content = this.form_overlay.get("bodyContent"); | ||
1925 | 171 | // Note: see failing test_bodyContent_is_single_node above for why | ||
1926 | 172 | // an index is used here. | ||
1930 | 173 | Assert.isTrue( | 163 | Assert.isTrue( |
1931 | 174 | body_content.contains( | 164 | body_content.contains( |
1934 | 175 | this.form_overlay.get("form_cancel_button"))[1], | 165 | this.form_overlay.get("form_cancel_button")), |
1935 | 176 | "The bodyContent includes the form_cancel_button."); | 166 | "The body content includes the form_cancel_button."); |
1936 | 177 | }, | 167 | }, |
1937 | 178 | 168 | ||
1939 | 179 | test_users_cancel_button_in_bodyContent: function() { | 169 | test_users_cancel_button_in_body_content: function() { |
1940 | 180 | // If a user supplies a custom cancel button, it should be included | 170 | // If a user supplies a custom cancel button, it should be included |
1941 | 181 | // in the form instead of the default one. | 171 | // in the form instead of the default one. |
1942 | 182 | var cancel_button = Y.Node.create( | 172 | var cancel_button = Y.Node.create( |
1943 | @@ -193,7 +183,7 @@ | |||
1944 | 193 | form_overlay.form_node.contains(cancel_button), | 183 | form_overlay.form_node.contains(cancel_button), |
1945 | 194 | "The form should include the users cancel button."); | 184 | "The form should include the users cancel button."); |
1946 | 195 | 185 | ||
1948 | 196 | this.cleanUp(form_overlay); | 186 | cleanup_form_overlay(form_overlay); |
1949 | 197 | }, | 187 | }, |
1950 | 198 | 188 | ||
1951 | 199 | test_hide_when_cancel_clicked: function() { | 189 | test_hide_when_cancel_clicked: function() { |
1952 | @@ -219,11 +209,9 @@ | |||
1953 | 219 | 209 | ||
1954 | 220 | this.form_overlay.showError("My special error"); | 210 | this.form_overlay.showError("My special error"); |
1955 | 221 | 211 | ||
1959 | 222 | var body_content = this.form_overlay.get("bodyContent"); | 212 | var body_content = this.form_overlay.getStdModNode("body"); |
1957 | 223 | // Note: see failing test_bodyContent_is_single_node above for why | ||
1958 | 224 | // an index is used here. | ||
1960 | 225 | Assert.areNotEqual( | 213 | Assert.areNotEqual( |
1962 | 226 | body_content.get("innerHTML")[1].search("My special error"), | 214 | body_content.get("innerHTML").search("My special error"), |
1963 | 227 | -1, | 215 | -1, |
1964 | 228 | "The error text was included in the body content."); | 216 | "The error text was included in the body content."); |
1965 | 229 | }, | 217 | }, |
1966 | @@ -234,12 +222,10 @@ | |||
1967 | 234 | // chars. Not sure what to do about unicode, for eg. | 222 | // chars. Not sure what to do about unicode, for eg. |
1968 | 235 | this.form_overlay.showError("<h2>My special error</h2>"); | 223 | this.form_overlay.showError("<h2>My special error</h2>"); |
1969 | 236 | 224 | ||
1973 | 237 | var body_content = this.form_overlay.get("bodyContent"); | 225 | var body_content = this.form_overlay.getStdModNode("body"); |
1971 | 238 | // Note: see failing test_bodyContent_is_single_node above for why | ||
1972 | 239 | // an index is used here. | ||
1974 | 240 | Assert.areEqual( | 226 | Assert.areEqual( |
1975 | 241 | -1, | 227 | -1, |
1977 | 242 | body_content.get("innerHTML")[1].search("<h2>"), | 228 | body_content.get("innerHTML").search("<h2>"), |
1978 | 243 | "The tags were stripped from the error message."); | 229 | "The tags were stripped from the error message."); |
1979 | 244 | }, | 230 | }, |
1980 | 245 | 231 | ||
1981 | @@ -247,9 +233,9 @@ | |||
1982 | 247 | // The error message should be cleared from the body content. | 233 | // The error message should be cleared from the body content. |
1983 | 248 | this.form_overlay.showError("My special error"); | 234 | this.form_overlay.showError("My special error"); |
1984 | 249 | this.form_overlay.clearError(); | 235 | this.form_overlay.clearError(); |
1986 | 250 | var body_content = this.form_overlay.get("bodyContent"); | 236 | var body_content = this.form_overlay.getStdModNode("body"); |
1987 | 251 | Assert.areEqual( | 237 | Assert.areEqual( |
1989 | 252 | body_content.get("innerHTML")[1].search("My special error"), | 238 | body_content.get("innerHTML").search("My special error"), |
1990 | 253 | -1, | 239 | -1, |
1991 | 254 | "The error text is cleared from the body content."); | 240 | "The error text is cleared from the body content."); |
1992 | 255 | }, | 241 | }, |
1993 | @@ -272,7 +258,7 @@ | |||
1994 | 272 | this.form_overlay.hide(); | 258 | this.form_overlay.hide(); |
1995 | 273 | 259 | ||
1996 | 274 | // The position is updated after resizing the window and re-showing: | 260 | // The position is updated after resizing the window and re-showing: |
1998 | 275 | window.resizeTo(850, 550); | 261 | window.top.resizeTo(850, 550); |
1999 | 276 | this.form_overlay.show(); | 262 | this.form_overlay.show(); |
2000 | 277 | Assert.areNotEqual( | 263 | Assert.areNotEqual( |
2001 | 278 | Y.dump(centered_pos_before_resize), | 264 | Y.dump(centered_pos_before_resize), |
2002 | @@ -305,6 +291,7 @@ | |||
2003 | 305 | Assert.isTrue( | 291 | Assert.isTrue( |
2004 | 306 | callback_called, | 292 | callback_called, |
2005 | 307 | "The form_submit_callback should be called."); | 293 | "The form_submit_callback should be called."); |
2006 | 294 | cleanup_form_overlay(form_overlay); | ||
2007 | 308 | }, | 295 | }, |
2008 | 309 | 296 | ||
2009 | 310 | test_submit_with_callback_prevents_propagation: function() { | 297 | test_submit_with_callback_prevents_propagation: function() { |
2010 | @@ -334,6 +321,7 @@ | |||
2011 | 334 | Assert.isFalse( | 321 | Assert.isFalse( |
2012 | 335 | event_was_propagated, | 322 | event_was_propagated, |
2013 | 336 | "The onsubmit event should not be propagated."); | 323 | "The onsubmit event should not be propagated."); |
2014 | 324 | cleanup_form_overlay(form_overlay); | ||
2015 | 337 | }, 3000); | 325 | }, 3000); |
2016 | 338 | }, | 326 | }, |
2017 | 339 | 327 | ||
2018 | @@ -352,6 +340,8 @@ | |||
2019 | 352 | Assert.isTrue(event_was_propagated, | 340 | Assert.isTrue(event_was_propagated, |
2020 | 353 | "The normal form submission event is propagated as " + | 341 | "The normal form submission event is propagated as " + |
2021 | 354 | "normal when no callback is provided."); | 342 | "normal when no callback is provided."); |
2022 | 343 | cleanup_form_overlay(form_overlay); | ||
2023 | 344 | |||
2024 | 355 | }); | 345 | }); |
2025 | 356 | e.preventDefault(); | 346 | e.preventDefault(); |
2026 | 357 | }; | 347 | }; |
2027 | @@ -382,6 +372,7 @@ | |||
2028 | 382 | '{field1 => [val1], field2 => [val2], field3 => [val3]}', | 372 | '{field1 => [val1], field2 => [val2], field3 => [val3]}', |
2029 | 383 | Y.dump(form_overlay.getFormData()), | 373 | Y.dump(form_overlay.getFormData()), |
2030 | 384 | "The getFormData method returns simple input data correctly."); | 374 | "The getFormData method returns simple input data correctly."); |
2031 | 375 | cleanup_form_overlay(form_overlay); | ||
2032 | 385 | }, | 376 | }, |
2033 | 386 | 377 | ||
2034 | 387 | test_getFormData_returns_inputs_nested_several_levels: function() { | 378 | test_getFormData_returns_inputs_nested_several_levels: function() { |
2035 | @@ -406,6 +397,7 @@ | |||
2036 | 406 | '{field1 => [val1], field2 => [val2], field3 => [val3]}', | 397 | '{field1 => [val1], field2 => [val2], field3 => [val3]}', |
2037 | 407 | Y.dump(form_overlay.getFormData()), | 398 | Y.dump(form_overlay.getFormData()), |
2038 | 408 | "The getFormData method returns simple input data correctly."); | 399 | "The getFormData method returns simple input data correctly."); |
2039 | 400 | cleanup_form_overlay(form_overlay); | ||
2040 | 409 | 401 | ||
2041 | 410 | }, | 402 | }, |
2042 | 411 | 403 | ||
2043 | @@ -425,6 +417,7 @@ | |||
2044 | 425 | Assert.isTrue( | 417 | Assert.isTrue( |
2045 | 426 | form_overlay.form_node.contains(input_node), | 418 | form_overlay.form_node.contains(input_node), |
2046 | 427 | "Failed to pass the form content as a Y.Node instance."); | 419 | "Failed to pass the form content as a Y.Node instance."); |
2047 | 420 | cleanup_form_overlay(form_overlay); | ||
2048 | 428 | }, | 421 | }, |
2049 | 429 | 422 | ||
2050 | 430 | test_form_content_loaded_from_url_success: function() { | 423 | test_form_content_loaded_from_url_success: function() { |
2051 | @@ -455,6 +448,7 @@ | |||
2052 | 455 | Assert.areEqual( | 448 | Assert.areEqual( |
2053 | 456 | external_form_content, form_node_text.match(external_form_content), | 449 | external_form_content, form_node_text.match(external_form_content), |
2054 | 457 | "Failed to render the form."); | 450 | "Failed to render the form."); |
2055 | 451 | cleanup_form_overlay(form_overlay); | ||
2056 | 458 | }, | 452 | }, |
2057 | 459 | 453 | ||
2058 | 460 | test_form_content_loaded_from_url_failure: function() { | 454 | test_form_content_loaded_from_url_failure: function() { |
2059 | @@ -482,6 +476,7 @@ | |||
2060 | 482 | Assert.areEqual( | 476 | Assert.areEqual( |
2061 | 483 | error_message, form_node_text.match(error_message), | 477 | error_message, form_node_text.match(error_message), |
2062 | 484 | "Failed to render the error message."); | 478 | "Failed to render the error message."); |
2063 | 479 | cleanup_form_overlay(form_overlay); | ||
2064 | 485 | }, | 480 | }, |
2065 | 486 | 481 | ||
2066 | 487 | test_form_content_loaded_from_url_bind_submit: function() { | 482 | test_form_content_loaded_from_url_bind_submit: function() { |
2067 | @@ -511,18 +506,11 @@ | |||
2068 | 511 | "input[type=submit]", | 506 | "input[type=submit]", |
2069 | 512 | 'click'); | 507 | 'click'); |
2070 | 513 | Assert.isTrue(callback_called, "Submit button didn't get hooked up."); | 508 | Assert.isTrue(callback_called, "Submit button didn't get hooked up."); |
2071 | 509 | cleanup_form_overlay(form_overlay); | ||
2072 | 514 | } | 510 | } |
2073 | 515 | })); | 511 | })); |
2074 | 516 | 512 | ||
2085 | 517 | Y.Test.Runner.add(suite); | 513 | Y.lazr.testing.Runner.add(suite); |
2086 | 518 | 514 | Y.lazr.testing.Runner.run(); | |
2077 | 519 | var yconsole = new Y.Console({ | ||
2078 | 520 | newestOnTop: false | ||
2079 | 521 | }); | ||
2080 | 522 | yconsole.render('#log'); | ||
2081 | 523 | |||
2082 | 524 | Y.on('domready', function() { | ||
2083 | 525 | Y.Test.Runner.run(); | ||
2084 | 526 | }); | ||
2087 | 527 | 515 | ||
2088 | 528 | }); | 516 | }); |
2089 | 529 | 517 | ||
2090 | === modified file 'src-js/lazrjs/inlineedit/editor.js' | |||
2091 | --- src-js/lazrjs/inlineedit/editor.js 2009-10-28 19:04:25 +0000 | |||
2092 | +++ src-js/lazrjs/inlineedit/editor.js 2009-10-30 17:01:14 +0000 | |||
2093 | @@ -158,7 +158,7 @@ | |||
2094 | 158 | */ | 158 | */ |
2095 | 159 | submit_button: { | 159 | submit_button: { |
2096 | 160 | value: null, | 160 | value: null, |
2098 | 161 | set: function(v) { return this._setNode(v); } | 161 | setter: function(v) { return this._setNode(v); } |
2099 | 162 | }, | 162 | }, |
2100 | 163 | 163 | ||
2101 | 164 | /** | 164 | /** |
2102 | @@ -170,7 +170,7 @@ | |||
2103 | 170 | */ | 170 | */ |
2104 | 171 | cancel_button: { | 171 | cancel_button: { |
2105 | 172 | value: null, | 172 | value: null, |
2107 | 173 | set: function(v) { return this._setNode(v); } | 173 | setter: function(v) { return this._setNode(v); } |
2108 | 174 | }, | 174 | }, |
2109 | 175 | 175 | ||
2110 | 176 | /** | 176 | /** |
2111 | @@ -182,7 +182,7 @@ | |||
2112 | 182 | */ | 182 | */ |
2113 | 183 | top_buttons: { | 183 | top_buttons: { |
2114 | 184 | value: null, | 184 | value: null, |
2116 | 185 | set: function(v) { return this._setNode(v); } | 185 | setter: function(v) { return this._setNode(v); } |
2117 | 186 | }, | 186 | }, |
2118 | 187 | 187 | ||
2119 | 188 | /** | 188 | /** |
2120 | @@ -194,7 +194,7 @@ | |||
2121 | 194 | */ | 194 | */ |
2122 | 195 | bottom_buttons: { | 195 | bottom_buttons: { |
2123 | 196 | value: null, | 196 | value: null, |
2125 | 197 | set: function(v) { return this._setNode(v); } | 197 | setter: function(v) { return this._setNode(v); } |
2126 | 198 | }, | 198 | }, |
2127 | 199 | 199 | ||
2128 | 200 | /** | 200 | /** |
2129 | @@ -205,7 +205,7 @@ | |||
2130 | 205 | */ | 205 | */ |
2131 | 206 | error_message: { | 206 | error_message: { |
2132 | 207 | value: null, | 207 | value: null, |
2134 | 208 | set: function(v) { return this._setNode(v); } | 208 | setter: function(v) { return this._setNode(v); } |
2135 | 209 | }, | 209 | }, |
2136 | 210 | 210 | ||
2137 | 211 | /** | 211 | /** |
2138 | @@ -283,23 +283,6 @@ | |||
2139 | 283 | Y.extend(InlineEditor, Y.Widget, { | 283 | Y.extend(InlineEditor, Y.Widget, { |
2140 | 284 | 284 | ||
2141 | 285 | /** | 285 | /** |
2142 | 286 | * An extra button box at the top, shown only in multi-line mode. | ||
2143 | 287 | * | ||
2144 | 288 | * @property top_buttons | ||
2145 | 289 | * @type Node | ||
2146 | 290 | */ | ||
2147 | 291 | top_buttons: null, | ||
2148 | 292 | |||
2149 | 293 | /** | ||
2150 | 294 | * A reference to the button-box html element in single-line mode, and | ||
2151 | 295 | * the bottom button box in multi-line mode. | ||
2152 | 296 | * | ||
2153 | 297 | * @property buttons | ||
2154 | 298 | * @type Node | ||
2155 | 299 | */ | ||
2156 | 300 | buttons: null, | ||
2157 | 301 | |||
2158 | 302 | /** | ||
2159 | 303 | * A convenience method for retrieving a Node value from a Node | 286 | * A convenience method for retrieving a Node value from a Node |
2160 | 304 | * instance, an HTMLElement, or a CSS string selector. | 287 | * instance, an HTMLElement, or a CSS string selector. |
2161 | 305 | * | 288 | * |
2162 | @@ -337,7 +320,6 @@ | |||
2163 | 337 | * @method save | 320 | * @method save |
2164 | 338 | */ | 321 | */ |
2165 | 339 | save: function() { | 322 | save: function() { |
2166 | 340 | |||
2167 | 341 | // We don't want to save any whitespace characters. | 323 | // We don't want to save any whitespace characters. |
2168 | 342 | var input = Y.Lang.trim(this.getInput()); | 324 | var input = Y.Lang.trim(this.getInput()); |
2169 | 343 | 325 | ||
2170 | @@ -1045,7 +1027,7 @@ | |||
2171 | 1045 | * @type Node | 1027 | * @type Node |
2172 | 1046 | */ | 1028 | */ |
2173 | 1047 | trigger: { | 1029 | trigger: { |
2175 | 1048 | set: function(node) { | 1030 | setter: function(node) { |
2176 | 1049 | if (this.get(RENDERED)) { | 1031 | if (this.get(RENDERED)) { |
2177 | 1050 | this._bindTrigger(node); | 1032 | this._bindTrigger(node); |
2178 | 1051 | } | 1033 | } |
2179 | @@ -1061,7 +1043,7 @@ | |||
2180 | 1061 | * @type Node | 1043 | * @type Node |
2181 | 1062 | */ | 1044 | */ |
2182 | 1063 | text: { | 1045 | text: { |
2184 | 1064 | set: function(v) { | 1046 | setter: function(v) { |
2185 | 1065 | return Y.Node.get(v); | 1047 | return Y.Node.get(v); |
2186 | 1066 | }, | 1048 | }, |
2187 | 1067 | validator: function(v) { | 1049 | validator: function(v) { |
2188 | @@ -1081,10 +1063,10 @@ | |||
2189 | 1081 | * @readOnly | 1063 | * @readOnly |
2190 | 1082 | */ | 1064 | */ |
2191 | 1083 | value: { | 1065 | value: { |
2193 | 1084 | get: function() { | 1066 | getter: function() { |
2194 | 1085 | var text_node = this.get(TEXT); | 1067 | var text_node = this.get(TEXT); |
2195 | 1086 | var ptags = text_node.queryAll('p'); | 1068 | var ptags = text_node.queryAll('p'); |
2197 | 1087 | if (Y.Lang.isValue(ptags)) { | 1069 | if (Y.Lang.isValue(ptags) && ptags.size()) { |
2198 | 1088 | var lines = []; | 1070 | var lines = []; |
2199 | 1089 | ptags.each(function(ptag) { | 1071 | ptags.each(function(ptag) { |
2200 | 1090 | lines = lines.concat([ptag.get('text'), '\n\n']); | 1072 | lines = lines.concat([ptag.get('text'), '\n\n']); |
2201 | @@ -1106,7 +1088,7 @@ | |||
2202 | 1106 | */ | 1088 | */ |
2203 | 1107 | accept_empty: { | 1089 | accept_empty: { |
2204 | 1108 | value: false, | 1090 | value: false, |
2206 | 1109 | get: function() { | 1091 | getter: function() { |
2207 | 1110 | if (this.editor) { | 1092 | if (this.editor) { |
2208 | 1111 | return this.editor.get(ACCEPT_EMPTY); | 1093 | return this.editor.get(ACCEPT_EMPTY); |
2209 | 1112 | } | 1094 | } |
2210 | @@ -1431,7 +1413,7 @@ | |||
2211 | 1431 | if (this._click_handler) { | 1413 | if (this._click_handler) { |
2212 | 1432 | this._click_handler.detach(); | 1414 | this._click_handler.detach(); |
2213 | 1433 | } | 1415 | } |
2215 | 1434 | this._click_handler = Y.on('click', this._triggerEdit, node, this); | 1416 | this._click_handler = node.on('click', this._triggerEdit, this); |
2216 | 1435 | }, | 1417 | }, |
2217 | 1436 | 1418 | ||
2218 | 1437 | 1419 | ||
2219 | @@ -1496,5 +1478,5 @@ | |||
2220 | 1496 | 1478 | ||
2221 | 1497 | //~ Y.log("Module loaded", 'info', 'lazr.editor'); | 1479 | //~ Y.log("Module loaded", 'info', 'lazr.editor'); |
2222 | 1498 | 1480 | ||
2225 | 1499 | }, '0.2', {requires: | 1481 | }, '0.2', {requires: ['oop', 'anim', 'event', 'node', 'widget', |
2226 | 1500 | ['oop', 'event', 'node', 'widget', 'lazr.anim', 'lazr.base']}); | 1482 | 'lazr.anim', 'lazr.base']}); |
2227 | 1501 | 1483 | ||
2228 | === modified file 'src-js/lazrjs/inlineedit/tests/index.html' | |||
2229 | --- src-js/lazrjs/inlineedit/tests/index.html 2009-05-14 18:21:37 +0000 | |||
2230 | +++ src-js/lazrjs/inlineedit/tests/index.html 2009-10-30 17:01:14 +0000 | |||
2231 | @@ -5,33 +5,23 @@ | |||
2232 | 5 | <title>Inline Edit</title> | 5 | <title>Inline Edit</title> |
2233 | 6 | 6 | ||
2234 | 7 | <!-- YUI 3.0 Setup --> | 7 | <!-- YUI 3.0 Setup --> |
2239 | 8 | <script type="text/javascript" src="../../../lib/yui/current/build/yui/yui.js"></script> | 8 | <script type="text/javascript" src="../../yui/current/build/yui/yui.js"></script> |
2240 | 9 | <link rel="stylesheet" href="../../../lib/yui/current/build/cssreset/reset.css"/> | 9 | <link rel="stylesheet" href="../../yui/current/build/cssreset/reset.css"/> |
2241 | 10 | <link rel="stylesheet" href="../../../lib/yui/current/build/cssfonts/fonts.css"/> | 10 | <link rel="stylesheet" href="../../yui/current/build/cssfonts/fonts.css"/> |
2242 | 11 | <link rel="stylesheet" href="../../../lib/yui/current/build/cssbase/base.css"/> | 11 | <link rel="stylesheet" href="../../yui/current/build/cssbase/base.css"/> |
2243 | 12 | <link rel="stylesheet" href="../../testing/assets/testlogger.css"/> | ||
2244 | 12 | 13 | ||
2245 | 13 | <!-- The module under test --> | 14 | <!-- The module under test --> |
2249 | 14 | <script type="text/javascript" src="../../../build/inlineedit/editor.js"></script> | 15 | <script type="text/javascript" src="../../inlineedit/editor.js"></script> |
2250 | 15 | <script type="text/javascript" src="../../../build/anim/anim.js"></script> | 16 | <script type="text/javascript" src="../../anim/anim.js"></script> |
2251 | 16 | <script type="text/javascript" src="../../../build/lazr/lazr.js"></script> | 17 | <script type="text/javascript" src="../../lazr/lazr.js"></script> |
2252 | 18 | <script type="text/javascript" src="../../testing/testing.js"></script> | ||
2253 | 17 | 19 | ||
2254 | 18 | <!-- The test suite --> | 20 | <!-- The test suite --> |
2255 | 19 | <script type="text/javascript" src="inline_edit.js"></script> | 21 | <script type="text/javascript" src="inline_edit.js"></script> |
2256 | 20 | 22 | ||
2257 | 21 | <link rel="stylesheet" href="../../../src/testing/assets/testlogger.css"/> | ||
2258 | 22 | </head> | 23 | </head> |
2259 | 23 | <body class="yui-skin-sam"> | 24 | <body class="yui-skin-sam"> |
2260 | 24 | <h1>Single-line editing</h1> | ||
2261 | 25 | <div id="editable_single_text"> | ||
2262 | 26 | <span id="single_text" class="yui-editable_text-text">Some editable inline text.</span> | ||
2263 | 27 | <button id="single_edit" class="yui-editable_text-trigger">Edit this</button> | ||
2264 | 28 | </div> | ||
2265 | 29 | <hr /> | ||
2266 | 30 | <h1>Multi-line editing</h1> | ||
2267 | 31 | <div id="editable_multi_text"> | ||
2268 | 32 | <button id="multi_edit" class="yui-editable_text-trigger">Edit this</button> | ||
2269 | 33 | <span id="multi_text" class="yui-editable_text-text">Some editable multi-line text.</span> | ||
2270 | 34 | </div> | ||
2271 | 35 | <div id="log"></div> | 25 | <div id="log"></div> |
2272 | 36 | </body> | 26 | </body> |
2273 | 37 | </html> | 27 | </html> |
2274 | 38 | 28 | ||
2275 | === modified file 'src-js/lazrjs/inlineedit/tests/inline_edit.js' | |||
2276 | --- src-js/lazrjs/inlineedit/tests/inline_edit.js 2009-08-13 08:54:56 +0000 | |||
2277 | +++ src-js/lazrjs/inlineedit/tests/inline_edit.js 2009-10-30 17:01:14 +0000 | |||
2278 | @@ -1,10 +1,24 @@ | |||
2279 | 1 | /* Copyright (c) 2009, Canonical Ltd. All rights reserved. */ | 1 | /* Copyright (c) 2009, Canonical Ltd. All rights reserved. */ |
2280 | 2 | 2 | ||
2281 | 3 | YUI({ | 3 | YUI({ |
2283 | 4 | base: '../../../lib/yui/current/build/', | 4 | base: '../../yui/current/build/', |
2284 | 5 | filter: 'raw', | 5 | filter: 'raw', |
2285 | 6 | combine: false | 6 | combine: false |
2287 | 7 | }).use('lazr.editor', 'node', 'event', 'yuitest', 'console', function(Y) { | 7 | }).use('lazr.editor', 'lazr.testing.runner', 'node', 'event', 'console', function(Y) { |
2288 | 8 | |||
2289 | 9 | var SAMPLE_HTML = " \ | ||
2290 | 10 | <h1>Single-line editing</h1> \ | ||
2291 | 11 | <div id='editable_single_text'> \ | ||
2292 | 12 | <span id='single_text' class='yui-editable_text-text'>Some editable inline text.</span> \ | ||
2293 | 13 | <button id='single_edit' class='yui-editable_text-trigger'>Edit this</button> \ | ||
2294 | 14 | </div> \ | ||
2295 | 15 | <hr /> \ | ||
2296 | 16 | <h1>Multi-line editing</h1> \ | ||
2297 | 17 | <div id='editable_multi_text'> \ | ||
2298 | 18 | <button id='multi_edit' class='yui-editable_text-trigger'>Edit this</button> \ | ||
2299 | 19 | <span id='multi_text' class='yui-editable_text-text'>Some editable multi-line text.</span> \ | ||
2300 | 20 | </div> \ | ||
2301 | 21 | "; | ||
2302 | 8 | 22 | ||
2303 | 9 | var Assert = Y.Assert; // For easy access to isTrue(), etc. | 23 | var Assert = Y.Assert; // For easy access to isTrue(), etc. |
2304 | 10 | 24 | ||
2305 | @@ -46,6 +60,15 @@ | |||
2306 | 46 | widget.destroy(); | 60 | widget.destroy(); |
2307 | 47 | } | 61 | } |
2308 | 48 | 62 | ||
2309 | 63 | function setup_sample_html() { | ||
2310 | 64 | if (! Y.get("#scaffolding")) { | ||
2311 | 65 | Y.get(document.body).appendChild( | ||
2312 | 66 | Y.Node.create("<div id='scaffolding'></div>")); | ||
2313 | 67 | } | ||
2314 | 68 | |||
2315 | 69 | Y.get("#scaffolding").set("innerHTML", SAMPLE_HTML); | ||
2316 | 70 | } | ||
2317 | 71 | |||
2318 | 49 | function make_editable_text(cfg) { | 72 | function make_editable_text(cfg) { |
2319 | 50 | // For the editor | 73 | // For the editor |
2320 | 51 | // TODO: fix this ugly hack | 74 | // TODO: fix this ugly hack |
2321 | @@ -396,6 +419,7 @@ | |||
2322 | 396 | name: 'Editable text initial values', | 419 | name: 'Editable text initial values', |
2323 | 397 | 420 | ||
2324 | 398 | setUp: function() { | 421 | setUp: function() { |
2325 | 422 | setup_sample_html(); | ||
2326 | 399 | this.etext = make_editable_text( | 423 | this.etext = make_editable_text( |
2327 | 400 | {initial_value_override: 'Initial value'}); | 424 | {initial_value_override: 'Initial value'}); |
2328 | 401 | }, | 425 | }, |
2329 | @@ -621,6 +645,7 @@ | |||
2330 | 621 | name: 'editable_text', | 645 | name: 'editable_text', |
2331 | 622 | 646 | ||
2332 | 623 | setUp: function() { | 647 | setUp: function() { |
2333 | 648 | setup_sample_html(); | ||
2334 | 624 | this.etext = make_editable_text(); | 649 | this.etext = make_editable_text(); |
2335 | 625 | }, | 650 | }, |
2336 | 626 | 651 | ||
2337 | @@ -704,6 +729,7 @@ | |||
2338 | 704 | this.etext.editor | 729 | this.etext.editor |
2339 | 705 | .get('input_field') | 730 | .get('input_field') |
2340 | 706 | .set('value', expected_value); | 731 | .set('value', expected_value); |
2341 | 732 | |||
2342 | 707 | this.etext.editor.save(); | 733 | this.etext.editor.save(); |
2343 | 708 | 734 | ||
2344 | 709 | Assert.areEqual( | 735 | Assert.areEqual( |
2345 | @@ -801,6 +827,7 @@ | |||
2346 | 801 | name: "EditableText single-line/multi-line modes", | 827 | name: "EditableText single-line/multi-line modes", |
2347 | 802 | 828 | ||
2348 | 803 | setUp: function() { | 829 | setUp: function() { |
2349 | 830 | setup_sample_html(); | ||
2350 | 804 | this.single = make_editable_text({ | 831 | this.single = make_editable_text({ |
2351 | 805 | contentBox: '#editable_single_text', | 832 | contentBox: '#editable_single_text', |
2352 | 806 | multiline: false | 833 | multiline: false |
2353 | @@ -843,7 +870,7 @@ | |||
2354 | 843 | }, | 870 | }, |
2355 | 844 | 871 | ||
2356 | 845 | test_single_line_top_button_box: function() { | 872 | test_single_line_top_button_box: function() { |
2358 | 846 | var box = this.single.editor.top_buttons; | 873 | var box = this.single.editor.get("top_buttons"); |
2359 | 847 | Assert.areEqual( | 874 | Assert.areEqual( |
2360 | 848 | null, | 875 | null, |
2361 | 849 | box, | 876 | box, |
2362 | @@ -851,12 +878,12 @@ | |||
2363 | 851 | }, | 878 | }, |
2364 | 852 | 879 | ||
2365 | 853 | test_multi_line_top_button_box: function() { | 880 | test_multi_line_top_button_box: function() { |
2367 | 854 | var box = this.multi.editor.top_buttons; | 881 | var box = this.multi.editor.get("top_buttons"); |
2368 | 855 | Assert.areNotEqual( | 882 | Assert.areNotEqual( |
2369 | 856 | null, | 883 | null, |
2370 | 857 | box, | 884 | box, |
2371 | 858 | "Multi-line editor should have a top button box."); | 885 | "Multi-line editor should have a top button box."); |
2373 | 859 | } | 886 | }, |
2374 | 860 | 887 | ||
2375 | 861 | })); | 888 | })); |
2376 | 862 | 889 | ||
2377 | @@ -1116,15 +1143,7 @@ | |||
2378 | 1116 | } | 1143 | } |
2379 | 1117 | })); | 1144 | })); |
2380 | 1118 | 1145 | ||
2391 | 1119 | Y.Test.Runner.add(suite); | 1146 | Y.lazr.testing.Runner.add(suite); |
2392 | 1120 | 1147 | Y.lazr.testing.Runner.run(); | |
2383 | 1121 | var yconsole = new Y.Console({ | ||
2384 | 1122 | newestOnTop: false | ||
2385 | 1123 | }); | ||
2386 | 1124 | yconsole.render('#log'); | ||
2387 | 1125 | |||
2388 | 1126 | Y.on('domready', function() { | ||
2389 | 1127 | Y.Test.Runner.run(); | ||
2390 | 1128 | }); | ||
2393 | 1129 | 1148 | ||
2394 | 1130 | }); | 1149 | }); |
2395 | 1131 | 1150 | ||
2396 | === modified file 'src-js/lazrjs/overlay/overlay.js' | |||
2397 | --- src-js/lazrjs/overlay/overlay.js 2009-04-19 22:48:09 +0000 | |||
2398 | +++ src-js/lazrjs/overlay/overlay.js 2009-10-30 17:01:14 +0000 | |||
2399 | @@ -11,7 +11,9 @@ | |||
2400 | 11 | var ESCAPE = 27, | 11 | var ESCAPE = 27, |
2401 | 12 | CANCEL = 'cancel', | 12 | CANCEL = 'cancel', |
2402 | 13 | BOUNDING_BOX = 'boundingBox', | 13 | BOUNDING_BOX = 'boundingBox', |
2404 | 14 | CONTENT_BOX = 'contentBox'; | 14 | CONTENT_BOX = 'contentBox', |
2405 | 15 | BINDUI = "bindUI"; | ||
2406 | 16 | |||
2407 | 15 | 17 | ||
2408 | 16 | /** | 18 | /** |
2409 | 17 | * An Overlay subclass which draws a rounded-corner, drop-shadow | 19 | * An Overlay subclass which draws a rounded-corner, drop-shadow |
2410 | @@ -36,6 +38,8 @@ | |||
2411 | 36 | arguments[0].zIndex = 1000; | 38 | arguments[0].zIndex = 1000; |
2412 | 37 | } | 39 | } |
2413 | 38 | PrettyOverlay.superclass.constructor.apply(this, arguments); | 40 | PrettyOverlay.superclass.constructor.apply(this, arguments); |
2414 | 41 | Y.after(this._bindUIPrettyOverlay, this, BINDUI); | ||
2415 | 42 | |||
2416 | 39 | }; | 43 | }; |
2417 | 40 | 44 | ||
2418 | 41 | PrettyOverlay.NAME = 'pretty-overlay'; | 45 | PrettyOverlay.NAME = 'pretty-overlay'; |
2419 | @@ -221,8 +225,14 @@ | |||
2420 | 221 | * @method _removeBlockingDiv | 225 | * @method _removeBlockingDiv |
2421 | 222 | */ | 226 | */ |
2422 | 223 | _removeBlockingDiv: function() { | 227 | _removeBlockingDiv: function() { |
2425 | 224 | if (Y.get('.blocking-div')) { | 228 | if (this._blocking_div) { |
2426 | 225 | Y.get('body').removeChild(this._blocking_div); | 229 | var blocking_div = Y.get(this._blocking_div); |
2427 | 230 | if (blocking_div) { | ||
2428 | 231 | var parent = blocking_div.get('parentNode'); | ||
2429 | 232 | if (parent) { | ||
2430 | 233 | parent.removeChild(this._blocking_div); | ||
2431 | 234 | } | ||
2432 | 235 | } | ||
2433 | 226 | } | 236 | } |
2434 | 227 | }, | 237 | }, |
2435 | 228 | 238 | ||
2436 | @@ -236,13 +246,16 @@ | |||
2437 | 236 | }, | 246 | }, |
2438 | 237 | 247 | ||
2439 | 238 | /** | 248 | /** |
2442 | 239 | * Bind UI events. Subclasses must call this function using | 249 | * Bind UI events. |
2443 | 240 | * <code>this.constructor.superclass.bindUI.call(this)</code>. | 250 | * <p> |
2444 | 251 | * This method is invoked after bindUI is invoked for the Widget class | ||
2445 | 252 | * using YUI's aop infrastructure. | ||
2446 | 253 | * </p> | ||
2447 | 241 | * | 254 | * |
2448 | 255 | * @method _bindUIPrettyOverlay | ||
2449 | 242 | * @protected | 256 | * @protected |
2450 | 243 | * @method bindUI | ||
2451 | 244 | */ | 257 | */ |
2453 | 245 | bindUI: function() { | 258 | _bindUIPrettyOverlay: function() { |
2454 | 246 | var self = this; | 259 | var self = this; |
2455 | 247 | var close_button = this.get(BOUNDING_BOX).query('.close a'); | 260 | var close_button = this.get(BOUNDING_BOX).query('.close a'); |
2456 | 248 | close_button.on('click', function(e) { | 261 | close_button.on('click', function(e) { |
2457 | @@ -352,4 +365,4 @@ | |||
2458 | 352 | 365 | ||
2459 | 353 | Y.lazr.PrettyOverlay = PrettyOverlay; | 366 | Y.lazr.PrettyOverlay = PrettyOverlay; |
2460 | 354 | 367 | ||
2462 | 355 | }, '0.1', {requires: ['oop', 'overlay', 'event']}); | 368 | }, '0.1', {requires: ['oop', 'overlay', 'event', 'widget-position']}); |
2463 | 356 | 369 | ||
2464 | === modified file 'src-js/lazrjs/overlay/tests/overlay.html' | |||
2465 | --- src-js/lazrjs/overlay/tests/overlay.html 2009-02-20 17:41:32 +0000 | |||
2466 | +++ src-js/lazrjs/overlay/tests/overlay.html 2009-10-30 17:01:14 +0000 | |||
2467 | @@ -5,14 +5,15 @@ | |||
2468 | 5 | <title>Pretty Overlay</title> | 5 | <title>Pretty Overlay</title> |
2469 | 6 | 6 | ||
2470 | 7 | <!-- YUI 3.0 Setup --> | 7 | <!-- YUI 3.0 Setup --> |
2476 | 8 | <script type="text/javascript" src="../../../lib/yui/current/build/yui/yui.js"></script> | 8 | <script type="text/javascript" src="../../yui/current/build/yui/yui.js"></script> |
2477 | 9 | <link rel="stylesheet" href="../../../lib/yui/current/build/cssreset/reset.css"/> | 9 | <link rel="stylesheet" href="../../yui/current/build/cssreset/reset.css"/> |
2478 | 10 | <link rel="stylesheet" href="../../../lib/yui/current/build/cssfonts/fonts.css"/> | 10 | <link rel="stylesheet" href="../../yui/current/build/cssfonts/fonts.css"/> |
2479 | 11 | <link rel="stylesheet" href="../../../lib/yui/current/build/cssbase/base.css"/> | 11 | <link rel="stylesheet" href="../../yui/current/build/cssbase/base.css"/> |
2480 | 12 | <link rel="stylesheet" href="../../../src/testing/assets/testlogger.css"/> | 12 | <link rel="stylesheet" href="../../testing/assets/testlogger.css"/> |
2481 | 13 | 13 | ||
2482 | 14 | <!-- The module under test --> | 14 | <!-- The module under test --> |
2484 | 15 | <script type="text/javascript" src="../../../build/overlay/overlay.js"></script> | 15 | <script type="text/javascript" src="../../overlay/overlay.js"></script> |
2485 | 16 | <script type="text/javascript" src="../../testing/testing.js"></script> | ||
2486 | 16 | 17 | ||
2487 | 17 | <!-- The test suite --> | 18 | <!-- The test suite --> |
2488 | 18 | <script type="text/javascript" src="overlay.js"></script> | 19 | <script type="text/javascript" src="overlay.js"></script> |
2489 | 19 | 20 | ||
2490 | === modified file 'src-js/lazrjs/overlay/tests/overlay.js' | |||
2491 | --- src-js/lazrjs/overlay/tests/overlay.js 2009-02-20 18:05:48 +0000 | |||
2492 | +++ src-js/lazrjs/overlay/tests/overlay.js 2009-10-30 17:01:14 +0000 | |||
2493 | @@ -1,10 +1,11 @@ | |||
2494 | 1 | /* Copyright (c) 2009, Canonical Ltd. All rights reserved. */ | 1 | /* Copyright (c) 2009, Canonical Ltd. All rights reserved. */ |
2495 | 2 | 2 | ||
2496 | 3 | YUI({ | 3 | YUI({ |
2498 | 4 | base: '../../../lib/yui/current/build/', | 4 | base: '../../yui/current/build/', |
2499 | 5 | filter: 'raw', | 5 | filter: 'raw', |
2500 | 6 | combine: false | 6 | combine: false |
2502 | 7 | }).use('lazr.overlay', 'node', 'event', 'yuitest', 'widget-stack', 'console', function(Y) { | 7 | }).use('lazr.overlay', 'lazr.testing.runner', 'node', |
2503 | 8 | 'event', 'widget-stack', 'console', function(Y) { | ||
2504 | 8 | 9 | ||
2505 | 9 | // KeyCode for escape | 10 | // KeyCode for escape |
2506 | 10 | var ESCAPE = 27; | 11 | var ESCAPE = 27; |
2507 | @@ -85,8 +86,8 @@ | |||
2508 | 85 | }, | 86 | }, |
2509 | 86 | 87 | ||
2510 | 87 | test_overlay_can_hide_progressbar: function() { | 88 | test_overlay_can_hide_progressbar: function() { |
2513 | 88 | this.overlay = new Y.lazr.PrettyOverlay(); | 89 | this.overlay = new Y.lazr.PrettyOverlay({progressbar: false}); |
2514 | 89 | this.overlay.render({progressbar: false}); | 90 | this.overlay.render(); |
2515 | 90 | var bb = this.overlay.get('boundingBox'); | 91 | var bb = this.overlay.get('boundingBox'); |
2516 | 91 | bb.set('headerContent', 'ALL HAIL DISCORDIA!'); | 92 | bb.set('headerContent', 'ALL HAIL DISCORDIA!'); |
2517 | 92 | Assert.isNull( | 93 | Assert.isNull( |
2518 | @@ -106,8 +107,8 @@ | |||
2519 | 106 | }, | 107 | }, |
2520 | 107 | 108 | ||
2521 | 108 | test_overlay_can_hide_steptitle: function() { | 109 | test_overlay_can_hide_steptitle: function() { |
2524 | 109 | this.overlay = new Y.lazr.PrettyOverlay(); | 110 | this.overlay = new Y.lazr.PrettyOverlay({progressbar: false}); |
2525 | 110 | this.overlay.render({progressbar: false}); | 111 | this.overlay.render(); |
2526 | 111 | var bb = this.overlay.get('boundingBox'); | 112 | var bb = this.overlay.get('boundingBox'); |
2527 | 112 | bb.set('headerContent', 'ALL HAIL DISCORDIA!'); | 113 | bb.set('headerContent', 'ALL HAIL DISCORDIA!'); |
2528 | 113 | Assert.isNull( | 114 | Assert.isNull( |
2529 | @@ -230,15 +231,7 @@ | |||
2530 | 230 | 231 | ||
2531 | 231 | })); | 232 | })); |
2532 | 232 | 233 | ||
2543 | 233 | Y.Test.Runner.add(suite); | 234 | Y.lazr.testing.Runner.add(suite); |
2544 | 234 | 235 | Y.lazr.testing.Runner.run(); | |
2535 | 235 | var yconsole = new Y.Console({ | ||
2536 | 236 | newestOnTop: false | ||
2537 | 237 | }); | ||
2538 | 238 | yconsole.render('#log'); | ||
2539 | 239 | |||
2540 | 240 | Y.on('domready', function() { | ||
2541 | 241 | Y.Test.Runner.run(); | ||
2542 | 242 | }); | ||
2545 | 243 | 236 | ||
2546 | 244 | }); | 237 | }); |
2547 | 245 | 238 | ||
2548 | === modified file 'src-js/lazrjs/picker/picker.js' | |||
2549 | --- src-js/lazrjs/picker/picker.js 2009-07-06 16:18:36 +0000 | |||
2550 | +++ src-js/lazrjs/picker/picker.js 2009-10-30 17:01:14 +0000 | |||
2551 | @@ -54,10 +54,18 @@ | |||
2552 | 54 | FOOTER_SLOT = 'footer_slot', | 54 | FOOTER_SLOT = 'footer_slot', |
2553 | 55 | SELECTED_BATCH = 'selected_batch', | 55 | SELECTED_BATCH = 'selected_batch', |
2554 | 56 | SEARCH_MODE = 'search_mode', | 56 | SEARCH_MODE = 'search_mode', |
2556 | 57 | NO_RESULTS_SEARCH_MESSAGE = 'no_results_search_message'; | 57 | NO_RESULTS_SEARCH_MESSAGE = 'no_results_search_message', |
2557 | 58 | RENDERUI = "renderUI", | ||
2558 | 59 | BINDUI = "bindUI", | ||
2559 | 60 | SYNCUI = "syncUI"; | ||
2560 | 61 | |||
2561 | 58 | 62 | ||
2562 | 59 | var Picker = function () { | 63 | var Picker = function () { |
2563 | 60 | Picker.superclass.constructor.apply(this, arguments); | 64 | Picker.superclass.constructor.apply(this, arguments); |
2564 | 65 | |||
2565 | 66 | Y.after(this._renderUIPicker, this, RENDERUI); | ||
2566 | 67 | Y.after(this._bindUIPicker, this, BINDUI); | ||
2567 | 68 | Y.after(this._syncUIPicker, this, BINDUI); | ||
2568 | 61 | }; | 69 | }; |
2569 | 62 | 70 | ||
2570 | 63 | Y.extend(Picker, Y.lazr.PrettyOverlay, { | 71 | Y.extend(Picker, Y.lazr.PrettyOverlay, { |
2571 | @@ -204,7 +212,7 @@ | |||
2572 | 204 | var options = this.get(BATCHES); | 212 | var options = this.get(BATCHES); |
2573 | 205 | 213 | ||
2574 | 206 | // Clear previous batches. | 214 | // Clear previous batches. |
2576 | 207 | Y.Event.purgeElement(this.batches_box, true); | 215 | Y.Event.purgeElement(this._batches_box, true); |
2577 | 208 | this._batches_box.set('innerHTML', ''); | 216 | this._batches_box.set('innerHTML', ''); |
2578 | 209 | 217 | ||
2579 | 210 | if (options.length === 0) { | 218 | if (options.length === 0) { |
2580 | @@ -232,7 +240,7 @@ | |||
2581 | 232 | this._batches_box.appendChild(batch_item); | 240 | this._batches_box.appendChild(batch_item); |
2582 | 233 | 241 | ||
2583 | 234 | batch_item.on('click', function (e) { | 242 | batch_item.on('click', function (e) { |
2585 | 235 | this.set('selected_batch', i); | 243 | this.set(SELECTED_BATCH, i); |
2586 | 236 | this.fire( | 244 | this.fire( |
2587 | 237 | SEARCH, this.get(CURRENT_SEARCH_STRING), data.value); | 245 | SEARCH, this.get(CURRENT_SEARCH_STRING), data.value); |
2588 | 238 | }, this); | 246 | }, this); |
2589 | @@ -259,7 +267,7 @@ | |||
2590 | 259 | var idx = this.get(SELECTED_BATCH); | 267 | var idx = this.get(SELECTED_BATCH); |
2591 | 260 | 268 | ||
2592 | 261 | var items = this._batches_box.queryAll('span'); | 269 | var items = this._batches_box.queryAll('span'); |
2594 | 262 | if (items) { | 270 | if (items.size()) { |
2595 | 263 | this._prev_button.set('disabled', idx === 0); | 271 | this._prev_button.set('disabled', idx === 0); |
2596 | 264 | items.removeClass(C_SELECTED_BATCH); | 272 | items.removeClass(C_SELECTED_BATCH); |
2597 | 265 | items.item(idx).addClass(C_SELECTED_BATCH); | 273 | items.item(idx).addClass(C_SELECTED_BATCH); |
2598 | @@ -377,12 +385,15 @@ | |||
2599 | 377 | 385 | ||
2600 | 378 | /** | 386 | /** |
2601 | 379 | * Create the widget's HTML components. | 387 | * Create the widget's HTML components. |
2602 | 388 | * <p> | ||
2603 | 389 | * This method is invoked after renderUI is invoked for the Widget class | ||
2604 | 390 | * using YUI's aop infrastructure. | ||
2605 | 391 | * </p> | ||
2606 | 380 | * | 392 | * |
2608 | 381 | * @method renderUI | 393 | * @method _renderUIPicker |
2609 | 382 | * @protected | 394 | * @protected |
2610 | 383 | */ | 395 | */ |
2613 | 384 | renderUI: function() { | 396 | _renderUIPicker: function() { |
2612 | 385 | Picker.superclass.renderUI.apply(this, arguments); | ||
2614 | 386 | this._search_button = Y.Node.create(Y.lazr.ui.SEARCH_BUTTON); | 397 | this._search_button = Y.Node.create(Y.lazr.ui.SEARCH_BUTTON); |
2615 | 387 | 398 | ||
2616 | 388 | var search_box = Y.Node.create([ | 399 | var search_box = Y.Node.create([ |
2617 | @@ -415,26 +426,27 @@ | |||
2618 | 415 | this._footer_slot_box = Y.Node.create('<div></div'); | 426 | this._footer_slot_box = Y.Node.create('<div></div'); |
2619 | 416 | this._footer_slot_box.addClass(C_FOOTER_SLOT); | 427 | this._footer_slot_box.addClass(C_FOOTER_SLOT); |
2620 | 417 | 428 | ||
2621 | 418 | //We cannot set the bodyContent element here, because | ||
2622 | 419 | //YUI screwed it up. So fake it. | ||
2623 | 420 | var body = Y.Node.create('<div></div>'); | 429 | var body = Y.Node.create('<div></div>'); |
2624 | 421 | body.appendChild(search_box); | 430 | body.appendChild(search_box); |
2625 | 422 | body.appendChild(this._batches_box); | 431 | body.appendChild(this._batches_box); |
2626 | 423 | body.appendChild(this._results_box); | 432 | body.appendChild(this._results_box); |
2627 | 424 | body.appendChild(this._footer_slot_box); | 433 | body.appendChild(this._footer_slot_box); |
2628 | 425 | body.addClass('yui-widget-bd'); | 434 | body.addClass('yui-widget-bd'); |
2630 | 426 | this.get(CONTENT_BOX).appendChild(body); | 435 | |
2631 | 436 | this.setStdModContent(Y.WidgetStdMod.BODY, body, Y.WidgetStdMod.APPEND); | ||
2632 | 427 | }, | 437 | }, |
2633 | 428 | 438 | ||
2634 | 429 | /** | 439 | /** |
2635 | 430 | * Bind the widget's DOM elements to their event handlers. | 440 | * Bind the widget's DOM elements to their event handlers. |
2636 | 441 | * <p> | ||
2637 | 442 | * This method is invoked after bindUI is invoked for the Widget class | ||
2638 | 443 | * using YUI's aop infrastructure. | ||
2639 | 444 | * </p> | ||
2640 | 431 | * | 445 | * |
2642 | 432 | * @method bindUI | 446 | * @method _bindUIPicker |
2643 | 433 | * @protected | 447 | * @protected |
2644 | 434 | */ | 448 | */ |
2648 | 435 | bindUI: function() { | 449 | _bindUIPicker: function() { |
2646 | 436 | Picker.superclass.bindUI.apply(this, arguments); | ||
2647 | 437 | |||
2649 | 438 | Y.on('click', this._defaultSearchUserAction, this._search_button, | 450 | Y.on('click', this._defaultSearchUserAction, this._search_button, |
2650 | 439 | this); | 451 | this); |
2651 | 440 | 452 | ||
2652 | @@ -445,8 +457,10 @@ | |||
2653 | 445 | 457 | ||
2654 | 446 | // Give the focus to the search input. | 458 | // Give the focus to the search input. |
2655 | 447 | Y.on('focus', function (e) { | 459 | Y.on('focus', function (e) { |
2658 | 448 | e.halt(); | 460 | if (e.target !== this._search_input){ |
2659 | 449 | this._search_input.focus(); | 461 | e.halt(); |
2660 | 462 | this._search_input.focus(); | ||
2661 | 463 | } | ||
2662 | 450 | }, this.get(BOUNDING_BOX), this); | 464 | }, this.get(BOUNDING_BOX), this); |
2663 | 451 | 465 | ||
2664 | 452 | // Focus search box when the widget is first displayed. | 466 | // Focus search box when the widget is first displayed. |
2665 | @@ -485,7 +499,14 @@ | |||
2666 | 485 | // is changed, and reset the selected one to the first one. | 499 | // is changed, and reset the selected one to the first one. |
2667 | 486 | this.after('batchesChange', function (e) { | 500 | this.after('batchesChange', function (e) { |
2668 | 487 | this._syncBatchesUI(); | 501 | this._syncBatchesUI(); |
2670 | 488 | this.set(SELECTED_BATCH, 0); | 502 | if (this.get(SELECTED_BATCH) == 0){ |
2671 | 503 | // If the attribute is already set to the same value, | ||
2672 | 504 | // the 'after' events won't be triggered, so we have | ||
2673 | 505 | // to trigger it manually. | ||
2674 | 506 | this._syncSelectedBatchUI(); | ||
2675 | 507 | } else { | ||
2676 | 508 | this.set(SELECTED_BATCH, 0); | ||
2677 | 509 | } | ||
2678 | 489 | }, this); | 510 | }, this); |
2679 | 490 | 511 | ||
2680 | 491 | // Keep the UI in sync with the currently selected batch. | 512 | // Keep the UI in sync with the currently selected batch. |
2681 | @@ -512,12 +533,15 @@ | |||
2682 | 512 | 533 | ||
2683 | 513 | /** | 534 | /** |
2684 | 514 | * Synchronize the search box, error message and results with the UI. | 535 | * Synchronize the search box, error message and results with the UI. |
2685 | 536 | * <p> | ||
2686 | 537 | * This method is invoked after syncUI is invoked for the Widget class | ||
2687 | 538 | * using YUI's aop infrastructure. | ||
2688 | 539 | * </p> | ||
2689 | 515 | * | 540 | * |
2691 | 516 | * @method syncUI | 541 | * @method _syncUIPicker |
2692 | 517 | * @protected | 542 | * @protected |
2693 | 518 | */ | 543 | */ |
2696 | 519 | syncUI: function() { | 544 | _syncUIPicker: function() { |
2695 | 520 | Picker.superclass.syncUI.apply(this, arguments); | ||
2697 | 521 | this._syncResultsUI(); | 545 | this._syncResultsUI(); |
2698 | 522 | this._syncSearchModeUI(); | 546 | this._syncSearchModeUI(); |
2699 | 523 | this._syncBatchesUI(); | 547 | this._syncBatchesUI(); |
2700 | @@ -686,7 +710,7 @@ | |||
2701 | 686 | */ | 710 | */ |
2702 | 687 | selected_batch: { | 711 | selected_batch: { |
2703 | 688 | value: 0, | 712 | value: 0, |
2705 | 689 | get: function (value) { | 713 | getter: function (value) { |
2706 | 690 | return value || 0; | 714 | return value || 0; |
2707 | 691 | }, | 715 | }, |
2708 | 692 | validator: function (value) { | 716 | validator: function (value) { |
2709 | @@ -728,8 +752,7 @@ | |||
2710 | 728 | 752 | ||
2711 | 729 | Y.Picker = Picker; | 753 | Y.Picker = Picker; |
2712 | 730 | 754 | ||
2717 | 731 | }, '0.1', { | 755 | }, '0.1', {requires: ['oop', 'event', 'event-focus', 'node', |
2718 | 732 | requires: [ | 756 | 'substitute', 'widget', 'widget-stdmod', |
2719 | 733 | 'oop', 'event', 'node', 'substitute', 'lazr.overlay', 'lazr.anim', | 757 | 'lazr.overlay', 'lazr.anim', 'lazr.base'] |
2716 | 734 | 'lazr.base'] | ||
2720 | 735 | }); | 758 | }); |
2721 | 736 | 759 | ||
2722 | === modified file 'src-js/lazrjs/picker/tests/picker.html' | |||
2723 | --- src-js/lazrjs/picker/tests/picker.html 2009-02-20 17:19:40 +0000 | |||
2724 | +++ src-js/lazrjs/picker/tests/picker.html 2009-10-30 17:01:14 +0000 | |||
2725 | @@ -1,50 +1,25 @@ | |||
2727 | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
2728 | 2 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | 2 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
2729 | 3 | <html> | 3 | <html> |
2730 | 4 | <head> | 4 | <head> |
2731 | 5 | <title>Picker</title> | 5 | <title>Picker</title> |
2732 | 6 | 6 | ||
2733 | 7 | <!-- YUI 3.0 Setup --> | 7 | <!-- YUI 3.0 Setup --> |
2738 | 8 | <script type="text/javascript" src="../../../lib/yui/current/build/yui/yui.js"></script> | 8 | <script type="text/javascript" src="../../yui/current/build/yui/yui.js"></script> |
2739 | 9 | <link rel="stylesheet" href="../../../lib/yui/current/build/cssreset/reset.css"/> | 9 | <link rel="stylesheet" href="../../yui/current/build/cssreset/reset.css"/> |
2740 | 10 | <link rel="stylesheet" href="../../../lib/yui/current/build/cssfonts/fonts.css"/> | 10 | <link rel="stylesheet" href="../../yui/current/build/cssfonts/fonts.css"/> |
2741 | 11 | <link rel="stylesheet" href="../../../lib/yui/current/build/cssbase/base.css"/> | 11 | <link rel="stylesheet" href="../../yui/current/build/cssbase/base.css"/> |
2742 | 12 | <link rel="stylesheet" href="../../testing/assets/testlogger.css"/> | ||
2743 | 12 | 13 | ||
2744 | 13 | <!-- The module under test --> | 14 | <!-- The module under test --> |
2749 | 14 | <script type="text/javascript" src="../../../build/overlay/overlay.js"></script> | 15 | <script type="text/javascript" src="../../overlay/overlay.js"></script> |
2750 | 15 | <script type="text/javascript" src="../../../build/picker/picker.js"></script> | 16 | <script type="text/javascript" src="../../picker/picker.js"></script> |
2751 | 16 | <script type="text/javascript" src="../../../build/anim/anim.js"></script> | 17 | <script type="text/javascript" src="../../anim/anim.js"></script> |
2752 | 17 | <script type="text/javascript" src="../../../build/lazr/lazr.js"></script> | 18 | <script type="text/javascript" src="../../lazr/lazr.js"></script> |
2753 | 19 | <script type="text/javascript" src="../../testing/testing.js"></script> | ||
2754 | 18 | 20 | ||
2755 | 19 | <!-- The test suite --> | 21 | <!-- The test suite --> |
2756 | 20 | <script type="text/javascript" src="picker.js"></script> | 22 | <script type="text/javascript" src="picker.js"></script> |
2757 | 21 | |||
2758 | 22 | <style> | ||
2759 | 23 | /* Taken and customized from testlogger.css */ | ||
2760 | 24 | #log .yui-console-content { width:44em } | ||
2761 | 25 | #log .yui-console .yui-console-bd { height:30em } | ||
2762 | 26 | #log .yui-console .yui-console-controls { display:none; } | ||
2763 | 27 | #log .yui-console .yui-console-hd { display:none; } | ||
2764 | 28 | #log .yui-console .yui-console-ft { position:absolute;top:0em; } | ||
2765 | 29 | |||
2766 | 30 | #log .yui-console-entry-src { display:none; } | ||
2767 | 31 | |||
2768 | 32 | #log .yui-console-entry-pass .yui-console-entry-cat { | ||
2769 | 33 | background-color: green; | ||
2770 | 34 | font-weight: bold; | ||
2771 | 35 | color: white; | ||
2772 | 36 | } | ||
2773 | 37 | #log .yui-console-entry-fail .yui-console-entry-cat { | ||
2774 | 38 | background-color: red; | ||
2775 | 39 | font-weight: bold; | ||
2776 | 40 | color: white; | ||
2777 | 41 | } | ||
2778 | 42 | #log .yui-console-entry-ignore .yui-console-entry-cat { | ||
2779 | 43 | background-color: #666; | ||
2780 | 44 | font-weight: bold; | ||
2781 | 45 | color: white; | ||
2782 | 46 | } | ||
2783 | 47 | </style> | ||
2784 | 48 | </head> | 23 | </head> |
2785 | 49 | <body class="yui-skin-sam"> | 24 | <body class="yui-skin-sam"> |
2786 | 50 | <div id="log"></div> | 25 | <div id="log"></div> |
2787 | 51 | 26 | ||
2788 | === modified file 'src-js/lazrjs/picker/tests/picker.js' | |||
2789 | --- src-js/lazrjs/picker/tests/picker.js 2009-07-07 09:38:20 +0000 | |||
2790 | +++ src-js/lazrjs/picker/tests/picker.js 2009-10-30 17:01:14 +0000 | |||
2791 | @@ -1,10 +1,11 @@ | |||
2792 | 1 | /* Copyright (c) 2009, Canonical Ltd. All rights reserved. */ | 1 | /* Copyright (c) 2009, Canonical Ltd. All rights reserved. */ |
2793 | 2 | 2 | ||
2794 | 3 | YUI({ | 3 | YUI({ |
2796 | 4 | base: '../../../lib/yui/current/build/', | 4 | base: '../../yui/current/build/', |
2797 | 5 | filter: 'raw', | 5 | filter: 'raw', |
2798 | 6 | combine: false | 6 | combine: false |
2800 | 7 | }).use('lazr.picker', 'node', 'event', 'yuitest', 'console', 'dump', | 7 | }).use('lazr.picker', 'lazr.testing.runner', 'node', |
2801 | 8 | 'event', 'event-focus', 'console', 'dump', | ||
2802 | 8 | function(Y) { | 9 | function(Y) { |
2803 | 9 | 10 | ||
2804 | 10 | // Local aliases | 11 | // Local aliases |
2805 | @@ -487,7 +488,7 @@ | |||
2806 | 487 | bb.query('.yui-picker-batches span'), | 488 | bb.query('.yui-picker-batches span'), |
2807 | 488 | "Container for batches not found."); | 489 | "Container for batches not found."); |
2808 | 489 | var batches = bb.queryAll('.yui-picker-batches span'); | 490 | var batches = bb.queryAll('.yui-picker-batches span'); |
2810 | 490 | Assert.isNotNull(batches, "Batches not found"); | 491 | Assert.isNotNull(batches, "Batches not found"); |
2811 | 491 | Assert.areEqual(2, batches.size()); | 492 | Assert.areEqual(2, batches.size()); |
2812 | 492 | ArrayAssert.itemsAreEqual( | 493 | ArrayAssert.itemsAreEqual( |
2813 | 493 | ['New', 'Assigned'], | 494 | ['New', 'Assigned'], |
2814 | @@ -782,15 +783,7 @@ | |||
2815 | 782 | 783 | ||
2816 | 783 | })); | 784 | })); |
2817 | 784 | 785 | ||
2828 | 785 | Y.Test.Runner.add(suite); | 786 | Y.lazr.testing.Runner.add(suite); |
2829 | 786 | 787 | Y.lazr.testing.Runner.run(); | |
2820 | 787 | var yconsole = new Y.Console({ | ||
2821 | 788 | newestOnTop: false | ||
2822 | 789 | }); | ||
2823 | 790 | yconsole.render('#log'); | ||
2824 | 791 | |||
2825 | 792 | Y.on('domready', function() { | ||
2826 | 793 | Y.Test.Runner.run(); | ||
2827 | 794 | }); | ||
2830 | 795 | 788 | ||
2831 | 796 | }); | 789 | }); |
2832 | 797 | 790 | ||
2833 | === modified file 'src-js/lazrjs/testing/assets/testlogger.css' | |||
2834 | --- src-js/lazrjs/testing/assets/testlogger.css 2009-02-20 17:41:32 +0000 | |||
2835 | +++ src-js/lazrjs/testing/assets/testlogger.css 2009-10-30 17:01:14 +0000 | |||
2836 | @@ -1,6 +1,6 @@ | |||
2837 | 1 | /* Taken and customized from testlogger.css */ | 1 | /* Taken and customized from testlogger.css */ |
2840 | 2 | #log .yui-console-content { width: 44em } | 2 | /*#log .yui-console-content { width: 44em }*/ |
2841 | 3 | #log .yui-console .yui-console-bd { height: 30em } | 3 | /*#log .yui-console .yui-console-bd { height: 30em }*/ |
2842 | 4 | #log .yui-console .yui-console-controls { display: none; } | 4 | #log .yui-console .yui-console-controls { display: none; } |
2843 | 5 | #log .yui-console .yui-console-hd { display: none; } | 5 | #log .yui-console .yui-console-hd { display: none; } |
2844 | 6 | #log .yui-console .yui-console-ft { position: absolute; top: 0; } | 6 | #log .yui-console .yui-console-ft { position: absolute; top: 0; } |
2845 | 7 | 7 | ||
2846 | === added file 'src-js/lazrjs/testing/jsUnitMockTimeout.js' | |||
2847 | --- src-js/lazrjs/testing/jsUnitMockTimeout.js 1970-01-01 00:00:00 +0000 | |||
2848 | +++ src-js/lazrjs/testing/jsUnitMockTimeout.js 2009-10-30 17:01:14 +0000 | |||
2849 | @@ -0,0 +1,120 @@ | |||
2850 | 1 | /* | ||
2851 | 2 | Version: MPL 1.1/GPL 2.0/LGPL 2.1 | ||
2852 | 3 | |||
2853 | 4 | The contents of this file are subject to the Mozilla Public License Version | ||
2854 | 5 | 1.1 (the "License"); you may not use this file except in compliance with | ||
2855 | 6 | the License. You may obtain a copy of the License at | ||
2856 | 7 | http://www.mozilla.org/MPL/ | ||
2857 | 8 | |||
2858 | 9 | Software distributed under the License is distributed on an "AS IS" basis, | ||
2859 | 10 | WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | ||
2860 | 11 | for the specific language governing rights and limitations under the | ||
2861 | 12 | License. | ||
2862 | 13 | |||
2863 | 14 | The Original Code is Edward Hieatt code. | ||
2864 | 15 | |||
2865 | 16 | The Initial Developer of the Original Code is | ||
2866 | 17 | Edward Hieatt, edward@jsunit.net. | ||
2867 | 18 | Portions created by the Initial Developer are Copyright (C) 2003 | ||
2868 | 19 | the Initial Developer. All Rights Reserved. | ||
2869 | 20 | |||
2870 | 21 | Author Edward Hieatt, edward@jsunit.net | ||
2871 | 22 | |||
2872 | 23 | Alternatively, the contents of this file may be used under the terms of | ||
2873 | 24 | either the GNU General Public License Version 2 or later (the "GPL"), or | ||
2874 | 25 | the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), | ||
2875 | 26 | in which case the provisions of the GPL or the LGPL are applicable instead | ||
2876 | 27 | of those above. If you wish to allow use of your version of this file only | ||
2877 | 28 | under the terms of either the GPL or the LGPL, and not to allow others to | ||
2878 | 29 | use your version of this file under the terms of the MPL, indicate your | ||
2879 | 30 | decision by deleting the provisions above and replace them with the notice | ||
2880 | 31 | and other provisions required by the LGPL or the GPL. If you do not delete | ||
2881 | 32 | the provisions above, a recipient may use your version of this file under | ||
2882 | 33 | the terms of any one of the MPL, the GPL or the LGPL. | ||
2883 | 34 | */ | ||
2884 | 35 | |||
2885 | 36 | // Mock setTimeout, clearTimeout | ||
2886 | 37 | // Contributed by Pivotal Computer Systems, www.pivotalsf.com | ||
2887 | 38 | // | ||
2888 | 39 | // Copied from the JsUnit 2.2alpha1 release, made in Mar 24 2006 | ||
2889 | 40 | // (http://www.jsunit.net/) | ||
2890 | 41 | |||
2891 | 42 | var Clock = { | ||
2892 | 43 | timeoutsMade: 0, | ||
2893 | 44 | scheduledFunctions: {}, | ||
2894 | 45 | nowMillis: 0, | ||
2895 | 46 | reset: function() { | ||
2896 | 47 | this.scheduledFunctions = {}; | ||
2897 | 48 | this.nowMillis = 0; | ||
2898 | 49 | this.timeoutsMade = 0; | ||
2899 | 50 | }, | ||
2900 | 51 | tick: function(millis) { | ||
2901 | 52 | var oldMillis = this.nowMillis; | ||
2902 | 53 | var newMillis = oldMillis + millis; | ||
2903 | 54 | this.runFunctionsWithinRange(oldMillis, newMillis); | ||
2904 | 55 | this.nowMillis = newMillis; | ||
2905 | 56 | }, | ||
2906 | 57 | runFunctionsWithinRange: function(oldMillis, nowMillis) { | ||
2907 | 58 | var scheduledFunc; | ||
2908 | 59 | var funcsToRun = []; | ||
2909 | 60 | for (var timeoutKey in this.scheduledFunctions) { | ||
2910 | 61 | scheduledFunc = this.scheduledFunctions[timeoutKey]; | ||
2911 | 62 | if (scheduledFunc != undefined && | ||
2912 | 63 | scheduledFunc.runAtMillis >= oldMillis && | ||
2913 | 64 | scheduledFunc.runAtMillis <= nowMillis) { | ||
2914 | 65 | funcsToRun.push(scheduledFunc); | ||
2915 | 66 | this.scheduledFunctions[timeoutKey] = undefined; | ||
2916 | 67 | } | ||
2917 | 68 | } | ||
2918 | 69 | |||
2919 | 70 | if (funcsToRun.length > 0) { | ||
2920 | 71 | funcsToRun.sort(function(a, b) { | ||
2921 | 72 | return a.runAtMillis - b.runAtMillis; | ||
2922 | 73 | }); | ||
2923 | 74 | for (var i = 0; i < funcsToRun.length; ++i) { | ||
2924 | 75 | try { | ||
2925 | 76 | this.nowMillis = funcsToRun[i].runAtMillis; | ||
2926 | 77 | funcsToRun[i].funcToCall(); | ||
2927 | 78 | if (funcsToRun[i].recurring) { | ||
2928 | 79 | Clock.scheduleFunction(funcsToRun[i].timeoutKey, | ||
2929 | 80 | funcsToRun[i].funcToCall, | ||
2930 | 81 | funcsToRun[i].millis, | ||
2931 | 82 | true); | ||
2932 | 83 | } | ||
2933 | 84 | } catch(e) { | ||
2934 | 85 | console.log(e); | ||
2935 | 86 | } | ||
2936 | 87 | } | ||
2937 | 88 | this.runFunctionsWithinRange(oldMillis, nowMillis); | ||
2938 | 89 | } | ||
2939 | 90 | }, | ||
2940 | 91 | scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) { | ||
2941 | 92 | Clock.scheduledFunctions[timeoutKey] = { | ||
2942 | 93 | runAtMillis: Clock.nowMillis + millis, | ||
2943 | 94 | funcToCall: funcToCall, | ||
2944 | 95 | recurring: recurring, | ||
2945 | 96 | timeoutKey: timeoutKey, | ||
2946 | 97 | millis: millis | ||
2947 | 98 | }; | ||
2948 | 99 | } | ||
2949 | 100 | }; | ||
2950 | 101 | |||
2951 | 102 | function setTimeout(funcToCall, millis) { | ||
2952 | 103 | Clock.timeoutsMade = Clock.timeoutsMade + 1; | ||
2953 | 104 | Clock.scheduleFunction(Clock.timeoutsMade, funcToCall, millis, false); | ||
2954 | 105 | return Clock.timeoutsMade; | ||
2955 | 106 | } | ||
2956 | 107 | |||
2957 | 108 | function setInterval(funcToCall, millis) { | ||
2958 | 109 | Clock.timeoutsMade = Clock.timeoutsMade + 1; | ||
2959 | 110 | Clock.scheduleFunction(Clock.timeoutsMade, funcToCall, millis, true); | ||
2960 | 111 | return Clock.timeoutsMade; | ||
2961 | 112 | } | ||
2962 | 113 | |||
2963 | 114 | function clearTimeout(timeoutKey) { | ||
2964 | 115 | Clock.scheduledFunctions[timeoutKey] = undefined; | ||
2965 | 116 | } | ||
2966 | 117 | |||
2967 | 118 | function clearInterval(timeoutKey) { | ||
2968 | 119 | Clock.scheduledFunctions[timeoutKey] = undefined; | ||
2969 | 120 | } | ||
2970 | 0 | 121 | ||
2971 | === modified file 'src-js/lazrjs/testing/mockio.js' | |||
2972 | --- src-js/lazrjs/testing/mockio.js 2009-08-13 12:17:44 +0000 | |||
2973 | +++ src-js/lazrjs/testing/mockio.js 2009-10-30 17:01:14 +0000 | |||
2974 | @@ -1,6 +1,6 @@ | |||
2975 | 1 | /* Copyright (c) 2009, Canonical Ltd. All rights reserved. */ | 1 | /* Copyright (c) 2009, Canonical Ltd. All rights reserved. */ |
2976 | 2 | 2 | ||
2978 | 3 | YUI.add('lazr.testing', function(Y) { | 3 | YUI.add('lazr.testing.mockio', function(Y) { |
2979 | 4 | /** | 4 | /** |
2980 | 5 | * A utility module for use in YUI unit-tests with a helper for mocking Y.io. | 5 | * A utility module for use in YUI unit-tests with a helper for mocking Y.io. |
2981 | 6 | * | 6 | * |
2982 | @@ -63,9 +63,7 @@ | |||
2983 | 63 | }; | 63 | }; |
2984 | 64 | }; | 64 | }; |
2985 | 65 | 65 | ||
2989 | 66 | if (Y.lazr.testing === undefined) { | 66 | Y.namespace("lazr.testing"); |
2987 | 67 | Y.lazr.testing = {}; | ||
2988 | 68 | } | ||
2990 | 69 | Y.lazr.testing.MockIo = MockIo; | 67 | Y.lazr.testing.MockIo = MockIo; |
2991 | 70 | 68 | ||
2992 | 71 | }, '0.1', {}); | 69 | }, '0.1', {}); |
2993 | 72 | 70 | ||
2994 | === added file 'src-js/lazrjs/testing/testing.js' | |||
2995 | --- src-js/lazrjs/testing/testing.js 1970-01-01 00:00:00 +0000 | |||
2996 | +++ src-js/lazrjs/testing/testing.js 2009-10-30 17:01:14 +0000 | |||
2997 | @@ -0,0 +1,123 @@ | |||
2998 | 1 | /* Copyright (c) 2009, Canonical Ltd. All rights reserved. */ | ||
2999 | 2 | |||
3000 | 3 | YUI.add("lazr.testing.runner", function(Y) { | ||
3001 | 4 | |||
3002 | 5 | /** | ||
3003 | 6 | * Testing utilities. | ||
3004 | 7 | * | ||
3005 | 8 | * @module lazr.testing | ||
3006 | 9 | * @namespace lazr | ||
3007 | 10 | */ | ||
3008 | 11 | |||
3009 | 12 | Runner = Y.namespace("lazr.testing.Runner"); | ||
3010 | 13 | |||
3011 | 14 | Runner.add = function(suite) { | ||
3012 | 15 | if ((typeof jstestdriver === "undefined")) { | ||
3013 | 16 | // If we are not running under JsTestDriver, then | ||
3014 | 17 | // register the suite with Y.Test.Runner and run it. | ||
3015 | 18 | Y.Test.Runner.add(suite); | ||
3016 | 19 | } else { | ||
3017 | 20 | // If ``jstestdriver`` is defined, that means we are | ||
3018 | 21 | // running under JsTestDriver, so instead register each | ||
3019 | 22 | // test case from the suite as a separate TestCase() with | ||
3020 | 23 | // JsTestDriver. | ||
3021 | 24 | var tests = []; | ||
3022 | 25 | |||
3023 | 26 | for (var idx in suite.items) { | ||
3024 | 27 | var suiteName = suite.name; | ||
3025 | 28 | var testCase = suite.items[idx]; | ||
3026 | 29 | var testCaseName = testCase.name; | ||
3027 | 30 | |||
3028 | 31 | var clone = {}; | ||
3029 | 32 | for (var prop in testCase){ | ||
3030 | 33 | // Clone everything that is not a test method. | ||
3031 | 34 | if (prop.indexOf("test") === -1){ | ||
3032 | 35 | clone[prop] = testCase[prop]; | ||
3033 | 36 | } | ||
3034 | 37 | } | ||
3035 | 38 | |||
3036 | 39 | // Now for each test method, create a JsTestDriver | ||
3037 | 40 | // TestCase that wraps a single YUI TestSuite, that wraps | ||
3038 | 41 | // a clone of the original TestCase but with only the | ||
3039 | 42 | // single test method that we are interested in. | ||
3040 | 43 | for (var prop in testCase){ | ||
3041 | 44 | if (prop.indexOf("test") === 0 && | ||
3042 | 45 | Y.Lang.isFunction(testCase[prop])){ | ||
3043 | 46 | tests.push({"suiteName": suiteName, | ||
3044 | 47 | "caseName": testCaseName, | ||
3045 | 48 | "case": clone, | ||
3046 | 49 | "methodName": prop, | ||
3047 | 50 | "method": testCase[prop]}); | ||
3048 | 51 | } | ||
3049 | 52 | } | ||
3050 | 53 | } | ||
3051 | 54 | |||
3052 | 55 | for (var i=0; i<tests.length; i++){ | ||
3053 | 56 | testObject = tests[i]; | ||
3054 | 57 | |||
3055 | 58 | var fakeTestCase = { | ||
3056 | 59 | "setUp": Y.bind(function(testObject){ | ||
3057 | 60 | var testSuite = new Y.Test.Suite(testObject["suiteName"]); | ||
3058 | 61 | var testCase = new Y.Test.Case(testObject["case"]); | ||
3059 | 62 | testCase[testObject["methodName"]] = testObject["method"]; | ||
3060 | 63 | testSuite.add(testCase); | ||
3061 | 64 | Y.Test.Runner.clear(); | ||
3062 | 65 | Y.Test.Runner.add(testSuite); | ||
3063 | 66 | }, this, testObject), | ||
3064 | 67 | "tearDown": function(){ | ||
3065 | 68 | Y.Test.Runner.clear(); | ||
3066 | 69 | }, | ||
3067 | 70 | }; | ||
3068 | 71 | |||
3069 | 72 | fakeTestCase[testObject["methodName"]] = Y.bind(function (testObject) { | ||
3070 | 73 | var results = []; | ||
3071 | 74 | |||
3072 | 75 | var onComplete = function (caseName, methodName, results, e) { | ||
3073 | 76 | Y.Test.Runner.unsubscribe("testsuitecomplete"); | ||
3074 | 77 | results.push(e.results[caseName][methodName]); | ||
3075 | 78 | }; | ||
3076 | 79 | |||
3077 | 80 | Y.Test.Runner.subscribe( | ||
3078 | 81 | "testsuitecomplete", | ||
3079 | 82 | Y.bind(onComplete, this, testObject["caseName"], | ||
3080 | 83 | testObject["methodName"], results), | ||
3081 | 84 | Y.Test.Runner); | ||
3082 | 85 | |||
3083 | 86 | Clock.reset(); | ||
3084 | 87 | Y.Test.Runner.run(); | ||
3085 | 88 | for (var i=0;i<100 && !results.length; i++){ | ||
3086 | 89 | Clock.tick(100); | ||
3087 | 90 | } | ||
3088 | 91 | |||
3089 | 92 | var result = results.pop(); | ||
3090 | 93 | if (result === undefined) { | ||
3091 | 94 | fail("Test did not finish after 100 iterations."); | ||
3092 | 95 | } else { | ||
3093 | 96 | if (result["result"] == "fail"){ | ||
3094 | 97 | fail(result["message"]); | ||
3095 | 98 | } | ||
3096 | 99 | } | ||
3097 | 100 | |||
3098 | 101 | }, this, testObject); | ||
3099 | 102 | |||
3100 | 103 | TestCase(testObject["caseName"] + "." + testObject["methodName"], | ||
3101 | 104 | fakeTestCase); | ||
3102 | 105 | } | ||
3103 | 106 | } | ||
3104 | 107 | }; | ||
3105 | 108 | |||
3106 | 109 | Runner.run = function(suite) { | ||
3107 | 110 | Y.on("domready", function() { | ||
3108 | 111 | if ((typeof jstestdriver === "undefined")) { | ||
3109 | 112 | // If we are not running under JsTestDriver, then run all | ||
3110 | 113 | // the registered test suites with Y.Test.Runner. | ||
3111 | 114 | var yconsole = new Y.Console({ | ||
3112 | 115 | newestOnTop: false | ||
3113 | 116 | }); | ||
3114 | 117 | yconsole.render("#log"); | ||
3115 | 118 | Y.Test.Runner.run(); | ||
3116 | 119 | } | ||
3117 | 120 | }); | ||
3118 | 121 | }; | ||
3119 | 122 | |||
3120 | 123 | }, "0.1", {requires: ["oop", "test", "console"]}); | ||
3121 | 0 | 124 | ||
3122 | === added file 'src-js/lazrjs/testing/yui-patch.js' | |||
3123 | --- src-js/lazrjs/testing/yui-patch.js 1970-01-01 00:00:00 +0000 | |||
3124 | +++ src-js/lazrjs/testing/yui-patch.js 2009-10-30 17:01:14 +0000 | |||
3125 | @@ -0,0 +1,2137 @@ | |||
3126 | 1 | /* | ||
3127 | 2 | Copyright (c) 2009, Yahoo! Inc. All rights reserved. | ||
3128 | 3 | Code licensed under the BSD License: | ||
3129 | 4 | http://developer.yahoo.net/yui/license.txt | ||
3130 | 5 | version: 3.0.0 | ||
3131 | 6 | build: 1549 | ||
3132 | 7 | */ | ||
3133 | 8 | |||
3134 | 9 | /* | ||
3135 | 10 | Copied from yui/loader/loader.js | ||
3136 | 11 | |||
3137 | 12 | Patched by the JsTestDriver team to avoid trying to load files, since | ||
3138 | 13 | JsTestDriver itself will load the files for you. | ||
3139 | 14 | */ | ||
3140 | 15 | |||
3141 | 16 | YUI.add('loader', function(Y) { | ||
3142 | 17 | |||
3143 | 18 | (function() { | ||
3144 | 19 | /** | ||
3145 | 20 | * Loader dynamically loads script and css files. It includes the dependency | ||
3146 | 21 | * info for the version of the library in use, and will automatically pull in | ||
3147 | 22 | * dependencies for the modules requested. It supports rollup files and will | ||
3148 | 23 | * automatically use these when appropriate in order to minimize the number of | ||
3149 | 24 | * http connections required to load all of the dependencies. It can load the | ||
3150 | 25 | * files from the Yahoo! CDN, and it can utilize the combo service provided on | ||
3151 | 26 | * this network to reduce the number of http connections required to download | ||
3152 | 27 | * YUI files. | ||
3153 | 28 | * | ||
3154 | 29 | * @module loader | ||
3155 | 30 | */ | ||
3156 | 31 | |||
3157 | 32 | /** | ||
3158 | 33 | * Loader dynamically loads script and css files. It includes the dependency | ||
3159 | 34 | * info for the version of the library in use, and will automatically pull in | ||
3160 | 35 | * dependencies for the modules requested. It supports rollup files and will | ||
3161 | 36 | * automatically use these when appropriate in order to minimize the number of | ||
3162 | 37 | * http connections required to load all of the dependencies. It can load the | ||
3163 | 38 | * files from the Yahoo! CDN, and it can utilize the combo service provided on | ||
3164 | 39 | * this network to reduce the number of http connections required to download | ||
3165 | 40 | * YUI files. | ||
3166 | 41 | * | ||
3167 | 42 | * While the loader can be instantiated by the end user, it normally is not. | ||
3168 | 43 | * @see YUI.use for the normal use case. The use function automatically will | ||
3169 | 44 | * pull in missing dependencies. | ||
3170 | 45 | * | ||
3171 | 46 | * @class Loader | ||
3172 | 47 | * @constructor | ||
3173 | 48 | * @param o an optional set of configuration options. Valid options: | ||
3174 | 49 | * <ul> | ||
3175 | 50 | * <li>base: | ||
3176 | 51 | * The base dir</li> | ||
3177 | 52 | * <li>secureBase: | ||
3178 | 53 | * The secure base dir (not implemented)</li> | ||
3179 | 54 | * <li>comboBase: | ||
3180 | 55 | * The YUI combo service base dir. Ex: http://yui.yahooapis.com/combo?</li> | ||
3181 | 56 | * <li>root: | ||
3182 | 57 | * The root path to prepend to module names for the combo service. Ex: 2.5.2/build/</li> | ||
3183 | 58 | * <li>filter: | ||
3184 | 59 | * | ||
3185 | 60 | * A filter to apply to result urls. This filter will modify the default | ||
3186 | 61 | * path for all modules. The default path for the YUI library is the | ||
3187 | 62 | * minified version of the files (e.g., event-min.js). The filter property | ||
3188 | 63 | * can be a predefined filter or a custom filter. The valid predefined | ||
3189 | 64 | * filters are: | ||
3190 | 65 | * <dl> | ||
3191 | 66 | * <dt>DEBUG</dt> | ||
3192 | 67 | * <dd>Selects the debug versions of the library (e.g., event-debug.js). | ||
3193 | 68 | * This option will automatically include the Logger widget</dd> | ||
3194 | 69 | * <dt>RAW</dt> | ||
3195 | 70 | * <dd>Selects the non-minified version of the library (e.g., event.js).</dd> | ||
3196 | 71 | * </dl> | ||
3197 | 72 | * You can also define a custom filter, which must be an object literal | ||
3198 | 73 | * containing a search expression and a replace string: | ||
3199 | 74 | * <pre> | ||
3200 | 75 | * myFilter: { | ||
3201 | 76 | * 'searchExp': "-min\\.js", | ||
3202 | 77 | * 'replaceStr': "-debug.js" | ||
3203 | 78 | * } | ||
3204 | 79 | * </pre> | ||
3205 | 80 | * | ||
3206 | 81 | * </li> | ||
3207 | 82 | * <li>filters: per-component filter specification. If specified for a given component, this overrides the filter config</li> | ||
3208 | 83 | * <li>combine: | ||
3209 | 84 | * Use the YUI combo service to reduce the number of http connections required to load your dependencies</li> | ||
3210 | 85 | * <li>ignore: | ||
3211 | 86 | * A list of modules that should never be dynamically loaded</li> | ||
3212 | 87 | * <li>force: | ||
3213 | 88 | * A list of modules that should always be loaded when required, even if already present on the page</li> | ||
3214 | 89 | * <li>insertBefore: | ||
3215 | 90 | * Node or id for a node that should be used as the insertion point for new nodes</li> | ||
3216 | 91 | * <li>charset: | ||
3217 | 92 | * charset for dynamic nodes (deprecated, use jsAttributes or cssAttributes)</li> | ||
3218 | 93 | * <li>jsAttributes: object literal containing attributes to add to script nodes</li> | ||
3219 | 94 | * <li>cssAttributes: object literal containing attributes to add to link nodes</li> | ||
3220 | 95 | * <li>timeout: | ||
3221 | 96 | * number of milliseconds before a timeout occurs when dynamically loading nodes. in not set, there is no timeout</li> | ||
3222 | 97 | * <li>context: | ||
3223 | 98 | * execution context for all callbacks</li> | ||
3224 | 99 | * <li>onSuccess: | ||
3225 | 100 | * callback for the 'success' event</li> | ||
3226 | 101 | * <li>onFailure: callback for the 'failure' event</li> | ||
3227 | 102 | * <li>onCSS: callback for the 'CSSComplete' event. When loading YUI components with CSS | ||
3228 | 103 | * the CSS is loaded first, then the script. This provides a moment you can tie into to improve | ||
3229 | 104 | * the presentation of the page while the script is loading.</li> | ||
3230 | 105 | * <li>onTimeout: | ||
3231 | 106 | * callback for the 'timeout' event</li> | ||
3232 | 107 | * <li>onProgress: | ||
3233 | 108 | * callback executed each time a script or css file is loaded</li> | ||
3234 | 109 | * <li>modules: | ||
3235 | 110 | * A list of module definitions. See Loader.addModule for the supported module metadata</li> | ||
3236 | 111 | * </ul> | ||
3237 | 112 | */ | ||
3238 | 113 | |||
3239 | 114 | /* | ||
3240 | 115 | * Global loader queue | ||
3241 | 116 | * @property _loaderQueue | ||
3242 | 117 | * @type Queue | ||
3243 | 118 | * @private | ||
3244 | 119 | */ | ||
3245 | 120 | YUI.Env._loaderQueue = YUI.Env._loaderQueue || new Y.Queue(); | ||
3246 | 121 | |||
3247 | 122 | var NOT_FOUND = {}, | ||
3248 | 123 | GLOBAL_ENV = YUI.Env, | ||
3249 | 124 | GLOBAL_LOADED, | ||
3250 | 125 | BASE = 'base', | ||
3251 | 126 | CSS = 'css', | ||
3252 | 127 | JS = 'js', | ||
3253 | 128 | CSSRESET = 'cssreset', | ||
3254 | 129 | CSSFONTS = 'cssfonts', | ||
3255 | 130 | CSSGRIDS = 'cssgrids', | ||
3256 | 131 | CSSBASE = 'cssbase', | ||
3257 | 132 | CSS_AFTER = [CSSRESET, CSSFONTS, CSSGRIDS, | ||
3258 | 133 | 'cssreset-context', 'cssfonts-context', 'cssgrids-context'], | ||
3259 | 134 | YUI_CSS = ['reset', 'fonts', 'grids', BASE], | ||
3260 | 135 | VERSION = Y.version, | ||
3261 | 136 | ROOT = VERSION + '/build/', | ||
3262 | 137 | CONTEXT = '-context', | ||
3263 | 138 | |||
3264 | 139 | ANIMBASE = 'anim-base', | ||
3265 | 140 | ATTRIBUTE = 'attribute', | ||
3266 | 141 | ATTRIBUTEBASE = ATTRIBUTE + '-base', | ||
3267 | 142 | BASEBASE = 'base-base', | ||
3268 | 143 | DDDRAG = 'dd-drag', | ||
3269 | 144 | DOM = 'dom', | ||
3270 | 145 | DATASCHEMABASE = 'dataschema-base', | ||
3271 | 146 | DATASOURCELOCAL = 'datasource-local', | ||
3272 | 147 | DOMBASE = 'dom-base', | ||
3273 | 148 | DOMSTYLE = 'dom-style', | ||
3274 | 149 | DOMSCREEN = 'dom-screen', | ||
3275 | 150 | DUMP = 'dump', | ||
3276 | 151 | GET = 'get', | ||
3277 | 152 | EVENTBASE = 'event-base', | ||
3278 | 153 | EVENTCUSTOM = 'event-custom', | ||
3279 | 154 | EVENTCUSTOMBASE = 'event-custom-base', | ||
3280 | 155 | IOBASE = 'io-base', | ||
3281 | 156 | NODE = 'node', | ||
3282 | 157 | NODEBASE = 'node-base', | ||
3283 | 158 | NODESTYLE = 'node-style', | ||
3284 | 159 | NODESCREEN = 'node-screen', | ||
3285 | 160 | OOP = 'oop', | ||
3286 | 161 | PLUGINHOST = 'pluginhost', | ||
3287 | 162 | SELECTORCSS2 = 'selector-css2', | ||
3288 | 163 | SUBSTITUTE = 'substitute', | ||
3289 | 164 | WIDGET = 'widget', | ||
3290 | 165 | WIDGETPOSITION = 'widget-position', | ||
3291 | 166 | YUIBASE = 'yui-base', | ||
3292 | 167 | |||
3293 | 168 | PLUGIN = 'plugin', | ||
3294 | 169 | |||
3295 | 170 | META = { | ||
3296 | 171 | |||
3297 | 172 | version: VERSION, | ||
3298 | 173 | |||
3299 | 174 | root: ROOT, | ||
3300 | 175 | |||
3301 | 176 | base: 'http://yui.yahooapis.com/' + ROOT, | ||
3302 | 177 | |||
3303 | 178 | comboBase: 'http://yui.yahooapis.com/combo?', | ||
3304 | 179 | |||
3305 | 180 | skin: { | ||
3306 | 181 | defaultSkin: 'sam', | ||
3307 | 182 | base: 'assets/skins/', | ||
3308 | 183 | path: 'skin.css', | ||
3309 | 184 | after: CSS_AFTER | ||
3310 | 185 | //rollup: 3 | ||
3311 | 186 | }, | ||
3312 | 187 | |||
3313 | 188 | modules: { | ||
3314 | 189 | |||
3315 | 190 | dom: { | ||
3316 | 191 | requires: [OOP], | ||
3317 | 192 | submodules: { | ||
3318 | 193 | |||
3319 | 194 | 'dom-base': { | ||
3320 | 195 | requires: [OOP] | ||
3321 | 196 | }, | ||
3322 | 197 | |||
3323 | 198 | 'dom-style': { | ||
3324 | 199 | requires: [DOMBASE] | ||
3325 | 200 | }, | ||
3326 | 201 | |||
3327 | 202 | 'dom-screen': { | ||
3328 | 203 | requires: [DOMBASE, DOMSTYLE] | ||
3329 | 204 | }, | ||
3330 | 205 | |||
3331 | 206 | 'selector-native': { | ||
3332 | 207 | requires: [DOMBASE] | ||
3333 | 208 | }, | ||
3334 | 209 | |||
3335 | 210 | 'selector-css2': { | ||
3336 | 211 | requires: ['selector-native'] | ||
3337 | 212 | }, | ||
3338 | 213 | |||
3339 | 214 | 'selector': { | ||
3340 | 215 | requires: [DOMBASE] | ||
3341 | 216 | } | ||
3342 | 217 | |||
3343 | 218 | }, | ||
3344 | 219 | |||
3345 | 220 | plugins: { | ||
3346 | 221 | 'selector-css3': { | ||
3347 | 222 | requires: [SELECTORCSS2] | ||
3348 | 223 | } | ||
3349 | 224 | } | ||
3350 | 225 | }, | ||
3351 | 226 | |||
3352 | 227 | node: { | ||
3353 | 228 | requires: [DOM, EVENTBASE], | ||
3354 | 229 | // expound: EVENT, | ||
3355 | 230 | |||
3356 | 231 | submodules: { | ||
3357 | 232 | 'node-base': { | ||
3358 | 233 | requires: [DOMBASE, SELECTORCSS2, EVENTBASE] | ||
3359 | 234 | }, | ||
3360 | 235 | |||
3361 | 236 | 'node-style': { | ||
3362 | 237 | requires: [DOMSTYLE, NODEBASE] | ||
3363 | 238 | }, | ||
3364 | 239 | |||
3365 | 240 | 'node-screen': { | ||
3366 | 241 | requires: [DOMSCREEN, NODEBASE] | ||
3367 | 242 | }, | ||
3368 | 243 | |||
3369 | 244 | 'node-pluginhost': { | ||
3370 | 245 | requires: [NODEBASE, PLUGINHOST] | ||
3371 | 246 | }, | ||
3372 | 247 | |||
3373 | 248 | |||
3374 | 249 | 'node-event-delegate': { | ||
3375 | 250 | requires: [NODEBASE, 'event-delegate'] | ||
3376 | 251 | } | ||
3377 | 252 | }, | ||
3378 | 253 | |||
3379 | 254 | plugins: { | ||
3380 | 255 | 'node-event-simulate': { | ||
3381 | 256 | requires: [NODEBASE, 'event-simulate'] | ||
3382 | 257 | } | ||
3383 | 258 | } | ||
3384 | 259 | }, | ||
3385 | 260 | |||
3386 | 261 | anim: { | ||
3387 | 262 | submodules: { | ||
3388 | 263 | |||
3389 | 264 | 'anim-base': { | ||
3390 | 265 | requires: [BASEBASE, NODESTYLE] | ||
3391 | 266 | }, | ||
3392 | 267 | |||
3393 | 268 | 'anim-color': { | ||
3394 | 269 | requires: [ANIMBASE] | ||
3395 | 270 | }, | ||
3396 | 271 | |||
3397 | 272 | 'anim-easing': { | ||
3398 | 273 | requires: [ANIMBASE] | ||
3399 | 274 | }, | ||
3400 | 275 | |||
3401 | 276 | 'anim-scroll': { | ||
3402 | 277 | requires: [ANIMBASE] | ||
3403 | 278 | }, | ||
3404 | 279 | |||
3405 | 280 | 'anim-xy': { | ||
3406 | 281 | requires: [ANIMBASE, NODESCREEN] | ||
3407 | 282 | }, | ||
3408 | 283 | |||
3409 | 284 | 'anim-curve': { | ||
3410 | 285 | requires: ['anim-xy'] | ||
3411 | 286 | }, | ||
3412 | 287 | |||
3413 | 288 | 'anim-node-plugin': { | ||
3414 | 289 | requires: ['node-pluginhost', ANIMBASE] | ||
3415 | 290 | } | ||
3416 | 291 | } | ||
3417 | 292 | }, | ||
3418 | 293 | |||
3419 | 294 | attribute: { | ||
3420 | 295 | submodules: { | ||
3421 | 296 | 'attribute-base': { | ||
3422 | 297 | requires: [EVENTCUSTOM] | ||
3423 | 298 | }, | ||
3424 | 299 | |||
3425 | 300 | 'attribute-complex': { | ||
3426 | 301 | requires: [ATTRIBUTEBASE] | ||
3427 | 302 | } | ||
3428 | 303 | } | ||
3429 | 304 | }, | ||
3430 | 305 | |||
3431 | 306 | base: { | ||
3432 | 307 | submodules: { | ||
3433 | 308 | 'base-base': { | ||
3434 | 309 | requires: [ATTRIBUTEBASE] | ||
3435 | 310 | }, | ||
3436 | 311 | |||
3437 | 312 | 'base-build': { | ||
3438 | 313 | requires: [BASEBASE] | ||
3439 | 314 | }, | ||
3440 | 315 | |||
3441 | 316 | 'base-pluginhost': { | ||
3442 | 317 | requires: [BASEBASE, PLUGINHOST] | ||
3443 | 318 | } | ||
3444 | 319 | } | ||
3445 | 320 | }, | ||
3446 | 321 | |||
3447 | 322 | cache: { | ||
3448 | 323 | requires: [PLUGIN] | ||
3449 | 324 | }, | ||
3450 | 325 | |||
3451 | 326 | compat: { | ||
3452 | 327 | requires: [NODE, DUMP, SUBSTITUTE] | ||
3453 | 328 | }, | ||
3454 | 329 | |||
3455 | 330 | classnamemanager: { | ||
3456 | 331 | requires: [YUIBASE] | ||
3457 | 332 | }, | ||
3458 | 333 | |||
3459 | 334 | collection: { | ||
3460 | 335 | requires: [OOP] | ||
3461 | 336 | }, | ||
3462 | 337 | |||
3463 | 338 | console: { | ||
3464 | 339 | requires: ['yui-log', WIDGET, SUBSTITUTE], | ||
3465 | 340 | skinnable: true, | ||
3466 | 341 | plugins: { | ||
3467 | 342 | 'console-filters': { | ||
3468 | 343 | requires: [PLUGIN, 'console'], | ||
3469 | 344 | skinnable: true | ||
3470 | 345 | } | ||
3471 | 346 | } | ||
3472 | 347 | }, | ||
3473 | 348 | |||
3474 | 349 | cookie: { | ||
3475 | 350 | requires: [YUIBASE] | ||
3476 | 351 | }, | ||
3477 | 352 | |||
3478 | 353 | dataschema:{ | ||
3479 | 354 | submodules: { | ||
3480 | 355 | 'dataschema-base': { | ||
3481 | 356 | requires: [BASE] | ||
3482 | 357 | }, | ||
3483 | 358 | 'dataschema-array': { | ||
3484 | 359 | requires: [DATASCHEMABASE] | ||
3485 | 360 | }, | ||
3486 | 361 | 'dataschema-json': { | ||
3487 | 362 | requires: [DATASCHEMABASE, 'json'] | ||
3488 | 363 | }, | ||
3489 | 364 | 'dataschema-text': { | ||
3490 | 365 | requires: [DATASCHEMABASE] | ||
3491 | 366 | }, | ||
3492 | 367 | 'dataschema-xml': { | ||
3493 | 368 | requires: [DATASCHEMABASE] | ||
3494 | 369 | } | ||
3495 | 370 | } | ||
3496 | 371 | }, | ||
3497 | 372 | |||
3498 | 373 | datasource:{ | ||
3499 | 374 | submodules: { | ||
3500 | 375 | 'datasource-local': { | ||
3501 | 376 | requires: [BASE] | ||
3502 | 377 | }, | ||
3503 | 378 | 'datasource-arrayschema': { | ||
3504 | 379 | requires: [DATASOURCELOCAL, PLUGIN, 'dataschema-array'] | ||
3505 | 380 | }, | ||
3506 | 381 | 'datasource-cache': { | ||
3507 | 382 | requires: [DATASOURCELOCAL, 'cache'] | ||
3508 | 383 | }, | ||
3509 | 384 | 'datasource-function': { | ||
3510 | 385 | requires: [DATASOURCELOCAL] | ||
3511 | 386 | }, | ||
3512 | 387 | 'datasource-jsonschema': { | ||
3513 | 388 | requires: [DATASOURCELOCAL, PLUGIN, 'dataschema-json'] | ||
3514 | 389 | }, | ||
3515 | 390 | 'datasource-polling': { | ||
3516 | 391 | requires: [DATASOURCELOCAL] | ||
3517 | 392 | }, | ||
3518 | 393 | 'datasource-get': { | ||
3519 | 394 | requires: [DATASOURCELOCAL, GET] | ||
3520 | 395 | }, | ||
3521 | 396 | 'datasource-textschema': { | ||
3522 | 397 | requires: [DATASOURCELOCAL, PLUGIN, 'dataschema-text'] | ||
3523 | 398 | }, | ||
3524 | 399 | 'datasource-io': { | ||
3525 | 400 | requires: [DATASOURCELOCAL, IOBASE] | ||
3526 | 401 | }, | ||
3527 | 402 | 'datasource-xmlschema': { | ||
3528 | 403 | requires: [DATASOURCELOCAL, PLUGIN, 'dataschema-xml'] | ||
3529 | 404 | } | ||
3530 | 405 | } | ||
3531 | 406 | }, | ||
3532 | 407 | |||
3533 | 408 | datatype:{ | ||
3534 | 409 | submodules: { | ||
3535 | 410 | 'datatype-date': { | ||
3536 | 411 | requires: [YUIBASE] | ||
3537 | 412 | }, | ||
3538 | 413 | 'datatype-number': { | ||
3539 | 414 | requires: [YUIBASE] | ||
3540 | 415 | }, | ||
3541 | 416 | 'datatype-xml': { | ||
3542 | 417 | requires: [YUIBASE] | ||
3543 | 418 | } | ||
3544 | 419 | } | ||
3545 | 420 | }, | ||
3546 | 421 | |||
3547 | 422 | dd:{ | ||
3548 | 423 | submodules: { | ||
3549 | 424 | 'dd-ddm-base': { | ||
3550 | 425 | requires: [NODE, BASE] | ||
3551 | 426 | }, | ||
3552 | 427 | 'dd-ddm':{ | ||
3553 | 428 | requires: ['dd-ddm-base', 'event-resize'] | ||
3554 | 429 | }, | ||
3555 | 430 | 'dd-ddm-drop':{ | ||
3556 | 431 | requires: ['dd-ddm'] | ||
3557 | 432 | }, | ||
3558 | 433 | 'dd-drag':{ | ||
3559 | 434 | requires: ['dd-ddm-base'] | ||
3560 | 435 | }, | ||
3561 | 436 | 'dd-drop':{ | ||
3562 | 437 | requires: ['dd-ddm-drop'] | ||
3563 | 438 | }, | ||
3564 | 439 | 'dd-proxy':{ | ||
3565 | 440 | requires: [DDDRAG] | ||
3566 | 441 | }, | ||
3567 | 442 | 'dd-constrain':{ | ||
3568 | 443 | requires: [DDDRAG] | ||
3569 | 444 | }, | ||
3570 | 445 | 'dd-scroll':{ | ||
3571 | 446 | requires: [DDDRAG] | ||
3572 | 447 | }, | ||
3573 | 448 | 'dd-plugin':{ | ||
3574 | 449 | requires: [DDDRAG], | ||
3575 | 450 | optional: ['dd-constrain', 'dd-proxy'] | ||
3576 | 451 | }, | ||
3577 | 452 | 'dd-drop-plugin':{ | ||
3578 | 453 | requires: ['dd-drop'] | ||
3579 | 454 | } | ||
3580 | 455 | } | ||
3581 | 456 | }, | ||
3582 | 457 | |||
3583 | 458 | dump: { | ||
3584 | 459 | requires: [YUIBASE] | ||
3585 | 460 | }, | ||
3586 | 461 | |||
3587 | 462 | event: { | ||
3588 | 463 | expound: NODEBASE, | ||
3589 | 464 | submodules: { | ||
3590 | 465 | 'event-base': { | ||
3591 | 466 | expound: NODEBASE, | ||
3592 | 467 | requires: [EVENTCUSTOMBASE] | ||
3593 | 468 | }, | ||
3594 | 469 | 'event-delegate': { | ||
3595 | 470 | requires: [NODEBASE] | ||
3596 | 471 | }, | ||
3597 | 472 | 'event-focus': { | ||
3598 | 473 | requires: [NODEBASE] | ||
3599 | 474 | }, | ||
3600 | 475 | 'event-key': { | ||
3601 | 476 | requires: [NODEBASE] | ||
3602 | 477 | }, | ||
3603 | 478 | 'event-mouseenter': { | ||
3604 | 479 | requires: [NODEBASE] | ||
3605 | 480 | }, | ||
3606 | 481 | 'event-mousewheel': { | ||
3607 | 482 | requires: [NODEBASE] | ||
3608 | 483 | }, | ||
3609 | 484 | 'event-resize': { | ||
3610 | 485 | requires: [NODEBASE] | ||
3611 | 486 | } | ||
3612 | 487 | } | ||
3613 | 488 | }, | ||
3614 | 489 | |||
3615 | 490 | 'event-custom': { | ||
3616 | 491 | submodules: { | ||
3617 | 492 | 'event-custom-base': { | ||
3618 | 493 | requires: [OOP, 'yui-later'] | ||
3619 | 494 | }, | ||
3620 | 495 | 'event-custom-complex': { | ||
3621 | 496 | requires: [EVENTCUSTOMBASE] | ||
3622 | 497 | } | ||
3623 | 498 | } | ||
3624 | 499 | }, | ||
3625 | 500 | |||
3626 | 501 | 'event-simulate': { | ||
3627 | 502 | requires: [EVENTBASE] | ||
3628 | 503 | }, | ||
3629 | 504 | |||
3630 | 505 | 'node-focusmanager': { | ||
3631 | 506 | requires: [ATTRIBUTE, NODE, PLUGIN, 'node-event-simulate', 'event-key', 'event-focus'] | ||
3632 | 507 | }, | ||
3633 | 508 | |||
3634 | 509 | history: { | ||
3635 | 510 | requires: [NODE] | ||
3636 | 511 | }, | ||
3637 | 512 | |||
3638 | 513 | imageloader: { | ||
3639 | 514 | requires: [BASEBASE, NODESTYLE, NODESCREEN] | ||
3640 | 515 | }, | ||
3641 | 516 | |||
3642 | 517 | io:{ | ||
3643 | 518 | submodules: { | ||
3644 | 519 | |||
3645 | 520 | 'io-base': { | ||
3646 | 521 | requires: [EVENTCUSTOMBASE] | ||
3647 | 522 | }, | ||
3648 | 523 | |||
3649 | 524 | 'io-xdr': { | ||
3650 | 525 | requires: [IOBASE, 'datatype-xml'] | ||
3651 | 526 | }, | ||
3652 | 527 | |||
3653 | 528 | 'io-form': { | ||
3654 | 529 | requires: [IOBASE, NODEBASE, NODESTYLE] | ||
3655 | 530 | }, | ||
3656 | 531 | |||
3657 | 532 | 'io-upload-iframe': { | ||
3658 | 533 | requires: [IOBASE, NODEBASE] | ||
3659 | 534 | }, | ||
3660 | 535 | |||
3661 | 536 | 'io-queue': { | ||
3662 | 537 | requires: [IOBASE, 'queue-promote'] | ||
3663 | 538 | } | ||
3664 | 539 | } | ||
3665 | 540 | }, | ||
3666 | 541 | |||
3667 | 542 | json: { | ||
3668 | 543 | submodules: { | ||
3669 | 544 | 'json-parse': { | ||
3670 | 545 | requires: [YUIBASE] | ||
3671 | 546 | }, | ||
3672 | 547 | |||
3673 | 548 | 'json-stringify': { | ||
3674 | 549 | requires: [YUIBASE] | ||
3675 | 550 | } | ||
3676 | 551 | } | ||
3677 | 552 | }, | ||
3678 | 553 | |||
3679 | 554 | loader: { | ||
3680 | 555 | requires: [GET] | ||
3681 | 556 | }, | ||
3682 | 557 | |||
3683 | 558 | 'node-menunav': { | ||
3684 | 559 | requires: [NODE, 'classnamemanager', PLUGIN, 'node-focusmanager'], | ||
3685 | 560 | skinnable: true | ||
3686 | 561 | }, | ||
3687 | 562 | |||
3688 | 563 | oop: { | ||
3689 | 564 | requires: [YUIBASE] | ||
3690 | 565 | }, | ||
3691 | 566 | |||
3692 | 567 | overlay: { | ||
3693 | 568 | requires: [WIDGET, WIDGETPOSITION, 'widget-position-ext', 'widget-stack', 'widget-stdmod'], | ||
3694 | 569 | skinnable: true | ||
3695 | 570 | }, | ||
3696 | 571 | |||
3697 | 572 | plugin: { | ||
3698 | 573 | requires: [BASEBASE] | ||
3699 | 574 | }, | ||
3700 | 575 | |||
3701 | 576 | pluginhost: { | ||
3702 | 577 | requires: [YUIBASE] | ||
3703 | 578 | }, | ||
3704 | 579 | |||
3705 | 580 | profiler: { | ||
3706 | 581 | requires: [YUIBASE] | ||
3707 | 582 | }, | ||
3708 | 583 | |||
3709 | 584 | 'queue-promote': { | ||
3710 | 585 | requires: [YUIBASE] | ||
3711 | 586 | }, | ||
3712 | 587 | |||
3713 | 588 | // deprecated package, replaced with async-queue | ||
3714 | 589 | 'queue-run': { | ||
3715 | 590 | requires: [EVENTCUSTOM], | ||
3716 | 591 | path: 'async-queue/async-queue-min.js' | ||
3717 | 592 | }, | ||
3718 | 593 | |||
3719 | 594 | 'async-queue': { | ||
3720 | 595 | requires: [EVENTCUSTOM], | ||
3721 | 596 | supersedes: ['queue-run'] | ||
3722 | 597 | }, | ||
3723 | 598 | |||
3724 | 599 | slider: { | ||
3725 | 600 | requires: [WIDGET, 'dd-constrain'], | ||
3726 | 601 | skinnable: true | ||
3727 | 602 | }, | ||
3728 | 603 | |||
3729 | 604 | stylesheet: { | ||
3730 | 605 | requires: [YUIBASE] | ||
3731 | 606 | }, | ||
3732 | 607 | |||
3733 | 608 | substitute: { | ||
3734 | 609 | optional: [DUMP] | ||
3735 | 610 | }, | ||
3736 | 611 | |||
3737 | 612 | widget: { | ||
3738 | 613 | requires: [ATTRIBUTE, 'event-focus', BASE, NODE, 'classnamemanager'], | ||
3739 | 614 | plugins: { | ||
3740 | 615 | 'widget-position': { }, | ||
3741 | 616 | 'widget-position-ext': { | ||
3742 | 617 | requires: [WIDGETPOSITION] | ||
3743 | 618 | }, | ||
3744 | 619 | 'widget-stack': { | ||
3745 | 620 | skinnable: true | ||
3746 | 621 | }, | ||
3747 | 622 | 'widget-stdmod': { } | ||
3748 | 623 | }, | ||
3749 | 624 | skinnable: true | ||
3750 | 625 | }, | ||
3751 | 626 | |||
3752 | 627 | yui: { | ||
3753 | 628 | submodules: { | ||
3754 | 629 | 'yui-base': {}, | ||
3755 | 630 | get: {}, | ||
3756 | 631 | 'yui-log': {}, | ||
3757 | 632 | 'yui-later': {} | ||
3758 | 633 | } | ||
3759 | 634 | }, | ||
3760 | 635 | |||
3761 | 636 | test: { | ||
3762 | 637 | requires: [SUBSTITUTE, NODE, 'json', 'event-simulate'] | ||
3763 | 638 | } | ||
3764 | 639 | |||
3765 | 640 | } | ||
3766 | 641 | }, | ||
3767 | 642 | |||
3768 | 643 | _path = Y.cached(function(dir, file, type) { | ||
3769 | 644 | return dir + '/' + file + '-min.' + (type || CSS); | ||
3770 | 645 | }), | ||
3771 | 646 | |||
3772 | 647 | _queue = YUI.Env._loaderQueue, | ||
3773 | 648 | |||
3774 | 649 | mods = META.modules, i, bname, mname, contextname, | ||
3775 | 650 | L = Y.Lang; | ||
3776 | 651 | |||
3777 | 652 | // Create the metadata for both the regular and context-aware | ||
3778 | 653 | // versions of the YUI CSS foundation. | ||
3779 | 654 | for (i=0; i<YUI_CSS.length; i=i+1) { | ||
3780 | 655 | bname = YUI_CSS[i]; | ||
3781 | 656 | mname = CSS + bname; | ||
3782 | 657 | |||
3783 | 658 | mods[mname] = { | ||
3784 | 659 | type: CSS, | ||
3785 | 660 | path: _path(mname, bname) | ||
3786 | 661 | }; | ||
3787 | 662 | |||
3788 | 663 | // define -context module | ||
3789 | 664 | contextname = mname + CONTEXT; | ||
3790 | 665 | bname = bname + CONTEXT; | ||
3791 | 666 | |||
3792 | 667 | mods[contextname] = { | ||
3793 | 668 | type: CSS, | ||
3794 | 669 | path: _path(mname, bname) | ||
3795 | 670 | }; | ||
3796 | 671 | |||
3797 | 672 | if (mname == CSSGRIDS) { | ||
3798 | 673 | mods[mname].requires = [CSSFONTS]; | ||
3799 | 674 | mods[mname].optional = [CSSRESET]; | ||
3800 | 675 | mods[contextname].requires = [CSSFONTS + CONTEXT]; | ||
3801 | 676 | mods[contextname].optional = [CSSRESET + CONTEXT]; | ||
3802 | 677 | } else if (mname == CSSBASE) { | ||
3803 | 678 | mods[mname].after = CSS_AFTER; | ||
3804 | 679 | mods[contextname].after = CSS_AFTER; | ||
3805 | 680 | } | ||
3806 | 681 | } | ||
3807 | 682 | |||
3808 | 683 | Y.Env.meta = META; | ||
3809 | 684 | |||
3810 | 685 | GLOBAL_LOADED = GLOBAL_ENV._loaded; | ||
3811 | 686 | |||
3812 | 687 | Y.Loader = function(o) { | ||
3813 | 688 | |||
3814 | 689 | /** | ||
3815 | 690 | * Internal callback to handle multiple internal insert() calls | ||
3816 | 691 | * so that css is inserted prior to js | ||
3817 | 692 | * @property _internalCallback | ||
3818 | 693 | * @private | ||
3819 | 694 | */ | ||
3820 | 695 | // this._internalCallback = null; | ||
3821 | 696 | |||
3822 | 697 | /** | ||
3823 | 698 | * Callback that will be executed when the loader is finished | ||
3824 | 699 | * with an insert | ||
3825 | 700 | * @method onSuccess | ||
3826 | 701 | * @type function | ||
3827 | 702 | */ | ||
3828 | 703 | // this.onSuccess = null; | ||
3829 | 704 | |||
3830 | 705 | /** | ||
3831 | 706 | * Callback that will be executed if there is a failure | ||
3832 | 707 | * @method onFailure | ||
3833 | 708 | * @type function | ||
3834 | 709 | */ | ||
3835 | 710 | // this.onFailure = null; | ||
3836 | 711 | |||
3837 | 712 | /** | ||
3838 | 713 | * Callback for the 'CSSComplete' event. When loading YUI components with CSS | ||
3839 | 714 | * the CSS is loaded first, then the script. This provides a moment you can tie into to improve | ||
3840 | 715 | * the presentation of the page while the script is loading. | ||
3841 | 716 | * @method onCSS | ||
3842 | 717 | * @type function | ||
3843 | 718 | */ | ||
3844 | 719 | // this.onCSS = null; | ||
3845 | 720 | |||
3846 | 721 | /** | ||
3847 | 722 | * Callback executed each time a script or css file is loaded | ||
3848 | 723 | * @method onProgress | ||
3849 | 724 | * @type function | ||
3850 | 725 | */ | ||
3851 | 726 | // this.onProgress = null; | ||
3852 | 727 | |||
3853 | 728 | /** | ||
3854 | 729 | * Callback that will be executed if a timeout occurs | ||
3855 | 730 | * @method onTimeout | ||
3856 | 731 | * @type function | ||
3857 | 732 | */ | ||
3858 | 733 | // this.onTimeout = null; | ||
3859 | 734 | |||
3860 | 735 | /** | ||
3861 | 736 | * The execution context for all callbacks | ||
3862 | 737 | * @property context | ||
3863 | 738 | * @default {YUI} the YUI instance | ||
3864 | 739 | */ | ||
3865 | 740 | this.context = Y; | ||
3866 | 741 | |||
3867 | 742 | /** | ||
3868 | 743 | * Data that is passed to all callbacks | ||
3869 | 744 | * @property data | ||
3870 | 745 | */ | ||
3871 | 746 | // this.data = null; | ||
3872 | 747 | |||
3873 | 748 | /** | ||
3874 | 749 | * Node reference or id where new nodes should be inserted before | ||
3875 | 750 | * @property insertBefore | ||
3876 | 751 | * @type string|HTMLElement | ||
3877 | 752 | */ | ||
3878 | 753 | // this.insertBefore = null; | ||
3879 | 754 | |||
3880 | 755 | /** | ||
3881 | 756 | * The charset attribute for inserted nodes | ||
3882 | 757 | * @property charset | ||
3883 | 758 | * @type string | ||
3884 | 759 | * @deprecated, use cssAttributes or jsAttributes | ||
3885 | 760 | */ | ||
3886 | 761 | // this.charset = null; | ||
3887 | 762 | |||
3888 | 763 | /** | ||
3889 | 764 | * An object literal containing attributes to add to link nodes | ||
3890 | 765 | * @property cssAttributes | ||
3891 | 766 | * @type object | ||
3892 | 767 | */ | ||
3893 | 768 | // this.cssAttributes = null; | ||
3894 | 769 | |||
3895 | 770 | /** | ||
3896 | 771 | * An object literal containing attributes to add to script nodes | ||
3897 | 772 | * @property jsAttributes | ||
3898 | 773 | * @type object | ||
3899 | 774 | */ | ||
3900 | 775 | // this.jsAttributes = null; | ||
3901 | 776 | |||
3902 | 777 | /** | ||
3903 | 778 | * The base directory. | ||
3904 | 779 | * @property base | ||
3905 | 780 | * @type string | ||
3906 | 781 | * @default http://yui.yahooapis.com/[YUI VERSION]/build/ | ||
3907 | 782 | */ | ||
3908 | 783 | this.base = Y.Env.meta.base; | ||
3909 | 784 | |||
3910 | 785 | /** | ||
3911 | 786 | * Base path for the combo service | ||
3912 | 787 | * @property comboBase | ||
3913 | 788 | * @type string | ||
3914 | 789 | * @default http://yui.yahooapis.com/combo? | ||
3915 | 790 | */ | ||
3916 | 791 | this.comboBase = Y.Env.meta.comboBase; | ||
3917 | 792 | |||
3918 | 793 | /** | ||
3919 | 794 | * If configured, YUI JS resources will use the combo | ||
3920 | 795 | * handler | ||
3921 | 796 | * @property combine | ||
3922 | 797 | * @type boolean | ||
3923 | 798 | * @default true if a base dir isn't in the config | ||
3924 | 799 | */ | ||
3925 | 800 | this.combine = o.base && (o.base.indexOf( this.comboBase.substr(0, 20)) > -1); | ||
3926 | 801 | |||
3927 | 802 | /** | ||
3928 | 803 | * Ignore modules registered on the YUI global | ||
3929 | 804 | * @property ignoreRegistered | ||
3930 | 805 | * @default false | ||
3931 | 806 | */ | ||
3932 | 807 | // this.ignoreRegistered = false; | ||
3933 | 808 | |||
3934 | 809 | /** | ||
3935 | 810 | * Root path to prepend to module path for the combo | ||
3936 | 811 | * service | ||
3937 | 812 | * @property root | ||
3938 | 813 | * @type string | ||
3939 | 814 | * @default [YUI VERSION]/build/ | ||
3940 | 815 | */ | ||
3941 | 816 | this.root = Y.Env.meta.root; | ||
3942 | 817 | |||
3943 | 818 | /** | ||
3944 | 819 | * Timeout value in milliseconds. If set, this value will be used by | ||
3945 | 820 | * the get utility. the timeout event will fire if | ||
3946 | 821 | * a timeout occurs. | ||
3947 | 822 | * @property timeout | ||
3948 | 823 | * @type int | ||
3949 | 824 | */ | ||
3950 | 825 | this.timeout = 0; | ||
3951 | 826 | |||
3952 | 827 | /** | ||
3953 | 828 | * A list of modules that should not be loaded, even if | ||
3954 | 829 | * they turn up in the dependency tree | ||
3955 | 830 | * @property ignore | ||
3956 | 831 | * @type string[] | ||
3957 | 832 | */ | ||
3958 | 833 | // this.ignore = null; | ||
3959 | 834 | |||
3960 | 835 | /** | ||
3961 | 836 | * A list of modules that should always be loaded, even | ||
3962 | 837 | * if they have already been inserted into the page. | ||
3963 | 838 | * @property force | ||
3964 | 839 | * @type string[] | ||
3965 | 840 | */ | ||
3966 | 841 | // this.force = null; | ||
3967 | 842 | |||
3968 | 843 | this.forceMap = {}; | ||
3969 | 844 | |||
3970 | 845 | /** | ||
3971 | 846 | * Should we allow rollups | ||
3972 | 847 | * @property allowRollup | ||
3973 | 848 | * @type boolean | ||
3974 | 849 | * @default true | ||
3975 | 850 | */ | ||
3976 | 851 | // this.allowRollup = true; | ||
3977 | 852 | |||
3978 | 853 | /** | ||
3979 | 854 | * A filter to apply to result urls. This filter will modify the default | ||
3980 | 855 | * path for all modules. The default path for the YUI library is the | ||
3981 | 856 | * minified version of the files (e.g., event-min.js). The filter property | ||
3982 | 857 | * can be a predefined filter or a custom filter. The valid predefined | ||
3983 | 858 | * filters are: | ||
3984 | 859 | * <dl> | ||
3985 | 860 | * <dt>DEBUG</dt> | ||
3986 | 861 | * <dd>Selects the debug versions of the library (e.g., event-debug.js). | ||
3987 | 862 | * This option will automatically include the Logger widget</dd> | ||
3988 | 863 | * <dt>RAW</dt> | ||
3989 | 864 | * <dd>Selects the non-minified version of the library (e.g., event.js).</dd> | ||
3990 | 865 | * </dl> | ||
3991 | 866 | * You can also define a custom filter, which must be an object literal | ||
3992 | 867 | * containing a search expression and a replace string: | ||
3993 | 868 | * <pre> | ||
3994 | 869 | * myFilter: { | ||
3995 | 870 | * 'searchExp': "-min\\.js", | ||
3996 | 871 | * 'replaceStr': "-debug.js" | ||
3997 | 872 | * } | ||
3998 | 873 | * </pre> | ||
3999 | 874 | * @property filter | ||
4000 | 875 | * @type string|{searchExp: string, replaceStr: string} | ||
4001 | 876 | */ | ||
4002 | 877 | // this.filter = null; | ||
4003 | 878 | |||
4004 | 879 | /** | ||
4005 | 880 | * per-component filter specification. If specified for a given component, this | ||
4006 | 881 | * overrides the filter config. | ||
4007 | 882 | * @property filters | ||
4008 | 883 | * @type object | ||
4009 | 884 | */ | ||
4010 | 885 | this.filters = {}; | ||
4011 | 886 | |||
4012 | 887 | /** | ||
4013 | 888 | * The list of requested modules | ||
4014 | 889 | * @property required | ||
4015 | 890 | * @type {string: boolean} | ||
4016 | 891 | */ | ||
4017 | 892 | this.required = {}; | ||
4018 | 893 | |||
4019 | 894 | /** | ||
4020 | 895 | * The library metadata | ||
4021 | 896 | * @property moduleInfo | ||
4022 | 897 | */ | ||
4023 | 898 | // this.moduleInfo = Y.merge(Y.Env.meta.moduleInfo); | ||
4024 | 899 | this.moduleInfo = {}; | ||
4025 | 900 | |||
4026 | 901 | /** | ||
4027 | 902 | * Provides the information used to skin the skinnable components. | ||
4028 | 903 | * The following skin definition would result in 'skin1' and 'skin2' | ||
4029 | 904 | * being loaded for calendar (if calendar was requested), and | ||
4030 | 905 | * 'sam' for all other skinnable components: | ||
4031 | 906 | * | ||
4032 | 907 | * <code> | ||
4033 | 908 | * skin: { | ||
4034 | 909 | * | ||
4035 | 910 | * // The default skin, which is automatically applied if not | ||
4036 | 911 | * // overriden by a component-specific skin definition. | ||
4037 | 912 | * // Change this in to apply a different skin globally | ||
4038 | 913 | * defaultSkin: 'sam', | ||
4039 | 914 | * | ||
4040 | 915 | * // This is combined with the loader base property to get | ||
4041 | 916 | * // the default root directory for a skin. ex: | ||
4042 | 917 | * // http://yui.yahooapis.com/2.3.0/build/assets/skins/sam/ | ||
4043 | 918 | * base: 'assets/skins/', | ||
4044 | 919 | * | ||
4045 | 920 | * // The name of the rollup css file for the skin | ||
4046 | 921 | * path: 'skin.css', | ||
4047 | 922 | * | ||
4048 | 923 | * // The number of skinnable components requested that are | ||
4049 | 924 | * // required before using the rollup file rather than the | ||
4050 | 925 | * // individual component css files | ||
4051 | 926 | * rollup: 3, | ||
4052 | 927 | * | ||
4053 | 928 | * // Any component-specific overrides can be specified here, | ||
4054 | 929 | * // making it possible to load different skins for different | ||
4055 | 930 | * // components. It is possible to load more than one skin | ||
4056 | 931 | * // for a given component as well. | ||
4057 | 932 | * overrides: { | ||
4058 | 933 | * calendar: ['skin1', 'skin2'] | ||
4059 | 934 | * } | ||
4060 | 935 | * } | ||
4061 | 936 | * </code> | ||
4062 | 937 | * @property skin | ||
4063 | 938 | */ | ||
4064 | 939 | this.skin = Y.merge(Y.Env.meta.skin); | ||
4065 | 940 | |||
4066 | 941 | var defaults = Y.Env.meta.modules, i, onPage = YUI.Env.mods; | ||
4067 | 942 | |||
4068 | 943 | this._internal = true; | ||
4069 | 944 | for (i in defaults) { | ||
4070 | 945 | if (defaults.hasOwnProperty(i)) { | ||
4071 | 946 | this.addModule(defaults[i], i); | ||
4072 | 947 | } | ||
4073 | 948 | } | ||
4074 | 949 | |||
4075 | 950 | for (i in onPage) { | ||
4076 | 951 | if (onPage.hasOwnProperty(i) && !this.moduleInfo[i] && onPage[i].details) { | ||
4077 | 952 | this.addModule(onPage[i].details, i); | ||
4078 | 953 | } | ||
4079 | 954 | } | ||
4080 | 955 | this._internal = false; | ||
4081 | 956 | |||
4082 | 957 | /** | ||
4083 | 958 | * List of rollup files found in the library metadata | ||
4084 | 959 | * @property rollups | ||
4085 | 960 | */ | ||
4086 | 961 | // this.rollups = null; | ||
4087 | 962 | |||
4088 | 963 | /** | ||
4089 | 964 | * Whether or not to load optional dependencies for | ||
4090 | 965 | * the requested modules | ||
4091 | 966 | * @property loadOptional | ||
4092 | 967 | * @type boolean | ||
4093 | 968 | * @default false | ||
4094 | 969 | */ | ||
4095 | 970 | // this.loadOptional = false; | ||
4096 | 971 | |||
4097 | 972 | /** | ||
4098 | 973 | * All of the derived dependencies in sorted order, which | ||
4099 | 974 | * will be populated when either calculate() or insert() | ||
4100 | 975 | * is called | ||
4101 | 976 | * @property sorted | ||
4102 | 977 | * @type string[] | ||
4103 | 978 | */ | ||
4104 | 979 | this.sorted = []; | ||
4105 | 980 | |||
4106 | 981 | /** | ||
4107 | 982 | * Set when beginning to compute the dependency tree. | ||
4108 | 983 | * Composed of what YUI reports to be loaded combined | ||
4109 | 984 | * with what has been loaded by any instance on the page | ||
4110 | 985 | * with the version number specified in the metadata. | ||
4111 | 986 | * @propery loaded | ||
4112 | 987 | * @type {string: boolean} | ||
4113 | 988 | */ | ||
4114 | 989 | this.loaded = GLOBAL_LOADED[VERSION]; | ||
4115 | 990 | |||
4116 | 991 | /** | ||
4117 | 992 | * A list of modules to attach to the YUI instance when complete. | ||
4118 | 993 | * If not supplied, the sorted list of dependencies are applied. | ||
4119 | 994 | * @property attaching | ||
4120 | 995 | */ | ||
4121 | 996 | // this.attaching = null; | ||
4122 | 997 | |||
4123 | 998 | /** | ||
4124 | 999 | * Flag to indicate the dependency tree needs to be recomputed | ||
4125 | 1000 | * if insert is called again. | ||
4126 | 1001 | * @property dirty | ||
4127 | 1002 | * @type boolean | ||
4128 | 1003 | * @default true | ||
4129 | 1004 | */ | ||
4130 | 1005 | this.dirty = true; | ||
4131 | 1006 | |||
4132 | 1007 | /** | ||
4133 | 1008 | * List of modules inserted by the utility | ||
4134 | 1009 | * @property inserted | ||
4135 | 1010 | * @type {string: boolean} | ||
4136 | 1011 | */ | ||
4137 | 1012 | this.inserted = {}; | ||
4138 | 1013 | |||
4139 | 1014 | /** | ||
4140 | 1015 | * List of skipped modules during insert() because the module | ||
4141 | 1016 | * was not defined | ||
4142 | 1017 | * @property skipped | ||
4143 | 1018 | */ | ||
4144 | 1019 | this.skipped = {}; | ||
4145 | 1020 | |||
4146 | 1021 | |||
4147 | 1022 | // Y.on('yui:load', this.loadNext, this); | ||
4148 | 1023 | |||
4149 | 1024 | this._config(o); | ||
4150 | 1025 | |||
4151 | 1026 | }; | ||
4152 | 1027 | |||
4153 | 1028 | Y.Loader.prototype = { | ||
4154 | 1029 | |||
4155 | 1030 | FILTER_DEFS: { | ||
4156 | 1031 | RAW: { | ||
4157 | 1032 | 'searchExp': "-min\\.js", | ||
4158 | 1033 | 'replaceStr': ".js" | ||
4159 | 1034 | }, | ||
4160 | 1035 | DEBUG: { | ||
4161 | 1036 | 'searchExp': "-min\\.js", | ||
4162 | 1037 | 'replaceStr': "-debug.js" | ||
4163 | 1038 | } | ||
4164 | 1039 | }, | ||
4165 | 1040 | |||
4166 | 1041 | SKIN_PREFIX: "skin-", | ||
4167 | 1042 | |||
4168 | 1043 | _config: function(o) { | ||
4169 | 1044 | |||
4170 | 1045 | var i, j, val, f; | ||
4171 | 1046 | |||
4172 | 1047 | // apply config values | ||
4173 | 1048 | if (o) { | ||
4174 | 1049 | for (i in o) { | ||
4175 | 1050 | if (o.hasOwnProperty(i)) { | ||
4176 | 1051 | val = o[i]; | ||
4177 | 1052 | if (i == 'require') { | ||
4178 | 1053 | this.require(val); | ||
4179 | 1054 | } else if (i == 'modules') { | ||
4180 | 1055 | |||
4181 | 1056 | // add a hash of module definitions | ||
4182 | 1057 | for (j in val) { | ||
4183 | 1058 | if (val.hasOwnProperty(j)) { | ||
4184 | 1059 | this.addModule(val[j], j); | ||
4185 | 1060 | } | ||
4186 | 1061 | } | ||
4187 | 1062 | |||
4188 | 1063 | } else { | ||
4189 | 1064 | this[i] = val; | ||
4190 | 1065 | } | ||
4191 | 1066 | } | ||
4192 | 1067 | } | ||
4193 | 1068 | } | ||
4194 | 1069 | |||
4195 | 1070 | // fix filter | ||
4196 | 1071 | f = this.filter; | ||
4197 | 1072 | |||
4198 | 1073 | if (L.isString(f)) { | ||
4199 | 1074 | f = f.toUpperCase(); | ||
4200 | 1075 | this.filterName = f; | ||
4201 | 1076 | this.filter = this.FILTER_DEFS[f]; | ||
4202 | 1077 | if (f == 'DEBUG') { | ||
4203 | 1078 | this.require('yui-log', 'dump'); | ||
4204 | 1079 | } | ||
4205 | 1080 | } | ||
4206 | 1081 | |||
4207 | 1082 | }, | ||
4208 | 1083 | |||
4209 | 1084 | /** | ||
4210 | 1085 | * Returns the skin module name for the specified skin name. If a | ||
4211 | 1086 | * module name is supplied, the returned skin module name is | ||
4212 | 1087 | * specific to the module passed in. | ||
4213 | 1088 | * @method formatSkin | ||
4214 | 1089 | * @param skin {string} the name of the skin | ||
4215 | 1090 | * @param mod {string} optional: the name of a module to skin | ||
4216 | 1091 | * @return {string} the full skin module name | ||
4217 | 1092 | */ | ||
4218 | 1093 | formatSkin: function(skin, mod) { | ||
4219 | 1094 | var s = this.SKIN_PREFIX + skin; | ||
4220 | 1095 | if (mod) { | ||
4221 | 1096 | s = s + "-" + mod; | ||
4222 | 1097 | } | ||
4223 | 1098 | |||
4224 | 1099 | return s; | ||
4225 | 1100 | }, | ||
4226 | 1101 | |||
4227 | 1102 | /* | ||
4228 | 1103 | * Reverses <code>formatSkin</code>, providing the skin name and | ||
4229 | 1104 | * module name if the string matches the pattern for skins. | ||
4230 | 1105 | * @method parseSkin | ||
4231 | 1106 | * @param mod {string} the module name to parse | ||
4232 | 1107 | * @return {skin: string, module: string} the parsed skin name | ||
4233 | 1108 | * and module name, or null if the supplied string does not match | ||
4234 | 1109 | * the skin pattern | ||
4235 | 1110 | * | ||
4236 | 1111 | * This isn't being used at the moment | ||
4237 | 1112 | * | ||
4238 | 1113 | */ | ||
4239 | 1114 | // parseSkin: function(mod) { | ||
4240 | 1115 | // | ||
4241 | 1116 | // if (mod.indexOf(this.SKIN_PREFIX) === 0) { | ||
4242 | 1117 | // var a = mod.split("-"); | ||
4243 | 1118 | // return {skin: a[1], module: a[2]}; | ||
4244 | 1119 | // } | ||
4245 | 1120 | // return null; | ||
4246 | 1121 | // }, | ||
4247 | 1122 | |||
4248 | 1123 | /** | ||
4249 | 1124 | * Adds the skin def to the module info | ||
4250 | 1125 | * @method _addSkin | ||
4251 | 1126 | * @param skin {string} the name of the skin | ||
4252 | 1127 | * @param mod {string} the name of the module | ||
4253 | 1128 | * @param parent {string} parent module if this is a skin of a | ||
4254 | 1129 | * submodule or plugin | ||
4255 | 1130 | * @return {string} the module name for the skin | ||
4256 | 1131 | * @private | ||
4257 | 1132 | */ | ||
4258 | 1133 | _addSkin: function(skin, mod, parent) { | ||
4259 | 1134 | |||
4260 | 1135 | var name = this.formatSkin(skin), | ||
4261 | 1136 | info = this.moduleInfo, | ||
4262 | 1137 | sinf = this.skin, | ||
4263 | 1138 | ext = info[mod] && info[mod].ext, | ||
4264 | 1139 | mdef, pkg; | ||
4265 | 1140 | |||
4266 | 1141 | /* | ||
4267 | 1142 | // Add a module definition for the skin rollup css | ||
4268 | 1143 | if (!info[name]) { | ||
4269 | 1144 | this.addModule({ | ||
4270 | 1145 | 'name': name, | ||
4271 | 1146 | 'type': 'css', | ||
4272 | 1147 | 'path': sinf.base + skin + '/' + sinf.path, | ||
4273 | 1148 | //'supersedes': '*', | ||
4274 | 1149 | 'after': sinf.after, | ||
4275 | 1150 | 'rollup': sinf.rollup, | ||
4276 | 1151 | 'ext': ext | ||
4277 | 1152 | }); | ||
4278 | 1153 | } | ||
4279 | 1154 | */ | ||
4280 | 1155 | |||
4281 | 1156 | // Add a module definition for the module-specific skin css | ||
4282 | 1157 | if (mod) { | ||
4283 | 1158 | name = this.formatSkin(skin, mod); | ||
4284 | 1159 | if (!info[name]) { | ||
4285 | 1160 | mdef = info[mod]; | ||
4286 | 1161 | pkg = mdef.pkg || mod; | ||
4287 | 1162 | this.addModule({ | ||
4288 | 1163 | 'name': name, | ||
4289 | 1164 | 'type': 'css', | ||
4290 | 1165 | 'after': sinf.after, | ||
4291 | 1166 | 'path': (parent || pkg) + '/' + sinf.base + skin + '/' + mod + '.css', | ||
4292 | 1167 | 'ext': ext | ||
4293 | 1168 | }); | ||
4294 | 1169 | } | ||
4295 | 1170 | } | ||
4296 | 1171 | |||
4297 | 1172 | return name; | ||
4298 | 1173 | }, | ||
4299 | 1174 | |||
4300 | 1175 | /** Add a new module to the component metadata. | ||
4301 | 1176 | * <dl> | ||
4302 | 1177 | * <dt>name:</dt> <dd>required, the component name</dd> | ||
4303 | 1178 | * <dt>type:</dt> <dd>required, the component type (js or css)</dd> | ||
4304 | 1179 | * <dt>path:</dt> <dd>required, the path to the script from "base"</dd> | ||
4305 | 1180 | * <dt>requires:</dt> <dd>array of modules required by this component</dd> | ||
4306 | 1181 | * <dt>optional:</dt> <dd>array of optional modules for this component</dd> | ||
4307 | 1182 | * <dt>supersedes:</dt> <dd>array of the modules this component replaces</dd> | ||
4308 | 1183 | * <dt>after:</dt> <dd>array of modules the components which, if present, should be sorted above this one</dd> | ||
4309 | 1184 | * <dt>rollup:</dt> <dd>the number of superseded modules required for automatic rollup</dd> | ||
4310 | 1185 | * <dt>fullpath:</dt> <dd>If fullpath is specified, this is used instead of the configured base + path</dd> | ||
4311 | 1186 | * <dt>skinnable:</dt> <dd>flag to determine if skin assets should automatically be pulled in</dd> | ||
4312 | 1187 | * <dt>submodules:</dt> <dd>a has of submodules</dd> | ||
4313 | 1188 | * </dl> | ||
4314 | 1189 | * @method addModule | ||
4315 | 1190 | * @param o An object containing the module data | ||
4316 | 1191 | * @param name the module name (optional), required if not in the module data | ||
4317 | 1192 | * @return {boolean} true if the module was added, false if | ||
4318 | 1193 | * the object passed in did not provide all required attributes | ||
4319 | 1194 | */ | ||
4320 | 1195 | addModule: function(o, name) { | ||
4321 | 1196 | |||
4322 | 1197 | name = name || o.name; | ||
4323 | 1198 | o.name = name; | ||
4324 | 1199 | |||
4325 | 1200 | if (!o || !o.name) { | ||
4326 | 1201 | return false; | ||
4327 | 1202 | } | ||
4328 | 1203 | |||
4329 | 1204 | if (!o.type) { | ||
4330 | 1205 | o.type = JS; | ||
4331 | 1206 | } | ||
4332 | 1207 | |||
4333 | 1208 | if (!o.path && !o.fullpath) { | ||
4334 | 1209 | // o.path = name + "/" + name + "-min." + o.type; | ||
4335 | 1210 | o.path = _path(name, name, o.type); | ||
4336 | 1211 | } | ||
4337 | 1212 | |||
4338 | 1213 | o.ext = ('ext' in o) ? o.ext : (this._internal) ? false : true; | ||
4339 | 1214 | o.requires = o.requires || []; | ||
4340 | 1215 | |||
4341 | 1216 | |||
4342 | 1217 | this.moduleInfo[name] = o; | ||
4343 | 1218 | |||
4344 | 1219 | // Handle submodule logic | ||
4345 | 1220 | var subs = o.submodules, i, l, sup, s, smod, plugins, plug; | ||
4346 | 1221 | if (subs) { | ||
4347 | 1222 | sup = []; | ||
4348 | 1223 | l = 0; | ||
4349 | 1224 | |||
4350 | 1225 | for (i in subs) { | ||
4351 | 1226 | if (subs.hasOwnProperty(i)) { | ||
4352 | 1227 | s = subs[i]; | ||
4353 | 1228 | s.path = _path(name, i, o.type); | ||
4354 | 1229 | this.addModule(s, i); | ||
4355 | 1230 | sup.push(i); | ||
4356 | 1231 | |||
4357 | 1232 | if (o.skinnable) { | ||
4358 | 1233 | smod = this._addSkin(this.skin.defaultSkin, i, name); | ||
4359 | 1234 | sup.push(smod.name); | ||
4360 | 1235 | } | ||
4361 | 1236 | |||
4362 | 1237 | l++; | ||
4363 | 1238 | } | ||
4364 | 1239 | } | ||
4365 | 1240 | |||
4366 | 1241 | o.supersedes = sup; | ||
4367 | 1242 | o.rollup = (l<4) ? l : Math.min(l-1, 4); | ||
4368 | 1243 | } | ||
4369 | 1244 | |||
4370 | 1245 | plugins = o.plugins; | ||
4371 | 1246 | if (plugins) { | ||
4372 | 1247 | for (i in plugins) { | ||
4373 | 1248 | if (plugins.hasOwnProperty(i)) { | ||
4374 | 1249 | plug = plugins[i]; | ||
4375 | 1250 | plug.path = _path(name, i, o.type); | ||
4376 | 1251 | plug.requires = plug.requires || []; | ||
4377 | 1252 | // plug.requires.push(name); | ||
4378 | 1253 | this.addModule(plug, i); | ||
4379 | 1254 | if (o.skinnable) { | ||
4380 | 1255 | this._addSkin(this.skin.defaultSkin, i, name); | ||
4381 | 1256 | } | ||
4382 | 1257 | } | ||
4383 | 1258 | } | ||
4384 | 1259 | } | ||
4385 | 1260 | |||
4386 | 1261 | this.dirty = true; | ||
4387 | 1262 | |||
4388 | 1263 | return o; | ||
4389 | 1264 | }, | ||
4390 | 1265 | |||
4391 | 1266 | /** | ||
4392 | 1267 | * Add a requirement for one or more module | ||
4393 | 1268 | * @method require | ||
4394 | 1269 | * @param what {string[] | string*} the modules to load | ||
4395 | 1270 | */ | ||
4396 | 1271 | require: function(what) { | ||
4397 | 1272 | var a = (typeof what === "string") ? arguments : what; | ||
4398 | 1273 | this.dirty = true; | ||
4399 | 1274 | Y.mix(this.required, Y.Array.hash(a)); | ||
4400 | 1275 | }, | ||
4401 | 1276 | |||
4402 | 1277 | /** | ||
4403 | 1278 | * Returns an object containing properties for all modules required | ||
4404 | 1279 | * in order to load the requested module | ||
4405 | 1280 | * @method getRequires | ||
4406 | 1281 | * @param mod The module definition from moduleInfo | ||
4407 | 1282 | */ | ||
4408 | 1283 | getRequires: function(mod) { | ||
4409 | 1284 | |||
4410 | 1285 | if (!mod) { | ||
4411 | 1286 | return []; | ||
4412 | 1287 | } | ||
4413 | 1288 | |||
4414 | 1289 | if (!this.dirty && mod.expanded) { | ||
4415 | 1290 | return mod.expanded; | ||
4416 | 1291 | } | ||
4417 | 1292 | |||
4418 | 1293 | var i, d=[], r=mod.requires, o=mod.optional, | ||
4419 | 1294 | info=this.moduleInfo, m, j, add; | ||
4420 | 1295 | |||
4421 | 1296 | for (i=0; i<r.length; i=i+1) { | ||
4422 | 1297 | d.push(r[i]); | ||
4423 | 1298 | m = this.getModule(r[i]); | ||
4424 | 1299 | add = this.getRequires(m); | ||
4425 | 1300 | for (j=0;j<add.length;j=j+1) { | ||
4426 | 1301 | d.push(add[j]); | ||
4427 | 1302 | } | ||
4428 | 1303 | } | ||
4429 | 1304 | |||
4430 | 1305 | // get the requirements from superseded modules, if any | ||
4431 | 1306 | r=mod.supersedes; | ||
4432 | 1307 | if (r) { | ||
4433 | 1308 | for (i=0; i<r.length; i=i+1) { | ||
4434 | 1309 | d.push(r[i]); | ||
4435 | 1310 | m = this.getModule(r[i]); | ||
4436 | 1311 | add = this.getRequires(m); | ||
4437 | 1312 | for (j=0;j<add.length;j=j+1) { | ||
4438 | 1313 | d.push(add[j]); | ||
4439 | 1314 | } | ||
4440 | 1315 | } | ||
4441 | 1316 | } | ||
4442 | 1317 | |||
4443 | 1318 | if (o && this.loadOptional) { | ||
4444 | 1319 | for (i=0; i<o.length; i=i+1) { | ||
4445 | 1320 | d.push(o[i]); | ||
4446 | 1321 | add = this.getRequires(info[o[i]]); | ||
4447 | 1322 | for (j=0;j<add.length;j=j+1) { | ||
4448 | 1323 | d.push(add[j]); | ||
4449 | 1324 | } | ||
4450 | 1325 | } | ||
4451 | 1326 | } | ||
4452 | 1327 | |||
4453 | 1328 | mod.expanded = Y.Object.keys(Y.Array.hash(d)); | ||
4454 | 1329 | return mod.expanded; | ||
4455 | 1330 | }, | ||
4456 | 1331 | |||
4457 | 1332 | |||
4458 | 1333 | /** | ||
4459 | 1334 | * Returns a hash of module names the supplied module satisfies. | ||
4460 | 1335 | * @method getProvides | ||
4461 | 1336 | * @param name {string} The name of the module | ||
4462 | 1337 | * @return what this module provides | ||
4463 | 1338 | */ | ||
4464 | 1339 | getProvides: function(name) { | ||
4465 | 1340 | var m = this.getModule(name), o, s; | ||
4466 | 1341 | |||
4467 | 1342 | if (!m) { | ||
4468 | 1343 | return NOT_FOUND; | ||
4469 | 1344 | } | ||
4470 | 1345 | |||
4471 | 1346 | if (m && !m.provides) { | ||
4472 | 1347 | o = {}; | ||
4473 | 1348 | s = m.supersedes; | ||
4474 | 1349 | |||
4475 | 1350 | if (s) { | ||
4476 | 1351 | Y.Array.each(s, function(v) { | ||
4477 | 1352 | Y.mix(o, this.getProvides(v)); | ||
4478 | 1353 | }, this); | ||
4479 | 1354 | } | ||
4480 | 1355 | |||
4481 | 1356 | o[name] = true; | ||
4482 | 1357 | m.provides = o; | ||
4483 | 1358 | } | ||
4484 | 1359 | |||
4485 | 1360 | return m.provides; | ||
4486 | 1361 | }, | ||
4487 | 1362 | |||
4488 | 1363 | |||
4489 | 1364 | /** | ||
4490 | 1365 | * Calculates the dependency tree, the result is stored in the sorted | ||
4491 | 1366 | * property | ||
4492 | 1367 | * @method calculate | ||
4493 | 1368 | * @param o optional options object | ||
4494 | 1369 | * @param type optional argument to prune modules | ||
4495 | 1370 | */ | ||
4496 | 1371 | calculate: function(o, type) { | ||
4497 | 1372 | if (o || type || this.dirty) { | ||
4498 | 1373 | this._config(o); | ||
4499 | 1374 | this._setup(); | ||
4500 | 1375 | this._explode(); | ||
4501 | 1376 | if (this.allowRollup && !this.combine) { | ||
4502 | 1377 | this._rollup(); | ||
4503 | 1378 | } | ||
4504 | 1379 | this._reduce(); | ||
4505 | 1380 | this._sort(); | ||
4506 | 1381 | |||
4507 | 1382 | |||
4508 | 1383 | this.dirty = false; | ||
4509 | 1384 | } | ||
4510 | 1385 | }, | ||
4511 | 1386 | |||
4512 | 1387 | /** | ||
4513 | 1388 | * Investigates the current YUI configuration on the page. By default, | ||
4514 | 1389 | * modules already detected will not be loaded again unless a force | ||
4515 | 1390 | * option is encountered. Called by calculate() | ||
4516 | 1391 | * @method _setup | ||
4517 | 1392 | * @private | ||
4518 | 1393 | */ | ||
4519 | 1394 | _setup: function() { | ||
4520 | 1395 | |||
4521 | 1396 | var info = this.moduleInfo, name, i, j, m, o, l, smod; | ||
4522 | 1397 | |||
4523 | 1398 | // Create skin modules | ||
4524 | 1399 | for (name in info) { | ||
4525 | 1400 | if (info.hasOwnProperty(name)) { | ||
4526 | 1401 | m = info[name]; | ||
4527 | 1402 | if (m && m.skinnable) { | ||
4528 | 1403 | o = this.skin.overrides; | ||
4529 | 1404 | if (o && o[name]) { | ||
4530 | 1405 | for (i=0; i<o[name].length; i=i+1) { | ||
4531 | 1406 | smod = this._addSkin(o[name][i], name); | ||
4532 | 1407 | } | ||
4533 | 1408 | } else { | ||
4534 | 1409 | smod = this._addSkin(this.skin.defaultSkin, name); | ||
4535 | 1410 | } | ||
4536 | 1411 | |||
4537 | 1412 | m.requires.push(smod); | ||
4538 | 1413 | } | ||
4539 | 1414 | } | ||
4540 | 1415 | } | ||
4541 | 1416 | |||
4542 | 1417 | l = Y.merge(this.inserted); // shallow clone | ||
4543 | 1418 | |||
4544 | 1419 | // available modules | ||
4545 | 1420 | if (!this.ignoreRegistered) { | ||
4546 | 1421 | Y.mix(l, GLOBAL_ENV.mods); | ||
4547 | 1422 | } | ||
4548 | 1423 | |||
4549 | 1424 | |||
4550 | 1425 | // add the ignore list to the list of loaded packages | ||
4551 | 1426 | if (this.ignore) { | ||
4552 | 1427 | // OU.appendArray(l, this.ignore); | ||
4553 | 1428 | Y.mix(l, Y.Array.hash(this.ignore)); | ||
4554 | 1429 | } | ||
4555 | 1430 | |||
4556 | 1431 | // expand the list to include superseded modules | ||
4557 | 1432 | for (j in l) { | ||
4558 | 1433 | if (l.hasOwnProperty(j)) { | ||
4559 | 1434 | Y.mix(l, this.getProvides(j)); | ||
4560 | 1435 | } | ||
4561 | 1436 | } | ||
4562 | 1437 | |||
4563 | 1438 | // remove modules on the force list from the loaded list | ||
4564 | 1439 | if (this.force) { | ||
4565 | 1440 | for (i=0; i<this.force.length; i=i+1) { | ||
4566 | 1441 | if (this.force[i] in l) { | ||
4567 | 1442 | delete l[this.force[i]]; | ||
4568 | 1443 | } | ||
4569 | 1444 | } | ||
4570 | 1445 | } | ||
4571 | 1446 | |||
4572 | 1447 | |||
4573 | 1448 | Y.mix(this.loaded, l); | ||
4574 | 1449 | |||
4575 | 1450 | // this.loaded = l; | ||
4576 | 1451 | |||
4577 | 1452 | }, | ||
4578 | 1453 | |||
4579 | 1454 | |||
4580 | 1455 | /** | ||
4581 | 1456 | * Inspects the required modules list looking for additional | ||
4582 | 1457 | * dependencies. Expands the required list to include all | ||
4583 | 1458 | * required modules. Called by calculate() | ||
4584 | 1459 | * @method _explode | ||
4585 | 1460 | * @private | ||
4586 | 1461 | */ | ||
4587 | 1462 | _explode: function() { | ||
4588 | 1463 | |||
4589 | 1464 | var r = this.required, m, reqs; | ||
4590 | 1465 | |||
4591 | 1466 | Y.Object.each(r, function(v, name) { | ||
4592 | 1467 | |||
4593 | 1468 | m = this.getModule(name); | ||
4594 | 1469 | |||
4595 | 1470 | var expound = m && m.expound; | ||
4596 | 1471 | |||
4597 | 1472 | if (m) { | ||
4598 | 1473 | |||
4599 | 1474 | if (expound) { | ||
4600 | 1475 | r[expound] = this.getModule(expound); | ||
4601 | 1476 | reqs = this.getRequires(r[expound]); | ||
4602 | 1477 | Y.mix(r, Y.Array.hash(reqs)); | ||
4603 | 1478 | } | ||
4604 | 1479 | |||
4605 | 1480 | reqs = this.getRequires(m); | ||
4606 | 1481 | |||
4607 | 1482 | Y.mix(r, Y.Array.hash(reqs)); | ||
4608 | 1483 | } | ||
4609 | 1484 | |||
4610 | 1485 | }, this); | ||
4611 | 1486 | }, | ||
4612 | 1487 | |||
4613 | 1488 | getModule: function(name) { | ||
4614 | 1489 | |||
4615 | 1490 | var m = this.moduleInfo[name]; | ||
4616 | 1491 | |||
4617 | 1492 | // create the default module | ||
4618 | 1493 | // if (!m) { | ||
4619 | 1494 | // m = this.addModule({ext: false}, name); | ||
4620 | 1495 | // } | ||
4621 | 1496 | |||
4622 | 1497 | return m; | ||
4623 | 1498 | }, | ||
4624 | 1499 | |||
4625 | 1500 | /** | ||
4626 | 1501 | * Look for rollup packages to determine if all of the modules a | ||
4627 | 1502 | * rollup supersedes are required. If so, include the rollup to | ||
4628 | 1503 | * help reduce the total number of connections required. Called | ||
4629 | 1504 | * by calculate() | ||
4630 | 1505 | * @method _rollup | ||
4631 | 1506 | * @private | ||
4632 | 1507 | */ | ||
4633 | 1508 | _rollup: function() { | ||
4634 | 1509 | var i, j, m, s, rollups={}, r=this.required, roll, | ||
4635 | 1510 | info = this.moduleInfo, rolled, c; | ||
4636 | 1511 | |||
4637 | 1512 | // find and cache rollup modules | ||
4638 | 1513 | if (this.dirty || !this.rollups) { | ||
4639 | 1514 | for (i in info) { | ||
4640 | 1515 | if (info.hasOwnProperty(i)) { | ||
4641 | 1516 | m = this.getModule(i); | ||
4642 | 1517 | // if (m && m.rollup && m.supersedes) { | ||
4643 | 1518 | if (m && m.rollup) { | ||
4644 | 1519 | rollups[i] = m; | ||
4645 | 1520 | } | ||
4646 | 1521 | } | ||
4647 | 1522 | } | ||
4648 | 1523 | |||
4649 | 1524 | this.rollups = rollups; | ||
4650 | 1525 | this.forceMap = (this.force) ? Y.Array.hash(this.force) : {}; | ||
4651 | 1526 | } | ||
4652 | 1527 | |||
4653 | 1528 | // make as many passes as needed to pick up rollup rollups | ||
4654 | 1529 | for (;;) { | ||
4655 | 1530 | rolled = false; | ||
4656 | 1531 | |||
4657 | 1532 | // go through the rollup candidates | ||
4658 | 1533 | for (i in rollups) { | ||
4659 | 1534 | |||
4660 | 1535 | if (rollups.hasOwnProperty(i)) { | ||
4661 | 1536 | |||
4662 | 1537 | // there can be only one, unless forced | ||
4663 | 1538 | if (!r[i] && ((!this.loaded[i]) || this.forceMap[i])) { | ||
4664 | 1539 | m = this.getModule(i); | ||
4665 | 1540 | s = m.supersedes || []; | ||
4666 | 1541 | roll = false; | ||
4667 | 1542 | |||
4668 | 1543 | // @TODO remove continue | ||
4669 | 1544 | if (!m.rollup) { | ||
4670 | 1545 | continue; | ||
4671 | 1546 | } | ||
4672 | 1547 | |||
4673 | 1548 | c = 0; | ||
4674 | 1549 | |||
4675 | 1550 | // check the threshold | ||
4676 | 1551 | for (j=0;j<s.length;j=j+1) { | ||
4677 | 1552 | |||
4678 | 1553 | |||
4679 | 1554 | // if the superseded module is loaded, we can't load the rollup | ||
4680 | 1555 | // unless it has been forced | ||
4681 | 1556 | if (this.loaded[s[j]] && !this.forceMap[s[j]]) { | ||
4682 | 1557 | roll = false; | ||
4683 | 1558 | break; | ||
4684 | 1559 | // increment the counter if this module is required. if we are | ||
4685 | 1560 | // beyond the rollup threshold, we will use the rollup module | ||
4686 | 1561 | } else if (r[s[j]]) { | ||
4687 | 1562 | c++; | ||
4688 | 1563 | roll = (c >= m.rollup); | ||
4689 | 1564 | if (roll) { | ||
4690 | 1565 | break; | ||
4691 | 1566 | } | ||
4692 | 1567 | } | ||
4693 | 1568 | } | ||
4694 | 1569 | |||
4695 | 1570 | if (roll) { | ||
4696 | 1571 | // add the rollup | ||
4697 | 1572 | r[i] = true; | ||
4698 | 1573 | rolled = true; | ||
4699 | 1574 | |||
4700 | 1575 | // expand the rollup's dependencies | ||
4701 | 1576 | this.getRequires(m); | ||
4702 | 1577 | } | ||
4703 | 1578 | } | ||
4704 | 1579 | } | ||
4705 | 1580 | } | ||
4706 | 1581 | |||
4707 | 1582 | // if we made it here w/o rolling up something, we are done | ||
4708 | 1583 | if (!rolled) { | ||
4709 | 1584 | break; | ||
4710 | 1585 | } | ||
4711 | 1586 | } | ||
4712 | 1587 | }, | ||
4713 | 1588 | |||
4714 | 1589 | /** | ||
4715 | 1590 | * Remove superceded modules and loaded modules. Called by | ||
4716 | 1591 | * calculate() after we have the mega list of all dependencies | ||
4717 | 1592 | * @method _reduce | ||
4718 | 1593 | * @private | ||
4719 | 1594 | */ | ||
4720 | 1595 | _reduce: function() { | ||
4721 | 1596 | var i, j, s, m, r=this.required, type = this.loadType; | ||
4722 | 1597 | for (i in r) { | ||
4723 | 1598 | if (r.hasOwnProperty(i)) { | ||
4724 | 1599 | m = this.getModule(i); | ||
4725 | 1600 | // remove if already loaded | ||
4726 | 1601 | if ((this.loaded[i] && (!this.forceMap[i]) && !this.ignoreRegistered) || (type && m && m.type != type)) { | ||
4727 | 1602 | delete r[i]; | ||
4728 | 1603 | // remove anything this module supersedes | ||
4729 | 1604 | } else { | ||
4730 | 1605 | |||
4731 | 1606 | s = m && m.supersedes; | ||
4732 | 1607 | if (s) { | ||
4733 | 1608 | for (j=0; j<s.length; j=j+1) { | ||
4734 | 1609 | if (s[j] in r) { | ||
4735 | 1610 | delete r[s[j]]; | ||
4736 | 1611 | } | ||
4737 | 1612 | } | ||
4738 | 1613 | } | ||
4739 | 1614 | } | ||
4740 | 1615 | } | ||
4741 | 1616 | } | ||
4742 | 1617 | }, | ||
4743 | 1618 | |||
4744 | 1619 | _attach: function() { | ||
4745 | 1620 | // this is the full list of items the YUI needs attached, | ||
4746 | 1621 | // which is needed if some dependencies are already on | ||
4747 | 1622 | // the page without their dependencies. | ||
4748 | 1623 | if (this.attaching) { | ||
4749 | 1624 | Y._attach(this.attaching); | ||
4750 | 1625 | } else { | ||
4751 | 1626 | Y._attach(this.sorted); | ||
4752 | 1627 | } | ||
4753 | 1628 | |||
4754 | 1629 | // this._pushEvents(); | ||
4755 | 1630 | |||
4756 | 1631 | }, | ||
4757 | 1632 | |||
4758 | 1633 | _finish: function() { | ||
4759 | 1634 | _queue.running = false; | ||
4760 | 1635 | this._continue(); | ||
4761 | 1636 | }, | ||
4762 | 1637 | |||
4763 | 1638 | _onSuccess: function() { | ||
4764 | 1639 | |||
4765 | 1640 | |||
4766 | 1641 | this._attach(); | ||
4767 | 1642 | |||
4768 | 1643 | var skipped = this.skipped, i, f; | ||
4769 | 1644 | |||
4770 | 1645 | for (i in skipped) { | ||
4771 | 1646 | if (skipped.hasOwnProperty(i)) { | ||
4772 | 1647 | delete this.inserted[i]; | ||
4773 | 1648 | } | ||
4774 | 1649 | } | ||
4775 | 1650 | |||
4776 | 1651 | this.skipped = {}; | ||
4777 | 1652 | |||
4778 | 1653 | f = this.onSuccess; | ||
4779 | 1654 | |||
4780 | 1655 | if (f) { | ||
4781 | 1656 | f.call(this.context, { | ||
4782 | 1657 | msg: 'success', | ||
4783 | 1658 | data: this.data, | ||
4784 | 1659 | success: true | ||
4785 | 1660 | }); | ||
4786 | 1661 | } | ||
4787 | 1662 | |||
4788 | 1663 | this._finish(); | ||
4789 | 1664 | |||
4790 | 1665 | }, | ||
4791 | 1666 | |||
4792 | 1667 | _onFailure: function(o) { | ||
4793 | 1668 | |||
4794 | 1669 | |||
4795 | 1670 | this._attach(); | ||
4796 | 1671 | |||
4797 | 1672 | var f = this.onFailure; | ||
4798 | 1673 | if (f) { | ||
4799 | 1674 | f.call(this.context, { | ||
4800 | 1675 | msg: 'failure: ' + o.msg, | ||
4801 | 1676 | data: this.data, | ||
4802 | 1677 | success: false | ||
4803 | 1678 | }); | ||
4804 | 1679 | } | ||
4805 | 1680 | |||
4806 | 1681 | this._finish(); | ||
4807 | 1682 | }, | ||
4808 | 1683 | |||
4809 | 1684 | _onTimeout: function() { | ||
4810 | 1685 | |||
4811 | 1686 | |||
4812 | 1687 | this._attach(); | ||
4813 | 1688 | |||
4814 | 1689 | var f = this.onTimeout; | ||
4815 | 1690 | if (f) { | ||
4816 | 1691 | f.call(this.context, { | ||
4817 | 1692 | msg: 'timeout', | ||
4818 | 1693 | data: this.data, | ||
4819 | 1694 | success: false | ||
4820 | 1695 | }); | ||
4821 | 1696 | } | ||
4822 | 1697 | |||
4823 | 1698 | this._finish(); | ||
4824 | 1699 | }, | ||
4825 | 1700 | |||
4826 | 1701 | /** | ||
4827 | 1702 | * Sorts the dependency tree. The last step of calculate() | ||
4828 | 1703 | * @method _sort | ||
4829 | 1704 | * @private | ||
4830 | 1705 | */ | ||
4831 | 1706 | _sort: function() { | ||
4832 | 1707 | |||
4833 | 1708 | // create an indexed list | ||
4834 | 1709 | var s = Y.Object.keys(this.required), | ||
4835 | 1710 | info = this.moduleInfo, | ||
4836 | 1711 | loaded = this.loaded, | ||
4837 | 1712 | done = {}, | ||
4838 | 1713 | p=0, l, a, b, j, k, moved, doneKey, | ||
4839 | 1714 | |||
4840 | 1715 | // returns true if b is not loaded, and is required | ||
4841 | 1716 | // directly or by means of modules it supersedes. | ||
4842 | 1717 | requires = Y.cached(function(mod1, mod2) { | ||
4843 | 1718 | |||
4844 | 1719 | var m = info[mod1], i, r, after, other = info[mod2], s; | ||
4845 | 1720 | |||
4846 | 1721 | if (loaded[mod2] || !m || !other) { | ||
4847 | 1722 | return false; | ||
4848 | 1723 | } | ||
4849 | 1724 | |||
4850 | 1725 | r = m.expanded; | ||
4851 | 1726 | after = m.after; | ||
4852 | 1727 | |||
4853 | 1728 | // check if this module requires the other directly | ||
4854 | 1729 | if (r && Y.Array.indexOf(r, mod2) > -1) { | ||
4855 | 1730 | return true; | ||
4856 | 1731 | } | ||
4857 | 1732 | |||
4858 | 1733 | // check if this module should be sorted after the other | ||
4859 | 1734 | if (after && Y.Array.indexOf(after, mod2) > -1) { | ||
4860 | 1735 | return true; | ||
4861 | 1736 | } | ||
4862 | 1737 | |||
4863 | 1738 | // check if this module requires one the other supersedes | ||
4864 | 1739 | s = info[mod2] && info[mod2].supersedes; | ||
4865 | 1740 | if (s) { | ||
4866 | 1741 | for (i=0; i<s.length; i=i+1) { | ||
4867 | 1742 | if (requires(mod1, s[i])) { | ||
4868 | 1743 | return true; | ||
4869 | 1744 | } | ||
4870 | 1745 | } | ||
4871 | 1746 | } | ||
4872 | 1747 | |||
4873 | 1748 | // external css files should be sorted below yui css | ||
4874 | 1749 | if (m.ext && m.type == CSS && !other.ext && other.type == CSS) { | ||
4875 | 1750 | return true; | ||
4876 | 1751 | } | ||
4877 | 1752 | |||
4878 | 1753 | return false; | ||
4879 | 1754 | }); | ||
4880 | 1755 | |||
4881 | 1756 | // keep going until we make a pass without moving anything | ||
4882 | 1757 | for (;;) { | ||
4883 | 1758 | |||
4884 | 1759 | l = s.length; | ||
4885 | 1760 | moved = false; | ||
4886 | 1761 | |||
4887 | 1762 | // start the loop after items that are already sorted | ||
4888 | 1763 | for (j=p; j<l; j=j+1) { | ||
4889 | 1764 | |||
4890 | 1765 | // check the next module on the list to see if its | ||
4891 | 1766 | // dependencies have been met | ||
4892 | 1767 | a = s[j]; | ||
4893 | 1768 | |||
4894 | 1769 | // check everything below current item and move if we | ||
4895 | 1770 | // find a requirement for the current item | ||
4896 | 1771 | for (k=j+1; k<l; k=k+1) { | ||
4897 | 1772 | doneKey = a + s[k]; | ||
4898 | 1773 | if (!done[doneKey] && requires(a, s[k])) { | ||
4899 | 1774 | |||
4900 | 1775 | // extract the dependency so we can move it up | ||
4901 | 1776 | b = s.splice(k, 1); | ||
4902 | 1777 | |||
4903 | 1778 | // insert the dependency above the item that | ||
4904 | 1779 | // requires it | ||
4905 | 1780 | s.splice(j, 0, b[0]); | ||
4906 | 1781 | |||
4907 | 1782 | // only swap two dependencies once to short circut | ||
4908 | 1783 | // circular dependencies | ||
4909 | 1784 | done[doneKey] = true; | ||
4910 | 1785 | |||
4911 | 1786 | // keep working | ||
4912 | 1787 | moved = true; | ||
4913 | 1788 | |||
4914 | 1789 | break; | ||
4915 | 1790 | } | ||
4916 | 1791 | } | ||
4917 | 1792 | |||
4918 | 1793 | // jump out of loop if we moved something | ||
4919 | 1794 | if (moved) { | ||
4920 | 1795 | break; | ||
4921 | 1796 | // this item is sorted, move our pointer and keep going | ||
4922 | 1797 | } else { | ||
4923 | 1798 | p = p + 1; | ||
4924 | 1799 | } | ||
4925 | 1800 | } | ||
4926 | 1801 | |||
4927 | 1802 | // when we make it here and moved is false, we are | ||
4928 | 1803 | // finished sorting | ||
4929 | 1804 | if (!moved) { | ||
4930 | 1805 | break; | ||
4931 | 1806 | } | ||
4932 | 1807 | |||
4933 | 1808 | } | ||
4934 | 1809 | |||
4935 | 1810 | this.sorted = s; | ||
4936 | 1811 | }, | ||
4937 | 1812 | |||
4938 | 1813 | _insert: function(source, o, type) { | ||
4939 | 1814 | |||
4940 | 1815 | |||
4941 | 1816 | // restore the state at the time of the request | ||
4942 | 1817 | if (source) { | ||
4943 | 1818 | this._config(source); | ||
4944 | 1819 | } | ||
4945 | 1820 | |||
4946 | 1821 | // build the dependency list | ||
4947 | 1822 | this.calculate(o); // don't include type so we can process CSS and script in | ||
4948 | 1823 | // one pass when the type is not specified. | ||
4949 | 1824 | this.loadType = "js"; | ||
4950 | 1825 | |||
4951 | 1826 | // if (!type) { | ||
4952 | 1827 | |||
4953 | 1828 | // var self = this; | ||
4954 | 1829 | |||
4955 | 1830 | // this._internalCallback = function() { | ||
4956 | 1831 | // var f = self.onCSS; | ||
4957 | 1832 | // if (f) { | ||
4958 | 1833 | // f.call(self.context, Y); | ||
4959 | 1834 | // } | ||
4960 | 1835 | // self._internalCallback = null; | ||
4961 | 1836 | // self._insert(null, null, JS); | ||
4962 | 1837 | // }; | ||
4963 | 1838 | |||
4964 | 1839 | // // _queue.running = false; | ||
4965 | 1840 | // this._insert(null, null, CSS); | ||
4966 | 1841 | |||
4967 | 1842 | // return; | ||
4968 | 1843 | // } | ||
4969 | 1844 | |||
4970 | 1845 | |||
4971 | 1846 | // set a flag to indicate the load has started | ||
4972 | 1847 | this._loading = true; | ||
4973 | 1848 | |||
4974 | 1849 | // flag to indicate we are done with the combo service | ||
4975 | 1850 | // and any additional files will need to be loaded | ||
4976 | 1851 | // individually | ||
4977 | 1852 | this._combineComplete = {}; | ||
4978 | 1853 | |||
4979 | 1854 | |||
4980 | 1855 | // start the load | ||
4981 | 1856 | this.loadNext(); | ||
4982 | 1857 | |||
4983 | 1858 | }, | ||
4984 | 1859 | |||
4985 | 1860 | _continue: function() { | ||
4986 | 1861 | if (!(_queue.running) && _queue.size() > 0) { | ||
4987 | 1862 | _queue.running = true; | ||
4988 | 1863 | _queue.next()(); | ||
4989 | 1864 | } | ||
4990 | 1865 | }, | ||
4991 | 1866 | |||
4992 | 1867 | /** | ||
4993 | 1868 | * inserts the requested modules and their dependencies. | ||
4994 | 1869 | * <code>type</code> can be "js" or "css". Both script and | ||
4995 | 1870 | * css are inserted if type is not provided. | ||
4996 | 1871 | * @method insert | ||
4997 | 1872 | * @param o optional options object | ||
4998 | 1873 | * @param type {string} the type of dependency to insert | ||
4999 | 1874 | */ | ||
5000 | 1875 | insert: function(o, type) { |
- Updates YUI to 3.0.0
- Some cleanup in FormOverlay