source: trunk/popups/popup.js @ 999

Last change on this file since 999 was 999, checked in by ray, 11 years ago

#1195 Allow to specify an external url to load a plugin from

  • Property svn:eol-style set to native
  • Property svn:keywords set to LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
File size: 3.6 KB
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// $Id:popup.js 929 2008-01-09 21:10:59Z ray $
13if(typeof Xinha == 'undefined')
14  Xinha = window.opener.Xinha;
15
16// Backward compatibility will be removed some time or not?
17HTMLArea = Xinha;
18
19function getAbsolutePos(el) {
20        var r = { x: el.offsetLeft, y: el.offsetTop };
21        if (el.offsetParent) {
22                var tmp = getAbsolutePos(el.offsetParent);
23                r.x += tmp.x;
24                r.y += tmp.y;
25        }
26        return r;
27}
28
29function comboSelectValue(c, val) {
30        var ops = c.getElementsByTagName("option");
31        for (var i = ops.length; --i >= 0;) {
32                var op = ops[i];
33                op.selected = (op.value == val);
34        }
35        c.value = val;
36}
37
38function __dlg_onclose() {
39        opener.Dialog._return(null);
40}
41// ray: I mark this on deprecated, because bottom is never used
42function __dlg_init( bottom, win_dim ) {
43  __xinha_dlg_init(win_dim);
44}
45
46function __xinha_dlg_init( win_dim ) {
47  if(window.__dlg_init_done) return true;
48 
49  if(window.opener._editor_skin) {
50    var head = document.getElementsByTagName("head")[0];
51    var link = document.createElement("link");
52    link.type = "text/css";
53    link.href = window.opener._editor_url + 'skins/' + window.opener._editor_skin + '/skin.css';
54    link.rel = "stylesheet";
55    head.appendChild(link);
56  }
57  if (!window.dialogArguments && opener.Dialog._arguments)
58  {
59    window.dialogArguments = opener.Dialog._arguments;
60  }
61 
62
63  var page = Xinha.pageSize(window);
64  if ( !win_dim )
65  {
66    win_dim = {width:page.x, height: page.y};
67  }
68  window.resizeTo(win_dim.width, win_dim.height);
69
70  var dim = Xinha.viewportSize(window);
71
72  window.resizeBy(0, page.y - dim.y);
73
74  if(win_dim.top && win_dim.left)
75  {
76    window.moveTo(win_dim.left,win_dim.top);
77  }
78  else
79  {
80    if (!Xinha.is_ie)
81    {
82      var x = opener.screenX + (opener.outerWidth - win_dim.width) / 2;
83      var y = opener.screenY + (opener.outerHeight - win_dim.height) / 2;
84    }
85    else
86    {//IE does not have window.outer... , so center it on the screen at least
87      var x =  (self.screen.availWidth - win_dim.width) / 2;
88      var y =  (self.screen.availHeight - win_dim.height) / 2; 
89    }
90    window.moveTo(x,y);
91  }
92 
93  Xinha.addDom0Event(document.body, 'keypress', __dlg_close_on_esc);
94  window.__dlg_init_done = true;
95}
96
97function __dlg_translate(context) {
98        var types = ["input", "select", "legend", "span", "option", "td", "th", "button", "div", "label", "a", "img"];
99        for (var type = 0; type < types.length; ++type) {
100                var spans = document.getElementsByTagName(types[type]);
101                for (var i = spans.length; --i >= 0;) {
102                        var span = spans[i];
103                        if (span.firstChild && span.firstChild.data) {
104                                var txt = Xinha._lc(span.firstChild.data, context);
105                                if (txt) {
106                                        span.firstChild.data = txt;
107                                }
108                        }
109                        if (span.title) {
110                                var txt = Xinha._lc(span.title, context);
111                                if (txt) {
112                                        span.title = txt;
113                                }
114                        }
115                        if (span.tagName.toLowerCase() == 'input' &&
116                                        (/^(button|submit|reset)$/i.test(span.type))) {
117                                var txt = Xinha._lc(span.value, context);
118                                if (txt) {
119                                        span.value = txt;
120                                }
121                        }
122                }
123        }
124        document.title = Xinha._lc(document.title, context);
125}
126
127// closes the dialog and passes the return info upper.
128function __dlg_close(val) {
129        opener.Dialog._return(val);
130        window.close();
131}
132
133function __dlg_close_on_esc(ev) {
134        ev || (ev = window.event);
135        if (ev.keyCode == 27) {
136                __dlg_close(null);
137                return false;
138        }
139        return true;
140}
Note: See TracBrowser for help on using the repository browser.