Merge lp:~muffinresearch/phazr/click-outside-to-dismiss into lp:phazr

Proposed by Stuart Colville
Status: Superseded
Proposed branch: lp:~muffinresearch/phazr/click-outside-to-dismiss
Merge into: lp:phazr
Diff against target: 807 lines (+528/-117)
14 files modified
assets/cancel.svg (+90/-0)
assets/close.svg (+90/-0)
assets/ok.svg (+90/-0)
examples/editableplugin/index.html (+70/-0)
examples/formplugin/index.html (+3/-3)
examples/modaloverlay/index.html (+0/-37)
examples/overlay/index.html (+1/-3)
src/css/phazr.css (+5/-1)
src/js/editableplugin/editableplugin.js (+88/-0)
src/js/formplugin/formplugin.js (+26/-17)
src/js/modaloverlay/modaloverlay.js (+0/-48)
src/js/phazroverlay/phazroverlay.js (+63/-6)
tests/formplugin.js (+1/-1)
tests/phazroverlay.js (+1/-1)
To merge this branch: bzr merge lp:~muffinresearch/phazr/click-outside-to-dismiss
Reviewer Review Type Date Requested Status
Phazr team Pending
Review via email: mp+63720@code.launchpad.net

This proposal has been superseded by a proposal from 2011-06-07.

Description of the change

Add click outside to dismiss modal dialogue.

