source: branches/1.2/workflow/js/htmlarea/dialog.js @ 1349

Revision 1349, 2.3 KB checked in by niltonneto, 15 years ago (diff)

Ticket #561 - Inclusão do módulo Workflow faltante nessa versão.

  • Property svn:executable set to *
Line 
1// htmlArea v3.0 - Copyright (c) 2003-2004 interactivetools.com, inc.
2// This copyright notice MUST stay intact for use (see license.txt).
3//
4// Portions (c) dynarch.com, 2003-2004
5//
6// A free WYSIWYG editor replacement for <textarea> fields.
7// For full source code and docs, visit http://www.interactivetools.com/
8//
9// Version 3.0 developed by Mihai Bazon.
10//   http://dynarch.com/mishoo
11//
12
13// Though "Dialog" looks like an object, it isn't really an object.  Instead
14// it's just namespace for protecting global symbols.
15
16function Dialog(url, action, init) {
17        if (typeof init == "undefined") {
18                init = window;  // pass this window object by default
19        }
20        Dialog._geckoOpenModal(url, action, init);
21};
22
23Dialog._parentEvent = function(ev) {
24        setTimeout( function() { if (Dialog._modal && !Dialog._modal.closed) { Dialog._modal.focus() } }, 50);
25        if (Dialog._modal && !Dialog._modal.closed) {
26                HTMLArea._stopEvent(ev);
27        }
28};
29
30
31// should be a function, the return handler of the currently opened dialog.
32Dialog._return = null;
33
34// constant, the currently opened dialog
35Dialog._modal = null;
36
37// the dialog will read it's args from this variable
38Dialog._arguments = null;
39
40Dialog._geckoOpenModal = function(url, action, init) {
41        var dlg = window.open(url, "hadialog",
42                              "toolbar=no,menubar=no,personalbar=no,width=10,height=10," +
43                              "scrollbars=no,resizable=yes,modal=yes,dependable=yes");
44        Dialog._modal = dlg;
45        Dialog._arguments = init;
46
47        // capture some window's events
48        function capwin(w) {
49                HTMLArea._addEvent(w, "click", Dialog._parentEvent);
50                HTMLArea._addEvent(w, "mousedown", Dialog._parentEvent);
51                HTMLArea._addEvent(w, "focus", Dialog._parentEvent);
52        };
53        // release the captured events
54        function relwin(w) {
55                HTMLArea._removeEvent(w, "click", Dialog._parentEvent);
56                HTMLArea._removeEvent(w, "mousedown", Dialog._parentEvent);
57                HTMLArea._removeEvent(w, "focus", Dialog._parentEvent);
58        };
59        capwin(window);
60        // capture other frames
61        for (var i = 0; i < window.frames.length; capwin(window.frames[i++]));
62        // make up a function to be called when the Dialog ends.
63        Dialog._return = function (val) {
64                if (val && action) {
65                        action(val);
66                }
67                relwin(window);
68                // capture other frames
69                for (var i = 0; i < window.frames.length; relwin(window.frames[i++]));
70                Dialog._modal = null;
71        };
72};
Note: See TracBrowser for help on using the repository browser.