Merge lp:~sidnei/lazr-js/yui-3.0.0-redux into lp:lazr-js

Proposed by Sidnei da Silva
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
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.

To post a comment you must log in.
Revision history for this message
Sidnei da Silva (sidnei) wrote :

- Updates YUI to 3.0.0
- Some cleanup in FormOverlay

Revision history for this message
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).

- https://pastebin.canonical.com/23675/

Revision history for this message
Edwin Grubbs (edwin-grubbs) wrote :
Download full text (21.6 KiB)

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/inlineeditor/index.html'
>--- examples/inlineeditor/index.html 2009-10-21 17:35:08.000000000 -0500
>+++ new 2009-10-21 17:31:07.000000000 -0500
> var multiline_text = new Y.EditableText({
>- contentBox: '#edit-description',
>- multiline: true,
>- buttons: 'top'
>+ contentBox: '#multiline_text',
>+ multi_line: true,
>+ size: 70
> });
> multiline_text.render();
>
>- // Add the 2 second delay to the underlying editor widget.
>- multiline_text.editor.plug({fn:DelayedSavePlugin});

Why was this removed?

>+ // XXX remove this when done writing the *error CSS stuff.
>+ // editor.editor.showError("Empty text is unacceptable!");
>+ // editor.show_editor();

Why were these comments added?