To post a comment you must log in.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'assets'
2=== added file 'assets/cancel.svg'
3--- assets/cancel.svg 1970-01-01 00:00:00 +0000
4+++ assets/cancel.svg 2011-06-07 15:32:35 +0000
5@@ -0,0 +1,90 @@
6+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
7+<!-- Created with Inkscape (http://www.inkscape.org/) -->
8+
9+<svg
10+ xmlns:dc="http://purl.org/dc/elements/1.1/"
11+ xmlns:cc="http://creativecommons.org/ns#"
12+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
13+ xmlns:svg="http://www.w3.org/2000/svg"
14+ xmlns="http://www.w3.org/2000/svg"
15+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
16+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
17+ width="128"
18+ height="128"
19+ id="svg2985"
20+ version="1.1"
21+ inkscape:version="0.48.1 r9760"
22+ sodipodi:docname="close.svg">
23+ <defs
24+ id="defs2987" />
25+ <sodipodi:namedview
26+ id="base"
27+ pagecolor="#ffffff"
28+ bordercolor="#666666"
29+ borderopacity="1.0"
30+ inkscape:pageopacity="0.0"
31+ inkscape:pageshadow="2"
32+ inkscape:zoom="2.8284271"
33+ inkscape:cx="61.841334"
34+ inkscape:cy="80.280491"
35+ inkscape:current-layer="g3788"
36+ showgrid="true"
37+ inkscape:document-units="px"
38+ inkscape:grid-bbox="true"
39+ inkscape:window-width="1280"
40+ inkscape:window-height="702"
41+ inkscape:window-x="0"
42+ inkscape:window-y="0"
43+ inkscape:window-maximized="0" />
44+ <metadata
45+ id="metadata2990">
46+ <rdf:RDF>
47+ <cc:Work
48+ rdf:about="">
49+ <dc:format>image/svg+xml</dc:format>
50+ <dc:type
51+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
52+ <dc:title></dc:title>
53+ </cc:Work>
54+ </rdf:RDF>
55+ </metadata>
56+ <g
57+ id="layer1"
58+ inkscape:label="Layer 1"
59+ inkscape:groupmode="layer"
60+ transform="translate(0,64)">
61+ <path
62+ sodipodi:type="arc"
63+ style="fill:none;fill-rule:evenodd;stroke:#646464;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
64+ id="path2993"
65+ sodipodi:cx="63.090908"
66+ sodipodi:cy="64"
67+ sodipodi:rx="55.454544"
68+ sodipodi:ry="54.18182"
69+ d="M 118.54545,64 A 55.454544,54.18182 0 1 1 7.636364,64 55.454544,54.18182 0 1 1 118.54545,64 z"
70+ transform="matrix(1.0721871,0,0,1.0973726,-3.6452576,-70.231844)" />
71+ <g
72+ id="g3788"
73+ transform="matrix(0.70710678,-0.70710678,0.70710678,0.70710678,20.695964,43.304036)">
74+ <rect
75+ ry="3"
76+ rx="4.5"
77+ y="-50"
78+ x="54"
79+ height="100"
80+ width="15"
81+ id="rect3763"
82+ style="fill:#a40000;fill-opacity:1;stroke:none" />
83+ <rect
84+ transform="matrix(0,1,-1,0,0,0)"
85+ style="fill:#a40000;fill-opacity:1;stroke:none"
86+ id="rect3786"
87+ width="15"
88+ height="100"
89+ x="-7.5"
90+ y="-111.5"
91+ rx="4.5"
92+ ry="3" />
93+ </g>
94+ </g>
95+</svg>
96
97=== added file 'assets/close.svg'
98--- assets/close.svg 1970-01-01 00:00:00 +0000
99+++ assets/close.svg 2011-06-07 15:32:35 +0000
100@@ -0,0 +1,90 @@
101+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
102+<!-- Created with Inkscape (http://www.inkscape.org/) -->
103+
104+<svg
105+ xmlns:dc="http://purl.org/dc/elements/1.1/"
106+ xmlns:cc="http://creativecommons.org/ns#"
107+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
108+ xmlns:svg="http://www.w3.org/2000/svg"
109+ xmlns="http://www.w3.org/2000/svg"
110+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
111+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
112+ width="128"
113+ height="128"
114+ id="svg2985"
115+ version="1.1"
116+ inkscape:version="0.48.1 r9760"
117+ sodipodi:docname="close.svg">
118+ <defs
119+ id="defs2987" />
120+ <sodipodi:namedview
121+ id="base"
122+ pagecolor="#ffffff"
123+ bordercolor="#666666"
124+ borderopacity="1.0"
125+ inkscape:pageopacity="0.0"
126+ inkscape:pageshadow="2"
127+ inkscape:zoom="2.8284271"
128+ inkscape:cx="57.068363"
129+ inkscape:cy="80.280491"
130+ inkscape:current-layer="g3788"
131+ showgrid="true"
132+ inkscape:document-units="px"
133+ inkscape:grid-bbox="true"
134+ inkscape:window-width="1280"
135+ inkscape:window-height="702"
136+ inkscape:window-x="0"
137+ inkscape:window-y="0"
138+ inkscape:window-maximized="0" />
139+ <metadata
140+ id="metadata2990">
141+ <rdf:RDF>
142+ <cc:Work
143+ rdf:about="">
144+ <dc:format>image/svg+xml</dc:format>
145+ <dc:type
146+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
147+ <dc:title></dc:title>
148+ </cc:Work>
149+ </rdf:RDF>
150+ </metadata>
151+ <g
152+ id="layer1"
153+ inkscape:label="Layer 1"
154+ inkscape:groupmode="layer"
155+ transform="translate(0,64)">
156+ <path
157+ sodipodi:type="arc"
158+ style="fill:none;fill-rule:evenodd;stroke:#646464;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
159+ id="path2993"
160+ sodipodi:cx="63.090908"
161+ sodipodi:cy="64"
162+ sodipodi:rx="55.454544"
163+ sodipodi:ry="54.18182"
164+ d="M 118.54545,64 A 55.454544,54.18182 0 1 1 7.636364,64 55.454544,54.18182 0 1 1 118.54545,64 z"
165+ transform="matrix(1.0721871,0,0,1.0973726,-3.6452576,-70.231844)" />
166+ <g
167+ id="g3788"
168+ transform="matrix(0.70710678,-0.70710678,0.70710678,0.70710678,20.695964,43.304036)">
169+ <rect
170+ ry="3"
171+ rx="4.5"
172+ y="-50"
173+ x="54"
174+ height="100"
175+ width="15"
176+ id="rect3763"
177+ style="fill:#646464;fill-opacity:1;stroke:none" />
178+ <rect
179+ transform="matrix(0,1,-1,0,0,0)"
180+ style="fill:#646464;fill-opacity:1;stroke:none"
181+ id="rect3786"
182+ width="15"
183+ height="100"
184+ x="-7.5"
185+ y="-111.5"
186+ rx="4.5"
187+ ry="3" />
188+ </g>
189+ </g>
190+</svg>
191
192=== added file 'assets/ok.svg'
193--- assets/ok.svg 1970-01-01 00:00:00 +0000
194+++ assets/ok.svg 2011-06-07 15:32:35 +0000
195@@ -0,0 +1,90 @@
196+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
197+<!-- Created with Inkscape (http://www.inkscape.org/) -->
198+
199+<svg
200+ xmlns:dc="http://purl.org/dc/elements/1.1/"
201+ xmlns:cc="http://creativecommons.org/ns#"
202+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
203+ xmlns:svg="http://www.w3.org/2000/svg"
204+ xmlns="http://www.w3.org/2000/svg"
205+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
206+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
207+ width="128"
208+ height="128"
209+ id="svg2985"
210+ version="1.1"
211+ inkscape:version="0.48.1 r9760"
212+ sodipodi:docname="ok.svg">
213+ <defs
214+ id="defs2987" />
215+ <sodipodi:namedview
216+ id="base"
217+ pagecolor="#ffffff"
218+ bordercolor="#666666"
219+ borderopacity="1.0"
220+ inkscape:pageopacity="0.0"
221+ inkscape:pageshadow="2"
222+ inkscape:zoom="2.8284271"
223+ inkscape:cx="68.165161"
224+ inkscape:cy="54.161237"
225+ inkscape:current-layer="g3788"
226+ showgrid="true"
227+ inkscape:document-units="px"
228+ inkscape:grid-bbox="true"
229+ inkscape:window-width="1280"
230+ inkscape:window-height="702"
231+ inkscape:window-x="0"
232+ inkscape:window-y="0"
233+ inkscape:window-maximized="0" />
234+ <metadata
235+ id="metadata2990">
236+ <rdf:RDF>
237+ <cc:Work
238+ rdf:about="">
239+ <dc:format>image/svg+xml</dc:format>
240+ <dc:type
241+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
242+ <dc:title></dc:title>
243+ </cc:Work>
244+ </rdf:RDF>
245+ </metadata>
246+ <g
247+ id="layer1"
248+ inkscape:label="Layer 1"
249+ inkscape:groupmode="layer"
250+ transform="translate(0,64)">
251+ <path
252+ sodipodi:type="arc"
253+ style="fill:none;fill-rule:evenodd;stroke:#646464;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
254+ id="path2993"
255+ sodipodi:cx="63.090908"
256+ sodipodi:cy="64"
257+ sodipodi:rx="55.454544"
258+ sodipodi:ry="54.18182"
259+ d="M 118.54545,64 A 55.454544,54.18182 0 1 1 7.636364,64 55.454544,54.18182 0 1 1 118.54545,64 z"
260+ transform="matrix(1.0721871,0,0,1.0973726,-3.6452576,-70.231844)" />
261+ <g
262+ id="g3788"
263+ transform="matrix(0.70710678,-0.70710678,0.70710678,0.70710678,20.695964,43.304036)">
264+ <rect
265+ style="fill:#00a400;fill-opacity:1;stroke:none"
266+ id="rect3896"
267+ width="15"
268+ height="40"
269+ x="22.212006"
270+ y="-26.36396"
271+ rx="3"
272+ ry="3" />
273+ <rect
274+ ry="2.7"
275+ rx="3"
276+ transform="matrix(0,1,-1,0,0,0)"
277+ y="-112.58459"
278+ x="-1.437555"
279+ height="90"
280+ width="15"
281+ id="rect3898"
282+ style="fill:#00a400;fill-opacity:1;stroke:none" />
283+ </g>
284+ </g>
285+</svg>
286
287=== added directory 'examples/editableplugin'
288=== added file 'examples/editableplugin/index.html'
289--- examples/editableplugin/index.html 1970-01-01 00:00:00 +0000
290+++ examples/editableplugin/index.html 2011-06-07 15:32:35 +0000
291@@ -0,0 +1,70 @@
292+<!DOCTYPE html>
293+<meta charset="utf-8" />
294+<html>
295+ <head>
296+ <title>Editable Plugin</title>
297+ <script type="text/javascript"
298+ src="http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js"></script>
299+ <script type="text/javascript"
300+ src="../../src/js/editableplugin/editableplugin.js"></script>
301+ <link rel="stylesheet" href="../../src/css/phazr.css" />
302+ </head>
303+ <body>
304+ <div id="editable-example">
305+ <h1>Editable Plugin</h1>
306+ <p>EditablePlugin allows any text Node to be editable. Select the Node
307+ and plug Editable into it.</p>
308+ <p>
309+ <span id="editable-demo">
310+ This text has a typo, but it's compeletely editable.
311+ </span>
312+ </p>
313+ <script type="text/javascript">
314+ YUI().use('phazr-editable', 'node', function(Y) {
315+ var demo = Y.one('#editable-demo');
316+ demo.plug(Y.Editable, {
317+ saveFn: function(value) { alert(value); }
318+ });
319+ });
320+ </script>
321+ <pre><code>
322+YUI().use('phazr-editable', 'node', function(Y) {
323+ var demo = Y.one('#editable-demo');
324+ demo.plug(Y.Editable, {
325+ saveFn: function(value) { alert(value); }
326+ });
327+});
328+ </code></pre>
329+
330+ <h2>Multi-line editing</h2>
331+ <p>By default, the editor only supports a single line. In some cases,
332+ you may want to edit paragraphs of text. In this case, you can simply
333+ pass <code>multiline: true</code> when you plug the editor into the
334+ Node.</p>
335+ <p>
336+ <p id="multiline-editable-demo">
337+ This is a paragraph of text. There are no typos in this paragraph, but you may want to edit it anyway. Go ahead and try it.
338+ </p>
339+ </p>
340+ <script type="text/javascript">
341+ YUI().use('phazr-editable', 'node', function(Y) {
342+ var demo = Y.one('#multiline-editable-demo');
343+ demo.plug(Y.Editable, {
344+ multiline: true,
345+ saveFn: function(value) { alert(value); }
346+ });
347+ });
348+ </script>
349+ <pre><code>
350+YUI().use('phazr-editable', 'node', function(Y) {
351+ var demo = Y.one('#multiline-editable-demo');
352+ demo.plug(Y.Editable, {
353+ multiline: true,
354+ saveFn: function(value) { alert(value); }
355+ });
356+});
357+ </code></pre>
358+
359+ </div>
360+ </body>
361+</html>
362
363=== modified file 'examples/formplugin/index.html'
364--- examples/formplugin/index.html 2011-03-19 04:57:56 +0000
365+++ examples/formplugin/index.html 2011-06-07 15:32:35 +0000
366@@ -24,19 +24,19 @@
367 whereas <code>loadFormFromURL</code> will load a form from a specified
368 URL.</p>
369 <script type="text/javascript">
370- YUI().use('formplugin', 'overlay', function(Y) {
371+ YUI().use('phazr-formplugin', 'overlay', function(Y) {
372 var overlay = new Y.Overlay({
373 bodyContent: 'This is where the body content goes',
374 centered: true,
375 footerContent: 'This is a footer.',
376 headerContent: 'This is a header',
377 plugins: [{fn: Y.FormPlugin, cfg: {
378- submitFn: function() { alert('submitted'); }
379+ submitFn: function() { alert('submitted'); this.hide(); }
380 }}],
381 visible: true,
382 zIndex: 10
383 });
384- overlay.loadForm(
385+ overlay.form.loadForm(
386 '<form action=""><label>Name</label><input type="text" name="name" /></form>');
387 overlay.render();
388 });
389
390=== removed directory 'examples/modaloverlay'
391=== removed file 'examples/modaloverlay/index.html'
392--- examples/modaloverlay/index.html 2011-05-02 02:18:55 +0000
393+++ examples/modaloverlay/index.html 1970-01-01 00:00:00 +0000
394@@ -1,37 +0,0 @@
395-<!DOCTYPE html>
396-<meta charset="utf-8" />
397-<html>
398- <head>
399- <title>Modal Overlay</title>
400- <script type="text/javascript"
401- src="http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js"></script>
402- <script type="text/javascript"
403- src="../../src/js/modaloverlay/modaloverlay.js"></script>
404- <link rel="stylesheet" href="../../src/css/phazr.css" />
405- </head>
406- <body>
407- <div id="modaloverlay-demo">
408- <h1>Modal Extension for Overlays</h1>
409- <p>Modal Extension allows on overlay to operate more like a modal dialog.
410- It has a "close" button at the top right and will also close when hitting
411- "Esc" on the keyboard or clicking outside the overlay.</p>
412- <script type="text/javascript">
413- YUI().use('modaloverlay', 'overlay', function(Y) {
414- var Overlay = Y.Base.create('overlay', Y.Overlay, [
415- Y.ModalOverlay]);
416- var overlay = new Overlay({
417- bodyContent: 'This is where the body content goes',
418- centered: true,
419- footerContent: 'This is a footer.',
420- headerContent: 'This is a header',
421- visible: true,
422- zIndex: 10
423- });
424- overlay.render();
425- });
426- </script>
427- <pre><code>
428- </code></pre>
429- </div>
430- </body>
431-</html>
432
433=== modified file 'examples/overlay/index.html'
434--- examples/overlay/index.html 2011-04-07 05:53:46 +0000
435+++ examples/overlay/index.html 2011-06-07 15:32:35 +0000
436@@ -6,8 +6,6 @@
437 <script type="text/javascript"
438 src="http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js"></script>
439 <script type="text/javascript"
440- src="../../src/js/modaloverlay/modaloverlay.js"></script>
441- <script type="text/javascript"
442 src="../../src/js/phazroverlay/phazroverlay.js"></script>
443 <link rel="stylesheet" href="../../src/css/phazr.css" />
444 </head>
445@@ -18,7 +16,7 @@
446 overlay. We skin it with CSS, so that it looks consistent with the
447 previous lazr-js PrettyOverlay.</p>
448 <script type="text/javascript">
449- YUI().use('phazroverlay', function(Y) {
450+ YUI().use('phazr-overlay', function(Y) {
451 var overlay = new Y.PhazrOverlay({
452 centered: true,
453 zIndex: 10,
454
455=== modified file 'src/css/images/cancel.png'
456Binary files src/css/images/cancel.png 2011-03-23 02:17:50 +0000 and src/css/images/cancel.png 2011-06-07 15:32:35 +0000 differ
457=== modified file 'src/css/images/close.png'
458Binary files src/css/images/close.png 2011-03-23 02:17:50 +0000 and src/css/images/close.png 2011-06-07 15:32:35 +0000 differ
459=== renamed file 'src/css/images/okay.png' => 'src/css/images/ok.png'
460Binary files src/css/images/okay.png 2011-03-23 02:17:50 +0000 and src/css/images/ok.png 2011-06-07 15:32:35 +0000 differ
461=== modified file 'src/css/phazr.css'
462--- src/css/phazr.css 2011-04-07 05:41:04 +0000
463+++ src/css/phazr.css 2011-06-07 15:32:35 +0000
464@@ -1,3 +1,7 @@
465+a.save { background: url('images/ok.png') 0 0 no-repeat; display: inline-block; height: 16px; width: 16px; }
466+a.cancel { background: url('images/cancel.png') 0 0 no-repeat; display: inline-block; height: 16px; width: 16px; }
467+
468+
469 div.yui3-widget .clickable {
470 cursor: pointer;
471 }
472@@ -41,7 +45,7 @@
473 width: 32px;
474 }
475 div.yui3-overlay div.yui3-overlay-controls a#save-control {
476- background: url('images/okay.png') 0 0 no-repeat;
477+ background: url('images/ok.png') 0 0 no-repeat;
478 }
479 div.yui3-overlay div.yui3-overlay-controls a#cancel-control {
480 background: url('images/cancel.png') 0 0 no-repeat;
481
482=== added directory 'src/js/editableplugin'
483=== added file 'src/js/editableplugin/editableplugin.js'
484--- src/js/editableplugin/editableplugin.js 1970-01-01 00:00:00 +0000
485+++ src/js/editableplugin/editableplugin.js 2011-06-07 15:32:35 +0000
486@@ -0,0 +1,88 @@
487+YUI.add('phazr-editable', function(Y) {
488+
489+ Y.Editable = Y.Base.create('editable', Y.Plugin.Base, [], {
490+ initializer: function(config) {
491+ var host = this.get('host');
492+ host.addClass('editable');
493+ host.on('click', Y.bind(this.edit, this));
494+ },
495+ cancel: function() {
496+ var editor = this.get('editor'),
497+ host = this.get('host');
498+ editor.hide();
499+ host.show();
500+ },
501+ edit: function(e) {
502+ e.preventDefault();
503+ var host = this.get('host');
504+ multiline = this.get('multiline'),
505+ text = Y.Lang.trim(host.get('text')),
506+ editor = this.get('editor');
507+
508+ if (editor === null) {
509+ var parentNode = host.get('parentNode'),
510+ editor = Y.Node.create('<div></div>'),
511+ controlTemplate = multiline ? '<div></div>' : '<span></span>',
512+ controls = Y.Node.create(controlTemplate),
513+ save = Y.Node.create(this.get('saveTemplate')),
514+ cancel = Y.Node.create(this.get('cancelTemplate')),
515+ textbox = null;
516+
517+ if (multiline) {
518+ textbox = Y.Node.create('<textarea></textarea>');
519+ } else {
520+ textbox = Y.Node.create('<input type="text" />');
521+ }
522+
523+ save.on('click', this.save, this);
524+ cancel.on('click', this.cancel, this);
525+
526+ controls.appendChild(save);
527+ controls.appendChild(cancel);
528+ editor.appendChild(textbox);
529+ editor.appendChild(controls);
530+ editor.hide();
531+
532+ textbox.on('keyup', this._handleKeyPress, this);
533+ parentNode.insert(editor, host);
534+ this.set('editor', editor);
535+ }
536+
537+ editor.get('firstChild').set('value', text);
538+ editor.show();
539+ host.hide();
540+ },
541+ save: function() {
542+ var editor = this.get('editor'),
543+ host = this.get('host'),
544+ save = this.get('saveFn'),
545+ value = editor.get('firstChild').get('value');
546+ if (save !== null) { save(value); }
547+ host.setContent(value);
548+ editor.hide();
549+ host.show();
550+ },
551+ _handleKeyPress: function(e) {
552+ if (e.keyCode) {
553+ if (e.keyCode === 27) { this.cancel(); }
554+ if (e.keyCode === 13 && this.get('multiline') === false) {
555+ this.save();
556+ }
557+ }
558+ }
559+ }, {
560+ ATTRS: {
561+ cancelTemplate: { value: '<button class="phazr-button phazr-cancel">Cancel</button>' },
562+ editor: { value: null },
563+ multiline: { value: false },
564+ saveFn: { value: null },
565+ saveTemplate: { value: '<button class="phazr-button phazr-save">Save</button>' }
566+ },
567+ NS: 'editable'
568+ });
569+
570+}, '1.0', { requires: [
571+ 'base',
572+ 'node',
573+ 'plugin',
574+]});
575
576=== modified file 'src/js/formplugin/formplugin.js'
577--- src/js/formplugin/formplugin.js 2011-03-23 02:29:46 +0000
578+++ src/js/formplugin/formplugin.js 2011-06-07 15:32:35 +0000
579@@ -1,10 +1,8 @@
580-YUI.add('formplugin', function(Y) {
581+YUI.add('phazr-formplugin', function(Y) {
582
583 var FormPlugin = Y.Base.create('formplugin', Y.Plugin.Base, [], {
584 initializer: function(config) {
585 var host = this.get('host');
586- host.loadForm = Y.bind(this.loadForm, this);
587- host.loadFormFromURL = Y.bind(this.loadFormFromURL, this);
588
589 if (config.submitFn) {
590 this.set('submitFn', config.submitFn);
591@@ -15,26 +13,23 @@
592 },
593 renderUI: function() {
594 var host = this.get('host'),
595- saveButton = Y.Node.create(
596- '<a class="clickable" id="save-control"></a>'),
597- cancelButton = Y.Node.create(
598- '<a class="clickable" id="cancel-control"></a>'),
599+ saveButton = this.get('saveButton'),
600+ cancelButton = this.get('cancelButton'),
601 controls = Y.Node.create('<div></div>');
602 controls.addClass(host.getClassName() + '-controls');
603 controls.appendChild(saveButton);
604 controls.appendChild(cancelButton);
605- this.set('saveButton', saveButton);
606- this.set('cancelButton', cancelButton);
607 host.get('contentBox').appendChild(controls);
608 },
609 bindUI: function() {
610 var host = this.get('host');
611 footer = host.get('boundingBox').one('.yui3-widget-ft');
612- this.get('saveButton').on('click', this.get('submitFn'));
613- this.get('cancelButton').on('click', function(e) {
614- e.preventDefault();
615- host.hide();
616- });
617+ this.get('saveButton').on('click', this.get('submitFn'), this.get('host'));
618+ this.get('cancelButton').on('click', this.close, this);
619+ },
620+ close: function(e) {
621+ e.preventDefault();
622+ this.get('host').hide();
623 },
624 loadForm: function(form) {
625 var host = this.get('host'),
626@@ -54,16 +49,30 @@
627 }
628 }, {
629 ATTRS: {
630- cancelButton: {},
631+ cancelButton: {
632+ valueFn: function() {
633+ return Y.Node.create(this.get('cancelTemplate'));
634+ }
635+ },
636+ cancelTemplate: {
637+ value: '<button class="phazr-button phazr-cancel">Cancel</button>'
638+ },
639 form: {},
640- saveButton: {},
641+ saveButton: {
642+ valueFn: function() {
643+ return Y.Node.create(this.get('saveTemplate'));
644+ }
645+ },
646+ saveTemplate: {
647+ value: '<button class="phazr-button phazr-save">Save</button>'
648+ },
649 submitFn: {
650 defaultFn: function() {
651 return function() {};
652 }
653 }
654 },
655- NS: 'formPlugin'
656+ NS: 'form'
657 });
658 Y.FormPlugin = FormPlugin;
659
660
661=== removed directory 'src/js/modaloverlay'
662=== removed file 'src/js/modaloverlay/modaloverlay.js'
663--- src/js/modaloverlay/modaloverlay.js 2011-04-07 05:53:46 +0000
664+++ src/js/modaloverlay/modaloverlay.js 1970-01-01 00:00:00 +0000
665@@ -1,48 +0,0 @@
666-YUI.add('modaloverlay', function(Y) {
667-
668- var ModalOverlay = function(config) {
669- Y.Do.after(this.afterRenderUI, this, 'renderUI');
670- Y.Do.after(this.afterBindUI, this, 'bindUI');
671- };
672- ModalOverlay.ATTRS = {
673- closeButton: { value: null },
674- dragDelegate: { value: null }
675- };
676- ModalOverlay.prototype = {
677- afterRenderUI: function() {
678- var template = '<div class="{containerClassName}"><a class="{linkClassName}"></a></div>',
679- className = this.getClassName(),
680- context = {
681- containerClassName: className + '-close',
682- linkClassName: className + '-close-button'
683- },
684- closeContainer = Y.Node.create(
685- Y.substitute(template, context));
686- this.get('contentBox').prepend(closeContainer);
687- this.set('closeButton',
688- closeContainer.one('.' + className + '-close-button'));
689- },
690- afterBindUI: function() {
691- this.get('closeButton').on('click', this.hide, this);
692- Y.on('keyup', function(e) {
693- if (e.keyCode == 27) {
694- this.hide();
695- }
696- }, window, this);
697-
698- var box = this.get('boundingBox'),
699- header = box.one('.' + className + '-hd'),
700- className = this.getClassName(),
701- dd = new Y.DD.Drag({
702- node: box,
703- handle: header
704- });
705- this.set('dragDelegate', dd);
706-
707- }
708- };
709- Y.ModalOverlay = ModalOverlay;
710-
711-}, '0.1', {requires: [
712- 'base', 'dd-delegate', 'node', 'plugin', 'substitute'
713-]});
714
715=== modified file 'src/js/phazroverlay/phazroverlay.js'
716--- src/js/phazroverlay/phazroverlay.js 2011-04-07 05:02:25 +0000
717+++ src/js/phazroverlay/phazroverlay.js 2011-06-07 15:32:35 +0000
718@@ -1,6 +1,63 @@
719-YUI.add('phazroverlay', function(Y) {
720-
721- Y.PhazrOverlay = Y.Base.create('overlay', Y.Overlay, [
722- Y.ModalOverlay]);
723-
724-}, '1.0', { requires: ['base', 'modaloverlay', 'overlay']})
725+YUI.add('phazr-overlay', function(Y) {
726+
727+ var ModalOverlay = function(config) {
728+ Y.Do.after(this.afterRenderUI, this, 'renderUI');
729+ Y.Do.after(this.afterBindUI, this, 'bindUI');
730+ };
731+ ModalOverlay.ATTRS = {
732+ closeButton: { value: null },
733+ dragDelegate: { value: null }
734+ };
735+ ModalOverlay.prototype = {
736+ afterRenderUI: function() {
737+ var template = '<div class="{containerClassName}"><a class="{linkClassName}"></a></div>',
738+ className = this.getClassName(),
739+ context = {
740+ containerClassName: className + '-close',
741+ linkClassName: className + '-close-button'
742+ },
743+ closeContainer = Y.Node.create(
744+ Y.substitute(template, context));
745+ this.get('contentBox').prepend(closeContainer);
746+ this.set('closeButton',
747+ closeContainer.one('.' + className + '-close-button'));
748+ },
749+ afterBindUI: function() {
750+ this.get('closeButton').on('click', this.hide, this);
751+ Y.on('keyup', function(e) {
752+ if (e.keyCode == 27) {
753+ this.hide();
754+ }
755+ }, window, this);
756+
757+ var box = this.get('boundingBox'),
758+ header = box.one('.' + className + '-hd'),
759+ className = this.getClassName(),
760+ dd = new Y.DD.Drag({
761+ node: box,
762+ handle: header
763+ });
764+ this.set('dragDelegate', dd);
765+
766+ Y.one("html").on("modaloutside|click",
767+ function(e) {
768+ var targ = e.target;
769+ if (!box.contains(targ)) {
770+ this.hide();
771+ Y.detach("modaloutside|click");
772+ }
773+ },
774+ this);
775+ }
776+ };
777+
778+ Y.PhazrOverlay = Y.Base.create('overlay', Y.Overlay, [ModalOverlay]);
779+
780+}, '1.0', { requires: [
781+ 'base',
782+ 'dd-delegate',
783+ 'node',
784+ 'overlay',
785+ 'plugin',
786+ 'substitute'
787+]});
788
789=== modified file 'tests/formplugin.js'
790--- tests/formplugin.js 2011-03-19 22:09:56 +0000
791+++ tests/formplugin.js 2011-06-07 15:32:35 +0000
792@@ -1,4 +1,4 @@
793-YUI().use('formplugin', 'overlay', 'test', function(Y) {
794+YUI().use('phazr-formplugin', 'overlay', 'test', function(Y) {
795
796 var suite = new Y.Test.Suite('FormPlugin tests');
797 suite.add(new Y.Test.Case({
798
799=== modified file 'tests/phazroverlay.js'
800--- tests/phazroverlay.js 2011-04-07 05:02:25 +0000
801+++ tests/phazroverlay.js 2011-06-07 15:32:35 +0000
802@@ -1,4 +1,4 @@
803-YUI().use('phazroverlay', 'node-event-simulate', 'test', function(Y) {
804+YUI().use('phazr-overlay', 'node-event-simulate', 'test', function(Y) {
805
806 var suite = new Y.Test.Suite('PhazrOverlay tests');
807 suite.add(new Y.Test.Case({

Subscribers

People subscribed via source and target branches