source: branches/1.2/workflow/js/htmlarea/popups/popup.js @ 1349

Revision 1349, 2.9 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) 2002, 2003 interactivetools.com, inc.
2// This copyright notice MUST stay intact for use (see license.txt).
3//
4// Portions (c) dynarch.com, 2003
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
13function getAbsolutePos(el) {
14        var r = { x: el.offsetLeft, y: el.offsetTop };
15        if (el.offsetParent) {
16                var tmp = getAbsolutePos(el.offsetParent);
17                r.x += tmp.x;
18                r.y += tmp.y;
19        }
20        return r;
21};
22
23function comboSelectValue(c, val) {
24        var ops = c.getElementsByTagName("option");
25        for (var i = ops.length; --i >= 0;) {
26                var op = ops[i];
27                op.selected = (op.value == val);
28        }
29        c.value = val;
30};
31
32function __dlg_onclose() {
33        opener.Dialog._return(null);
34};
35
36function __dlg_init(bottom) {
37        var body = document.body;
38        var body_height = 0;
39        if (typeof bottom == "undefined") {
40                var div = document.createElement("div");
41                body.appendChild(div);
42                var pos = getAbsolutePos(div);
43                body_height = pos.y;
44        } else {
45                var pos = getAbsolutePos(bottom);
46                body_height = pos.y + bottom.offsetHeight;
47        }
48        window.dialogArguments = opener.Dialog._arguments;
49        if (!document.all) {
50                window.sizeToContent();
51                window.sizeToContent(); // for reasons beyond understanding,
52                                        // only if we call it twice we get the
53                                        // correct size.
54                window.addEventListener("unload", __dlg_onclose, true);
55                // center on parent
56                var x = opener.screenX + (opener.outerWidth - window.outerWidth) / 2;
57                var y = opener.screenY + (opener.outerHeight - window.outerHeight) / 2;
58                window.moveTo(x, y);
59                window.innerWidth = body.offsetWidth + 5;
60                window.innerHeight = body_height + 2;
61        } else {
62                // window.dialogHeight = body.offsetHeight + 50 + "px";
63                // window.dialogWidth = body.offsetWidth + "px";
64                window.resizeTo(body.offsetWidth, body_height);
65                var ch = body.clientHeight;
66                var cw = body.clientWidth;
67                window.resizeBy(body.offsetWidth - cw, body_height - ch);
68                var W = body.offsetWidth;
69                var H = 2 * body_height - ch;
70                var x = (screen.availWidth - W) / 2;
71                var y = (screen.availHeight - H) / 2;
72                window.moveTo(x, y);
73        }
74        document.body.onkeypress = __dlg_close_on_esc;
75};
76
77function __dlg_translate(i18n) {
78        var types = ["span", "option", "td", "button", "div"];
79        for (var type in types) {
80                var spans = document.getElementsByTagName(types[type]);
81                for (var i = spans.length; --i >= 0;) {
82                        var span = spans[i];
83                        if (span.firstChild && span.firstChild.data) {
84                                var txt = i18n[span.firstChild.data];
85                                if (txt)
86                                        span.firstChild.data = txt;
87                        }
88                }
89        }
90        var txt = i18n[document.title];
91        if (txt)
92                document.title = txt;
93};
94
95// closes the dialog and passes the return info upper.
96function __dlg_close(val) {
97        opener.Dialog._return(val);
98        window.close();
99};
100
101function __dlg_close_on_esc(ev) {
102        ev || (ev = window.event);
103        if (ev.keyCode == 27) {
104                window.close();
105                return false;
106        }
107        return true;
108};
Note: See TracBrowser for help on using the repository browser.