> });
> </script>
>
>=== modified file 'src-js/lazrjs/choiceedit/tests/choiceedit.js'
>--- src-js/lazrjs/choiceedit/tests/choiceedit.js 2009-10-19 18:16:13 +0000
>+++ src-js/lazrjs/choiceedit/tests/choiceedit.js 2009-10-21 22:29:49 +0000
>@@ -4,7 +4,7 @@
> base: '../../yui/current/build/',
> filter: 'raw',
> combine: false
>- }).use('lazr.choiceedit', 'lazr.testing.runner', 'node', 'event', 'yuitest', 'widget-stack', 'console', function(Y) {
>+ }).use('lazr.choiceedit', 'lazr.testing.runner', 'node', 'event', 'widget-stack', 'console', function(Y) {

Line too long.

> // Local aliases
> var Assert = Y.Assert,
>
>=== modified file 'src-js/lazrjs/formoverlay/tests/formoverlay.js'
>--- src-js/lazrjs/formoverlay/tests/formoverlay.js 2009-10-20 13:47:36 +0000
>+++ src-js/lazrjs/formoverlay/tests/formoverlay.js 2009-10-21 22:29:49 +0000
>@@ -1,11 +1,11 @@
> /* Copyright (c) 2008, Canonical Ltd. All rights reserved. */
>
> YUI({
>- base: '../../yui/3.0.0pr2/build/',
>+ base: '../../yui/current/build/',
> filter: 'raw',
> combine: false
> }).use('lazr.formoverlay', 'lazr.testing.runner',
>- 'lazr.testing.mockio', 'node', 'event', 'yuitest', 'dump',
>+ 'lazr.testing.mockio', 'node', 'event', 'dump',
> 'console', function(Y) {
>
> var Assert = Y.Assert; // For easy access to isTrue(), etc.
>@@ -20,6 +20,17 @@
> Y.Event.simulate(rawnode, evtype, options);
> }
>
>+/* Helper function to cleanup and destroy a form overlay instance */
>+function cleanup_form_overlay(form_overlay) {
>+ if (form_overlay.get('rendered')) {
>+ var bb = form_overlay.get('boundingBox');
>+ bb.get('parentNode').removeChild(bb);
>+ }
>+
>+ // Kill the widget itself.
>+ form_overlay.destroy();
>+}
>+
> /* Helper function that creates a new form overlay instance. */
> function make_form_overlay(cfg) {
> var form_overlay = new Y.lazr.FormOverlay(cfg);
>@@ -52,17 +63,7 @@
>
> tearDown: function() {
> window.top.resizeTo(this.width, this.height);
>- this.cleanUp(this.form_overlay);
>- },
>-
>- cleanUp: function(form_overlay) {
>- if (form_overlay.get('rendered')) {
>- var bb = form_overlay.get('boundingBox');
>- ...

review: Needs Fixing (code)
lp:~sidnei/lazr-js/yui-3.0.0-redux updated
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

Revision history for this message
Sidnei da Silva (sidnei) wrote :
Download full text (17.3 KiB)

>>=== modified file 'examples/inlineeditor/index.html'
>>--- examples/inlineeditor/index.html   2009-10-21 17:35:08.000000000 -0500
>>-    // Add the 2 second delay to the underlying editor widget.
>>-    multiline_text.editor.plug({fn:DelayedSavePlugin});
>
> 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.showError("Empty text is unacceptable!");
>>+    // editor.show_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/inlineeditor/index.html'
--- examples/inlineeditor/index.html 2009-09-01 02:14:14 +0000
+++ examples/inlineeditor/index.html 2009-10-22 18:37:47 +0000
@@ -421,9 +421,8 @@
     });
     multiline_text.render();

- // XXX remove this when done writing the *error CSS stuff.
- // editor.editor.showError("Empty text is unacceptable!");
- // editor.show_editor();
+ // Add the 2 second delay to the underlying editor widget.
+ multiline_text.editor.plug({fn:DelayedSavePlugin});

 });
   </script>

=== modified file 'src-js/lazrjs/choiceedit/tests/choiceedit.js'
--- src-js/lazrjs/choiceedit/tests/choiceedit.js 2009-10-21 21:43:07 +0000
+++ src-js/lazrjs/choiceedit/tests/choiceedit.js 2009-10-22 18:37:47 +0000
@@ -4,7 +4,8 @@
     base: '../../yui/current/build/',
     filter: 'raw',
     combine: false
- }).use('lazr.choiceedit', 'lazr.testing.runner', 'node', 'event',
'widget-stack', 'console', function(Y) {
+ }).use('lazr.choiceedit', 'lazr.testing.runner', 'node',
+ 'event', 'widget-stack', 'console', function(Y) {

 // Local aliases
 var Assert = Y.Assert,

=== modified file 'src-js/lazrjs/formoverlay/tests/formoverlay.js'
--- src-js/lazrjs/formoverlay/tests/formoverlay.js 2009-10-21 21:43:07 +0000
+++ src-js/lazrjs/formoverlay/tests/formoverlay.js 2009-10-22 18:37:47 +0000
@@ -75,28 +75,19 @@
         cleanup_form_overlay(overlay);
     },

- // 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_content_in_bodyContent below.
- // _should: {
- // fail: {test_bodyContent_is_single_node: true}
- // },
-
- test_bodyContent_is_single_node: function() {
+ test_body_content_is_single_node: function(...

lp:~sidnei/lazr-js/yui-3.0.0-redux updated
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

Revision history for this message
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

review: Approve (code)
lp:~sidnei/lazr-js/yui-3.0.0-redux updated
155. By Sidnei da Silva

- Merge from parent branch

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'buildout.cfg'
--- buildout.cfg 2009-10-27 08:59:24 +0000
+++ buildout.cfg 2009-10-30 17:01:13 +0000
@@ -2,6 +2,7 @@
2develop = .2develop = .
3parts =3parts =
4 scripts4 scripts
5 test
56
6unzip = true7unzip = true
7eggs-directory = eggs8eggs-directory = eggs
@@ -27,6 +28,16 @@
27[versions]28[versions]
28# Alphabetical, case-insensitive, please! :-)29# Alphabetical, case-insensitive, please! :-)
29bzr = 2.0.030bzr = 2.0.0
31lazr.testing = 0.1.1
32mocker = 0.10.1
30setuptools = 0.6c933setuptools = 0.6c9
31zc.buildout = 1.4.134zc.buildout = 1.4.1
32zc.recipe.egg = 1.2.235zc.recipe.egg = 1.2.2
36zc.recipe.testrunner = 1.2.0
37zope.exceptions = 3.5.2
38zope.interface = 3.5.1
39zope.testing = 3.8.1
40
41[test]
42recipe = zc.recipe.testrunner
43eggs = lazr-js
3344
=== modified file 'examples/activator/index.html'
--- examples/activator/index.html 2009-04-22 02:42:02 +0000
+++ examples/activator/index.html 2009-10-30 17:01:13 +0000
@@ -3,7 +3,7 @@
3<html>3<html>
4<head>4<head>
5 <title>Lazr-js examples: Activator</title>5 <title>Lazr-js examples: Activator</title>
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>
7 <script type="text/javascript" src="../../build/anim/anim.js"></script>7 <script type="text/javascript" src="../../build/anim/anim.js"></script>
8 <script type="text/javascript" src="../../build/lazr/lazr.js"></script>8 <script type="text/javascript" src="../../build/lazr/lazr.js"></script>
9 <script type="text/javascript" src="../../build/activator/activator.js"></script>9 <script type="text/javascript" src="../../build/activator/activator.js"></script>
@@ -11,7 +11,7 @@
11<script id="example-script" type="text/javascript">11<script id="example-script" type="text/javascript">
1212
13YUI({13YUI({
14 base: '../../lib/yui/current/build/',14 base: '../../build/yui/current/build/',
15 filter: 'raw'15 filter: 'raw'
16 }).use('node', 'lazr.activator', function(Y) {16 }).use('node', 'lazr.activator', function(Y) {
1717
@@ -96,9 +96,9 @@
96 We need to include individual css files because some of them have96 We need to include individual css files because some of them have
97 relative paths to images.97 relative paths to images.
98 -->98 -->
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" />
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" />
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" />
102102
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>
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>
105105
=== modified file 'examples/anim/index.html'
--- examples/anim/index.html 2009-03-12 02:55:06 +0000
+++ examples/anim/index.html 2009-10-30 17:01:13 +0000
@@ -3,14 +3,14 @@
3<html>3<html>
4<head>4<head>
5 <title>Lazr-js examples: anim</title>5 <title>Lazr-js examples: anim</title>
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>
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>
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>
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>
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>
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>
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>
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>
1414
15 <script type="text/javascript" src="../../build/anim/anim.js"></script>15 <script type="text/javascript" src="../../build/anim/anim.js"></script>
16 <script type="text/javascript">16 <script type="text/javascript">
1717
=== modified file 'examples/autocomplete/index.html'
--- examples/autocomplete/index.html 2009-04-22 19:02:42 +0000
+++ examples/autocomplete/index.html 2009-10-30 17:01:13 +0000
@@ -4,20 +4,20 @@
4<head>4<head>
5 <title>Lazr-js examples: autocomplete</title>5 <title>Lazr-js examples: autocomplete</title>
66
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>
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>
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>
1010
1111
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>
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>
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>
15 <script type="text/javascript" src="../../lib/lazr/build/lazr.js"></script>15 <script type="text/javascript" src="../../build/lazr/lazr.js"></script>
16 <script type="text/javascript" src="../../lib/lazr/build/autocomplete/autocomplete.js"></script>16 <script type="text/javascript" src="../../build/autocomplete/autocomplete.js"></script>
17 <script type="text/javascript">17 <script type="text/javascript">
1818
19var LP = YUI({19var LP = YUI({
20 base: '../../lib/yui/current/build/',20 base: '../../build/yui/current/build/',
21 filter: 'raw'21 filter: 'raw'
22});22});
2323
@@ -241,9 +241,9 @@
241 We need to include individual css files because some of them have241 We need to include individual css files because some of them have
242 relative paths to images.242 relative paths to images.
243 -->243 -->
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>
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>
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>
247247
248 <style type="text/css">248 <style type="text/css">
249 #example {249 #example {
250250
=== modified file 'examples/choiceedit/index.html'
--- examples/choiceedit/index.html 2009-07-30 22:55:42 +0000
+++ examples/choiceedit/index.html 2009-10-30 17:01:13 +0000
@@ -2,150 +2,27 @@
2<html>2<html>
3<head>3<head>
4 <title>Lazr-js examples: Choice editing</title>4 <title>Lazr-js examples: Choice editing</title>
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>
6 <script type="text/javascript" src="../../lib/lazr/build/lazr.js"></script>6 <script type="text/javascript" src="../../build/lazr/lazr.js"></script>
7 <script type="text/javascript" src="../../build/anim/anim.js"></script>
8 <script type="text/javascript" src="../../build/overlay/overlay.js"></script>
79
8 <!--10 <!--
9 We need to include individual css files because some of them have11 We need to include individual css files because some of them have
10 relative paths to images.12 relative paths to images.
11 -->13 -->
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>
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>
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>
15 17
16 <script type="text/javascript" src="../../lib/lazr/build/choiceedit/choiceedit.js"></script>18 <script type="text/javascript" src="../../build/choiceedit/choiceedit.js"></script>
17 <script>19
18 YUI({20 <link type="text/css" rel="stylesheet"
19 base: '../../lib/yui/3.0.0pr2/build/',21 href="../../build/overlay/assets/pretty-overlay-core.css">
20 filter: 'raw'22 <link type="text/css" rel="stylesheet"
21 }).use('node', 'event', 'widget', 'plugin', 'overlay', 'lazr.choiceedit', function(Y) {23 href="../../build/overlay/assets/skins/sam/pretty-overlay-skin.css">
22 24 <link type="text/css" rel="stylesheet"
23 // Add a delay between the start and end of the inline editor widget's25 href="../../build/choiceedit/assets/choiceedit-core.css">
24 // "save" event.
25 var DelayedSavePlugin = function(config) {
26 DelayedSavePlugin.superclass.constructor.apply(this, arguments);
27 };
28
29 DelayedSavePlugin.NAME = 'delayedsave';
30 DelayedSavePlugin.NS = 'fx';
31
32 DelayedSavePlugin.ATTRS = {
33 /*
34 * Default duration of the 'saving' delay, in milliseconds.
35 */
36 duration: {
37 value: 2000
38 }
39 };
40
41 Y.extend(DelayedSavePlugin, Y.Plugin, {
42
43 initializer: function(config) {
44 // Save a reference to the original _saveData() method before
45 // we wrap it up.
46 this.original_save = config.owner._saveData;
47
48 // We want to run our delayed-save code before the original
49 // 'save' method. Using doBefore() means that unplugging our
50 // code will leave the original widget in a clean state.
51 this.doBefore("_saveData", this._altSave);
52 },
53
54 destructor: function() {},
55
56 /*
57 * Our own _altSave() method, used to override the owner's default
58 * behaviour. This method will only be called if the editor's input
59 * is valid.
60 */
61 _altSave: function() {
62 var owner = this._owner,
63 delay = this.get('duration');
64
65 Y.log("Running alternative _saveData()", 'info');
66
67 // Set the UI 'waiting' status.
68 owner._uiSetWaiting();
69
70 // Introduce a configurable delay around the owner's _saveData()
71 // method.
72 Y.later(delay, this, function() {
73
74 Y.log("Running original 'save' method.", 'info');
75 this.original_save.apply(owner, arguments[0]);
76
77 // Make sure we clear the 'waiting' status.
78 owner._uiClearWaiting();
79
80 }, arguments);
81
82 // Make sure we prevent the default _devSave() method from
83 // running.
84 return new Y.Do.Halt();
85 }
86 });
87
88
89 var choice_edit = new Y.ChoiceSource({
90 contentBox: '#status',
91 value: 'incomplete',
92 title: 'Change status to',
93 items: [
94 { name: 'New', value: 'new', style: '',
95 help: '', disabled: false },
96 { name: 'Invalid', value: 'invalid', style: '',
97 help: '', disabled: true },
98 { name: 'Incomplete', value: 'incomplete', style: '',
99 help: '', disabled: false },
100 { name: 'Fix Released', value: 'fixreleased', style: '',
101 help: '', disabled: false },
102 { name: 'Fix Committed', value: 'fixcommitted', style: '',
103 help: '', disabled: true },
104 { name: 'In Progress', value: 'inprogress', style: '',
105 help: '', disabled: false }
106 ]
107 });
108
109 // Add the 2 second delay to the underlying editor widget.
110 choice_edit.plug({fn:DelayedSavePlugin});
111
112 choice_edit.render();
113
114
115 var null_choice_edit = new Y.NullChoiceSource({
116 contentBox: '#nullchoiceedit',
117 value: null,
118 title: 'Choose something',
119 items: [
120 { name: 'Chico', value: 'chico', style: '',
121 help: '', disabled: false },
122 { name: 'Harpo', value: 'harpo', style: '',
123 help: '', disabled: false },
124 { name: 'Groucho', value: 'groucho', style: '',
125 help: '', disabled: false },
126 { name: 'Gummo', value: 'gummo', style: '',
127 help: '', disabled: false },
128 { name: 'Zeppo', value: 'zeppo', style: '',
129 help: '', disabled: false },
130 { name: 'Not funny!', value: null, style: '',
131 help: '', disabled: false }
132 ]
133 });
134
135 // Add the 2 second delay to the underlying editor widget.
136 null_choice_edit.plug({fn:DelayedSavePlugin});
137
138 null_choice_edit.render();
139 })
140
141 </script>
142
143 <link type="text/css" rel="stylesheet"
144 href="../../lib/lazr/build/overlay/assets/pretty-overlay-core.css">
145 <link type="text/css" rel="stylesheet"
146 href="../../lib/lazr/build/overlay/assets/skins/sam/pretty-overlay-skin.css">
147 <link type="text/css" rel="stylesheet"
148 href="../../lib/lazr/build/choiceedit/assets/choiceedit-core.css">
149</head>26</head>
150<body class="yui-skin-sam">27<body class="yui-skin-sam">
15128
@@ -159,15 +36,15 @@
15936
160<h2>Required include dependencies</h2>37<h2>Required include dependencies</h2>
161<pre>38<pre>
162 &lt;script type=&quot;text/javascript&quot; src=&quot;../../lib/yui/3.0.0pr2/build/yui/yui.js&quot;&gt;&lt;/script&gt;39 &lt;script type=&quot;text/javascript&quot; src=&quot;../../build/yui/current/build/yui/yui.js&quot;&gt;&lt;/script&gt;
163 &lt;script type=&quot;text/javascript&quot; src=&quot;../../lib/lazr/build/choiceedit/choiceedit.js&quot;&gt;&lt;/script&gt;40 &lt;script type=&quot;text/javascript&quot; src=&quot;../../build/choiceedit/choiceedit.js&quot;&gt;&lt;/script&gt;
164 &lt;script type=&quot;text/javascript&quot; src=&quot;../../lib/lazr/build/anim/anim.js&quot;&gt;&lt;/script&gt;41 &lt;script type=&quot;text/javascript&quot; src=&quot;../../build/anim/anim.js&quot;&gt;&lt;/script&gt;
16542
166 &lt;!-- overlay required files --&gt;43 &lt;!-- overlay required files --&gt;
167 &lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;../../lib/lazr/build/overlay/assets/pretty-overlay-core.css&quot;&gt;&lt;/link&gt;44 &lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;../../build/overlay/assets/pretty-overlay-core.css&quot;&gt;&lt;/link&gt;
168 &lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;../../lib/lazr/build/overlay/assets/skins/sam/pretty-overlay-skin.css&quot;&gt;&lt;/link&gt;45 &lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;../../build/overlay/assets/skins/sam/pretty-overlay-skin.css&quot;&gt;&lt;/link&gt;
169 &lt;!-- choiceedit required files --&gt;46 &lt;!-- choiceedit required files --&gt;
170 &lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;../../lib/lazr/build/choiceedit/assets/choiceedit-core.css&quot;&gt;&lt;/link&gt;47 &lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;../../build/choiceedit/assets/choiceedit-core.css&quot;&gt;&lt;/link&gt;
17148
172</pre>49</pre>
17350
@@ -297,5 +174,131 @@
297&lt;/p>174&lt;/p>
298</pre>175</pre>
299176
177 <script>
178 YUI({
179 base: '../../build/yui/current/build/',
180 filter: 'raw'
181 }).use('node', 'event', 'widget', 'plugin', 'overlay', 'lazr.choiceedit', function(Y) {
182
183 // Add a delay between the start and end of the inline editor widget's
184 // "save" event.
185 var DelayedSavePlugin = function(config) {
186 DelayedSavePlugin.superclass.constructor.apply(this, arguments);
187 };
188
189 DelayedSavePlugin.NAME = 'delayedsave';
190 DelayedSavePlugin.NS = 'fx';
191
192 DelayedSavePlugin.ATTRS = {
193 /*
194 * Default duration of the 'saving' delay, in milliseconds.
195 */
196 duration: {
197 value: 2000
198 }
199 };
200
201 Y.extend(DelayedSavePlugin, Y.Plugin.Base, {
202
203 initializer: function(config) {
204 // Save a reference to the original _saveData() method before
205 // we wrap it up.
206 this.original_save = config.host._saveData;
207
208 // We want to run our delayed-save code before the original
209 // 'save' method. Using doBefore() means that unplugging our
210 // code will leave the original widget in a clean state.
211 this.doBefore("_saveData", this._altSave);
212 },
213
214 destructor: function() {},
215
216 /*
217 * Our own _altSave() method, used to override the host's default
218 * behaviour. This method will only be called if the editor's input
219 * is valid.
220 */
221 _altSave: function() {
222 var host = this.get('host'),
223 delay = this.get('duration');
224
225 Y.log("Running alternative _saveData()", 'info');
226
227 // Set the UI 'waiting' status.
228 host._uiSetWaiting();
229
230 // Introduce a configurable delay around the host's _saveData()
231 // method.
232 Y.later(delay, this, function() {
233
234 Y.log("Running original 'save' method.", 'info');
235 this.original_save.apply(host, arguments);
236
237 // Make sure we clear the 'waiting' status.
238 host._uiClearWaiting();
239
240 }, arguments);
241
242 // Make sure we prevent the default _devSave() method from
243 // running.
244 return new Y.Do.Halt();
245 }
246 });
247
248
249 var choice_edit = new Y.ChoiceSource({
250 contentBox: '#status',
251 value: 'incomplete',
252 title: 'Change status to',
253 items: [
254 { name: 'New', value: 'new', style: '',
255 help: '', disabled: false },
256 { name: 'Invalid', value: 'invalid', style: '',
257 help: '', disabled: true },
258 { name: 'Incomplete', value: 'incomplete', style: '',
259 help: '', disabled: false },
260 { name: 'Fix Released', value: 'fixreleased', style: '',
261 help: '', disabled: false },
262 { name: 'Fix Committed', value: 'fixcommitted', style: '',
263 help: '', disabled: true },
264 { name: 'In Progress', value: 'inprogress', style: '',
265 help: '', disabled: false }
266 ]
267 });
268
269 // Add the 2 second delay to the underlying editor widget.
270 choice_edit.plug({fn:DelayedSavePlugin});
271
272 choice_edit.render();
273
274
275 var null_choice_edit = new Y.NullChoiceSource({
276 contentBox: '#nullchoiceedit',
277 value: null,
278 title: 'Choose something',
279 items: [
280 { name: 'Chico', value: 'chico', style: '',
281 help: '', disabled: false },
282 { name: 'Harpo', value: 'harpo', style: '',
283 help: '', disabled: false },
284 { name: 'Groucho', value: 'groucho', style: '',
285 help: '', disabled: false },
286 { name: 'Gummo', value: 'gummo', style: '',
287 help: '', disabled: false },
288 { name: 'Zeppo', value: 'zeppo', style: '',
289 help: '', disabled: false },
290 { name: 'Not funny!', value: null, style: '',
291 help: '', disabled: false }
292 ]
293 });
294
295 // Add the 2 second delay to the underlying editor widget.
296 null_choice_edit.plug({fn:DelayedSavePlugin});
297
298 null_choice_edit.render();
299 })
300
301 </script>
302
300</body>303</body>
301</html>304</html>
302305
=== modified file 'examples/effects/index.html'
--- examples/effects/index.html 2009-07-21 02:14:12 +0000
+++ examples/effects/index.html 2009-10-30 17:01:13 +0000
@@ -4,21 +4,21 @@
4<head>4<head>
5 <title>Lazr-js examples: lazr.effects</title>5 <title>Lazr-js examples: lazr.effects</title>
66
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>
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>
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>
1010
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>
12 <script type="text/javascript" src="../../lib/lazr/build/lazr.js"></script>12 <script type="text/javascript" src="../../build/lazr.js"></script>
13 <script type="text/javascript" src="../../lib/lazr/build/effects/effects.js"></script>13 <script type="text/javascript" src="../../build/effects/effects.js"></script>
1414
15 <!--15 <!--
16 We need to include individual css files because some of them have16 We need to include individual css files because some of them have
17 relative paths to images.17 relative paths to images.
18 -->18 -->
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>
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>
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>
2222
23 <style type="text/css">23 <style type="text/css">
24 .example {24 .example {
@@ -192,7 +192,7 @@
192<script type="text/javascript">192<script type="text/javascript">
193193
194YUI({194YUI({
195 base: '../../lib/yui/current/build/',195 base: '../../build/yui/current/build/',
196 filter: 'raw'196 filter: 'raw'
197 }).use('node', 'event', 'lazr.effects', function(Y) {197 }).use('node', 'event', 'lazr.effects', function(Y) {
198198
199199
=== modified file 'examples/formoverlay/index.html'
--- examples/formoverlay/index.html 2009-05-15 07:38:48 +0000
+++ examples/formoverlay/index.html 2009-10-30 17:01:13 +0000
@@ -5,21 +5,22 @@
5 <title>LAZR JS Examples: lazr.formoverlay</title>5 <title>LAZR JS Examples: lazr.formoverlay</title>
6 <meta http-equiv="content-type" content="text/html;charset=utf-8" />6 <meta http-equiv="content-type" content="text/html;charset=utf-8" />
77
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>
9 <script type="text/javascript" src="../../lib/lazr/build/overlay/overlay.js"></script>9 <script type="text/javascript" src="../../build/lazr/lazr.js"></script>
10 <script type="text/javascript" src="../../lib/lazr/build/formoverlay/formoverlay.js"></script>10 <script type="text/javascript" src="../../build/overlay/overlay.js"></script>
11 <script type="text/javascript" src="../../build/formoverlay/formoverlay.js"></script>
1112
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"/>
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"/>
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"/>
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"/>
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"/>
17 <link rel="stylesheet" href="../../lib/lazr/build/formoverlay/assets/formoverlay.css"/>18 <link rel="stylesheet" href="../../build/formoverlay/assets/formoverlay.css"/>
1819
19 <script type="text/javascript">20 <script type="text/javascript">
2021
21YUI({22YUI({
22 base: "../../lib/yui/3.0.0pr2/build/",23 base: "../../build/yui/current/build/",
23 filter: 'raw',24 filter: 'raw',
24}).use('lazr.formoverlay', 'node', 'event', 'dump', function(Y) {25}).use('lazr.formoverlay', 'node', 'event', 'dump', function(Y) {
2526
@@ -93,7 +94,9 @@
93 });94 });
94 formoverlay.render();95 formoverlay.render();
9596
96 Y.on("domready", function(){ formoverlay.show()});97 Y.on("domready", function(){
98 formoverlay.show();
99 });
97100
98 Y.on('click', function(e) {101 Y.on('click', function(e) {
99 Y.log("Showing overlay", "info");102 Y.log("Showing overlay", "info");
@@ -123,16 +126,16 @@
123126
124 <h3>Javascript</h3>127 <h3>Javascript</h3>
125 <pre>128 <pre>
126 &lt;script type=&quot;text/javascript&quot; src=&quot;../../lib/yui/3.0.0pr2/build/yui/yui.js&quot;&gt;&lt;/script&gt;129 &lt;script type=&quot;text/javascript&quot; src=&quot;../../build/yui/current/build/yui/yui.js&quot;&gt;&lt;/script&gt;
127 &lt;script type=&quot;text/javascript&quot; src=&quot;../../lib/lazr/build/overlay/overlay.js&quot;&gt;&lt;/script&gt;130 &lt;script type=&quot;text/javascript&quot; src=&quot;../../build/overlay/overlay.js&quot;&gt;&lt;/script&gt;
128 &lt;script type=&quot;text/javascript&quot; src=&quot;../../lib/lazr/build/formoverlay/formoverlay.js&quot;&gt;&lt;/script&gt;131 &lt;script type=&quot;text/javascript&quot; src=&quot;../../build/formoverlay/formoverlay.js&quot;&gt;&lt;/script&gt;
129 </pre>132 </pre>
130133
131 <h3>CSS</h3>134 <h3>CSS</h3>
132 <pre>135 <pre>
133 &lt;link rel=&quot;stylesheet&quot; href=&quot;../../lib/lazr/build/overlay/assets/pretty-overlay-core.css&quot; /&gt;136 &lt;link rel=&quot;stylesheet&quot; href=&quot;../../build/overlay/assets/pretty-overlay-core.css&quot; /&gt;
134 &lt;link rel=&quot;stylesheet&quot; href=&quot;../../lib/lazr/build/overlay/assets/skins/sam/pretty-overlay-skin.css&quot; /&gt;137 &lt;link rel=&quot;stylesheet&quot; href=&quot;../../build/overlay/assets/skins/sam/pretty-overlay-skin.css&quot; /&gt;
135 &lt;link rel=&quot;stylesheet&quot; href=&quot;../../lib/lazr/build/formoverlay/assets/formoverlay.css&quot; /&gt;138 &lt;link rel=&quot;stylesheet&quot; href=&quot;../../build/formoverlay/assets/formoverlay.css&quot; /&gt;
136 </pre>139 </pre>
137140
138 <h2>Widget Setup</h2>141 <h2>Widget Setup</h2>
139142
=== modified file 'examples/inlineeditor/index.html'
--- examples/inlineeditor/index.html 2009-10-22 02:04:44 +0000
+++ examples/inlineeditor/index.html 2009-10-30 17:01:13 +0000
@@ -3,117 +3,19 @@
3<html>3<html>
4<head>4<head>
5 <title>Lazr-js examples: In-line text editing</title>5 <title>Lazr-js examples: In-line text editing</title>
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>
7 <script type="text/javascript" src="../../lib/lazr/build/lazr.js"></script>7 <script type="text/javascript" src="../../build/lazr/lazr.js"></script>
8 <script type="text/javascript" src="../../lib/lazr/build/inlineedit/editor.js"></script>8 <script type="text/javascript" src="../../build/anim/anim.js"></script>
9 <script type="text/javascript">9 <script type="text/javascript" src="../../build/inlineedit/editor.js"></script>
10
11YUI({
12 base: '../../lib/yui/3.0.0pr2/build/',
13 filter: 'raw'
14 }).use('node', 'event', 'plugin', 'lazr.editor', function(Y) {
15
16 // Add a delay between the start and end of the inline editor widget's
17 // "save" event.
18 var DelayedSavePlugin = function(config) {
19 DelayedSavePlugin.superclass.constructor.apply(this, arguments);
20 };
21
22 DelayedSavePlugin.NAME = 'delayedsave';
23 DelayedSavePlugin.NS = 'fx';
24
25 DelayedSavePlugin.ATTRS = {
26 /*
27 * Default duration of the 'saving' delay, in milliseconds.
28 */
29 duration: {
30 value: 2000
31 }
32 };
33
34 Y.extend(DelayedSavePlugin, Y.Plugin, {
35
36 initializer: function(config) {
37 // Save a reference to the original _saveData() method before
38 // we wrap it up.
39 this.original_save = config.owner._saveData;
40
41 // We want to run our delayed-save code before the original
42 // 'save' method. Using doBefore() means that unplugging our
43 // code will leave the original widget in a clean state.
44 this.doBefore("_saveData", this._altSave);
45 },
46
47 destructor: function() {},
48
49 /*
50 * Our own _altSave() method, used to override the owner's default
51 * behaviour. This method will only be called if the editor's input
52 * is valid.
53 */
54 _altSave: function() {
55 var owner = this._owner,
56 delay = this.get('duration');
57
58 Y.log("Running alternative _saveData()", 'info');
59
60 // Set the UI 'waiting' status.
61 owner._uiSetWaiting();
62
63 // Introduce a configurable delay around the owner's _saveData()
64 // method.
65 Y.later(delay, this, function() {
66
67 Y.log("Running original 'save' method.", 'info');
68 this.original_save.apply(owner, arguments[0]);
69
70 // Make sure we clear the 'waiting' status.
71 owner._uiClearWaiting();
72
73 }, arguments);
74
75 // Make sure we prevent the default _devSave() method from
76 // running.
77 return new Y.Do.Halt();
78 }
79 });
80
81 var editable_text = new Y.EditableText({
82 contentBox: '#editable_text'
83 });
84
85 editable_text.render();
86
87 // Add the 2 second delay to the underlying editor widget.
88 editable_text.editor.plug({fn:DelayedSavePlugin});
89
90 // Hook up the "allow empty" button.
91 Y.on('click', function(ev) {
92 var accept_empty = !editor.get('accept_empty');
93 Y.log("Allowing empty editor input: " + accept_empty, 'info');
94 editor.set('accept_empty', accept_empty);
95 }, 'input[name=accept_empty]');
96
97 var multiline_text = new Y.EditableText({
98 contentBox: '#edit-test-description',
99 multiline: true,
100 buttons: 'top'
101 });
102 multiline_text.render();
103
104 // Add the 2 second delay to the underlying editor widget.
105 multiline_text.editor.plug({fn:DelayedSavePlugin});
106});
107 </script>
10810
109 <!--11 <!--
110 We need to include individual css files because some of them have12 We need to include individual css files because some of them have
111 relative paths to images.13 relative paths to images.
112 -->14 -->
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>
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>
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>
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" />
117 <style>19 <style>
118 #example {20 #example {
119 margin-left: 20px;21 margin-left: 20px;
@@ -163,11 +65,11 @@
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>
16466
165<pre>67<pre>
166 &lt;script type=&quot;text/javascript&quot; src=&quot;../../lib/yui/3.0.0pr2/build/yui/yui.js&quot;&gt;&lt;/script&gt;68 &lt;script type=&quot;text/javascript&quot; src=&quot;../../build/yui/3.0.0pr2/build/yui/yui.js&quot;&gt;&lt;/script&gt;
167 &lt;script type=&quot;text/javascript&quot; src=&quot;../../lib/lazr/build/inlineedit/editor.js&quot;&gt;&lt;/script&gt;69 &lt;script type=&quot;text/javascript&quot; src=&quot;../../build/inlineedit/editor.js&quot;&gt;&lt;/script&gt;
168 &lt;script type=&quot;text/javascript&quot; src=&quot;../../lib/lazr/build/anim/anim.js&quot;&gt;&lt;/script&gt;70 &lt;script type=&quot;text/javascript&quot; src=&quot;../../build/anim/anim.js&quot;&gt;&lt;/script&gt;
16971
170 &lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;../../lib/lazr/build/inlineedit/assets/skins/sam/editor.css&quot;&gt;&lt;/link&gt;72 &lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;../../build/inlineedit/assets/skins/sam/editor.css&quot;&gt;&lt;/link&gt;
171</pre>73</pre>
17274
173<pre>75<pre>
@@ -425,5 +327,106 @@
425 </li>327 </li>
426</ul>328</ul>
427329
330 <script type="text/javascript">
331
332YUI({
333 base: '../../build/yui/current/build/',
334 filter: 'raw'
335 }).use('node', 'event', 'plugin', 'lazr.editor', function(Y) {
336
337 // Add a delay between the start and end of the inline editor widget's
338 // "save" event.
339 var DelayedSavePlugin = function(config) {
340 DelayedSavePlugin.superclass.constructor.apply(this, arguments);
341 };
342
343 DelayedSavePlugin.NAME = 'delayedsave';
344 DelayedSavePlugin.NS = 'fx';
345
346 DelayedSavePlugin.ATTRS = {
347 /*
348 * Default duration of the 'saving' delay, in milliseconds.
349 */
350 duration: {
351 value: 2000
352 }
353 };
354
355 Y.extend(DelayedSavePlugin, Y.Plugin.Base, {
356
357 initializer: function(config) {
358 // Save a reference to the original _saveData() method before
359 // we wrap it up.
360 this.original_save = config.host._saveData;
361
362 // We want to run our delayed-save code before the original
363 // 'save' method. Using doBefore() means that unplugging our
364 // code will leave the original widget in a clean state.
365 this.doBefore("_saveData", this._altSave);
366 },
367
368 destructor: function() {},
369
370 /*
371 * Our own _altSave() method, used to override the host's default
372 * behaviour. This method will only be called if the editor's input
373 * is valid.
374 */
375 _altSave: function() {
376 var host = this.get('host'),
377 delay = this.get('duration');
378
379 Y.log("Running alternative _saveData()", 'info');
380
381 // Set the UI 'waiting' status.
382 host._uiSetWaiting();
383
384 // Introduce a configurable delay around the host's _saveData()
385 // method.
386 Y.later(delay, this, function() {
387
388 Y.log("Running original 'save' method.", 'info');
389 this.original_save.apply(host, arguments);
390
391 // Make sure we clear the 'waiting' status.
392 host._uiClearWaiting();
393
394 }, arguments);
395
396 // Make sure we prevent the default _devSave() method from
397 // running.
398 return new Y.Do.Halt();
399 }
400 });
401
402 var editable_text = new Y.EditableText({
403 contentBox: '#editable_text'
404 });
405
406 editable_text.render();
407
408 // Add the 2 second delay to the underlying editor widget.
409 editable_text.editor.plug({fn:DelayedSavePlugin});
410
411 // Hook up the "allow empty" button.
412 Y.on('click', function(ev) {
413 var accept_empty = !editable_text.get('accept_empty');
414 Y.log("Allowing empty editor input: " + accept_empty, 'info');
415 editable_text.set('accept_empty', accept_empty);
416 }, 'input[name=accept_empty]');
417
418 var multiline_text = new Y.EditableText({
419 contentBox: '#edit-test-description',
420 multiline: true,
421 buttons: 'top',
422 });
423 multiline_text.render();
424
425 // Add the 2 second delay to the underlying editor widget.
426 multiline_text.editor.plug({fn:DelayedSavePlugin});
427
428});
429 </script>
430
428</body>431</body>
429</html>432</html>
430433
=== modified file 'examples/lazr/index.html'
--- examples/lazr/index.html 2009-03-05 01:50:43 +0000
+++ examples/lazr/index.html 2009-10-30 17:01:13 +0000
@@ -5,13 +5,13 @@
5 <title>LAZR JS Examples: lazr.base</title>5 <title>LAZR JS Examples: lazr.base</title>
6 <meta http-equiv="content-type" content="text/html;charset=utf-8" />6 <meta http-equiv="content-type" content="text/html;charset=utf-8" />
77
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>
9 <script type="text/javascript" src="../../build/lazr/lazr.js"></script>9 <script type="text/javascript" src="../../build/lazr/lazr.js"></script>
1010
11 <script type="text/javascript">11 <script type="text/javascript">
1212
13YUI({13YUI({
14 base: "../../lib/yui/current/build/",14 base: "../../build/yui/current/build/",
15 filter: 'raw',15 filter: 'raw',
16}).use('node', 'lazr.base', function(Y) {16}).use('node', 'lazr.base', function(Y) {
1717
@@ -72,7 +72,7 @@
72<p>The common usage:</p>72<p>The common usage:</p>
7373
74<pre>74<pre>
75 &lt;script type=&quot;text/javascript&quot; src=&quot;../../lib/yui/current/build/yui/yui.js&quot;&gt;&lt;/script&gt;75 &lt;script type=&quot;text/javascript&quot; src=&quot;../../build/yui/current/build/yui/yui.js&quot;&gt;&lt;/script&gt;
76 &lt;script type=&quot;text/javascript&quot; src=&quot;../../build/lazr/lazr.js&quot;&gt;&lt;/script&gt;76 &lt;script type=&quot;text/javascript&quot; src=&quot;../../build/lazr/lazr.js&quot;&gt;&lt;/script&gt;
77 &lt;script type=&quot;text/javascript&quot; src=&quot;../../build/lazr/assets/skins/sam/lazr-skin.css&quot;&gt;&lt;/script&gt;77 &lt;script type=&quot;text/javascript&quot; src=&quot;../../build/lazr/assets/skins/sam/lazr-skin.css&quot;&gt;&lt;/script&gt;
78</pre>78</pre>
7979
=== modified file 'examples/overlay/index.html'
--- examples/overlay/index.html 2009-02-21 18:21:14 +0000
+++ examples/overlay/index.html 2009-10-30 17:01:13 +0000
@@ -5,12 +5,12 @@
5 <title>LAZR JS Examples: lazr.overlay</title>5 <title>LAZR JS Examples: lazr.overlay</title>
6 <meta http-equiv="content-type" content="text/html;charset=utf-8" />6 <meta http-equiv="content-type" content="text/html;charset=utf-8" />
77
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>
9 <script type="text/javascript" src="../../build/overlay/overlay.js"></script>9 <script type="text/javascript" src="../../build/overlay/overlay.js"></script>
1010
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" />
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" />
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" />
1414
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" />
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" />
@@ -109,7 +109,7 @@
109109
110<script type="text/javascript">110<script type="text/javascript">
111YUI({111YUI({
112 base: '../../lib/yui/current/build/',112 base: '../../build/yui/current/build/',
113 filter: "raw",113 filter: "raw",
114 combine: false114 combine: false
115}).use('lazr.overlay', function(Y) {115}).use('lazr.overlay', function(Y) {
116116
=== modified file 'examples/picker/index.html'
--- examples/picker/index.html 2009-05-07 16:27:01 +0000
+++ examples/picker/index.html 2009-10-30 17:01:13 +0000
@@ -3,7 +3,7 @@
3<html>3<html>
4<head>4<head>
5 <title>Lazr-js examples: Picker widget</title>5 <title>Lazr-js examples: Picker widget</title>
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>
7 <script type="text/javascript" src="../../build/anim/anim.js"></script>7 <script type="text/javascript" src="../../build/anim/anim.js"></script>
8 <script type="text/javascript" src="../../build/lazr/lazr.js"></script>8 <script type="text/javascript" src="../../build/lazr/lazr.js"></script>
9 <script type="text/javascript" src="../../build/overlay/overlay.js"></script>9 <script type="text/javascript" src="../../build/overlay/overlay.js"></script>
@@ -12,7 +12,7 @@
12 <script type="text/javascript">12 <script type="text/javascript">
1313
14YUI({14YUI({
15 base: '../../lib/yui/current/build/',15 base: '../../build/yui/current/build/',
16 filter: 'raw'16 filter: 'raw'
17 }).use('lazr.picker', 'dump', function(Y) {17 }).use('lazr.picker', 'dump', function(Y) {
18 // Parse the content of the textarea in the data structure18 // Parse the content of the textarea in the data structure
@@ -160,9 +160,9 @@
160});160});
161 </script>161 </script>
162162
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" />
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" />
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" />
166166
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" />
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" />
169169
=== modified file 'setup.py'
--- setup.py 2009-10-28 19:04:25 +0000
+++ setup.py 2009-10-30 17:01:13 +0000
@@ -26,6 +26,7 @@
26 license='GPL v3',26 license='GPL v3',
27 install_requires=[27 install_requires=[
28 'bzr',28 'bzr',
29 'lazr.testing',
29 'setuptools',30 'setuptools',
30 ],31 ],
31 url='https://launchpad.net/lazr-js',32 url='https://launchpad.net/lazr-js',
3233
=== modified file 'src-js/lazrjs/activator/tests/activator.html'
--- src-js/lazrjs/activator/tests/activator.html 2009-03-13 15:54:02 +0000
+++ src-js/lazrjs/activator/tests/activator.html 2009-10-30 17:01:13 +0000
@@ -5,30 +5,24 @@
5 <title>Activator</title>5 <title>Activator</title>
66
7 <!-- YUI 3.0 Setup -->7 <!-- YUI 3.0 Setup -->
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>
9 <link rel="stylesheet" href="../../../lib/yui/current/build/cssreset/reset.css"/>9 <link rel="stylesheet" href="../../yui/current/build/cssreset/reset.css"/>
10 <link rel="stylesheet" href="../../../lib/yui/current/build/cssfonts/fonts.css"/>10 <link rel="stylesheet" href="../../yui/current/build/cssfonts/fonts.css"/>
11 <link rel="stylesheet" href="../../../lib/yui/current/build/cssbase/base.css"/>11 <link rel="stylesheet" href="../../yui/current/build/cssbase/base.css"/>
1212
13 <!-- The module under test -->13 <!-- The module under test -->
14 <script type="text/javascript" src="../../../build/activator/activator.js"></script>14 <script type="text/javascript" src="../../activator/activator.js"></script>
15 <script type="text/javascript" src="../../../build/anim/anim.js"></script>15 <script type="text/javascript" src="../../anim/anim.js"></script>
16 <script type="text/javascript" src="../../../build/lazr/lazr.js"></script>16 <script type="text/javascript" src="../../lazr/lazr.js"></script>
17 <script type="text/javascript" src="../../testing/testing.js"></script>
1718
18 <!-- The test suite -->19 <!-- The test suite -->
19 <script type="text/javascript" src="activator.js"></script>20 <script type="text/javascript" src="activator.js"></script>
2021
21 <link rel="stylesheet" href="../../../src/testing/assets/testlogger.css"/>22 <link rel="stylesheet" href="../../testing/assets/testlogger.css"/>
22</head>23</head>
23<body class="yui-skin-sam">24<body class="yui-skin-sam">
2425
25<div id="workspace"
26 style="border: 1px solid blue;
27 width: 20em;
28 margin: 1em;
29 padding: 1em">
30</div>
31
32<div id="log"></div>26<div id="log"></div>
33</body>27</body>
34</html>28</html>
3529
=== modified file 'src-js/lazrjs/activator/tests/activator.js'
--- src-js/lazrjs/activator/tests/activator.js 2009-04-22 02:42:02 +0000
+++ src-js/lazrjs/activator/tests/activator.js 2009-10-30 17:01:13 +0000
@@ -1,10 +1,11 @@
1/* Copyright (c) 2009, Canonical Ltd. All rights reserved. */1/* Copyright (c) 2009, Canonical Ltd. All rights reserved. */
22
3YUI({3YUI({
4 base: '../../../lib/yui/current/build/',4 base: '../../yui/current/build/',
5 filter: 'raw',5 filter: 'raw',
6 combine: false6 combine: false
7 }).use('lazr.activator', 'node', 'event', 'yuitest', 'console', function(Y) {7 }).use('lazr.activator', 'lazr.testing.runner', 'node',
8 'event', 'event-simulate', 'console', function(Y) {
89
9var Assert = Y.Assert; // For easy access to isTrue(), etc.10var Assert = Y.Assert; // For easy access to isTrue(), etc.
1011
@@ -37,6 +38,16 @@
3738
38 setUp: function() {39 setUp: function() {
39 this.workspace = Y.get('#workspace');40 this.workspace = Y.get('#workspace');
41 if (!this.workspace){
42 Y.get(document.body).appendChild(Y.Node.create(
43 '<div id="workspace" ' +
44 'style="border: 1px solid blue; ' +
45 'width: 20em; ' +
46 'margin: 1em; ' +
47 'padding: 1em">'+
48 '</div>'));
49 this.workspace = Y.get('#workspace');
50 }
40 this.workspace.appendChild(Y.Node.create(51 this.workspace.appendChild(Y.Node.create(
41 '<div id="example-1">' +52 '<div id="example-1">' +
42 '<span class="yui-activator-data-box">' +53 '<span class="yui-activator-data-box">' +
@@ -233,15 +244,7 @@
233 }244 }
234}));245}));
235246
236Y.Test.Runner.add(suite);247Y.lazr.testing.Runner.add(suite);
237248Y.lazr.testing.Runner.run();
238var yconsole = new Y.Console({
239 newestOnTop: false
240});
241yconsole.render('#log');
242
243Y.on('domready', function() {
244 Y.Test.Runner.run();
245});
246249
247});250});
248251
=== modified file 'src-js/lazrjs/autocomplete/autocomplete.js'
--- src-js/lazrjs/autocomplete/autocomplete.js 2009-07-16 19:35:57 +0000
+++ src-js/lazrjs/autocomplete/autocomplete.js 2009-10-30 17:01:14 +0000
@@ -1,19 +1,4 @@
1/*1/* Copyright (c) 2009, Canonical Ltd. All rights reserved. */
2 Copyright (c) 2009, Canonical Ltd. All rights reserved.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Affero General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Affero General Public License for more details.
13
14 You should have received a copy of the GNU Affero General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
172
18YUI.add('lazr.autocomplete', function(Y) {3YUI.add('lazr.autocomplete', function(Y) {
194
@@ -51,7 +36,7 @@
5136
52// We need a base class on which to build our autocomplete widget, so we will37// We need a base class on which to build our autocomplete widget, so we will
53// make that class capable of positioning itself, too.38// make that class capable of positioning itself, too.
54var AutoCompleteBase = Y.Base.build(Y.Widget, [Y.WidgetStack]);39var AutoCompleteBase = Y.Base.build("AutoCompleteBase", Y.Widget, [Y.WidgetStack]);
5540
5641
57/**42/**
@@ -119,7 +104,7 @@
119 */104 */
120 input: {105 input: {
121 value: null,106 value: null,
122 set: function(val) {107 setter: function(val) {
123 return this._setInput(val);108 return this._setInput(val);
124 }109 }
125 },110 },
@@ -254,6 +239,8 @@
254239
255 var cbox = this.get(CONTENT_BOX);240 var cbox = this.get(CONTENT_BOX);
256241
242 this.get(BOUNDING_BOX).unplug(Y.Plugin.NodeMenuNav);
243
257 if (this._completions) {244 if (this._completions) {
258 cbox.replaceChild(list, this._completions);245 cbox.replaceChild(list, this._completions);
259 } else {246 } else {
@@ -261,7 +248,7 @@
261 }248 }
262249
263 // Re-plug the MenuNav, so it updates the menu options.250 // Re-plug the MenuNav, so it updates the menu options.
264 this.get(BOUNDING_BOX).plug(Y.plugin.NodeMenuNav);251 this.get(BOUNDING_BOX).plug(Y.Plugin.NodeMenuNav);
265252
266 // Highlight the first item.253 // Highlight the first item.
267 this._selectItem(0, false);254 this._selectItem(0, false);
@@ -601,7 +588,7 @@
601 // It is ugly to have to check protected members of the menu588 // It is ugly to have to check protected members of the menu
602 // like this, but the 'currently selected item' should589 // like this, but the 'currently selected item' should
603 // really be public, don't you think?590 // really be public, don't you think?
604 var menu = this.get(BOUNDING_BOX).MenuNav;591 var menu = this.get(BOUNDING_BOX).menuNav;
605 if (menu) {592 if (menu) {
606 return menu._activeItem ? menu._activeItem : null;593 return menu._activeItem ? menu._activeItem : null;
607 }594 }
@@ -620,11 +607,12 @@
620 * be found.607 * be found.
621 */608 */
622 _selectItem: function(index, set_focus) {609 _selectItem: function(index, set_focus) {
623 var menu = this.get(BOUNDING_BOX).MenuNav;610 var menu = this.get(BOUNDING_BOX).menuNav;
624611
625 // More ugliness, looking at protected object members that should612 // More ugliness, looking at protected object members that should
626 // be made public.613 // be made public.
627 var item = menu ? menu._firstItem : null;614 var firstItem = menu._rootMenu.all('.yui-menuitem').item(0)
615 var item = menu ? firstItem : null;
628 if (!menu || !item) {616 if (!menu || !item) {
629 return null;617 return null;
630 }618 }
@@ -636,11 +624,14 @@
636 }624 }
637 }625 }
638626
639 menu._setActiveItem(item);
640 if (set_focus) {627 if (set_focus) {
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)
642 // don't like focusing non-anchor things.629 // don't like focusing non-anchor things.
643 var anchor = item.query('a');630 var anchor = item.query('a');
631
632 menu._focusManager.set("activeDescendant", anchor);
633 menu._focusItem(item);
634
644 if (anchor) {635 if (anchor) {
645 // Use a 5ms timer to give the browser rendering engine some636 // Use a 5ms timer to give the browser rendering engine some
646 // time to catch up to the JS call, and prevent a race637 // time to catch up to the JS call, and prevent a race
@@ -648,6 +639,7 @@
648 Y.later(5, anchor, anchor.focus);639 Y.later(5, anchor, anchor.focus);
649 }640 }
650 }641 }
642 menu._setActiveItem(item);
651 return item;643 return item;
652 },644 },
653645
@@ -722,7 +714,7 @@
722 },714 },
723715
724 /**716 /**
725 * Handle presses of keys like Tab ane Enter717 * Handle presses of keys like Tab and Enter
726 *718 *
727 * @method _onInputKeydown719 * @method _onInputKeydown
728 * @protected720 * @protected
@@ -797,11 +789,4 @@
797};789};
798790
799791
800}, null, {792}, '0.1', {requires:['oop', 'base', 'event', 'widget', 'widget-stack', 'node-menunav']});
801 requires:[
802 'oop',
803 'base',
804 'widget',
805 'widget-stack',
806 'node-menunav'
807]});
808793
=== renamed file 'src-js/lazrjs/autocomplete/tests/test.js' => 'src-js/lazrjs/autocomplete/tests/autocomplete.js'
--- src-js/lazrjs/autocomplete/tests/test.js 2009-03-27 04:38:14 +0000
+++ src-js/lazrjs/autocomplete/tests/autocomplete.js 2009-10-30 17:01:14 +0000
@@ -1,33 +1,17 @@
1/*1/* Copyright (c) 2009, Canonical Ltd. All rights reserved. */
2 Copyright (c) 2009, Canonical Ltd. All rights reserved.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Affero General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Affero General Public License for more details.
13
14 You should have received a copy of the GNU Affero General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
172
18YUI({3YUI({
19 base: '../../../lib/yui/current/build/',4 base: '../../yui/current/build/',
20 filter: 'raw',5 filter: 'raw',
21 combine: false6 combine: false
22 }).use('lazr.autocomplete', 'node', 'event', 'yuitest', 'console', function(Y) {7 }).use('lazr.autocomplete', 'lazr.testing.runner',
238 'node', 'event', 'console', function(Y) {
249
25/*****************************10/*****************************
26 *11 *
27 * Helper methods and aliases12 * Helper methods and aliases
28 *13 *
29 */14 */
30
31var Assert = Y.Assert;15var Assert = Y.Assert;
3216
33/* Helper function to clean up a dynamically added widget instance. */17/* Helper function to clean up a dynamically added widget instance. */
@@ -584,16 +568,7 @@
584 }568 }
585}));569}));
586570
587571Y.lazr.testing.Runner.add(suite);
588Y.Test.Runner.add(suite);572Y.lazr.testing.Runner.run();
589
590var yconsole = new Y.Console({
591 newestOnTop: false
592});
593yconsole.render('#log');
594
595Y.on('domready', function() {
596 Y.Test.Runner.run();
597});
598573
599});574});
600575
=== modified file 'src-js/lazrjs/autocomplete/tests/index.html'
--- src-js/lazrjs/autocomplete/tests/index.html 2009-03-18 00:42:42 +0000
+++ src-js/lazrjs/autocomplete/tests/index.html 2009-10-30 17:01:14 +0000
@@ -5,18 +5,19 @@
5 <title>autocomplete unit tests</title>5 <title>autocomplete unit tests</title>
66
7 <!-- YUI 3.0 Setup -->7 <!-- YUI 3.0 Setup -->
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>
9 <link rel="stylesheet" href="../../../lib/yui/current/build/cssreset/reset.css"/>9 <link rel="stylesheet" href="../../yui/current/build/cssreset/reset.css"/>
10 <link rel="stylesheet" href="../../../lib/yui/current/build/cssfonts/fonts.css"/>10 <link rel="stylesheet" href="../../yui/current/build/cssfonts/fonts.css"/>
11 <link rel="stylesheet" href="../../../lib/yui/current/build/cssbase/base.css"/>11 <link rel="stylesheet" href="../../yui/current/build/cssbase/base.css"/>
1212
13 <link rel="stylesheet" href="../../../src/testing/assets/testlogger.css"/>13 <link rel="stylesheet" href="../../testing/assets/testlogger.css"/>
14 <script type="text/javascript" src="../../testing/testing.js"></script>
1415
15 <!-- The module under test -->16 <!-- The module under test -->
16 <script type="text/javascript" src="../autocomplete.js"></script>17 <script type="text/javascript" src="../autocomplete.js"></script>
1718
18 <!-- The test suite -->19 <!-- The test suite -->
19 <script type="text/javascript" src="test.js"></script>20 <script type="text/javascript" src="autocomplete.js"></script>
2021
21</head>22</head>
22<body class="yui-skin-sam">23<body class="yui-skin-sam">
2324
=== modified file 'src-js/lazrjs/choiceedit/choiceedit.js'
--- src-js/lazrjs/choiceedit/choiceedit.js 2009-08-21 14:06:19 +0000
+++ src-js/lazrjs/choiceedit/choiceedit.js 2009-10-30 17:01:14 +0000
@@ -20,6 +20,9 @@
20 C_ADDICON = 'addicon',20 C_ADDICON = 'addicon',
21 SAVE = 'save',21 SAVE = 'save',
22 LEFT_MOUSE_BUTTON = 1,22 LEFT_MOUSE_BUTTON = 1,
23 RENDERUI = "renderUI",
24 BINDUI = "bindUI",
25 SYNCUI = "syncUI",
23 NOTHING = new Object();26 NOTHING = new Object();
2427
25/**28/**
@@ -33,6 +36,8 @@
3336
34var ChoiceSource = function() {37var ChoiceSource = function() {
35 ChoiceSource.superclass.constructor.apply(this, arguments);38 ChoiceSource.superclass.constructor.apply(this, arguments);
39 Y.after(this._bindUIChoiceSource, this, BINDUI);
40 Y.after(this._syncUIChoiceSource, this, SYNCUI);
36};41};
3742
38ChoiceSource.NAME = CHOICESOURCE;43ChoiceSource.NAME = CHOICESOURCE;
@@ -94,7 +99,7 @@
94 */99 */
95 value_location: {100 value_location: {
96 value: null,101 value: null,
97 set: function(v) {102 setter: function(v) {
98 return Y.get(v);103 return Y.get(v);
99 }104 }
100 },105 },
@@ -110,7 +115,7 @@
110 */115 */
111 editicon: {116 editicon: {
112 value: null,117 value: null,
113 set: function(v) {118 setter: function(v) {
114 return Y.get(v);119 return Y.get(v);
115 }120 }
116 },121 },
@@ -123,14 +128,14 @@
123 * @type Node128 * @type Node
124 */129 */
125 actionicon: {130 actionicon: {
126 get: function() {131 getter: function() {
127 return this.get('editicon');132 return this.get('editicon');
128 }133 }
129 },134 },
130135
131 elementToFlash: {136 elementToFlash: {
132 value: null,137 value: null,
133 set: function(v) {138 setter: function(v) {
134 return Y.get(v);139 return Y.get(v);
135 }140 }
136 },141 },
@@ -138,7 +143,7 @@
138 backgroundColor: {143 backgroundColor: {
139 value: null144 value: null
140 },145 },
141 146
142 clickable_content: {147 clickable_content: {
143 value: true148 value: true
144 }149 }
@@ -160,10 +165,15 @@
160165
161 /**166 /**
162 * bind UI events167 * bind UI events
168 * <p>
169 * This method is invoked after bindUI is invoked for the Widget class
170 * using YUI's aop infrastructure.
171 * </p>
163 *172 *
164 * @method bindUI173 * @method _bindUIChoiceSource
174 * @protected
165 */175 */
166 bindUI: function() {176 _bindUIChoiceSource: function() {
167 var that = this;177 var that = this;
168 if (this.get('clickable_content')) {178 if (this.get('clickable_content')) {
169 var clickable_element = this.get('contentBox');179 var clickable_element = this.get('contentBox');
@@ -188,10 +198,15 @@
188198
189 /**199 /**
190 * Update in-page HTML with current value of the field200 * Update in-page HTML with current value of the field
201 * <p>
202 * This method is invoked after syncUI is invoked for the Widget class
203 * using YUI's aop infrastructure.
204 * </p>
191 *205 *
192 * @method syncUI206 * @method _syncUIChoiceSource
207 * @protected
193 */208 */
194 syncUI: function() {209 _syncUIChoiceSource: function() {
195 var items = this.get("items");210 var items = this.get("items");
196 var value = this.get("value");211 var value = this.get("value");
197 var node = this.get("value_location");212 var node = this.get("value_location");
@@ -411,14 +426,21 @@
411 */426 */
412 this.publish("valueChosen");427 this.publish("valueChosen");
413 this.after("renderedChange", this._positionCorrectly);428 this.after("renderedChange", this._positionCorrectly);
429 Y.after(this._renderUIChoiceList, this, RENDERUI);
430 Y.after(this._bindUIChoiceList, this, BINDUI);
414 },431 },
415432
416 /**433 /**
417 * Render the popup menu434 * Render the popup menu
435 * <p>
436 * This method is invoked after renderUI is invoked for the Widget class
437 * using YUI's aop infrastructure.
438 * </p>
418 *439 *
419 * @method renderUI440 * @method _renderUIChoiceList
441 * @protected
420 */442 */
421 renderUI: function() {443 _renderUIChoiceList: function() {
422 this.set("align", {444 this.set("align", {
423 node: this.get("value_location"),445 node: this.get("value_location"),
424 points:[Y.WidgetPositionExt.TL, Y.WidgetPositionExt.TL]446 points:[Y.WidgetPositionExt.TL, Y.WidgetPositionExt.TL]
@@ -448,26 +470,26 @@
448 }470 }
449 display_items_list.appendChild(li);471 display_items_list.appendChild(li);
450 }472 }
451 this.set("bodyContent", display_items_list);473
474 this.setStdModContent(Y.WidgetStdMod.BODY, display_items_list, Y.WidgetStdMod.REPLACE);
452 this.move(-10000, 0);475 this.move(-10000, 0);
453 },476 },
454477
455 /**478 /**
456 * Bind UI events479 * Bind UI events
480 * <p>
481 * This method is invoked after bindUI is invoked for the Widget class
482 * using YUI's aop infrastructure.
483 * </p>
457 *484 *
458 * @method bindUI485 * @method _bindUIChoiceList
486 * @protected
459 */487 */
460 bindUI: function() {488 _bindUIChoiceList: function() {
461 // We need to call the superclass's bindUI because it does things.
462 ChoiceList.superclass.bindUI.apply(this);
463
464 var display_items_list = this.get("display_items_list");489 var display_items_list = this.get("display_items_list");
465 var that = this;490 var that = this;
466 display_items_list.on("click", function(e) {491 Y.delegate("click", function(e) {
467 var target = e.target;492 var target = e.currentTarget;
468 while (target.get("nodeName").toLowerCase() != "a") {
469 target = target.get("parentNode");
470 }
471 var value = target._value;493 var value = target._value;
472 var items = that.get("items");494 var items = that.get("items");
473 for (var i=0; i<items.length; i++) {495 for (var i=0; i<items.length; i++) {
@@ -478,7 +500,7 @@
478 break;500 break;
479 }501 }
480 }502 }
481 });503 }, display_items_list, "li a");
482 },504 },
483505
484 /**506 /**
@@ -581,7 +603,7 @@
581 * @attribute actionicon603 * @attribute actionicon
582 */604 */
583 actionicon: {605 actionicon: {
584 get: function() {606 getter: function() {
585 if (Y.Lang.isValue(this.get('value'))) {607 if (Y.Lang.isValue(this.get('value'))) {
586 return this.get('editicon');608 return this.get('editicon');
587 } else {609 } else {
@@ -598,7 +620,7 @@
598 */620 */
599 items: {621 items: {
600 value: [],622 value: [],
601 get: function(v) {623 getter: function(v) {
602 if (!Y.Lang.isValue(this.get("value"))) {624 if (!Y.Lang.isValue(this.get("value"))) {
603 v = Y.Array(v).filter(function(item) {625 v = Y.Array(v).filter(function(item) {
604 return (Y.Lang.isValue(item.value));626 return (Y.Lang.isValue(item.value));
@@ -619,7 +641,7 @@
619 }641 }
620 return v;642 return v;
621 },643 },
622 clone : Y.Attribute.CLONE.DEEP644 clone : "deep"
623 }645 }
624}646}
625647
@@ -647,6 +669,7 @@
647669
648Y.NullChoiceSource = NullChoiceSource;670Y.NullChoiceSource = NullChoiceSource;
649671
650},'0.2', {requires:672},'0.2', {requires: ['oop', 'event', 'event-delegate', 'node',
651 ['oop', 'event', 'node', 'widget', 'overlay', 'lazr.overlay', 'lazr.anim', 'lazr.base']});673 'widget', 'widget-stdmod', 'overlay',
674 'lazr.overlay', 'lazr.anim', 'lazr.base']});
652675
653676
=== modified file 'src-js/lazrjs/choiceedit/tests/choiceedit.html'
--- src-js/lazrjs/choiceedit/tests/choiceedit.html 2009-02-20 14:15:34 +0000
+++ src-js/lazrjs/choiceedit/tests/choiceedit.html 2009-10-30 17:01:14 +0000
@@ -4,17 +4,19 @@
4 <title>Status Editor</title>4 <title>Status Editor</title>
55
6 <!-- YUI 3.0 Setup -->6 <!-- YUI 3.0 Setup -->
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>
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"/>
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"/>
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"/>
1111
12 <!-- Dependency -->12 <!-- Dependency -->
13 <script type="text/javascript" src="../../../lib/lazr/build/lazr.js"></script>13 <script type="text/javascript" src="../../lazr/lazr.js"></script>
14 <script type="text/javascript" src="../../../lib/lazr/build/overlay/overlay.js"></script>14 <script type="text/javascript" src="../../anim/anim.js"></script>
15 <script type="text/javascript" src="../../testing/testing.js"></script>
16 <script type="text/javascript" src="../../overlay/overlay.js"></script>
1517
16 <!-- The module under test -->18 <!-- The module under test -->
17 <script type="text/javascript" src="../../../lib/lazr/build/choiceedit/choiceedit.js"></script>19 <script type="text/javascript" src="../../choiceedit/choiceedit.js"></script>
1820
19 <!-- The test suite -->21 <!-- The test suite -->
20 <script type="text/javascript" src="choiceedit.js"></script>22 <script type="text/javascript" src="choiceedit.js"></script>
2123
=== modified file 'src-js/lazrjs/choiceedit/tests/choiceedit.js'
--- src-js/lazrjs/choiceedit/tests/choiceedit.js 2009-08-21 14:06:19 +0000
+++ src-js/lazrjs/choiceedit/tests/choiceedit.js 2009-10-30 17:01:14 +0000
@@ -1,10 +1,11 @@
1/* Copyright (c) 2008, Canonical Ltd. All rights reserved. */1/* Copyright (c) 2008, Canonical Ltd. All rights reserved. */
22
3YUI({3YUI({
4 base: '../../../lib/yui/current/build/',4 base: '../../yui/current/build/',
5 filter: 'raw',5 filter: 'raw',
6 combine: false6 combine: false
7 }).use('lazr.choiceedit', 'node', 'event', 'yuitest', 'widget-stack', 'console', function(Y) {7 }).use('lazr.choiceedit', 'lazr.testing.runner', 'node',
8 'event', 'widget-stack', 'console', function(Y) {
89
9// Local aliases10// Local aliases
10var Assert = Y.Assert,11var Assert = Y.Assert,
@@ -525,15 +526,7 @@
525 }526 }
526}));527}));
527528
528Y.Test.Runner.add(suite);529Y.lazr.testing.Runner.add(suite);
529530Y.lazr.testing.Runner.run();
530var yconsole = new Y.Console({
531 newestOnTop: false
532});
533yconsole.render('#log');
534
535Y.on('domready', function() {
536 Y.Test.Runner.run();
537});
538531
539});532});
540533
=== modified file 'src-js/lazrjs/formoverlay/formoverlay.js'
--- src-js/lazrjs/formoverlay/formoverlay.js 2009-08-13 13:08:36 +0000
+++ src-js/lazrjs/formoverlay/formoverlay.js 2009-10-30 17:01:14 +0000
@@ -8,6 +8,13 @@
8 * @module lazr.formoverlay8 * @module lazr.formoverlay
9 */9 */
1010
11
12var getCN = Y.ClassNameManager.getClassName,
13 NAME = 'lazr-formoverlay',
14 CONTENT_BOX = 'contentBox',
15 RENDERUI = "renderUI",
16 BINDUI = "bindUI";
17
11 /**18 /**
12 * The FormOverlay class builds on the lazr.PrettyOverlay class19 * The FormOverlay class builds on the lazr.PrettyOverlay class
13 * to display form content and extract form data for the callsite.20 * to display form content and extract form data for the callsite.
@@ -17,11 +24,12 @@
17 */24 */
18function FormOverlay(config) {25function FormOverlay(config) {
19 FormOverlay.superclass.constructor.apply(this, arguments);26 FormOverlay.superclass.constructor.apply(this, arguments);
27
28 Y.after(this._renderUIFormOverlay, this, RENDERUI);
29 Y.after(this._bindUIFormOverlay, this, BINDUI);
30
20}31}
2132
22var getCN = Y.ClassNameManager.getClassName;
23var NAME = 'lazr-formoverlay';
24
25FormOverlay.NAME = NAME;33FormOverlay.NAME = NAME;
2634
27/**35/**
@@ -184,16 +192,19 @@
184192
185 /**193 /**
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.
195 * <p>
196 * This method is invoked after renderUI is invoked for the Widget class
197 * using YUI's aop infrastructure.
198 * </p>
187 *199 *
188 * @method renderUI200 * @method _renderUIFormOverlay
201 * @protected
189 */202 */
190 renderUI: function(){203 _renderUIFormOverlay: function(){
191 FormOverlay.superclass.renderUI.apply(this);
192
193 // Create a node that will contain the form header:204 // Create a node that will contain the form header:
194 this.form_header_node = Y.Node.create(205 this.form_header_node = Y.Node.create(
195 FormOverlay.FORM_HEADER_TEMPLATE);206 FormOverlay.FORM_HEADER_TEMPLATE);
196 207
197 // Create a form node that will contain the form content:208 // Create a form node that will contain the form content:
198 this.form_node = Y.Node.create(FormOverlay.FORM_TEMPLATE);209 this.form_node = Y.Node.create(FormOverlay.FORM_TEMPLATE);
199210
@@ -216,51 +227,43 @@
216 this.error_node = Y.Node.create(FormOverlay.ERROR_TEMPLATE);227 this.error_node = Y.Node.create(FormOverlay.ERROR_TEMPLATE);
217228
218 this._setFormContent();229 this._setFormContent();
219
220 },230 },
221231
222 /**232 /**
223 * Bind the submit button to the _onFormSubmit() method.233 * Bind the submit button to the _onFormSubmit() method.
234 * <p>
235 * This method is invoked after bindUI is invoked for the Widget class
236 * using YUI's aop infrastructure.
237 * </p>
224 *238 *
225 * @method bindUI239 * @method bindUI
240 * @protected
226 */241 */
227 bindUI: function(){242 _bindUIFormOverlay: function(){
228 this.constructor.superclass.bindUI.call(this);243 Y.on("submit",
229244 Y.bind(this._onFormSubmit, this),
230 Y.on(245 this.form_node);
231 "submit",
232 Y.bind(this._onFormSubmit, this),
233 this.form_node);
234246
235 // Setup the cancel button to hide the formoverlay.247 // Setup the cancel button to hide the formoverlay.
236 Y.on(248 Y.on("click",
237 "click",249 Y.bind(function(e){ this.hide();}, this),
238 Y.bind(function(e){ this.hide();}, this),250 this.get("form_cancel_button"));
239 this.get("form_cancel_button"));251
240 },252 this.on("visibleChange", function(e) {
241253 // If the 'centered' configuration attribute is set to true,
242 /**254 // then we should always re-center relative to the current
243 * Show the widget by setting the "visible" attribute to "true".255 // viewport when shown:
244 *256 if (e.newVal) {
245 * Overridden here to ensure that the focus is given to the first257 if (this.get('centered')){
246 * input element whenever the FormOverlay is shown.258 this.centered();
247 *259 }
248 * @method show260
249 */261 var form_elem = Y.Node.getDOMNode(this.form_node);
250 show: function(){262 if (form_elem.elements.length > 0) {
251 // If the 'centered' configuration attribute is set to true,263 Y.get(form_elem.elements[0]).focus();
252 // then we should always re-center relative to the current264 }
253 // viewport when shown:265 }
254 if (this.get('centered')){266 });
255 this.centered();
256 }
257
258 this.constructor.superclass.show.call(this);
259
260 var form_elem = Y.Node.getDOMNode(this.form_node);
261 if (form_elem.elements.length > 0) {
262 form_elem.elements[0].focus();
263 }
264 },267 },
265268
266 /**269 /**
@@ -274,6 +277,7 @@
274 this.form_header_node.set('innerHTML',277 this.form_header_node.set('innerHTML',
275 this.get('form_header'));278 this.get('form_header'));
276279
280
277 // Add the form content to the form node.281 // Add the form content to the form node.
278 // The form_content can be a string of HTML (as is useful when282 // The form_content can be a string of HTML (as is useful when
279 // it is obtained via AJAX) or a form node (as is useful if the283 // it is obtained via AJAX) or a form node (as is useful if the
@@ -300,7 +304,7 @@
300 body_node.appendChild(this.form_header_node);304 body_node.appendChild(this.form_header_node);
301 body_node.appendChild(this.form_node);305 body_node.appendChild(this.form_node);
302306
303 this.set("bodyContent", body_node);307 this.setStdModContent(Y.WidgetStdMod.BODY, body_node, Y.WidgetStdMod.REPLACE);
304 },308 },
305309
306 /**310 /**
307311
=== modified file 'src-js/lazrjs/formoverlay/tests/formoverlay.html'
--- src-js/lazrjs/formoverlay/tests/formoverlay.html 2009-08-13 08:54:56 +0000
+++ src-js/lazrjs/formoverlay/tests/formoverlay.html 2009-10-30 17:01:14 +0000
@@ -4,50 +4,26 @@
4 <title>Form Overlay</title>4 <title>Form Overlay</title>
55
6 <!-- YUI 3.0 Setup -->6 <!-- YUI 3.0 Setup -->
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>
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"/>
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"/>
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"/>
11 <link rel="stylesheet" href="../../testing/assets/testlogger.css"/>
1112
12 <!-- dependent modules from lazr-->13 <!-- dependent modules from lazr-->
13 <script type="text/javascript" src="../../../lib/lazr/build/lazr/lazr.js"></script>14 <script type="text/javascript" src="../../lazr/lazr.js"></script>
14 <script type="text/javascript" src="../../../lib/lazr/build/overlay/overlay.js"></script>15 <script type="text/javascript" src="../../overlay/overlay.js"></script>
16 <script type="text/javascript" src="../../testing/testing.js"></script>
1517
16 <!-- The module under test -->18 <!-- The module under test -->
17 <script type="text/javascript" src="../../../lib/lazr/build/formoverlay/formoverlay.js"></script>19 <script type="text/javascript" src="../../formoverlay/formoverlay.js"></script>
1820
19 <!-- Testing helpers -->21 <!-- Testing helpers -->
20 <script type="text/javascript" src="../../../lib/lazr/build/testing/mockio.js"></script>22 <script type="text/javascript" src="../../testing/mockio.js"></script>
2123
22 <!-- The test suite -->24 <!-- The test suite -->
23 <script type="text/javascript" src="formoverlay.js"></script>25 <script type="text/javascript" src="formoverlay.js"></script>
2426
25 <style>
26 /* Taken and customized from testlogger.css */
27 #log .yui-console-content { width:44em }
28 #log .yui-console .yui-console-bd { height:30em }
29 #log .yui-console .yui-console-controls { display:none; }
30 #log .yui-console .yui-console-hd { display:none; }
31 #log .yui-console .yui-console-ft { position:absolute;top:0em; }
32
33 #log .yui-console-entry-src { display:none; }
34
35 #log .yui-console-entry-pass .yui-console-entry-cat {
36 background-color: green;
37 font-weight: bold;
38 color: white;
39 }
40 #log .yui-console-entry-fail .yui-console-entry-cat {
41 background-color: red;
42 font-weight: bold;
43 color: white;
44 }
45 #log .yui-console-entry-ignore .yui-console-entry-cat {
46 background-color: #666;
47 font-weight: bold;
48 color: white;
49 }
50 </style>
51</head>27</head>
52<body class="yui-skin-sam">28<body class="yui-skin-sam">
53 <div id="form_overlay_example">29 <div id="form_overlay_example">
5430
=== modified file 'src-js/lazrjs/formoverlay/tests/formoverlay.js'
--- src-js/lazrjs/formoverlay/tests/formoverlay.js 2009-08-13 13:08:36 +0000
+++ src-js/lazrjs/formoverlay/tests/formoverlay.js 2009-10-30 17:01:14 +0000
@@ -1,11 +1,12 @@
1/* Copyright (c) 2008, Canonical Ltd. All rights reserved. */1/* Copyright (c) 2008, Canonical Ltd. All rights reserved. */
22
3YUI({3YUI({
4 base: '../../../lib/yui/3.0.0pr2/build/',4 base: '../../yui/current/build/',
5 filter: 'raw',5 filter: 'raw',
6 combine: false6 combine: false
7 }).use('lazr.formoverlay', 'lazr.testing', 'node', 'event', 'yuitest',7 }).use('lazr.formoverlay', 'lazr.testing.runner',
8 'dump', 'console', function(Y) {8 'lazr.testing.mockio', 'node', 'event', 'dump',
9 'console', function(Y) {
910
10var Assert = Y.Assert; // For easy access to isTrue(), etc.11var Assert = Y.Assert; // For easy access to isTrue(), etc.
1112
@@ -19,6 +20,17 @@
19 Y.Event.simulate(rawnode, evtype, options);20 Y.Event.simulate(rawnode, evtype, options);
20}21}
2122
23/* Helper function to cleanup and destroy a form overlay instance */
24function cleanup_form_overlay(form_overlay) {
25 if (form_overlay.get('rendered')) {
26 var bb = form_overlay.get('boundingBox');
27 bb.get('parentNode').removeChild(bb);
28 }
29
30 // Kill the widget itself.
31 form_overlay.destroy();
32}
33
22/* Helper function that creates a new form overlay instance. */34/* Helper function that creates a new form overlay instance. */
23function make_form_overlay(cfg) {35function make_form_overlay(cfg) {
24 var form_overlay = new Y.lazr.FormOverlay(cfg);36 var form_overlay = new Y.lazr.FormOverlay(cfg);
@@ -44,21 +56,14 @@
44 });56 });
4557
46 // Ensure window size is constant for tests58 // Ensure window size is constant for tests
47 window.resizeTo(800, 600);59 this.width = window.top.outerWidth;
60 this.height = window.top.outerHeight;
61 window.top.resizeTo(800, 600);
48 },62 },
4963
50 tearDown: function() {64 tearDown: function() {
51 this.cleanUp(this.form_overlay);65 window.top.resizeTo(this.width, this.height);
52 },66 cleanup_form_overlay(this.form_overlay);
53
54 cleanUp: function(form_overlay) {
55 if (form_overlay.get('rendered')) {
56 var bb = form_overlay.get('boundingBox');
57 bb.get('parentNode').removeChild(bb);
58 }
59
60 // Kill the widget itself.
61 form_overlay.destroy();
62 },67 },
6368
64 test_form_overlay_can_be_instantiated: function() {69 test_form_overlay_can_be_instantiated: function() {
@@ -67,45 +72,36 @@
67 Y.lazr.FormOverlay,72 Y.lazr.FormOverlay,
68 overlay,73 overlay,
69 "Form overlay could not be instantiated.");74 "Form overlay could not be instantiated.");
70 },75 cleanup_form_overlay(overlay);
7176 },
72 // This fails because YUI adds an extra div for some reason.77
73 // If and when this is fixed, and this passes, we'll need to78 test_body_content_is_single_node: function() {
74 // update test_form_content_in_bodyContent below.
75 _should: {
76 fail: {test_bodyContent_is_single_node: true}
77 },
78
79 test_bodyContent_is_single_node: function() {
80 Assert.areEqual(79 Assert.areEqual(
81 1,80 1,
82 this.form_overlay.get("bodyContent").size(),81 this.form_overlay.getStdModNode("body").size(),
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.");
84 },83 },
8584
86 test_form_content_in_bodyContent: function() {85 test_form_content_in_body_content: function() {
87 // The form_content should be included in the bodyContent of the86 // The form_content should be included in the body of the
88 // overlay during initialization.87 // overlay during initialization.
89 var body_content = this.form_overlay.get("bodyContent");88 var body_content = this.form_overlay.getStdModNode("body");
9089
91 // Ensure the body_content contains our form node.90 // Ensure the body_content contains our form node.
92 // Note: see failing test_bodyContent_is_single_node above for why
93 // an index is used here.
94 Assert.isTrue(91 Assert.isTrue(
95 body_content.contains(this.form_overlay.form_node)[1],92 body_content.contains(this.form_overlay.form_node),
96 "The form node is part of the body content.");93 "The form node is part of the body content.");
9794
98 // And then make sure that the user-supplied form_content is95 // And then make sure that the user-supplied form_content is
99 // included in the form node:96 // included in the form node:
100 Assert.areNotEqual(97 Assert.areNotEqual(
101 body_content.get("innerHTML")[1].search(98 body_content.get("innerHTML").search(
102 this.form_overlay.get("form_content")));99 this.form_overlay.get("form_content")));
103 },100 },
104101
105 test_first_input_has_focus: function() {102 test_first_input_has_focus: function() {
106 // The first input element in the form content should have103 // The first input element in the form content should have
107 // focus.104 // focus.
108
109 var first_input = this.form_overlay.form_node.query('#field1');105 var first_input = this.form_overlay.form_node.query('#field1');
110106
111 // Hide the overlay and ensure that the first input does not107 // Hide the overlay and ensure that the first input does not
@@ -125,26 +121,23 @@
125 });121 });
126 };122 };
127123
128 Y.on('focus', onFocus, first_input);124 first_input.on('focus', onFocus);
129125
130 this.form_overlay.show();126 this.form_overlay.show();
131127
132 this.wait(5000);128 this.wait(5000);
133 },129 },
134130
135 test_form_submit_in_bodyContent: function() {131 test_form_submit_in_body_content: function() {
136 // The bodyContent should include the submit button.132 // The body content should include the submit button.
137133 var body_content = this.form_overlay.getStdModNode("body");
138 var body_content = this.form_overlay.get("bodyContent");
139 // Note: see failing test_bodyContent_is_single_node above for why
140 // an index is used here.
141 Assert.isTrue(134 Assert.isTrue(
142 body_content.contains(135 body_content.contains(
143 this.form_overlay.get("form_submit_button"))[1],136 this.form_overlay.get("form_submit_button")),
144 "The bodyContent includes the form_submit_button.");137 "The body content includes the form_submit_button.");
145 },138 },
146139
147 test_users_submit_button_in_bodyContent: function() {140 test_users_submit_button_in_body_content: function() {
148 // If a user supplies a custom submit button, it should be included141 // If a user supplies a custom submit button, it should be included
149 // in the form instead of the default one.142 // in the form instead of the default one.
150 var submit_button = Y.Node.create(143 var submit_button = Y.Node.create(
@@ -161,22 +154,19 @@
161 form_overlay.form_node.contains(submit_button),154 form_overlay.form_node.contains(submit_button),
162 "The form should include the users submit button.");155 "The form should include the users submit button.");
163156
164 this.cleanUp(form_overlay);157 cleanup_form_overlay(form_overlay);
165 },158 },
166159
167 test_form_cancel_in_bodyContent: function() {160 test_form_cancel_in_body_content: function() {
168 // The bodyContent should include the cancel button.161 // The body content should include the cancel button.
169162 var body_content = this.form_overlay.getStdModNode("body");
170 var body_content = this.form_overlay.get("bodyContent");
171 // Note: see failing test_bodyContent_is_single_node above for why
172 // an index is used here.
173 Assert.isTrue(163 Assert.isTrue(
174 body_content.contains(164 body_content.contains(
175 this.form_overlay.get("form_cancel_button"))[1],165 this.form_overlay.get("form_cancel_button")),
176 "The bodyContent includes the form_cancel_button.");166 "The body content includes the form_cancel_button.");
177 },167 },
178168
179 test_users_cancel_button_in_bodyContent: function() {169 test_users_cancel_button_in_body_content: function() {
180 // If a user supplies a custom cancel button, it should be included170 // If a user supplies a custom cancel button, it should be included
181 // in the form instead of the default one.171 // in the form instead of the default one.
182 var cancel_button = Y.Node.create(172 var cancel_button = Y.Node.create(
@@ -193,7 +183,7 @@
193 form_overlay.form_node.contains(cancel_button),183 form_overlay.form_node.contains(cancel_button),
194 "The form should include the users cancel button.");184 "The form should include the users cancel button.");
195185
196 this.cleanUp(form_overlay);186 cleanup_form_overlay(form_overlay);
197 },187 },
198188
199 test_hide_when_cancel_clicked: function() {189 test_hide_when_cancel_clicked: function() {
@@ -219,11 +209,9 @@
219209
220 this.form_overlay.showError("My special error");210 this.form_overlay.showError("My special error");
221211
222 var body_content = this.form_overlay.get("bodyContent");212 var body_content = this.form_overlay.getStdModNode("body");
223 // Note: see failing test_bodyContent_is_single_node above for why
224 // an index is used here.
225 Assert.areNotEqual(213 Assert.areNotEqual(
226 body_content.get("innerHTML")[1].search("My special error"),214 body_content.get("innerHTML").search("My special error"),
227 -1,215 -1,
228 "The error text was included in the body content.");216 "The error text was included in the body content.");
229 },217 },
@@ -234,12 +222,10 @@
234 // chars. Not sure what to do about unicode, for eg.222 // chars. Not sure what to do about unicode, for eg.
235 this.form_overlay.showError("<h2>My special error</h2>");223 this.form_overlay.showError("<h2>My special error</h2>");
236224
237 var body_content = this.form_overlay.get("bodyContent");225 var body_content = this.form_overlay.getStdModNode("body");
238 // Note: see failing test_bodyContent_is_single_node above for why
239 // an index is used here.
240 Assert.areEqual(226 Assert.areEqual(
241 -1,227 -1,
242 body_content.get("innerHTML")[1].search("<h2>"),228 body_content.get("innerHTML").search("<h2>"),
243 "The tags were stripped from the error message.");229 "The tags were stripped from the error message.");
244 },230 },
245231
@@ -247,9 +233,9 @@
247 // The error message should be cleared from the body content.233 // The error message should be cleared from the body content.
248 this.form_overlay.showError("My special error");234 this.form_overlay.showError("My special error");
249 this.form_overlay.clearError();235 this.form_overlay.clearError();
250 var body_content = this.form_overlay.get("bodyContent");236 var body_content = this.form_overlay.getStdModNode("body");
251 Assert.areEqual(237 Assert.areEqual(
252 body_content.get("innerHTML")[1].search("My special error"),238 body_content.get("innerHTML").search("My special error"),
253 -1,239 -1,
254 "The error text is cleared from the body content.");240 "The error text is cleared from the body content.");
255 },241 },
@@ -272,7 +258,7 @@
272 this.form_overlay.hide();258 this.form_overlay.hide();
273259
274 // The position is updated after resizing the window and re-showing:260 // The position is updated after resizing the window and re-showing:
275 window.resizeTo(850, 550);261 window.top.resizeTo(850, 550);
276 this.form_overlay.show();262 this.form_overlay.show();
277 Assert.areNotEqual(263 Assert.areNotEqual(
278 Y.dump(centered_pos_before_resize),264 Y.dump(centered_pos_before_resize),
@@ -305,6 +291,7 @@
305 Assert.isTrue(291 Assert.isTrue(
306 callback_called,292 callback_called,
307 "The form_submit_callback should be called.");293 "The form_submit_callback should be called.");
294 cleanup_form_overlay(form_overlay);
308 },295 },
309296
310 test_submit_with_callback_prevents_propagation: function() {297 test_submit_with_callback_prevents_propagation: function() {
@@ -334,6 +321,7 @@
334 Assert.isFalse(321 Assert.isFalse(
335 event_was_propagated,322 event_was_propagated,
336 "The onsubmit event should not be propagated.");323 "The onsubmit event should not be propagated.");
324 cleanup_form_overlay(form_overlay);
337 }, 3000);325 }, 3000);
338 },326 },
339327
@@ -352,6 +340,8 @@
352 Assert.isTrue(event_was_propagated,340 Assert.isTrue(event_was_propagated,
353 "The normal form submission event is propagated as " +341 "The normal form submission event is propagated as " +
354 "normal when no callback is provided.");342 "normal when no callback is provided.");
343 cleanup_form_overlay(form_overlay);
344
355 });345 });
356 e.preventDefault();346 e.preventDefault();
357 };347 };
@@ -382,6 +372,7 @@
382 '{field1 => [val1], field2 => [val2], field3 => [val3]}',372 '{field1 => [val1], field2 => [val2], field3 => [val3]}',
383 Y.dump(form_overlay.getFormData()),373 Y.dump(form_overlay.getFormData()),
384 "The getFormData method returns simple input data correctly.");374 "The getFormData method returns simple input data correctly.");
375 cleanup_form_overlay(form_overlay);
385 },376 },
386377
387 test_getFormData_returns_inputs_nested_several_levels: function() {378 test_getFormData_returns_inputs_nested_several_levels: function() {
@@ -406,6 +397,7 @@
406 '{field1 => [val1], field2 => [val2], field3 => [val3]}',397 '{field1 => [val1], field2 => [val2], field3 => [val3]}',
407 Y.dump(form_overlay.getFormData()),398 Y.dump(form_overlay.getFormData()),
408 "The getFormData method returns simple input data correctly.");399 "The getFormData method returns simple input data correctly.");
400 cleanup_form_overlay(form_overlay);
409401
410 },402 },
411403
@@ -425,6 +417,7 @@
425 Assert.isTrue(417 Assert.isTrue(
426 form_overlay.form_node.contains(input_node),418 form_overlay.form_node.contains(input_node),
427 "Failed to pass the form content as a Y.Node instance.");419 "Failed to pass the form content as a Y.Node instance.");
420 cleanup_form_overlay(form_overlay);
428 },421 },
429422
430 test_form_content_loaded_from_url_success: function() {423 test_form_content_loaded_from_url_success: function() {
@@ -455,6 +448,7 @@
455 Assert.areEqual(448 Assert.areEqual(
456 external_form_content, form_node_text.match(external_form_content),449 external_form_content, form_node_text.match(external_form_content),
457 "Failed to render the form.");450 "Failed to render the form.");
451 cleanup_form_overlay(form_overlay);
458 },452 },
459453
460 test_form_content_loaded_from_url_failure: function() {454 test_form_content_loaded_from_url_failure: function() {
@@ -482,6 +476,7 @@
482 Assert.areEqual(476 Assert.areEqual(
483 error_message, form_node_text.match(error_message),477 error_message, form_node_text.match(error_message),
484 "Failed to render the error message.");478 "Failed to render the error message.");
479 cleanup_form_overlay(form_overlay);
485 },480 },
486481
487 test_form_content_loaded_from_url_bind_submit: function() {482 test_form_content_loaded_from_url_bind_submit: function() {
@@ -511,18 +506,11 @@
511 "input[type=submit]",506 "input[type=submit]",
512 'click');507 'click');
513 Assert.isTrue(callback_called, "Submit button didn't get hooked up.");508 Assert.isTrue(callback_called, "Submit button didn't get hooked up.");
509 cleanup_form_overlay(form_overlay);
514 }510 }
515}));511}));
516512
517Y.Test.Runner.add(suite);513Y.lazr.testing.Runner.add(suite);
518514Y.lazr.testing.Runner.run();
519var yconsole = new Y.Console({
520 newestOnTop: false
521});
522yconsole.render('#log');
523
524Y.on('domready', function() {
525 Y.Test.Runner.run();
526});
527515
528});516});
529517
=== modified file 'src-js/lazrjs/inlineedit/editor.js'
--- src-js/lazrjs/inlineedit/editor.js 2009-10-28 19:04:25 +0000
+++ src-js/lazrjs/inlineedit/editor.js 2009-10-30 17:01:14 +0000
@@ -158,7 +158,7 @@
158 */158 */
159 submit_button: {159 submit_button: {
160 value: null,160 value: null,
161 set: function(v) { return this._setNode(v); }161 setter: function(v) { return this._setNode(v); }
162 },162 },
163163
164 /**164 /**
@@ -170,7 +170,7 @@
170 */170 */
171 cancel_button: {171 cancel_button: {
172 value: null,172 value: null,
173 set: function(v) { return this._setNode(v); }173 setter: function(v) { return this._setNode(v); }
174 },174 },
175175
176 /**176 /**
@@ -182,7 +182,7 @@
182 */182 */
183 top_buttons: {183 top_buttons: {
184 value: null,184 value: null,
185 set: function(v) { return this._setNode(v); }185 setter: function(v) { return this._setNode(v); }
186 },186 },
187187
188 /**188 /**
@@ -194,7 +194,7 @@
194 */194 */
195 bottom_buttons: {195 bottom_buttons: {
196 value: null,196 value: null,
197 set: function(v) { return this._setNode(v); }197 setter: function(v) { return this._setNode(v); }
198 },198 },
199199
200 /**200 /**
@@ -205,7 +205,7 @@
205 */205 */
206 error_message: {206 error_message: {
207 value: null,207 value: null,
208 set: function(v) { return this._setNode(v); }208 setter: function(v) { return this._setNode(v); }
209 },209 },
210210
211 /**211 /**
@@ -283,23 +283,6 @@
283Y.extend(InlineEditor, Y.Widget, {283Y.extend(InlineEditor, Y.Widget, {
284284
285 /**285 /**
286 * An extra button box at the top, shown only in multi-line mode.
287 *
288 * @property top_buttons
289 * @type Node
290 */
291 top_buttons: null,
292
293 /**
294 * A reference to the button-box html element in single-line mode, and
295 * the bottom button box in multi-line mode.
296 *
297 * @property buttons
298 * @type Node
299 */
300 buttons: null,
301
302 /**
303 * A convenience method for retrieving a Node value from a Node286 * A convenience method for retrieving a Node value from a Node
304 * instance, an HTMLElement, or a CSS string selector.287 * instance, an HTMLElement, or a CSS string selector.
305 *288 *
@@ -337,7 +320,6 @@
337 * @method save320 * @method save
338 */321 */
339 save: function() {322 save: function() {
340
341 // We don't want to save any whitespace characters.323 // We don't want to save any whitespace characters.
342 var input = Y.Lang.trim(this.getInput());324 var input = Y.Lang.trim(this.getInput());
343325
@@ -1045,7 +1027,7 @@
1045 * @type Node1027 * @type Node
1046 */1028 */
1047 trigger: {1029 trigger: {
1048 set: function(node) {1030 setter: function(node) {
1049 if (this.get(RENDERED)) {1031 if (this.get(RENDERED)) {
1050 this._bindTrigger(node);1032 this._bindTrigger(node);
1051 }1033 }
@@ -1061,7 +1043,7 @@
1061 * @type Node1043 * @type Node
1062 */1044 */
1063 text: {1045 text: {
1064 set: function(v) {1046 setter: function(v) {
1065 return Y.Node.get(v);1047 return Y.Node.get(v);
1066 },1048 },
1067 validator: function(v) {1049 validator: function(v) {
@@ -1081,10 +1063,10 @@
1081 * @readOnly1063 * @readOnly
1082 */1064 */
1083 value: {1065 value: {
1084 get: function() {1066 getter: function() {
1085 var text_node = this.get(TEXT);1067 var text_node = this.get(TEXT);
1086 var ptags = text_node.queryAll('p');1068 var ptags = text_node.queryAll('p');
1087 if (Y.Lang.isValue(ptags)) {1069 if (Y.Lang.isValue(ptags) && ptags.size()) {
1088 var lines = [];1070 var lines = [];
1089 ptags.each(function(ptag) {1071 ptags.each(function(ptag) {
1090 lines = lines.concat([ptag.get('text'), '\n\n']);1072 lines = lines.concat([ptag.get('text'), '\n\n']);
@@ -1106,7 +1088,7 @@
1106 */1088 */
1107 accept_empty: {1089 accept_empty: {
1108 value: false,1090 value: false,
1109 get: function() {1091 getter: function() {
1110 if (this.editor) {1092 if (this.editor) {
1111 return this.editor.get(ACCEPT_EMPTY);1093 return this.editor.get(ACCEPT_EMPTY);
1112 }1094 }
@@ -1431,7 +1413,7 @@
1431 if (this._click_handler) {1413 if (this._click_handler) {
1432 this._click_handler.detach();1414 this._click_handler.detach();
1433 }1415 }
1434 this._click_handler = Y.on('click', this._triggerEdit, node, this);1416 this._click_handler = node.on('click', this._triggerEdit, this);
1435 },1417 },
14361418
14371419
@@ -1496,5 +1478,5 @@
14961478
1497//~ Y.log("Module loaded", 'info', 'lazr.editor');1479//~ Y.log("Module loaded", 'info', 'lazr.editor');
14981480
1499}, '0.2', {requires:1481}, '0.2', {requires: ['oop', 'anim', 'event', 'node', 'widget',
1500 ['oop', 'event', 'node', 'widget', 'lazr.anim', 'lazr.base']});1482 'lazr.anim', 'lazr.base']});
15011483
=== modified file 'src-js/lazrjs/inlineedit/tests/index.html'
--- src-js/lazrjs/inlineedit/tests/index.html 2009-05-14 18:21:37 +0000
+++ src-js/lazrjs/inlineedit/tests/index.html 2009-10-30 17:01:14 +0000
@@ -5,33 +5,23 @@
5 <title>Inline Edit</title>5 <title>Inline Edit</title>
66
7 <!-- YUI 3.0 Setup -->7 <!-- YUI 3.0 Setup -->
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>
9 <link rel="stylesheet" href="../../../lib/yui/current/build/cssreset/reset.css"/>9 <link rel="stylesheet" href="../../yui/current/build/cssreset/reset.css"/>
10 <link rel="stylesheet" href="../../../lib/yui/current/build/cssfonts/fonts.css"/>10 <link rel="stylesheet" href="../../yui/current/build/cssfonts/fonts.css"/>
11 <link rel="stylesheet" href="../../../lib/yui/current/build/cssbase/base.css"/>11 <link rel="stylesheet" href="../../yui/current/build/cssbase/base.css"/>
12 <link rel="stylesheet" href="../../testing/assets/testlogger.css"/>
1213
13 <!-- The module under test -->14 <!-- The module under test -->
14 <script type="text/javascript" src="../../../build/inlineedit/editor.js"></script>15 <script type="text/javascript" src="../../inlineedit/editor.js"></script>
15 <script type="text/javascript" src="../../../build/anim/anim.js"></script>16 <script type="text/javascript" src="../../anim/anim.js"></script>
16 <script type="text/javascript" src="../../../build/lazr/lazr.js"></script>17 <script type="text/javascript" src="../../lazr/lazr.js"></script>
18 <script type="text/javascript" src="../../testing/testing.js"></script>
1719
18 <!-- The test suite -->20 <!-- The test suite -->
19 <script type="text/javascript" src="inline_edit.js"></script>21 <script type="text/javascript" src="inline_edit.js"></script>
2022
21 <link rel="stylesheet" href="../../../src/testing/assets/testlogger.css"/>
22</head>23</head>
23<body class="yui-skin-sam">24<body class="yui-skin-sam">
24 <h1>Single-line editing</h1>
25 <div id="editable_single_text">
26 <span id="single_text" class="yui-editable_text-text">Some editable inline text.</span>
27 <button id="single_edit" class="yui-editable_text-trigger">Edit this</button>
28 </div>
29 <hr />
30 <h1>Multi-line editing</h1>
31 <div id="editable_multi_text">
32 <button id="multi_edit" class="yui-editable_text-trigger">Edit this</button>
33 <span id="multi_text" class="yui-editable_text-text">Some editable multi-line text.</span>
34 </div>
35 <div id="log"></div>25 <div id="log"></div>
36</body>26</body>
37</html>27</html>
3828
=== modified file 'src-js/lazrjs/inlineedit/tests/inline_edit.js'
--- src-js/lazrjs/inlineedit/tests/inline_edit.js 2009-08-13 08:54:56 +0000
+++ src-js/lazrjs/inlineedit/tests/inline_edit.js 2009-10-30 17:01:14 +0000
@@ -1,10 +1,24 @@
1/* Copyright (c) 2009, Canonical Ltd. All rights reserved. */1/* Copyright (c) 2009, Canonical Ltd. All rights reserved. */
22
3YUI({3YUI({
4 base: '../../../lib/yui/current/build/',4 base: '../../yui/current/build/',
5 filter: 'raw',5 filter: 'raw',
6 combine: false6 combine: false
7 }).use('lazr.editor', 'node', 'event', 'yuitest', 'console', function(Y) {7 }).use('lazr.editor', 'lazr.testing.runner', 'node', 'event', 'console', function(Y) {
8
9var SAMPLE_HTML = " \
10 <h1>Single-line editing</h1> \
11 <div id='editable_single_text'> \
12 <span id='single_text' class='yui-editable_text-text'>Some editable inline text.</span> \
13 <button id='single_edit' class='yui-editable_text-trigger'>Edit this</button> \
14 </div> \
15 <hr /> \
16 <h1>Multi-line editing</h1> \
17 <div id='editable_multi_text'> \
18 <button id='multi_edit' class='yui-editable_text-trigger'>Edit this</button> \
19 <span id='multi_text' class='yui-editable_text-text'>Some editable multi-line text.</span> \
20 </div> \
21";
822
9var Assert = Y.Assert; // For easy access to isTrue(), etc.23var Assert = Y.Assert; // For easy access to isTrue(), etc.
1024
@@ -46,6 +60,15 @@
46 widget.destroy();60 widget.destroy();
47}61}
4862
63function setup_sample_html() {
64 if (! Y.get("#scaffolding")) {
65 Y.get(document.body).appendChild(
66 Y.Node.create("<div id='scaffolding'></div>"));
67 }
68
69 Y.get("#scaffolding").set("innerHTML", SAMPLE_HTML);
70}
71
49function make_editable_text(cfg) {72function make_editable_text(cfg) {
50 // For the editor73 // For the editor
51 // TODO: fix this ugly hack74 // TODO: fix this ugly hack
@@ -396,6 +419,7 @@
396 name: 'Editable text initial values',419 name: 'Editable text initial values',
397420
398 setUp: function() {421 setUp: function() {
422 setup_sample_html();
399 this.etext = make_editable_text(423 this.etext = make_editable_text(
400 {initial_value_override: 'Initial value'});424 {initial_value_override: 'Initial value'});
401 },425 },
@@ -621,6 +645,7 @@
621 name: 'editable_text',645 name: 'editable_text',
622646
623 setUp: function() {647 setUp: function() {
648 setup_sample_html();
624 this.etext = make_editable_text();649 this.etext = make_editable_text();
625 },650 },
626651
@@ -704,6 +729,7 @@
704 this.etext.editor729 this.etext.editor
705 .get('input_field')730 .get('input_field')
706 .set('value', expected_value);731 .set('value', expected_value);
732
707 this.etext.editor.save();733 this.etext.editor.save();
708734
709 Assert.areEqual(735 Assert.areEqual(
@@ -801,6 +827,7 @@
801 name: "EditableText single-line/multi-line modes",827 name: "EditableText single-line/multi-line modes",
802828
803 setUp: function() {829 setUp: function() {
830 setup_sample_html();
804 this.single = make_editable_text({831 this.single = make_editable_text({
805 contentBox: '#editable_single_text',832 contentBox: '#editable_single_text',
806 multiline: false833 multiline: false
@@ -843,7 +870,7 @@
843 },870 },
844871
845 test_single_line_top_button_box: function() {872 test_single_line_top_button_box: function() {
846 var box = this.single.editor.top_buttons;873 var box = this.single.editor.get("top_buttons");
847 Assert.areEqual(874 Assert.areEqual(
848 null,875 null,
849 box,876 box,
@@ -851,12 +878,12 @@
851 },878 },
852879
853 test_multi_line_top_button_box: function() {880 test_multi_line_top_button_box: function() {
854 var box = this.multi.editor.top_buttons;881 var box = this.multi.editor.get("top_buttons");
855 Assert.areNotEqual(882 Assert.areNotEqual(
856 null,883 null,
857 box,884 box,
858 "Multi-line editor should have a top button box.");885 "Multi-line editor should have a top button box.");
859 }886 },
860887
861}));888}));
862889
@@ -1116,15 +1143,7 @@
1116 }1143 }
1117}));1144}));
11181145
1119Y.Test.Runner.add(suite);1146Y.lazr.testing.Runner.add(suite);
11201147Y.lazr.testing.Runner.run();
1121var yconsole = new Y.Console({
1122 newestOnTop: false
1123});
1124yconsole.render('#log');
1125
1126Y.on('domready', function() {
1127 Y.Test.Runner.run();
1128});
11291148
1130});1149});
11311150
=== modified file 'src-js/lazrjs/overlay/overlay.js'
--- src-js/lazrjs/overlay/overlay.js 2009-04-19 22:48:09 +0000
+++ src-js/lazrjs/overlay/overlay.js 2009-10-30 17:01:14 +0000
@@ -11,7 +11,9 @@
11var ESCAPE = 27,11var ESCAPE = 27,
12 CANCEL = 'cancel',12 CANCEL = 'cancel',
13 BOUNDING_BOX = 'boundingBox',13 BOUNDING_BOX = 'boundingBox',
14 CONTENT_BOX = 'contentBox';14 CONTENT_BOX = 'contentBox',
15 BINDUI = "bindUI";
16
1517
16 /**18 /**
17 * An Overlay subclass which draws a rounded-corner, drop-shadow19 * An Overlay subclass which draws a rounded-corner, drop-shadow
@@ -36,6 +38,8 @@
36 arguments[0].zIndex = 1000;38 arguments[0].zIndex = 1000;
37 }39 }
38 PrettyOverlay.superclass.constructor.apply(this, arguments);40 PrettyOverlay.superclass.constructor.apply(this, arguments);
41 Y.after(this._bindUIPrettyOverlay, this, BINDUI);
42
39 };43 };
4044
41 PrettyOverlay.NAME = 'pretty-overlay';45 PrettyOverlay.NAME = 'pretty-overlay';
@@ -221,8 +225,14 @@
221 * @method _removeBlockingDiv225 * @method _removeBlockingDiv
222 */226 */
223 _removeBlockingDiv: function() {227 _removeBlockingDiv: function() {
224 if (Y.get('.blocking-div')) {228 if (this._blocking_div) {
225 Y.get('body').removeChild(this._blocking_div);229 var blocking_div = Y.get(this._blocking_div);
230 if (blocking_div) {
231 var parent = blocking_div.get('parentNode');
232 if (parent) {
233 parent.removeChild(this._blocking_div);
234 }
235 }
226 }236 }
227 },237 },
228238
@@ -236,13 +246,16 @@
236 },246 },
237247
238 /**248 /**
239 * Bind UI events. Subclasses must call this function using249 * Bind UI events.
240 * <code>this.constructor.superclass.bindUI.call(this)</code>.250 * <p>
251 * This method is invoked after bindUI is invoked for the Widget class
252 * using YUI's aop infrastructure.
253 * </p>
241 *254 *
255 * @method _bindUIPrettyOverlay
242 * @protected256 * @protected
243 * @method bindUI
244 */257 */
245 bindUI: function() {258 _bindUIPrettyOverlay: function() {
246 var self = this;259 var self = this;
247 var close_button = this.get(BOUNDING_BOX).query('.close a');260 var close_button = this.get(BOUNDING_BOX).query('.close a');
248 close_button.on('click', function(e) {261 close_button.on('click', function(e) {
@@ -352,4 +365,4 @@
352365
353 Y.lazr.PrettyOverlay = PrettyOverlay;366 Y.lazr.PrettyOverlay = PrettyOverlay;
354367
355}, '0.1', {requires: ['oop', 'overlay', 'event']});368}, '0.1', {requires: ['oop', 'overlay', 'event', 'widget-position']});
356369
=== modified file 'src-js/lazrjs/overlay/tests/overlay.html'
--- src-js/lazrjs/overlay/tests/overlay.html 2009-02-20 17:41:32 +0000
+++ src-js/lazrjs/overlay/tests/overlay.html 2009-10-30 17:01:14 +0000
@@ -5,14 +5,15 @@
5 <title>Pretty Overlay</title>5 <title>Pretty Overlay</title>
66
7 <!-- YUI 3.0 Setup -->7 <!-- YUI 3.0 Setup -->
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>
9 <link rel="stylesheet" href="../../../lib/yui/current/build/cssreset/reset.css"/>9 <link rel="stylesheet" href="../../yui/current/build/cssreset/reset.css"/>
10 <link rel="stylesheet" href="../../../lib/yui/current/build/cssfonts/fonts.css"/>10 <link rel="stylesheet" href="../../yui/current/build/cssfonts/fonts.css"/>
11 <link rel="stylesheet" href="../../../lib/yui/current/build/cssbase/base.css"/>11 <link rel="stylesheet" href="../../yui/current/build/cssbase/base.css"/>
12 <link rel="stylesheet" href="../../../src/testing/assets/testlogger.css"/>12 <link rel="stylesheet" href="../../testing/assets/testlogger.css"/>
1313
14 <!-- The module under test -->14 <!-- The module under test -->
15 <script type="text/javascript" src="../../../build/overlay/overlay.js"></script>15 <script type="text/javascript" src="../../overlay/overlay.js"></script>
16 <script type="text/javascript" src="../../testing/testing.js"></script>
1617
17 <!-- The test suite -->18 <!-- The test suite -->
18 <script type="text/javascript" src="overlay.js"></script>19 <script type="text/javascript" src="overlay.js"></script>
1920
=== modified file 'src-js/lazrjs/overlay/tests/overlay.js'
--- src-js/lazrjs/overlay/tests/overlay.js 2009-02-20 18:05:48 +0000
+++ src-js/lazrjs/overlay/tests/overlay.js 2009-10-30 17:01:14 +0000
@@ -1,10 +1,11 @@
1/* Copyright (c) 2009, Canonical Ltd. All rights reserved. */1/* Copyright (c) 2009, Canonical Ltd. All rights reserved. */
22
3YUI({3YUI({
4 base: '../../../lib/yui/current/build/',4 base: '../../yui/current/build/',
5 filter: 'raw',5 filter: 'raw',
6 combine: false6 combine: false
7 }).use('lazr.overlay', 'node', 'event', 'yuitest', 'widget-stack', 'console', function(Y) {7 }).use('lazr.overlay', 'lazr.testing.runner', 'node',
8 'event', 'widget-stack', 'console', function(Y) {
89
9// KeyCode for escape10// KeyCode for escape
10var ESCAPE = 27;11var ESCAPE = 27;
@@ -85,8 +86,8 @@
85 },86 },
8687
87 test_overlay_can_hide_progressbar: function() {88 test_overlay_can_hide_progressbar: function() {
88 this.overlay = new Y.lazr.PrettyOverlay();89 this.overlay = new Y.lazr.PrettyOverlay({progressbar: false});
89 this.overlay.render({progressbar: false});90 this.overlay.render();
90 var bb = this.overlay.get('boundingBox');91 var bb = this.overlay.get('boundingBox');
91 bb.set('headerContent', 'ALL HAIL DISCORDIA!');92 bb.set('headerContent', 'ALL HAIL DISCORDIA!');
92 Assert.isNull(93 Assert.isNull(
@@ -106,8 +107,8 @@
106 },107 },
107108
108 test_overlay_can_hide_steptitle: function() {109 test_overlay_can_hide_steptitle: function() {
109 this.overlay = new Y.lazr.PrettyOverlay();110 this.overlay = new Y.lazr.PrettyOverlay({progressbar: false});
110 this.overlay.render({progressbar: false});111 this.overlay.render();
111 var bb = this.overlay.get('boundingBox');112 var bb = this.overlay.get('boundingBox');
112 bb.set('headerContent', 'ALL HAIL DISCORDIA!');113 bb.set('headerContent', 'ALL HAIL DISCORDIA!');
113 Assert.isNull(114 Assert.isNull(
@@ -230,15 +231,7 @@
230231
231}));232}));
232233
233Y.Test.Runner.add(suite);234Y.lazr.testing.Runner.add(suite);
234235Y.lazr.testing.Runner.run();
235var yconsole = new Y.Console({
236 newestOnTop: false
237});
238yconsole.render('#log');
239
240Y.on('domready', function() {
241 Y.Test.Runner.run();
242});
243236
244});237});
245238
=== modified file 'src-js/lazrjs/picker/picker.js'
--- src-js/lazrjs/picker/picker.js 2009-07-06 16:18:36 +0000
+++ src-js/lazrjs/picker/picker.js 2009-10-30 17:01:14 +0000
@@ -54,10 +54,18 @@
54 FOOTER_SLOT = 'footer_slot',54 FOOTER_SLOT = 'footer_slot',
55 SELECTED_BATCH = 'selected_batch',55 SELECTED_BATCH = 'selected_batch',
56 SEARCH_MODE = 'search_mode',56 SEARCH_MODE = 'search_mode',
57 NO_RESULTS_SEARCH_MESSAGE = 'no_results_search_message';57 NO_RESULTS_SEARCH_MESSAGE = 'no_results_search_message',
58 RENDERUI = "renderUI",
59 BINDUI = "bindUI",
60 SYNCUI = "syncUI";
61
5862
59var Picker = function () {63var Picker = function () {
60 Picker.superclass.constructor.apply(this, arguments);64 Picker.superclass.constructor.apply(this, arguments);
65
66 Y.after(this._renderUIPicker, this, RENDERUI);
67 Y.after(this._bindUIPicker, this, BINDUI);
68 Y.after(this._syncUIPicker, this, BINDUI);
61};69};
6270
63Y.extend(Picker, Y.lazr.PrettyOverlay, {71Y.extend(Picker, Y.lazr.PrettyOverlay, {
@@ -204,7 +212,7 @@
204 var options = this.get(BATCHES);212 var options = this.get(BATCHES);
205213
206 // Clear previous batches.214 // Clear previous batches.
207 Y.Event.purgeElement(this.batches_box, true);215 Y.Event.purgeElement(this._batches_box, true);
208 this._batches_box.set('innerHTML', '');216 this._batches_box.set('innerHTML', '');
209217
210 if (options.length === 0) {218 if (options.length === 0) {
@@ -232,7 +240,7 @@
232 this._batches_box.appendChild(batch_item);240 this._batches_box.appendChild(batch_item);
233241
234 batch_item.on('click', function (e) {242 batch_item.on('click', function (e) {
235 this.set('selected_batch', i);243 this.set(SELECTED_BATCH, i);
236 this.fire(244 this.fire(
237 SEARCH, this.get(CURRENT_SEARCH_STRING), data.value);245 SEARCH, this.get(CURRENT_SEARCH_STRING), data.value);
238 }, this);246 }, this);
@@ -259,7 +267,7 @@
259 var idx = this.get(SELECTED_BATCH);267 var idx = this.get(SELECTED_BATCH);
260268
261 var items = this._batches_box.queryAll('span');269 var items = this._batches_box.queryAll('span');
262 if (items) {270 if (items.size()) {
263 this._prev_button.set('disabled', idx === 0);271 this._prev_button.set('disabled', idx === 0);
264 items.removeClass(C_SELECTED_BATCH);272 items.removeClass(C_SELECTED_BATCH);
265 items.item(idx).addClass(C_SELECTED_BATCH);273 items.item(idx).addClass(C_SELECTED_BATCH);
@@ -377,12 +385,15 @@
377385
378 /**386 /**
379 * Create the widget's HTML components.387 * Create the widget's HTML components.
388 * <p>
389 * This method is invoked after renderUI is invoked for the Widget class
390 * using YUI's aop infrastructure.
391 * </p>
380 *392 *
381 * @method renderUI393 * @method _renderUIPicker
382 * @protected394 * @protected
383 */395 */
384 renderUI: function() {396 _renderUIPicker: function() {
385 Picker.superclass.renderUI.apply(this, arguments);
386 this._search_button = Y.Node.create(Y.lazr.ui.SEARCH_BUTTON);397 this._search_button = Y.Node.create(Y.lazr.ui.SEARCH_BUTTON);
387398
388 var search_box = Y.Node.create([399 var search_box = Y.Node.create([
@@ -415,26 +426,27 @@
415 this._footer_slot_box = Y.Node.create('<div></div');426 this._footer_slot_box = Y.Node.create('<div></div');
416 this._footer_slot_box.addClass(C_FOOTER_SLOT);427 this._footer_slot_box.addClass(C_FOOTER_SLOT);
417428
418 //We cannot set the bodyContent element here, because
419 //YUI screwed it up. So fake it.
420 var body = Y.Node.create('<div></div>');429 var body = Y.Node.create('<div></div>');
421 body.appendChild(search_box);430 body.appendChild(search_box);
422 body.appendChild(this._batches_box);431 body.appendChild(this._batches_box);
423 body.appendChild(this._results_box);432 body.appendChild(this._results_box);
424 body.appendChild(this._footer_slot_box);433 body.appendChild(this._footer_slot_box);
425 body.addClass('yui-widget-bd');434 body.addClass('yui-widget-bd');
426 this.get(CONTENT_BOX).appendChild(body);435
436 this.setStdModContent(Y.WidgetStdMod.BODY, body, Y.WidgetStdMod.APPEND);
427 },437 },
428438
429 /**439 /**
430 * Bind the widget's DOM elements to their event handlers.440 * Bind the widget's DOM elements to their event handlers.
441 * <p>
442 * This method is invoked after bindUI is invoked for the Widget class
443 * using YUI's aop infrastructure.
444 * </p>
431 *445 *
432 * @method bindUI446 * @method _bindUIPicker
433 * @protected447 * @protected
434 */448 */
435 bindUI: function() {449 _bindUIPicker: function() {
436 Picker.superclass.bindUI.apply(this, arguments);
437
438 Y.on('click', this._defaultSearchUserAction, this._search_button,450 Y.on('click', this._defaultSearchUserAction, this._search_button,
439 this);451 this);
440452
@@ -445,8 +457,10 @@
445457
446 // Give the focus to the search input.458 // Give the focus to the search input.
447 Y.on('focus', function (e) {459 Y.on('focus', function (e) {
448 e.halt();460 if (e.target !== this._search_input){
449 this._search_input.focus();461 e.halt();
462 this._search_input.focus();
463 }
450 }, this.get(BOUNDING_BOX), this);464 }, this.get(BOUNDING_BOX), this);
451465
452 // Focus search box when the widget is first displayed.466 // Focus search box when the widget is first displayed.
@@ -485,7 +499,14 @@
485 // is changed, and reset the selected one to the first one.499 // is changed, and reset the selected one to the first one.
486 this.after('batchesChange', function (e) {500 this.after('batchesChange', function (e) {
487 this._syncBatchesUI();501 this._syncBatchesUI();
488 this.set(SELECTED_BATCH, 0);502 if (this.get(SELECTED_BATCH) == 0){
503 // If the attribute is already set to the same value,
504 // the 'after' events won't be triggered, so we have
505 // to trigger it manually.
506 this._syncSelectedBatchUI();
507 } else {
508 this.set(SELECTED_BATCH, 0);
509 }
489 }, this);510 }, this);
490511
491 // Keep the UI in sync with the currently selected batch.512 // Keep the UI in sync with the currently selected batch.
@@ -512,12 +533,15 @@
512533
513 /**534 /**
514 * Synchronize the search box, error message and results with the UI.535 * Synchronize the search box, error message and results with the UI.
536 * <p>
537 * This method is invoked after syncUI is invoked for the Widget class
538 * using YUI's aop infrastructure.
539 * </p>
515 *540 *
516 * @method syncUI541 * @method _syncUIPicker
517 * @protected542 * @protected
518 */543 */
519 syncUI: function() {544 _syncUIPicker: function() {
520 Picker.superclass.syncUI.apply(this, arguments);
521 this._syncResultsUI();545 this._syncResultsUI();
522 this._syncSearchModeUI();546 this._syncSearchModeUI();
523 this._syncBatchesUI();547 this._syncBatchesUI();
@@ -686,7 +710,7 @@
686 */710 */
687 selected_batch: {711 selected_batch: {
688 value: 0,712 value: 0,
689 get: function (value) {713 getter: function (value) {
690 return value || 0;714 return value || 0;
691 },715 },
692 validator: function (value) {716 validator: function (value) {
@@ -728,8 +752,7 @@
728752
729Y.Picker = Picker;753Y.Picker = Picker;
730754
731}, '0.1', {755}, '0.1', {requires: ['oop', 'event', 'event-focus', 'node',
732 requires: [756 'substitute', 'widget', 'widget-stdmod',
733 'oop', 'event', 'node', 'substitute', 'lazr.overlay', 'lazr.anim',757 'lazr.overlay', 'lazr.anim', 'lazr.base']
734 'lazr.base']
735});758});
736759
=== modified file 'src-js/lazrjs/picker/tests/picker.html'
--- src-js/lazrjs/picker/tests/picker.html 2009-02-20 17:19:40 +0000
+++ src-js/lazrjs/picker/tests/picker.html 2009-10-30 17:01:14 +0000
@@ -1,50 +1,25 @@
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html>3<html>
4 <head>4 <head>
5 <title>Picker</title>5 <title>Picker</title>
66
7 <!-- YUI 3.0 Setup -->7 <!-- YUI 3.0 Setup -->
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>
9 <link rel="stylesheet" href="../../../lib/yui/current/build/cssreset/reset.css"/>9 <link rel="stylesheet" href="../../yui/current/build/cssreset/reset.css"/>
10 <link rel="stylesheet" href="../../../lib/yui/current/build/cssfonts/fonts.css"/>10 <link rel="stylesheet" href="../../yui/current/build/cssfonts/fonts.css"/>
11 <link rel="stylesheet" href="../../../lib/yui/current/build/cssbase/base.css"/>11 <link rel="stylesheet" href="../../yui/current/build/cssbase/base.css"/>
12 <link rel="stylesheet" href="../../testing/assets/testlogger.css"/>
1213
13 <!-- The module under test -->14 <!-- The module under test -->
14 <script type="text/javascript" src="../../../build/overlay/overlay.js"></script>15 <script type="text/javascript" src="../../overlay/overlay.js"></script>
15 <script type="text/javascript" src="../../../build/picker/picker.js"></script>16 <script type="text/javascript" src="../../picker/picker.js"></script>
16 <script type="text/javascript" src="../../../build/anim/anim.js"></script>17 <script type="text/javascript" src="../../anim/anim.js"></script>
17 <script type="text/javascript" src="../../../build/lazr/lazr.js"></script>18 <script type="text/javascript" src="../../lazr/lazr.js"></script>
19 <script type="text/javascript" src="../../testing/testing.js"></script>
1820
19 <!-- The test suite -->21 <!-- The test suite -->
20 <script type="text/javascript" src="picker.js"></script>22 <script type="text/javascript" src="picker.js"></script>
21
22 <style>
23 /* Taken and customized from testlogger.css */
24 #log .yui-console-content { width:44em }
25 #log .yui-console .yui-console-bd { height:30em }
26 #log .yui-console .yui-console-controls { display:none; }
27 #log .yui-console .yui-console-hd { display:none; }
28 #log .yui-console .yui-console-ft { position:absolute;top:0em; }
29
30 #log .yui-console-entry-src { display:none; }
31
32 #log .yui-console-entry-pass .yui-console-entry-cat {
33 background-color: green;
34 font-weight: bold;
35 color: white;
36 }
37 #log .yui-console-entry-fail .yui-console-entry-cat {
38 background-color: red;
39 font-weight: bold;
40 color: white;
41 }
42 #log .yui-console-entry-ignore .yui-console-entry-cat {
43 background-color: #666;
44 font-weight: bold;
45 color: white;
46 }
47 </style>
48</head>23</head>
49<body class="yui-skin-sam">24<body class="yui-skin-sam">
50 <div id="log"></div>25 <div id="log"></div>
5126
=== modified file 'src-js/lazrjs/picker/tests/picker.js'
--- src-js/lazrjs/picker/tests/picker.js 2009-07-07 09:38:20 +0000
+++ src-js/lazrjs/picker/tests/picker.js 2009-10-30 17:01:14 +0000
@@ -1,10 +1,11 @@
1/* Copyright (c) 2009, Canonical Ltd. All rights reserved. */1/* Copyright (c) 2009, Canonical Ltd. All rights reserved. */
22
3YUI({3YUI({
4 base: '../../../lib/yui/current/build/',4 base: '../../yui/current/build/',
5 filter: 'raw',5 filter: 'raw',
6 combine: false6 combine: false
7 }).use('lazr.picker', 'node', 'event', 'yuitest', 'console', 'dump',7 }).use('lazr.picker', 'lazr.testing.runner', 'node',
8 'event', 'event-focus', 'console', 'dump',
8 function(Y) {9 function(Y) {
910
10// Local aliases11// Local aliases
@@ -487,7 +488,7 @@
487 bb.query('.yui-picker-batches span'),488 bb.query('.yui-picker-batches span'),
488 "Container for batches not found.");489 "Container for batches not found.");
489 var batches = bb.queryAll('.yui-picker-batches span');490 var batches = bb.queryAll('.yui-picker-batches span');
490 Assert.isNotNull(batches, "Batches not found");491 Assert.isNotNull(batches, "Batches not found");
491 Assert.areEqual(2, batches.size());492 Assert.areEqual(2, batches.size());
492 ArrayAssert.itemsAreEqual(493 ArrayAssert.itemsAreEqual(
493 ['New', 'Assigned'],494 ['New', 'Assigned'],
@@ -782,15 +783,7 @@
782783
783}));784}));
784785
785Y.Test.Runner.add(suite);786Y.lazr.testing.Runner.add(suite);
786787Y.lazr.testing.Runner.run();
787var yconsole = new Y.Console({
788 newestOnTop: false
789});
790yconsole.render('#log');
791
792Y.on('domready', function() {
793 Y.Test.Runner.run();
794});
795788
796});789});
797790
=== modified file 'src-js/lazrjs/testing/assets/testlogger.css'
--- src-js/lazrjs/testing/assets/testlogger.css 2009-02-20 17:41:32 +0000
+++ src-js/lazrjs/testing/assets/testlogger.css 2009-10-30 17:01:14 +0000
@@ -1,6 +1,6 @@
1/* Taken and customized from testlogger.css */1/* Taken and customized from testlogger.css */
2#log .yui-console-content { width: 44em }2/*#log .yui-console-content { width: 44em }*/
3#log .yui-console .yui-console-bd { height: 30em }3/*#log .yui-console .yui-console-bd { height: 30em }*/
4#log .yui-console .yui-console-controls { display: none; }4#log .yui-console .yui-console-controls { display: none; }
5#log .yui-console .yui-console-hd { display: none; }5#log .yui-console .yui-console-hd { display: none; }
6#log .yui-console .yui-console-ft { position: absolute; top: 0; }6#log .yui-console .yui-console-ft { position: absolute; top: 0; }
77
=== added file 'src-js/lazrjs/testing/jsUnitMockTimeout.js'
--- src-js/lazrjs/testing/jsUnitMockTimeout.js 1970-01-01 00:00:00 +0000
+++ src-js/lazrjs/testing/jsUnitMockTimeout.js 2009-10-30 17:01:14 +0000
@@ -0,0 +1,120 @@
1/*
2 Version: MPL 1.1/GPL 2.0/LGPL 2.1
3
4 The contents of this file are subject to the Mozilla Public License Version
5 1.1 (the "License"); you may not use this file except in compliance with
6 the License. You may obtain a copy of the License at
7 http://www.mozilla.org/MPL/
8
9 Software distributed under the License is distributed on an "AS IS" basis,
10 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 for the specific language governing rights and limitations under the
12 License.
13
14 The Original Code is Edward Hieatt code.
15
16 The Initial Developer of the Original Code is
17 Edward Hieatt, edward@jsunit.net.
18 Portions created by the Initial Developer are Copyright (C) 2003
19 the Initial Developer. All Rights Reserved.
20
21 Author Edward Hieatt, edward@jsunit.net
22
23 Alternatively, the contents of this file may be used under the terms of
24 either the GNU General Public License Version 2 or later (the "GPL"), or
25 the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 in which case the provisions of the GPL or the LGPL are applicable instead
27 of those above. If you wish to allow use of your version of this file only
28 under the terms of either the GPL or the LGPL, and not to allow others to
29 use your version of this file under the terms of the MPL, indicate your
30 decision by deleting the provisions above and replace them with the notice
31 and other provisions required by the LGPL or the GPL. If you do not delete
32 the provisions above, a recipient may use your version of this file under
33 the terms of any one of the MPL, the GPL or the LGPL.
34*/
35
36// Mock setTimeout, clearTimeout
37// Contributed by Pivotal Computer Systems, www.pivotalsf.com
38//
39// Copied from the JsUnit 2.2alpha1 release, made in Mar 24 2006
40// (http://www.jsunit.net/)
41
42var Clock = {
43 timeoutsMade: 0,
44 scheduledFunctions: {},
45 nowMillis: 0,
46 reset: function() {
47 this.scheduledFunctions = {};
48 this.nowMillis = 0;
49 this.timeoutsMade = 0;
50 },
51 tick: function(millis) {
52 var oldMillis = this.nowMillis;
53 var newMillis = oldMillis + millis;
54 this.runFunctionsWithinRange(oldMillis, newMillis);
55 this.nowMillis = newMillis;
56 },
57 runFunctionsWithinRange: function(oldMillis, nowMillis) {
58 var scheduledFunc;
59 var funcsToRun = [];
60 for (var timeoutKey in this.scheduledFunctions) {
61 scheduledFunc = this.scheduledFunctions[timeoutKey];
62 if (scheduledFunc != undefined &&
63 scheduledFunc.runAtMillis >= oldMillis &&
64 scheduledFunc.runAtMillis <= nowMillis) {
65 funcsToRun.push(scheduledFunc);
66 this.scheduledFunctions[timeoutKey] = undefined;
67 }
68 }
69
70 if (funcsToRun.length > 0) {
71 funcsToRun.sort(function(a, b) {
72 return a.runAtMillis - b.runAtMillis;
73 });
74 for (var i = 0; i < funcsToRun.length; ++i) {
75 try {
76 this.nowMillis = funcsToRun[i].runAtMillis;
77 funcsToRun[i].funcToCall();
78 if (funcsToRun[i].recurring) {
79 Clock.scheduleFunction(funcsToRun[i].timeoutKey,
80 funcsToRun[i].funcToCall,
81 funcsToRun[i].millis,
82 true);
83 }
84 } catch(e) {
85 console.log(e);
86 }
87 }
88 this.runFunctionsWithinRange(oldMillis, nowMillis);
89 }
90 },
91 scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) {
92 Clock.scheduledFunctions[timeoutKey] = {
93 runAtMillis: Clock.nowMillis + millis,
94 funcToCall: funcToCall,
95 recurring: recurring,
96 timeoutKey: timeoutKey,
97 millis: millis
98 };
99 }
100};
101
102function setTimeout(funcToCall, millis) {
103 Clock.timeoutsMade = Clock.timeoutsMade + 1;
104 Clock.scheduleFunction(Clock.timeoutsMade, funcToCall, millis, false);
105 return Clock.timeoutsMade;
106}
107
108function setInterval(funcToCall, millis) {
109 Clock.timeoutsMade = Clock.timeoutsMade + 1;
110 Clock.scheduleFunction(Clock.timeoutsMade, funcToCall, millis, true);
111 return Clock.timeoutsMade;
112}
113
114function clearTimeout(timeoutKey) {
115 Clock.scheduledFunctions[timeoutKey] = undefined;
116}
117
118function clearInterval(timeoutKey) {
119 Clock.scheduledFunctions[timeoutKey] = undefined;
120}
0121
=== modified file 'src-js/lazrjs/testing/mockio.js'
--- src-js/lazrjs/testing/mockio.js 2009-08-13 12:17:44 +0000
+++ src-js/lazrjs/testing/mockio.js 2009-10-30 17:01:14 +0000
@@ -1,6 +1,6 @@
1/* Copyright (c) 2009, Canonical Ltd. All rights reserved. */1/* Copyright (c) 2009, Canonical Ltd. All rights reserved. */
22
3YUI.add('lazr.testing', function(Y) {3YUI.add('lazr.testing.mockio', function(Y) {
4/**4/**
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.
6 *6 *
@@ -63,9 +63,7 @@
63 };63 };
64};64};
6565
66if (Y.lazr.testing === undefined) {66Y.namespace("lazr.testing");
67 Y.lazr.testing = {};
68}
69Y.lazr.testing.MockIo = MockIo;67Y.lazr.testing.MockIo = MockIo;
7068
71}, '0.1', {});69}, '0.1', {});
7270
=== added file 'src-js/lazrjs/testing/testing.js'
--- src-js/lazrjs/testing/testing.js 1970-01-01 00:00:00 +0000
+++ src-js/lazrjs/testing/testing.js 2009-10-30 17:01:14 +0000
@@ -0,0 +1,123 @@
1/* Copyright (c) 2009, Canonical Ltd. All rights reserved. */
2
3YUI.add("lazr.testing.runner", function(Y) {
4
5/**
6 * Testing utilities.
7 *
8 * @module lazr.testing
9 * @namespace lazr
10 */
11
12Runner = Y.namespace("lazr.testing.Runner");
13
14Runner.add = function(suite) {
15 if ((typeof jstestdriver === "undefined")) {
16 // If we are not running under JsTestDriver, then
17 // register the suite with Y.Test.Runner and run it.
18 Y.Test.Runner.add(suite);
19 } else {
20 // If ``jstestdriver`` is defined, that means we are
21 // running under JsTestDriver, so instead register each
22 // test case from the suite as a separate TestCase() with
23 // JsTestDriver.
24 var tests = [];
25
26 for (var idx in suite.items) {
27 var suiteName = suite.name;
28 var testCase = suite.items[idx];
29 var testCaseName = testCase.name;
30
31 var clone = {};
32 for (var prop in testCase){
33 // Clone everything that is not a test method.
34 if (prop.indexOf("test") === -1){
35 clone[prop] = testCase[prop];
36 }
37 }
38
39 // Now for each test method, create a JsTestDriver
40 // TestCase that wraps a single YUI TestSuite, that wraps
41 // a clone of the original TestCase but with only the
42 // single test method that we are interested in.
43 for (var prop in testCase){
44 if (prop.indexOf("test") === 0 &&
45 Y.Lang.isFunction(testCase[prop])){
46 tests.push({"suiteName": suiteName,
47 "caseName": testCaseName,
48 "case": clone,
49 "methodName": prop,
50 "method": testCase[prop]});
51 }
52 }
53 }
54
55 for (var i=0; i<tests.length; i++){
56 testObject = tests[i];
57
58 var fakeTestCase = {
59 "setUp": Y.bind(function(testObject){
60 var testSuite = new Y.Test.Suite(testObject["suiteName"]);
61 var testCase = new Y.Test.Case(testObject["case"]);
62 testCase[testObject["methodName"]] = testObject["method"];
63 testSuite.add(testCase);
64 Y.Test.Runner.clear();
65 Y.Test.Runner.add(testSuite);
66 }, this, testObject),
67 "tearDown": function(){
68 Y.Test.Runner.clear();
69 },
70 };
71
72 fakeTestCase[testObject["methodName"]] = Y.bind(function (testObject) {
73 var results = [];
74
75 var onComplete = function (caseName, methodName, results, e) {
76 Y.Test.Runner.unsubscribe("testsuitecomplete");
77 results.push(e.results[caseName][methodName]);
78 };
79
80 Y.Test.Runner.subscribe(
81 "testsuitecomplete",
82 Y.bind(onComplete, this, testObject["caseName"],
83 testObject["methodName"], results),
84 Y.Test.Runner);
85
86 Clock.reset();
87 Y.Test.Runner.run();
88 for (var i=0;i<100 && !results.length; i++){
89 Clock.tick(100);
90 }
91
92 var result = results.pop();
93 if (result === undefined) {
94 fail("Test did not finish after 100 iterations.");
95 } else {
96 if (result["result"] == "fail"){
97 fail(result["message"]);
98 }
99 }
100
101 }, this, testObject);
102
103 TestCase(testObject["caseName"] + "." + testObject["methodName"],
104 fakeTestCase);
105 }
106 }
107};
108
109Runner.run = function(suite) {
110 Y.on("domready", function() {
111 if ((typeof jstestdriver === "undefined")) {
112 // If we are not running under JsTestDriver, then run all
113 // the registered test suites with Y.Test.Runner.
114 var yconsole = new Y.Console({
115 newestOnTop: false
116 });
117 yconsole.render("#log");
118 Y.Test.Runner.run();
119 }
120 });
121};
122
123}, "0.1", {requires: ["oop", "test", "console"]});
0124
=== added file 'src-js/lazrjs/testing/yui-patch.js'
--- src-js/lazrjs/testing/yui-patch.js 1970-01-01 00:00:00 +0000
+++ src-js/lazrjs/testing/yui-patch.js 2009-10-30 17:01:14 +0000
@@ -0,0 +1,2137 @@
1/*
2Copyright (c) 2009, Yahoo! Inc. All rights reserved.
3Code licensed under the BSD License:
4http://developer.yahoo.net/yui/license.txt
5version: 3.0.0
6build: 1549
7*/
8
9/*
10Copied from yui/loader/loader.js
11
12Patched by the JsTestDriver team to avoid trying to load files, since
13JsTestDriver itself will load the files for you.
14*/
15
16YUI.add('loader', function(Y) {
17
18(function() {
19/**
20 * Loader dynamically loads script and css files. It includes the dependency
21 * info for the version of the library in use, and will automatically pull in
22 * dependencies for the modules requested. It supports rollup files and will
23 * automatically use these when appropriate in order to minimize the number of
24 * http connections required to load all of the dependencies. It can load the
25 * files from the Yahoo! CDN, and it can utilize the combo service provided on
26 * this network to reduce the number of http connections required to download
27 * YUI files.
28 *
29 * @module loader
30 */
31
32/**
33 * Loader dynamically loads script and css files. It includes the dependency
34 * info for the version of the library in use, and will automatically pull in
35 * dependencies for the modules requested. It supports rollup files and will
36 * automatically use these when appropriate in order to minimize the number of
37 * http connections required to load all of the dependencies. It can load the
38 * files from the Yahoo! CDN, and it can utilize the combo service provided on
39 * this network to reduce the number of http connections required to download
40 * YUI files.
41 *
42 * While the loader can be instantiated by the end user, it normally is not.
43 * @see YUI.use for the normal use case. The use function automatically will
44 * pull in missing dependencies.
45 *
46 * @class Loader
47 * @constructor
48 * @param o an optional set of configuration options. Valid options:
49 * <ul>
50 * <li>base:
51 * The base dir</li>
52 * <li>secureBase:
53 * The secure base dir (not implemented)</li>
54 * <li>comboBase:
55 * The YUI combo service base dir. Ex: http://yui.yahooapis.com/combo?</li>
56 * <li>root:
57 * The root path to prepend to module names for the combo service. Ex: 2.5.2/build/</li>
58 * <li>filter:
59 *
60 * A filter to apply to result urls. This filter will modify the default
61 * path for all modules. The default path for the YUI library is the
62 * minified version of the files (e.g., event-min.js). The filter property
63 * can be a predefined filter or a custom filter. The valid predefined
64 * filters are:
65 * <dl>
66 * <dt>DEBUG</dt>
67 * <dd>Selects the debug versions of the library (e.g., event-debug.js).
68 * This option will automatically include the Logger widget</dd>
69 * <dt>RAW</dt>
70 * <dd>Selects the non-minified version of the library (e.g., event.js).</dd>
71 * </dl>
72 * You can also define a custom filter, which must be an object literal
73 * containing a search expression and a replace string:
74 * <pre>
75 * myFilter: &#123;
76 * 'searchExp': "-min\\.js",
77 * 'replaceStr': "-debug.js"
78 * &#125;
79 * </pre>
80 *
81 * </li>
82 * <li>filters: per-component filter specification. If specified for a given component, this overrides the filter config</li>
83 * <li>combine:
84 * Use the YUI combo service to reduce the number of http connections required to load your dependencies</li>
85 * <li>ignore:
86 * A list of modules that should never be dynamically loaded</li>
87 * <li>force:
88 * A list of modules that should always be loaded when required, even if already present on the page</li>
89 * <li>insertBefore:
90 * Node or id for a node that should be used as the insertion point for new nodes</li>
91 * <li>charset:
92 * charset for dynamic nodes (deprecated, use jsAttributes or cssAttributes)</li>
93 * <li>jsAttributes: object literal containing attributes to add to script nodes</li>
94 * <li>cssAttributes: object literal containing attributes to add to link nodes</li>
95 * <li>timeout:
96 * number of milliseconds before a timeout occurs when dynamically loading nodes. in not set, there is no timeout</li>
97 * <li>context:
98 * execution context for all callbacks</li>
99 * <li>onSuccess:
100 * callback for the 'success' event</li>
101 * <li>onFailure: callback for the 'failure' event</li>
102 * <li>onCSS: callback for the 'CSSComplete' event. When loading YUI components with CSS
103 * the CSS is loaded first, then the script. This provides a moment you can tie into to improve
104 * the presentation of the page while the script is loading.</li>
105 * <li>onTimeout:
106 * callback for the 'timeout' event</li>
107 * <li>onProgress:
108 * callback executed each time a script or css file is loaded</li>
109 * <li>modules:
110 * A list of module definitions. See Loader.addModule for the supported module metadata</li>
111 * </ul>
112 */
113
114/*
115 * Global loader queue
116 * @property _loaderQueue
117 * @type Queue
118 * @private
119 */
120YUI.Env._loaderQueue = YUI.Env._loaderQueue || new Y.Queue();
121
122var NOT_FOUND = {},
123 GLOBAL_ENV = YUI.Env,
124 GLOBAL_LOADED,
125 BASE = 'base',
126 CSS = 'css',
127 JS = 'js',
128 CSSRESET = 'cssreset',
129 CSSFONTS = 'cssfonts',
130 CSSGRIDS = 'cssgrids',
131 CSSBASE = 'cssbase',
132 CSS_AFTER = [CSSRESET, CSSFONTS, CSSGRIDS,
133 'cssreset-context', 'cssfonts-context', 'cssgrids-context'],
134 YUI_CSS = ['reset', 'fonts', 'grids', BASE],
135 VERSION = Y.version,
136 ROOT = VERSION + '/build/',
137 CONTEXT = '-context',
138
139 ANIMBASE = 'anim-base',
140 ATTRIBUTE = 'attribute',
141 ATTRIBUTEBASE = ATTRIBUTE + '-base',
142 BASEBASE = 'base-base',
143 DDDRAG = 'dd-drag',
144 DOM = 'dom',
145 DATASCHEMABASE = 'dataschema-base',
146 DATASOURCELOCAL = 'datasource-local',
147 DOMBASE = 'dom-base',
148 DOMSTYLE = 'dom-style',
149 DOMSCREEN = 'dom-screen',
150 DUMP = 'dump',
151 GET = 'get',
152 EVENTBASE = 'event-base',
153 EVENTCUSTOM = 'event-custom',
154 EVENTCUSTOMBASE = 'event-custom-base',
155 IOBASE = 'io-base',
156 NODE = 'node',
157 NODEBASE = 'node-base',
158 NODESTYLE = 'node-style',
159 NODESCREEN = 'node-screen',
160 OOP = 'oop',
161 PLUGINHOST = 'pluginhost',
162 SELECTORCSS2 = 'selector-css2',
163 SUBSTITUTE = 'substitute',
164 WIDGET = 'widget',
165 WIDGETPOSITION = 'widget-position',
166 YUIBASE = 'yui-base',
167
168 PLUGIN = 'plugin',
169
170 META = {
171
172 version: VERSION,
173
174 root: ROOT,
175
176 base: 'http://yui.yahooapis.com/' + ROOT,
177
178 comboBase: 'http://yui.yahooapis.com/combo?',
179
180 skin: {
181 defaultSkin: 'sam',
182 base: 'assets/skins/',
183 path: 'skin.css',
184 after: CSS_AFTER
185 //rollup: 3
186 },
187
188 modules: {
189
190 dom: {
191 requires: [OOP],
192 submodules: {
193
194 'dom-base': {
195 requires: [OOP]
196 },
197
198 'dom-style': {
199 requires: [DOMBASE]
200 },
201
202 'dom-screen': {
203 requires: [DOMBASE, DOMSTYLE]
204 },
205
206 'selector-native': {
207 requires: [DOMBASE]
208 },
209
210 'selector-css2': {
211 requires: ['selector-native']
212 },
213
214 'selector': {
215 requires: [DOMBASE]
216 }
217
218 },
219
220 plugins: {
221 'selector-css3': {
222 requires: [SELECTORCSS2]
223 }
224 }
225 },
226
227 node: {
228 requires: [DOM, EVENTBASE],
229 // expound: EVENT,
230
231 submodules: {
232 'node-base': {
233 requires: [DOMBASE, SELECTORCSS2, EVENTBASE]
234 },
235
236 'node-style': {
237 requires: [DOMSTYLE, NODEBASE]
238 },
239
240 'node-screen': {
241 requires: [DOMSCREEN, NODEBASE]
242 },
243
244 'node-pluginhost': {
245 requires: [NODEBASE, PLUGINHOST]
246 },
247
248
249 'node-event-delegate': {
250 requires: [NODEBASE, 'event-delegate']
251 }
252 },
253
254 plugins: {
255 'node-event-simulate': {
256 requires: [NODEBASE, 'event-simulate']
257 }
258 }
259 },
260
261 anim: {
262 submodules: {
263
264 'anim-base': {
265 requires: [BASEBASE, NODESTYLE]
266 },
267
268 'anim-color': {
269 requires: [ANIMBASE]
270 },
271
272 'anim-easing': {
273 requires: [ANIMBASE]
274 },
275
276 'anim-scroll': {
277 requires: [ANIMBASE]
278 },
279
280 'anim-xy': {
281 requires: [ANIMBASE, NODESCREEN]
282 },
283
284 'anim-curve': {
285 requires: ['anim-xy']
286 },
287
288 'anim-node-plugin': {
289 requires: ['node-pluginhost', ANIMBASE]
290 }
291 }
292 },
293
294 attribute: {
295 submodules: {
296 'attribute-base': {
297 requires: [EVENTCUSTOM]
298 },
299
300 'attribute-complex': {
301 requires: [ATTRIBUTEBASE]
302 }
303 }
304 },
305
306 base: {
307 submodules: {
308 'base-base': {
309 requires: [ATTRIBUTEBASE]
310 },
311
312 'base-build': {
313 requires: [BASEBASE]
314 },
315
316 'base-pluginhost': {
317 requires: [BASEBASE, PLUGINHOST]
318 }
319 }
320 },
321
322 cache: {
323 requires: [PLUGIN]
324 },
325
326 compat: {
327 requires: [NODE, DUMP, SUBSTITUTE]
328 },
329
330 classnamemanager: {
331 requires: [YUIBASE]
332 },
333
334 collection: {
335 requires: [OOP]
336 },
337
338 console: {
339 requires: ['yui-log', WIDGET, SUBSTITUTE],
340 skinnable: true,
341 plugins: {
342 'console-filters': {
343 requires: [PLUGIN, 'console'],
344 skinnable: true
345 }
346 }
347 },
348
349 cookie: {
350 requires: [YUIBASE]
351 },
352
353 dataschema:{
354 submodules: {
355 'dataschema-base': {
356 requires: [BASE]
357 },
358 'dataschema-array': {
359 requires: [DATASCHEMABASE]
360 },
361 'dataschema-json': {
362 requires: [DATASCHEMABASE, 'json']
363 },
364 'dataschema-text': {
365 requires: [DATASCHEMABASE]
366 },
367 'dataschema-xml': {
368 requires: [DATASCHEMABASE]
369 }
370 }
371 },
372
373 datasource:{
374 submodules: {
375 'datasource-local': {
376 requires: [BASE]
377 },
378 'datasource-arrayschema': {
379 requires: [DATASOURCELOCAL, PLUGIN, 'dataschema-array']
380 },
381 'datasource-cache': {
382 requires: [DATASOURCELOCAL, 'cache']
383 },
384 'datasource-function': {
385 requires: [DATASOURCELOCAL]
386 },
387 'datasource-jsonschema': {
388 requires: [DATASOURCELOCAL, PLUGIN, 'dataschema-json']
389 },
390 'datasource-polling': {
391 requires: [DATASOURCELOCAL]
392 },
393 'datasource-get': {
394 requires: [DATASOURCELOCAL, GET]
395 },
396 'datasource-textschema': {
397 requires: [DATASOURCELOCAL, PLUGIN, 'dataschema-text']
398 },
399 'datasource-io': {
400 requires: [DATASOURCELOCAL, IOBASE]
401 },
402 'datasource-xmlschema': {
403 requires: [DATASOURCELOCAL, PLUGIN, 'dataschema-xml']
404 }
405 }
406 },
407
408 datatype:{
409 submodules: {
410 'datatype-date': {
411 requires: [YUIBASE]
412 },
413 'datatype-number': {
414 requires: [YUIBASE]
415 },
416 'datatype-xml': {
417 requires: [YUIBASE]
418 }
419 }
420 },
421
422 dd:{
423 submodules: {
424 'dd-ddm-base': {
425 requires: [NODE, BASE]
426 },
427 'dd-ddm':{
428 requires: ['dd-ddm-base', 'event-resize']
429 },
430 'dd-ddm-drop':{
431 requires: ['dd-ddm']
432 },
433 'dd-drag':{
434 requires: ['dd-ddm-base']
435 },
436 'dd-drop':{
437 requires: ['dd-ddm-drop']
438 },
439 'dd-proxy':{
440 requires: [DDDRAG]
441 },
442 'dd-constrain':{
443 requires: [DDDRAG]
444 },
445 'dd-scroll':{
446 requires: [DDDRAG]
447 },
448 'dd-plugin':{
449 requires: [DDDRAG],
450 optional: ['dd-constrain', 'dd-proxy']
451 },
452 'dd-drop-plugin':{
453 requires: ['dd-drop']
454 }
455 }
456 },
457
458 dump: {
459 requires: [YUIBASE]
460 },
461
462 event: {
463 expound: NODEBASE,
464 submodules: {
465 'event-base': {
466 expound: NODEBASE,
467 requires: [EVENTCUSTOMBASE]
468 },
469 'event-delegate': {
470 requires: [NODEBASE]
471 },
472 'event-focus': {
473 requires: [NODEBASE]
474 },
475 'event-key': {
476 requires: [NODEBASE]
477 },
478 'event-mouseenter': {
479 requires: [NODEBASE]
480 },
481 'event-mousewheel': {
482 requires: [NODEBASE]
483 },
484 'event-resize': {
485 requires: [NODEBASE]
486 }
487 }
488 },
489
490 'event-custom': {
491 submodules: {
492 'event-custom-base': {
493 requires: [OOP, 'yui-later']
494 },
495 'event-custom-complex': {
496 requires: [EVENTCUSTOMBASE]
497 }
498 }
499 },
500
501 'event-simulate': {
502 requires: [EVENTBASE]
503 },
504
505 'node-focusmanager': {
506 requires: [ATTRIBUTE, NODE, PLUGIN, 'node-event-simulate', 'event-key', 'event-focus']
507 },
508
509 history: {
510 requires: [NODE]
511 },
512
513 imageloader: {
514 requires: [BASEBASE, NODESTYLE, NODESCREEN]
515 },
516
517 io:{
518 submodules: {
519
520 'io-base': {
521 requires: [EVENTCUSTOMBASE]
522 },
523
524 'io-xdr': {
525 requires: [IOBASE, 'datatype-xml']
526 },
527
528 'io-form': {
529 requires: [IOBASE, NODEBASE, NODESTYLE]
530 },
531
532 'io-upload-iframe': {
533 requires: [IOBASE, NODEBASE]
534 },
535
536 'io-queue': {
537 requires: [IOBASE, 'queue-promote']
538 }
539 }
540 },
541
542 json: {
543 submodules: {
544 'json-parse': {
545 requires: [YUIBASE]
546 },
547
548 'json-stringify': {
549 requires: [YUIBASE]
550 }
551 }
552 },
553
554 loader: {
555 requires: [GET]
556 },
557
558 'node-menunav': {
559 requires: [NODE, 'classnamemanager', PLUGIN, 'node-focusmanager'],
560 skinnable: true
561 },
562
563 oop: {
564 requires: [YUIBASE]
565 },
566
567 overlay: {
568 requires: [WIDGET, WIDGETPOSITION, 'widget-position-ext', 'widget-stack', 'widget-stdmod'],
569 skinnable: true
570 },
571
572 plugin: {
573 requires: [BASEBASE]
574 },
575
576 pluginhost: {
577 requires: [YUIBASE]
578 },
579
580 profiler: {
581 requires: [YUIBASE]
582 },
583
584 'queue-promote': {
585 requires: [YUIBASE]
586 },
587
588 // deprecated package, replaced with async-queue
589 'queue-run': {
590 requires: [EVENTCUSTOM],
591 path: 'async-queue/async-queue-min.js'
592 },
593
594 'async-queue': {
595 requires: [EVENTCUSTOM],
596 supersedes: ['queue-run']
597 },
598
599 slider: {
600 requires: [WIDGET, 'dd-constrain'],
601 skinnable: true
602 },
603
604 stylesheet: {
605 requires: [YUIBASE]
606 },
607
608 substitute: {
609 optional: [DUMP]
610 },
611
612 widget: {
613 requires: [ATTRIBUTE, 'event-focus', BASE, NODE, 'classnamemanager'],
614 plugins: {
615 'widget-position': { },
616 'widget-position-ext': {
617 requires: [WIDGETPOSITION]
618 },
619 'widget-stack': {
620 skinnable: true
621 },
622 'widget-stdmod': { }
623 },
624 skinnable: true
625 },
626
627 yui: {
628 submodules: {
629 'yui-base': {},
630 get: {},
631 'yui-log': {},
632 'yui-later': {}
633 }
634 },
635
636 test: {
637 requires: [SUBSTITUTE, NODE, 'json', 'event-simulate']
638 }
639
640 }
641},
642
643_path = Y.cached(function(dir, file, type) {
644 return dir + '/' + file + '-min.' + (type || CSS);
645}),
646
647_queue = YUI.Env._loaderQueue,
648
649mods = META.modules, i, bname, mname, contextname,
650L = Y.Lang;
651
652// Create the metadata for both the regular and context-aware
653// versions of the YUI CSS foundation.
654for (i=0; i<YUI_CSS.length; i=i+1) {
655 bname = YUI_CSS[i];
656 mname = CSS + bname;
657
658 mods[mname] = {
659 type: CSS,
660 path: _path(mname, bname)
661 };
662
663 // define -context module
664 contextname = mname + CONTEXT;
665 bname = bname + CONTEXT;
666
667 mods[contextname] = {
668 type: CSS,
669 path: _path(mname, bname)
670 };
671
672 if (mname == CSSGRIDS) {
673 mods[mname].requires = [CSSFONTS];
674 mods[mname].optional = [CSSRESET];
675 mods[contextname].requires = [CSSFONTS + CONTEXT];
676 mods[contextname].optional = [CSSRESET + CONTEXT];
677 } else if (mname == CSSBASE) {
678 mods[mname].after = CSS_AFTER;
679 mods[contextname].after = CSS_AFTER;
680 }
681}
682
683Y.Env.meta = META;
684
685GLOBAL_LOADED = GLOBAL_ENV._loaded;
686
687Y.Loader = function(o) {
688
689 /**
690 * Internal callback to handle multiple internal insert() calls
691 * so that css is inserted prior to js
692 * @property _internalCallback
693 * @private
694 */
695 // this._internalCallback = null;
696
697 /**
698 * Callback that will be executed when the loader is finished
699 * with an insert
700 * @method onSuccess
701 * @type function
702 */
703 // this.onSuccess = null;
704
705 /**
706 * Callback that will be executed if there is a failure
707 * @method onFailure
708 * @type function
709 */
710 // this.onFailure = null;
711
712 /**
713 * Callback for the 'CSSComplete' event. When loading YUI components with CSS
714 * the CSS is loaded first, then the script. This provides a moment you can tie into to improve
715 * the presentation of the page while the script is loading.
716 * @method onCSS
717 * @type function
718 */
719 // this.onCSS = null;
720
721 /**
722 * Callback executed each time a script or css file is loaded
723 * @method onProgress
724 * @type function
725 */
726 // this.onProgress = null;
727
728 /**
729 * Callback that will be executed if a timeout occurs
730 * @method onTimeout
731 * @type function
732 */
733 // this.onTimeout = null;
734
735 /**
736 * The execution context for all callbacks
737 * @property context
738 * @default {YUI} the YUI instance
739 */
740 this.context = Y;
741
742 /**
743 * Data that is passed to all callbacks
744 * @property data
745 */
746 // this.data = null;
747
748 /**
749 * Node reference or id where new nodes should be inserted before
750 * @property insertBefore
751 * @type string|HTMLElement
752 */
753 // this.insertBefore = null;
754
755 /**
756 * The charset attribute for inserted nodes
757 * @property charset
758 * @type string
759 * @deprecated, use cssAttributes or jsAttributes
760 */
761 // this.charset = null;
762
763 /**
764 * An object literal containing attributes to add to link nodes
765 * @property cssAttributes
766 * @type object
767 */
768 // this.cssAttributes = null;
769
770 /**
771 * An object literal containing attributes to add to script nodes
772 * @property jsAttributes
773 * @type object
774 */
775 // this.jsAttributes = null;
776
777 /**
778 * The base directory.
779 * @property base
780 * @type string
781 * @default http://yui.yahooapis.com/[YUI VERSION]/build/
782 */
783 this.base = Y.Env.meta.base;
784
785 /**
786 * Base path for the combo service
787 * @property comboBase
788 * @type string
789 * @default http://yui.yahooapis.com/combo?
790 */
791 this.comboBase = Y.Env.meta.comboBase;
792
793 /**
794 * If configured, YUI JS resources will use the combo
795 * handler
796 * @property combine
797 * @type boolean
798 * @default true if a base dir isn't in the config
799 */
800 this.combine = o.base && (o.base.indexOf( this.comboBase.substr(0, 20)) > -1);
801
802 /**
803 * Ignore modules registered on the YUI global
804 * @property ignoreRegistered
805 * @default false
806 */
807 // this.ignoreRegistered = false;
808
809 /**
810 * Root path to prepend to module path for the combo
811 * service
812 * @property root
813 * @type string
814 * @default [YUI VERSION]/build/
815 */
816 this.root = Y.Env.meta.root;
817
818 /**
819 * Timeout value in milliseconds. If set, this value will be used by
820 * the get utility. the timeout event will fire if
821 * a timeout occurs.
822 * @property timeout
823 * @type int
824 */
825 this.timeout = 0;
826
827 /**
828 * A list of modules that should not be loaded, even if
829 * they turn up in the dependency tree
830 * @property ignore
831 * @type string[]
832 */
833 // this.ignore = null;
834
835 /**
836 * A list of modules that should always be loaded, even
837 * if they have already been inserted into the page.
838 * @property force
839 * @type string[]
840 */
841 // this.force = null;
842
843 this.forceMap = {};
844
845 /**
846 * Should we allow rollups
847 * @property allowRollup
848 * @type boolean
849 * @default true
850 */
851 // this.allowRollup = true;
852
853 /**
854 * A filter to apply to result urls. This filter will modify the default
855 * path for all modules. The default path for the YUI library is the
856 * minified version of the files (e.g., event-min.js). The filter property
857 * can be a predefined filter or a custom filter. The valid predefined
858 * filters are:
859 * <dl>
860 * <dt>DEBUG</dt>
861 * <dd>Selects the debug versions of the library (e.g., event-debug.js).
862 * This option will automatically include the Logger widget</dd>
863 * <dt>RAW</dt>
864 * <dd>Selects the non-minified version of the library (e.g., event.js).</dd>
865 * </dl>
866 * You can also define a custom filter, which must be an object literal
867 * containing a search expression and a replace string:
868 * <pre>
869 * myFilter: &#123;
870 * 'searchExp': "-min\\.js",
871 * 'replaceStr': "-debug.js"
872 * &#125;
873 * </pre>
874 * @property filter
875 * @type string|{searchExp: string, replaceStr: string}
876 */
877 // this.filter = null;
878
879 /**
880 * per-component filter specification. If specified for a given component, this
881 * overrides the filter config.
882 * @property filters
883 * @type object
884 */
885 this.filters = {};
886
887 /**
888 * The list of requested modules
889 * @property required
890 * @type {string: boolean}
891 */
892 this.required = {};
893
894 /**
895 * The library metadata
896 * @property moduleInfo
897 */
898 // this.moduleInfo = Y.merge(Y.Env.meta.moduleInfo);
899 this.moduleInfo = {};
900
901 /**
902 * Provides the information used to skin the skinnable components.
903 * The following skin definition would result in 'skin1' and 'skin2'
904 * being loaded for calendar (if calendar was requested), and
905 * 'sam' for all other skinnable components:
906 *
907 * <code>
908 * skin: {
909 *
910 * // The default skin, which is automatically applied if not
911 * // overriden by a component-specific skin definition.
912 * // Change this in to apply a different skin globally
913 * defaultSkin: 'sam',
914 *
915 * // This is combined with the loader base property to get
916 * // the default root directory for a skin. ex:
917 * // http://yui.yahooapis.com/2.3.0/build/assets/skins/sam/
918 * base: 'assets/skins/',
919 *
920 * // The name of the rollup css file for the skin
921 * path: 'skin.css',
922 *
923 * // The number of skinnable components requested that are
924 * // required before using the rollup file rather than the
925 * // individual component css files
926 * rollup: 3,
927 *
928 * // Any component-specific overrides can be specified here,
929 * // making it possible to load different skins for different
930 * // components. It is possible to load more than one skin
931 * // for a given component as well.
932 * overrides: {
933 * calendar: ['skin1', 'skin2']
934 * }
935 * }
936 * </code>
937 * @property skin
938 */
939 this.skin = Y.merge(Y.Env.meta.skin);
940
941 var defaults = Y.Env.meta.modules, i, onPage = YUI.Env.mods;
942
943 this._internal = true;
944 for (i in defaults) {
945 if (defaults.hasOwnProperty(i)) {
946 this.addModule(defaults[i], i);
947 }
948 }
949
950 for (i in onPage) {
951 if (onPage.hasOwnProperty(i) && !this.moduleInfo[i] && onPage[i].details) {
952 this.addModule(onPage[i].details, i);
953 }
954 }
955 this._internal = false;
956
957 /**
958 * List of rollup files found in the library metadata
959 * @property rollups
960 */
961 // this.rollups = null;
962
963 /**
964 * Whether or not to load optional dependencies for
965 * the requested modules
966 * @property loadOptional
967 * @type boolean
968 * @default false
969 */
970 // this.loadOptional = false;
971
972 /**
973 * All of the derived dependencies in sorted order, which
974 * will be populated when either calculate() or insert()
975 * is called
976 * @property sorted
977 * @type string[]
978 */
979 this.sorted = [];
980
981 /**
982 * Set when beginning to compute the dependency tree.
983 * Composed of what YUI reports to be loaded combined
984 * with what has been loaded by any instance on the page
985 * with the version number specified in the metadata.
986 * @propery loaded
987 * @type {string: boolean}
988 */
989 this.loaded = GLOBAL_LOADED[VERSION];
990
991 /**
992 * A list of modules to attach to the YUI instance when complete.
993 * If not supplied, the sorted list of dependencies are applied.
994 * @property attaching
995 */
996 // this.attaching = null;
997
998 /**
999 * Flag to indicate the dependency tree needs to be recomputed
1000 * if insert is called again.
1001 * @property dirty
1002 * @type boolean
1003 * @default true
1004 */
1005 this.dirty = true;
1006
1007 /**
1008 * List of modules inserted by the utility
1009 * @property inserted
1010 * @type {string: boolean}
1011 */
1012 this.inserted = {};
1013
1014 /**
1015 * List of skipped modules during insert() because the module
1016 * was not defined
1017 * @property skipped
1018 */
1019 this.skipped = {};
1020
1021
1022 // Y.on('yui:load', this.loadNext, this);
1023
1024 this._config(o);
1025
1026};
1027
1028Y.Loader.prototype = {
1029
1030 FILTER_DEFS: {
1031 RAW: {
1032 'searchExp': "-min\\.js",
1033 'replaceStr': ".js"
1034 },
1035 DEBUG: {
1036 'searchExp': "-min\\.js",
1037 'replaceStr': "-debug.js"
1038 }
1039 },
1040
1041 SKIN_PREFIX: "skin-",
1042
1043 _config: function(o) {
1044
1045 var i, j, val, f;
1046
1047 // apply config values
1048 if (o) {
1049 for (i in o) {
1050 if (o.hasOwnProperty(i)) {
1051 val = o[i];
1052 if (i == 'require') {
1053 this.require(val);
1054 } else if (i == 'modules') {
1055
1056 // add a hash of module definitions
1057 for (j in val) {
1058 if (val.hasOwnProperty(j)) {
1059 this.addModule(val[j], j);
1060 }
1061 }
1062
1063 } else {
1064 this[i] = val;
1065 }
1066 }
1067 }
1068 }
1069
1070 // fix filter
1071 f = this.filter;
1072
1073 if (L.isString(f)) {
1074 f = f.toUpperCase();
1075 this.filterName = f;
1076 this.filter = this.FILTER_DEFS[f];
1077 if (f == 'DEBUG') {
1078 this.require('yui-log', 'dump');
1079 }
1080 }
1081
1082 },
1083
1084 /**
1085 * Returns the skin module name for the specified skin name. If a
1086 * module name is supplied, the returned skin module name is
1087 * specific to the module passed in.
1088 * @method formatSkin
1089 * @param skin {string} the name of the skin
1090 * @param mod {string} optional: the name of a module to skin
1091 * @return {string} the full skin module name
1092 */
1093 formatSkin: function(skin, mod) {
1094 var s = this.SKIN_PREFIX + skin;
1095 if (mod) {
1096 s = s + "-" + mod;
1097 }
1098
1099 return s;
1100 },
1101
1102 /*
1103 * Reverses <code>formatSkin</code>, providing the skin name and
1104 * module name if the string matches the pattern for skins.
1105 * @method parseSkin
1106 * @param mod {string} the module name to parse
1107 * @return {skin: string, module: string} the parsed skin name
1108 * and module name, or null if the supplied string does not match
1109 * the skin pattern
1110 *
1111 * This isn't being used at the moment
1112 *
1113 */
1114 // parseSkin: function(mod) {
1115 //
1116 // if (mod.indexOf(this.SKIN_PREFIX) === 0) {
1117 // var a = mod.split("-");
1118 // return {skin: a[1], module: a[2]};
1119 // }
1120 // return null;
1121 // },
1122
1123 /**
1124 * Adds the skin def to the module info
1125 * @method _addSkin
1126 * @param skin {string} the name of the skin
1127 * @param mod {string} the name of the module
1128 * @param parent {string} parent module if this is a skin of a
1129 * submodule or plugin
1130 * @return {string} the module name for the skin
1131 * @private
1132 */
1133 _addSkin: function(skin, mod, parent) {
1134
1135 var name = this.formatSkin(skin),
1136 info = this.moduleInfo,
1137 sinf = this.skin,
1138 ext = info[mod] && info[mod].ext,
1139 mdef, pkg;
1140
1141 /*
1142 // Add a module definition for the skin rollup css
1143 if (!info[name]) {
1144 this.addModule({
1145 'name': name,
1146 'type': 'css',
1147 'path': sinf.base + skin + '/' + sinf.path,
1148 //'supersedes': '*',
1149 'after': sinf.after,
1150 'rollup': sinf.rollup,
1151 'ext': ext
1152 });
1153 }
1154 */
1155
1156 // Add a module definition for the module-specific skin css
1157 if (mod) {
1158 name = this.formatSkin(skin, mod);
1159 if (!info[name]) {
1160 mdef = info[mod];
1161 pkg = mdef.pkg || mod;
1162 this.addModule({
1163 'name': name,
1164 'type': 'css',
1165 'after': sinf.after,
1166 'path': (parent || pkg) + '/' + sinf.base + skin + '/' + mod + '.css',
1167 'ext': ext
1168 });
1169 }
1170 }
1171
1172 return name;
1173 },
1174
1175 /** Add a new module to the component metadata.
1176 * <dl>
1177 * <dt>name:</dt> <dd>required, the component name</dd>
1178 * <dt>type:</dt> <dd>required, the component type (js or css)</dd>
1179 * <dt>path:</dt> <dd>required, the path to the script from "base"</dd>
1180 * <dt>requires:</dt> <dd>array of modules required by this component</dd>
1181 * <dt>optional:</dt> <dd>array of optional modules for this component</dd>
1182 * <dt>supersedes:</dt> <dd>array of the modules this component replaces</dd>
1183 * <dt>after:</dt> <dd>array of modules the components which, if present, should be sorted above this one</dd>
1184 * <dt>rollup:</dt> <dd>the number of superseded modules required for automatic rollup</dd>
1185 * <dt>fullpath:</dt> <dd>If fullpath is specified, this is used instead of the configured base + path</dd>
1186 * <dt>skinnable:</dt> <dd>flag to determine if skin assets should automatically be pulled in</dd>
1187 * <dt>submodules:</dt> <dd>a has of submodules</dd>
1188 * </dl>
1189 * @method addModule
1190 * @param o An object containing the module data
1191 * @param name the module name (optional), required if not in the module data
1192 * @return {boolean} true if the module was added, false if
1193 * the object passed in did not provide all required attributes
1194 */
1195 addModule: function(o, name) {
1196
1197 name = name || o.name;
1198 o.name = name;
1199
1200 if (!o || !o.name) {
1201 return false;
1202 }
1203
1204 if (!o.type) {
1205 o.type = JS;
1206 }
1207
1208 if (!o.path && !o.fullpath) {
1209 // o.path = name + "/" + name + "-min." + o.type;
1210 o.path = _path(name, name, o.type);
1211 }
1212
1213 o.ext = ('ext' in o) ? o.ext : (this._internal) ? false : true;
1214 o.requires = o.requires || [];
1215
1216
1217 this.moduleInfo[name] = o;
1218
1219 // Handle submodule logic
1220 var subs = o.submodules, i, l, sup, s, smod, plugins, plug;
1221 if (subs) {
1222 sup = [];
1223 l = 0;
1224
1225 for (i in subs) {
1226 if (subs.hasOwnProperty(i)) {
1227 s = subs[i];
1228 s.path = _path(name, i, o.type);
1229 this.addModule(s, i);
1230 sup.push(i);
1231
1232 if (o.skinnable) {
1233 smod = this._addSkin(this.skin.defaultSkin, i, name);
1234 sup.push(smod.name);
1235 }
1236
1237 l++;
1238 }
1239 }
1240
1241 o.supersedes = sup;
1242 o.rollup = (l<4) ? l : Math.min(l-1, 4);
1243 }
1244
1245 plugins = o.plugins;
1246 if (plugins) {
1247 for (i in plugins) {
1248 if (plugins.hasOwnProperty(i)) {
1249 plug = plugins[i];
1250 plug.path = _path(name, i, o.type);
1251 plug.requires = plug.requires || [];
1252 // plug.requires.push(name);
1253 this.addModule(plug, i);
1254 if (o.skinnable) {
1255 this._addSkin(this.skin.defaultSkin, i, name);
1256 }
1257 }
1258 }
1259 }
1260
1261 this.dirty = true;
1262
1263 return o;
1264 },
1265
1266 /**
1267 * Add a requirement for one or more module
1268 * @method require
1269 * @param what {string[] | string*} the modules to load
1270 */
1271 require: function(what) {
1272 var a = (typeof what === "string") ? arguments : what;
1273 this.dirty = true;
1274 Y.mix(this.required, Y.Array.hash(a));
1275 },
1276
1277 /**
1278 * Returns an object containing properties for all modules required
1279 * in order to load the requested module
1280 * @method getRequires
1281 * @param mod The module definition from moduleInfo
1282 */
1283 getRequires: function(mod) {
1284
1285 if (!mod) {
1286 return [];
1287 }
1288
1289 if (!this.dirty && mod.expanded) {
1290 return mod.expanded;
1291 }
1292
1293 var i, d=[], r=mod.requires, o=mod.optional,
1294 info=this.moduleInfo, m, j, add;
1295
1296 for (i=0; i<r.length; i=i+1) {
1297 d.push(r[i]);
1298 m = this.getModule(r[i]);
1299 add = this.getRequires(m);
1300 for (j=0;j<add.length;j=j+1) {
1301 d.push(add[j]);
1302 }
1303 }
1304
1305 // get the requirements from superseded modules, if any
1306 r=mod.supersedes;
1307 if (r) {
1308 for (i=0; i<r.length; i=i+1) {
1309 d.push(r[i]);
1310 m = this.getModule(r[i]);
1311 add = this.getRequires(m);
1312 for (j=0;j<add.length;j=j+1) {
1313 d.push(add[j]);
1314 }
1315 }
1316 }
1317
1318 if (o && this.loadOptional) {
1319 for (i=0; i<o.length; i=i+1) {
1320 d.push(o[i]);
1321 add = this.getRequires(info[o[i]]);
1322 for (j=0;j<add.length;j=j+1) {
1323 d.push(add[j]);
1324 }
1325 }
1326 }
1327
1328 mod.expanded = Y.Object.keys(Y.Array.hash(d));
1329 return mod.expanded;
1330 },
1331
1332
1333 /**
1334 * Returns a hash of module names the supplied module satisfies.
1335 * @method getProvides
1336 * @param name {string} The name of the module
1337 * @return what this module provides
1338 */
1339 getProvides: function(name) {
1340 var m = this.getModule(name), o, s;
1341
1342 if (!m) {
1343 return NOT_FOUND;
1344 }
1345
1346 if (m && !m.provides) {
1347 o = {};
1348 s = m.supersedes;
1349
1350 if (s) {
1351 Y.Array.each(s, function(v) {
1352 Y.mix(o, this.getProvides(v));
1353 }, this);
1354 }
1355
1356 o[name] = true;
1357 m.provides = o;
1358 }
1359
1360 return m.provides;
1361 },
1362
1363
1364 /**
1365 * Calculates the dependency tree, the result is stored in the sorted
1366 * property
1367 * @method calculate
1368 * @param o optional options object
1369 * @param type optional argument to prune modules
1370 */
1371 calculate: function(o, type) {
1372 if (o || type || this.dirty) {
1373 this._config(o);
1374 this._setup();
1375 this._explode();
1376 if (this.allowRollup && !this.combine) {
1377 this._rollup();
1378 }
1379 this._reduce();
1380 this._sort();
1381
1382
1383 this.dirty = false;
1384 }
1385 },
1386
1387 /**
1388 * Investigates the current YUI configuration on the page. By default,
1389 * modules already detected will not be loaded again unless a force
1390 * option is encountered. Called by calculate()
1391 * @method _setup
1392 * @private
1393 */
1394 _setup: function() {
1395
1396 var info = this.moduleInfo, name, i, j, m, o, l, smod;
1397
1398 // Create skin modules
1399 for (name in info) {
1400 if (info.hasOwnProperty(name)) {
1401 m = info[name];
1402 if (m && m.skinnable) {
1403 o = this.skin.overrides;
1404 if (o && o[name]) {
1405 for (i=0; i<o[name].length; i=i+1) {
1406 smod = this._addSkin(o[name][i], name);
1407 }
1408 } else {
1409 smod = this._addSkin(this.skin.defaultSkin, name);
1410 }
1411
1412 m.requires.push(smod);
1413 }
1414 }
1415 }
1416
1417 l = Y.merge(this.inserted); // shallow clone
1418
1419 // available modules
1420 if (!this.ignoreRegistered) {
1421 Y.mix(l, GLOBAL_ENV.mods);
1422 }
1423
1424
1425 // add the ignore list to the list of loaded packages
1426 if (this.ignore) {
1427 // OU.appendArray(l, this.ignore);
1428 Y.mix(l, Y.Array.hash(this.ignore));
1429 }
1430
1431 // expand the list to include superseded modules
1432 for (j in l) {
1433 if (l.hasOwnProperty(j)) {
1434 Y.mix(l, this.getProvides(j));
1435 }
1436 }
1437
1438 // remove modules on the force list from the loaded list
1439 if (this.force) {
1440 for (i=0; i<this.force.length; i=i+1) {
1441 if (this.force[i] in l) {
1442 delete l[this.force[i]];
1443 }
1444 }
1445 }
1446
1447
1448 Y.mix(this.loaded, l);
1449
1450 // this.loaded = l;
1451
1452 },
1453
1454
1455 /**
1456 * Inspects the required modules list looking for additional
1457 * dependencies. Expands the required list to include all
1458 * required modules. Called by calculate()
1459 * @method _explode
1460 * @private
1461 */
1462 _explode: function() {
1463
1464 var r = this.required, m, reqs;
1465
1466 Y.Object.each(r, function(v, name) {
1467
1468 m = this.getModule(name);
1469
1470 var expound = m && m.expound;
1471
1472 if (m) {
1473
1474 if (expound) {
1475 r[expound] = this.getModule(expound);
1476 reqs = this.getRequires(r[expound]);
1477 Y.mix(r, Y.Array.hash(reqs));
1478 }
1479
1480 reqs = this.getRequires(m);
1481
1482 Y.mix(r, Y.Array.hash(reqs));
1483 }
1484
1485 }, this);
1486 },
1487
1488 getModule: function(name) {
1489
1490 var m = this.moduleInfo[name];
1491
1492 // create the default module
1493 // if (!m) {
1494 // m = this.addModule({ext: false}, name);
1495 // }
1496
1497 return m;
1498 },
1499
1500 /**
1501 * Look for rollup packages to determine if all of the modules a
1502 * rollup supersedes are required. If so, include the rollup to
1503 * help reduce the total number of connections required. Called
1504 * by calculate()
1505 * @method _rollup
1506 * @private
1507 */
1508 _rollup: function() {
1509 var i, j, m, s, rollups={}, r=this.required, roll,
1510 info = this.moduleInfo, rolled, c;
1511
1512 // find and cache rollup modules
1513 if (this.dirty || !this.rollups) {
1514 for (i in info) {
1515 if (info.hasOwnProperty(i)) {
1516 m = this.getModule(i);
1517 // if (m && m.rollup && m.supersedes) {
1518 if (m && m.rollup) {
1519 rollups[i] = m;
1520 }
1521 }
1522 }
1523
1524 this.rollups = rollups;
1525 this.forceMap = (this.force) ? Y.Array.hash(this.force) : {};
1526 }
1527
1528 // make as many passes as needed to pick up rollup rollups
1529 for (;;) {
1530 rolled = false;
1531
1532 // go through the rollup candidates
1533 for (i in rollups) {
1534
1535 if (rollups.hasOwnProperty(i)) {
1536
1537 // there can be only one, unless forced
1538 if (!r[i] && ((!this.loaded[i]) || this.forceMap[i])) {
1539 m = this.getModule(i);
1540 s = m.supersedes || [];
1541 roll = false;
1542
1543 // @TODO remove continue
1544 if (!m.rollup) {
1545 continue;
1546 }
1547
1548 c = 0;
1549
1550 // check the threshold
1551 for (j=0;j<s.length;j=j+1) {
1552
1553
1554 // if the superseded module is loaded, we can't load the rollup
1555 // unless it has been forced
1556 if (this.loaded[s[j]] && !this.forceMap[s[j]]) {
1557 roll = false;
1558 break;
1559 // increment the counter if this module is required. if we are
1560 // beyond the rollup threshold, we will use the rollup module
1561 } else if (r[s[j]]) {
1562 c++;
1563 roll = (c >= m.rollup);
1564 if (roll) {
1565 break;
1566 }
1567 }
1568 }
1569
1570 if (roll) {
1571 // add the rollup
1572 r[i] = true;
1573 rolled = true;
1574
1575 // expand the rollup's dependencies
1576 this.getRequires(m);
1577 }
1578 }
1579 }
1580 }
1581
1582 // if we made it here w/o rolling up something, we are done
1583 if (!rolled) {
1584 break;
1585 }
1586 }
1587 },
1588
1589 /**
1590 * Remove superceded modules and loaded modules. Called by
1591 * calculate() after we have the mega list of all dependencies
1592 * @method _reduce
1593 * @private
1594 */
1595 _reduce: function() {
1596 var i, j, s, m, r=this.required, type = this.loadType;
1597 for (i in r) {
1598 if (r.hasOwnProperty(i)) {
1599 m = this.getModule(i);
1600 // remove if already loaded
1601 if ((this.loaded[i] && (!this.forceMap[i]) && !this.ignoreRegistered) || (type && m && m.type != type)) {
1602 delete r[i];
1603 // remove anything this module supersedes
1604 } else {
1605
1606 s = m && m.supersedes;
1607 if (s) {
1608 for (j=0; j<s.length; j=j+1) {
1609 if (s[j] in r) {
1610 delete r[s[j]];
1611 }
1612 }
1613 }
1614 }
1615 }
1616 }
1617 },
1618
1619 _attach: function() {
1620 // this is the full list of items the YUI needs attached,
1621 // which is needed if some dependencies are already on
1622 // the page without their dependencies.
1623 if (this.attaching) {
1624 Y._attach(this.attaching);
1625 } else {
1626 Y._attach(this.sorted);
1627 }
1628
1629 // this._pushEvents();
1630
1631 },
1632
1633 _finish: function() {
1634 _queue.running = false;
1635 this._continue();
1636 },
1637
1638 _onSuccess: function() {
1639
1640
1641 this._attach();
1642
1643 var skipped = this.skipped, i, f;
1644
1645 for (i in skipped) {
1646 if (skipped.hasOwnProperty(i)) {
1647 delete this.inserted[i];
1648 }
1649 }
1650
1651 this.skipped = {};
1652
1653 f = this.onSuccess;
1654
1655 if (f) {
1656 f.call(this.context, {
1657 msg: 'success',
1658 data: this.data,
1659 success: true
1660 });
1661 }
1662
1663 this._finish();
1664
1665 },
1666
1667 _onFailure: function(o) {
1668
1669
1670 this._attach();
1671
1672 var f = this.onFailure;
1673 if (f) {
1674 f.call(this.context, {
1675 msg: 'failure: ' + o.msg,
1676 data: this.data,
1677 success: false
1678 });
1679 }
1680
1681 this._finish();
1682 },
1683
1684 _onTimeout: function() {
1685
1686
1687 this._attach();
1688
1689 var f = this.onTimeout;
1690 if (f) {
1691 f.call(this.context, {
1692 msg: 'timeout',
1693 data: this.data,
1694 success: false
1695 });
1696 }
1697
1698 this._finish();
1699 },
1700
1701 /**
1702 * Sorts the dependency tree. The last step of calculate()
1703 * @method _sort
1704 * @private
1705 */
1706 _sort: function() {
1707
1708 // create an indexed list
1709 var s = Y.Object.keys(this.required),
1710 info = this.moduleInfo,
1711 loaded = this.loaded,
1712 done = {},
1713 p=0, l, a, b, j, k, moved, doneKey,
1714
1715 // returns true if b is not loaded, and is required
1716 // directly or by means of modules it supersedes.
1717 requires = Y.cached(function(mod1, mod2) {
1718
1719 var m = info[mod1], i, r, after, other = info[mod2], s;
1720
1721 if (loaded[mod2] || !m || !other) {
1722 return false;
1723 }
1724
1725 r = m.expanded;
1726 after = m.after;
1727
1728 // check if this module requires the other directly
1729 if (r && Y.Array.indexOf(r, mod2) > -1) {
1730 return true;
1731 }
1732
1733 // check if this module should be sorted after the other
1734 if (after && Y.Array.indexOf(after, mod2) > -1) {
1735 return true;
1736 }
1737
1738 // check if this module requires one the other supersedes
1739 s = info[mod2] && info[mod2].supersedes;
1740 if (s) {
1741 for (i=0; i<s.length; i=i+1) {
1742 if (requires(mod1, s[i])) {
1743 return true;
1744 }
1745 }
1746 }
1747
1748 // external css files should be sorted below yui css
1749 if (m.ext && m.type == CSS && !other.ext && other.type == CSS) {
1750 return true;
1751 }
1752
1753 return false;
1754 });
1755
1756 // keep going until we make a pass without moving anything
1757 for (;;) {
1758
1759 l = s.length;
1760 moved = false;
1761
1762 // start the loop after items that are already sorted
1763 for (j=p; j<l; j=j+1) {
1764
1765 // check the next module on the list to see if its
1766 // dependencies have been met
1767 a = s[j];
1768
1769 // check everything below current item and move if we
1770 // find a requirement for the current item
1771 for (k=j+1; k<l; k=k+1) {
1772 doneKey = a + s[k];
1773 if (!done[doneKey] && requires(a, s[k])) {
1774
1775 // extract the dependency so we can move it up
1776 b = s.splice(k, 1);
1777
1778 // insert the dependency above the item that
1779 // requires it
1780 s.splice(j, 0, b[0]);
1781
1782 // only swap two dependencies once to short circut
1783 // circular dependencies
1784 done[doneKey] = true;
1785
1786 // keep working
1787 moved = true;
1788
1789 break;
1790 }
1791 }
1792
1793 // jump out of loop if we moved something
1794 if (moved) {
1795 break;
1796 // this item is sorted, move our pointer and keep going
1797 } else {
1798 p = p + 1;
1799 }
1800 }
1801
1802 // when we make it here and moved is false, we are
1803 // finished sorting
1804 if (!moved) {
1805 break;
1806 }
1807
1808 }
1809
1810 this.sorted = s;
1811 },
1812
1813 _insert: function(source, o, type) {
1814
1815
1816 // restore the state at the time of the request
1817 if (source) {
1818 this._config(source);
1819 }
1820
1821 // build the dependency list
1822 this.calculate(o); // don't include type so we can process CSS and script in
1823 // one pass when the type is not specified.
1824 this.loadType = "js";
1825
1826 // if (!type) {
1827
1828 // var self = this;
1829
1830 // this._internalCallback = function() {
1831 // var f = self.onCSS;
1832 // if (f) {
1833 // f.call(self.context, Y);
1834 // }
1835 // self._internalCallback = null;
1836 // self._insert(null, null, JS);
1837 // };
1838
1839 // // _queue.running = false;
1840 // this._insert(null, null, CSS);
1841
1842 // return;
1843 // }
1844
1845
1846 // set a flag to indicate the load has started
1847 this._loading = true;
1848
1849 // flag to indicate we are done with the combo service
1850 // and any additional files will need to be loaded
1851 // individually
1852 this._combineComplete = {};
1853
1854
1855 // start the load
1856 this.loadNext();
1857
1858 },
1859
1860 _continue: function() {
1861 if (!(_queue.running) && _queue.size() > 0) {
1862 _queue.running = true;
1863 _queue.next()();
1864 }
1865 },
1866
1867 /**
1868 * inserts the requested modules and their dependencies.
1869 * <code>type</code> can be "js" or "css". Both script and
1870 * css are inserted if type is not provided.
1871 * @method insert
1872 * @param o optional options object
1873 * @param type {string} the type of dependency to insert
1874 */
1875 insert: function(o, type) {
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches