1
|
1 |
/**
|
|
2 |
* $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
|
|
3 |
*
|
|
4 |
* Moxiecode DHTML Windows script.
|
|
5 |
*
|
|
6 |
* @author Moxiecode
|
|
7 |
* @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
|
|
8 |
*/
|
|
9 |
|
|
10 |
// Patch openWindow, closeWindow TinyMCE functions
|
|
11 |
|
|
12 |
var TinyMCE_InlinePopupsPlugin = {
|
|
13 |
getInfo : function() {
|
|
14 |
return {
|
|
15 |
longname : 'Inline Popups',
|
|
16 |
author : 'Moxiecode Systems AB',
|
|
17 |
authorurl : 'http://tinymce.moxiecode.com',
|
|
18 |
infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/inlinepopups',
|
|
19 |
version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
|
|
20 |
};
|
|
21 |
}
|
|
22 |
};
|
|
23 |
|
|
24 |
tinyMCE.addPlugin("inlinepopups", TinyMCE_InlinePopupsPlugin);
|
|
25 |
|
|
26 |
// Patch openWindow, closeWindow TinyMCE functions
|
|
27 |
|
|
28 |
TinyMCE_Engine.prototype.orgOpenWindow = TinyMCE_Engine.prototype.openWindow;
|
|
29 |
TinyMCE_Engine.prototype.orgCloseWindow = TinyMCE_Engine.prototype.closeWindow;
|
|
30 |
|
|
31 |
TinyMCE_Engine.prototype.openWindow = function(template, args) {
|
|
32 |
// Does the caller support inline
|
|
33 |
if (args['inline'] != "yes" || tinyMCE.isOpera || tinyMCE.getParam("plugins").indexOf('inlinepopups') == -1) {
|
|
34 |
mcWindows.selectedWindow = null;
|
|
35 |
args['mce_inside_iframe'] = false;
|
|
36 |
this.orgOpenWindow(template, args);
|
|
37 |
return;
|
|
38 |
}
|
|
39 |
|
|
40 |
var url, resizable, scrollbars;
|
|
41 |
|
|
42 |
args['mce_inside_iframe'] = true;
|
|
43 |
tinyMCE.windowArgs = args;
|
|
44 |
|
|
45 |
if (template['file'].charAt(0) != '/' && template['file'].indexOf('://') == -1)
|
|
46 |
url = tinyMCE.baseURL + "/themes/" + tinyMCE.getParam("theme") + "/" + template['file'];
|
|
47 |
else
|
|
48 |
url = template['file'];
|
|
49 |
|
|
50 |
if (!(width = parseInt(template['width'])))
|
|
51 |
width = 320;
|
|
52 |
|
|
53 |
if (!(height = parseInt(template['height'])))
|
|
54 |
height = 200;
|
|
55 |
|
|
56 |
if (!(minWidth = parseInt(template['minWidth'])))
|
|
57 |
minWidth = 100;
|
|
58 |
|
|
59 |
if (!(minHeight = parseInt(template['minHeight'])))
|
|
60 |
minHeight = 100;
|
|
61 |
|
|
62 |
resizable = (args && args['resizable']) ? args['resizable'] : "no";
|
|
63 |
scrollbars = (args && args['scrollbars']) ? args['scrollbars'] : "no";
|
|
64 |
|
|
65 |
height += 18;
|
|
66 |
|
|
67 |
// Replace all args as variables in URL
|
|
68 |
for (var name in args) {
|
|
69 |
if (typeof(args[name]) == 'function')
|
|
70 |
continue;
|
|
71 |
|
|
72 |
url = tinyMCE.replaceVar(url, name, escape(args[name]));
|
|
73 |
}
|
|
74 |
|
|
75 |
var elm = document.getElementById(this.selectedInstance.editorId + '_parent');
|
|
76 |
|
|
77 |
if (tinyMCE.hasPlugin('fullscreen') && this.selectedInstance.getData('fullscreen').enabled)
|
|
78 |
pos = { absLeft: 0, absTop: 0 };
|
|
79 |
else
|
|
80 |
pos = tinyMCE.getAbsPosition(elm);
|
|
81 |
|
|
82 |
// Center div in editor area
|
|
83 |
pos.absLeft += Math.round((elm.firstChild.clientWidth / 2) - (width / 2));
|
|
84 |
pos.absTop += Math.round((elm.firstChild.clientHeight / 2) - (height / 2));
|
|
85 |
|
|
86 |
mcWindows.open(url, mcWindows.idCounter++, "modal=yes,width=" + width+ ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",statusbar=" + resizable + ",left=" + pos.absLeft + ",top=" + pos.absTop + ",minWidth=" + minWidth + ",minHeight=" + minHeight );
|
|
87 |
};
|
|
88 |
|
|
89 |
TinyMCE_Engine.prototype.closeWindow = function(win) {
|
|
90 |
var gotit = false, n, w;
|
|
91 |
for (n in mcWindows.windows) {
|
|
92 |
w = mcWindows.windows[n];
|
|
93 |
if (typeof(w) == 'function') continue;
|
|
94 |
if (win.name == w.id + '_iframe') {
|
|
95 |
w.close();
|
|
96 |
gotit = true;
|
|
97 |
}
|
|
98 |
}
|
|
99 |
if (!gotit)
|
|
100 |
this.orgCloseWindow(win);
|
|
101 |
|
|
102 |
tinyMCE.selectedInstance.getWin().focus();
|
|
103 |
};
|
|
104 |
|
|
105 |
TinyMCE_Engine.prototype.setWindowTitle = function(win_ref, title) {
|
|
106 |
for (var n in mcWindows.windows) {
|
|
107 |
var win = mcWindows.windows[n];
|
|
108 |
if (typeof(win) == 'function')
|
|
109 |
continue;
|
|
110 |
|
|
111 |
if (win_ref.name == win.id + "_iframe")
|
|
112 |
window.frames[win.id + "_iframe"].document.getElementById(win.id + '_title').innerHTML = title;
|
|
113 |
}
|
|
114 |
};
|
|
115 |
|
|
116 |
// * * * * * TinyMCE_Windows classes below
|
|
117 |
|
|
118 |
// Windows handler
|
|
119 |
function TinyMCE_Windows() {
|
|
120 |
this.settings = new Array();
|
|
121 |
this.windows = new Array();
|
|
122 |
this.isMSIE = (navigator.appName == "Microsoft Internet Explorer");
|
|
123 |
this.isGecko = navigator.userAgent.indexOf('Gecko') != -1;
|
|
124 |
this.isSafari = navigator.userAgent.indexOf('Safari') != -1;
|
|
125 |
this.isMac = navigator.userAgent.indexOf('Mac') != -1;
|
|
126 |
this.isMSIE5_0 = this.isMSIE && (navigator.userAgent.indexOf('MSIE 5.0') != -1);
|
|
127 |
this.action = "none";
|
|
128 |
this.selectedWindow = null;
|
|
129 |
this.lastSelectedWindow = null;
|
|
130 |
this.zindex = 1001;
|
|
131 |
this.mouseDownScreenX = 0;
|
|
132 |
this.mouseDownScreenY = 0;
|
|
133 |
this.mouseDownLayerX = 0;
|
|
134 |
this.mouseDownLayerY = 0;
|
|
135 |
this.mouseDownWidth = 0;
|
|
136 |
this.mouseDownHeight = 0;
|
|
137 |
this.idCounter = 0;
|
|
138 |
};
|
|
139 |
|
|
140 |
TinyMCE_Windows.prototype.init = function(settings) {
|
|
141 |
this.settings = settings;
|
|
142 |
|
|
143 |
if (this.isMSIE)
|
|
144 |
this.addEvent(document, "mousemove", mcWindows.eventDispatcher);
|
|
145 |
else
|
|
146 |
this.addEvent(window, "mousemove", mcWindows.eventDispatcher);
|
|
147 |
|
|
148 |
this.addEvent(document, "mouseup", mcWindows.eventDispatcher);
|
|
149 |
|
|
150 |
this.addEvent(window, "resize", mcWindows.eventDispatcher);
|
|
151 |
this.addEvent(document, "scroll", mcWindows.eventDispatcher);
|
|
152 |
|
|
153 |
this.doc = document;
|
|
154 |
};
|
|
155 |
|
|
156 |
TinyMCE_Windows.prototype.getBounds = function() {
|
|
157 |
if (!this.bounds) {
|
|
158 |
var vp = tinyMCE.getViewPort(window);
|
|
159 |
var top, left, bottom, right, docEl = this.doc.documentElement;
|
|
160 |
|
|
161 |
top = vp.top;
|
|
162 |
left = vp.left;
|
|
163 |
bottom = vp.height + top - 2;
|
|
164 |
right = vp.width + left - 22; // TODO this number is platform dependant
|
|
165 |
// x1, y1, x2, y2
|
|
166 |
this.bounds = [left, top, right, bottom];
|
|
167 |
}
|
|
168 |
return this.bounds;
|
|
169 |
};
|
|
170 |
|
|
171 |
TinyMCE_Windows.prototype.clampBoxPosition = function(x, y, w, h, minW, minH) {
|
|
172 |
var bounds = this.getBounds();
|
|
173 |
|
|
174 |
x = Math.max(bounds[0], Math.min(bounds[2], x + w) - w);
|
|
175 |
y = Math.max(bounds[1], Math.min(bounds[3], y + h) - h);
|
|
176 |
|
|
177 |
return this.clampBoxSize(x, y, w, h, minW, minH);
|
|
178 |
};
|
|
179 |
|
|
180 |
TinyMCE_Windows.prototype.clampBoxSize = function(x, y, w, h, minW, minH) {
|
|
181 |
var bounds = this.getBounds();
|
|
182 |
|
|
183 |
return [
|
|
184 |
x, y,
|
|
185 |
Math.max(minW, Math.min(bounds[2], x + w) - x),
|
|
186 |
Math.max(minH, Math.min(bounds[3], y + h) - y)
|
|
187 |
];
|
|
188 |
};
|
|
189 |
|
|
190 |
TinyMCE_Windows.prototype.getParam = function(name, default_value) {
|
|
191 |
var value = null;
|
|
192 |
|
|
193 |
value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];
|
|
194 |
|
|
195 |
// Fix bool values
|
|
196 |
if (value == "true" || value == "false")
|
|
197 |
return (value == "true");
|
|
198 |
|
|
199 |
return value;
|
|
200 |
};
|
|
201 |
|
|
202 |
TinyMCE_Windows.prototype.eventDispatcher = function(e) {
|
|
203 |
e = typeof(e) == "undefined" ? window.event : e;
|
|
204 |
|
|
205 |
if (mcWindows.selectedWindow == null)
|
|
206 |
return;
|
|
207 |
|
|
208 |
// Switch focus
|
|
209 |
if (mcWindows.isGecko && e.type == "mousedown") {
|
|
210 |
var elm = e.currentTarget;
|
|
211 |
|
|
212 |
for (var n in mcWindows.windows) {
|
|
213 |
var win = mcWindows.windows[n];
|
|
214 |
|
|
215 |
if (win.headElement == elm || win.resizeElement == elm) {
|
|
216 |
win.focus();
|
|
217 |
break;
|
|
218 |
}
|
|
219 |
}
|
|
220 |
}
|
|
221 |
|
|
222 |
switch (e.type) {
|
|
223 |
case "mousemove":
|
|
224 |
mcWindows.selectedWindow.onMouseMove(e);
|
|
225 |
break;
|
|
226 |
|
|
227 |
case "mouseup":
|
|
228 |
mcWindows.selectedWindow.onMouseUp(e);
|
|
229 |
break;
|
|
230 |
|
|
231 |
case "mousedown":
|
|
232 |
mcWindows.selectedWindow.onMouseDown(e);
|
|
233 |
break;
|
|
234 |
|
|
235 |
case "focus":
|
|
236 |
mcWindows.selectedWindow.onFocus(e);
|
|
237 |
break;
|
|
238 |
case "scroll":
|
|
239 |
case "resize":
|
|
240 |
if (mcWindows.clampUpdateTimeout)
|
|
241 |
clearTimeout(mcWindows.clampUpdateTimeout);
|
|
242 |
mcWindows.clampEventType = e.type;
|
|
243 |
mcWindows.clampUpdateTimeout =
|
|
244 |
setTimeout(function () {mcWindows.updateClamping()}, 100);
|
|
245 |
break;
|
|
246 |
}
|
|
247 |
};
|
|
248 |
|
|
249 |
TinyMCE_Windows.prototype.updateClamping = function () {
|
|
250 |
var clamp, oversize, etype = mcWindows.clampEventType;
|
|
251 |
|
|
252 |
this.bounds = null; // Recalc window bounds on resize/scroll
|
|
253 |
this.clampUpdateTimeout = null;
|
|
254 |
|
|
255 |
for (var n in this.windows) {
|
|
256 |
win = this.windows[n];
|
|
257 |
if (typeof(win) == 'function' || ! win.winElement) continue;
|
|
258 |
|
|
259 |
clamp = mcWindows.clampBoxPosition(
|
|
260 |
win.left, win.top,
|
|
261 |
win.winElement.scrollWidth,
|
|
262 |
win.winElement.scrollHeight,
|
|
263 |
win.features.minWidth,
|
|
264 |
win.features.minHeight
|
|
265 |
);
|
|
266 |
oversize = (
|
|
267 |
clamp[2] != win.winElement.scrollWidth ||
|
|
268 |
clamp[3] != win.winElement.scrollHeight
|
|
269 |
) ? true : false;
|
|
270 |
|
|
271 |
if (!oversize || win.features.resizable == "yes" || etype != "scroll")
|
|
272 |
win.moveTo(clamp[0], clamp[1]);
|
|
273 |
if (oversize && win.features.resizable == "yes")
|
|
274 |
win.resizeTo(clamp[2], clamp[3]);
|
|
275 |
}
|
|
276 |
};
|
|
277 |
|
|
278 |
TinyMCE_Windows.prototype.addEvent = function(obj, name, handler) {
|
|
279 |
if (this.isMSIE)
|
|
280 |
obj.attachEvent("on" + name, handler);
|
|
281 |
else
|
|
282 |
obj.addEventListener(name, handler, false);
|
|
283 |
};
|
|
284 |
|
|
285 |
TinyMCE_Windows.prototype.cancelEvent = function(e) {
|
|
286 |
if (this.isMSIE) {
|
|
287 |
e.returnValue = false;
|
|
288 |
e.cancelBubble = true;
|
|
289 |
} else
|
|
290 |
e.preventDefault();
|
|
291 |
};
|
|
292 |
|
|
293 |
TinyMCE_Windows.prototype.parseFeatures = function(opts) {
|
|
294 |
// Cleanup the options
|
|
295 |
opts = opts.toLowerCase();
|
|
296 |
opts = opts.replace(/;/g, ",");
|
|
297 |
opts = opts.replace(/[^0-9a-z=,]/g, "");
|
|
298 |
|
|
299 |
var optionChunks = opts.split(',');
|
|
300 |
var options = new Array();
|
|
301 |
|
|
302 |
options['left'] = "10";
|
|
303 |
options['top'] = "10";
|
|
304 |
options['width'] = "300";
|
|
305 |
options['height'] = "300";
|
|
306 |
options['minwidth'] = "100";
|
|
307 |
options['minheight'] = "100";
|
|
308 |
options['resizable'] = "yes";
|
|
309 |
options['minimizable'] = "yes";
|
|
310 |
options['maximizable'] = "yes";
|
|
311 |
options['close'] = "yes";
|
|
312 |
options['movable'] = "yes";
|
|
313 |
options['statusbar'] = "yes";
|
|
314 |
options['scrollbars'] = "auto";
|
|
315 |
options['modal'] = "no";
|
|
316 |
|
|
317 |
if (opts == "")
|
|
318 |
return options;
|
|
319 |
|
|
320 |
for (var i=0; i<optionChunks.length; i++) {
|
|
321 |
var parts = optionChunks[i].split('=');
|
|
322 |
|
|
323 |
if (parts.length == 2)
|
|
324 |
options[parts[0]] = parts[1];
|
|
325 |
}
|
|
326 |
|
|
327 |
options['left'] = parseInt(options['left']);
|
|
328 |
options['top'] = parseInt(options['top']);
|
|
329 |
options['width'] = parseInt(options['width']);
|
|
330 |
options['height'] = parseInt(options['height']);
|
|
331 |
options['minWidth'] = parseInt(options['minwidth']);
|
|
332 |
options['minHeight'] = parseInt(options['minheight']);
|
|
333 |
|
|
334 |
return options;
|
|
335 |
};
|
|
336 |
|
|
337 |
TinyMCE_Windows.prototype.open = function(url, name, features) {
|
|
338 |
this.lastSelectedWindow = this.selectedWindow;
|
|
339 |
|
|
340 |
var win = new TinyMCE_Window();
|
|
341 |
var winDiv, html = "", id;
|
|
342 |
var imgPath = this.getParam("images_path");
|
|
343 |
|
|
344 |
features = this.parseFeatures(features);
|
|
345 |
|
|
346 |
// Clamp specified dimensions
|
|
347 |
var clamp = mcWindows.clampBoxPosition(
|
|
348 |
features['left'], features['top'],
|
|
349 |
features['width'], features['height'],
|
|
350 |
features['minWidth'], features['minHeight']
|
|
351 |
);
|
|
352 |
|
|
353 |
features['left'] = clamp[0];
|
|
354 |
features['top'] = clamp[1];
|
|
355 |
|
|
356 |
if (features['resizable'] == "yes") {
|
|
357 |
features['width'] = clamp[2];
|
|
358 |
features['height'] = clamp[3];
|
|
359 |
}
|
|
360 |
|
|
361 |
// Create div
|
|
362 |
id = "mcWindow_" + name;
|
|
363 |
win.deltaHeight = 18;
|
|
364 |
|
|
365 |
if (features['statusbar'] == "yes") {
|
|
366 |
win.deltaHeight += 13;
|
|
367 |
|
|
368 |
if (this.isMSIE)
|
|
369 |
win.deltaHeight += 1;
|
|
370 |
}
|
|
371 |
|
|
372 |
width = parseInt(features['width']);
|
|
373 |
height = parseInt(features['height'])-win.deltaHeight;
|
|
374 |
|
|
375 |
if (this.isMSIE)
|
|
376 |
width -= 2;
|
|
377 |
|
|
378 |
// Setup first part of window
|
|
379 |
win.id = id;
|
|
380 |
win.url = url;
|
|
381 |
win.name = name;
|
|
382 |
win.features = features;
|
|
383 |
this.windows[name] = win;
|
|
384 |
|
|
385 |
iframeWidth = width;
|
|
386 |
iframeHeight = height;
|
|
387 |
|
|
388 |
// Create inner content
|
|
389 |
html += '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';
|
|
390 |
html += '<html>';
|
|
391 |
html += '<head>';
|
|
392 |
html += '<title>Wrapper iframe</title>';
|
|
393 |
html += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
|
|
394 |
html += '<link href="' + this.getParam("css_file") + '" rel="stylesheet" type="text/css" />';
|
|
395 |
html += '</head>';
|
|
396 |
html += '<body onload="parent.mcWindows.onLoad(\'' + name + '\');">';
|
|
397 |
|
|
398 |
html += '<div id="' + id + '_container" class="mceWindow">';
|
|
399 |
html += '<div id="' + id + '_head" class="mceWindowHead" onmousedown="parent.mcWindows.windows[\'' + name + '\'].focus();">';
|
|
400 |
html += ' <div id="' + id + '_title" class="mceWindowTitle"';
|
|
401 |
html += ' onselectstart="return false;" unselectable="on" style="-moz-user-select: none !important;"></div>';
|
|
402 |
html += ' <div class="mceWindowHeadTools">';
|
|
403 |
html += ' <a href="javascript:parent.mcWindows.windows[\'' + name + '\'].close();" target="_self" onmousedown="return false;" class="mceWindowClose"><img border="0" src="' + imgPath + '/window_close.gif" /></a>';
|
|
404 |
if (features['resizable'] == "yes" && features['maximizable'] == "yes")
|
|
405 |
html += ' <a href="javascript:parent.mcWindows.windows[\'' + name + '\'].maximize();" target="_self" onmousedown="return false;" class="mceWindowMaximize"><img border="0" src="' + imgPath + '/window_maximize.gif" /></a>';
|
|
406 |
// html += ' <a href="javascript:mcWindows.windows[\'' + name + '\'].minimize();" target="_self" onmousedown="return false;" class="mceWindowMinimize"></a>';
|
|
407 |
html += ' </div>';
|
|
408 |
html += '</div><div id="' + id + '_body" class="mceWindowBody" style="width: ' + width + 'px; height: ' + height + 'px;">';
|
|
409 |
html += '<iframe id="' + id + '_iframe" name="' + id + '_iframe" frameborder="0" width="' + iframeWidth + '" height="' + iframeHeight + '" src="' + url + '" class="mceWindowBodyIframe" scrolling="' + features['scrollbars'] + '"></iframe></div>';
|
|
410 |
|
|
411 |
if (features['statusbar'] == "yes") {
|
|
412 |
html += '<div id="' + id + '_statusbar" class="mceWindowStatusbar" onmousedown="parent.mcWindows.windows[\'' + name + '\'].focus();">';
|
|
413 |
|
|
414 |
if (features['resizable'] == "yes") {
|
|
415 |
if (this.isGecko)
|
|
416 |
html += '<div id="' + id + '_resize" class="mceWindowResize"><div style="background-image: url(\'' + imgPath + '/window_resize.gif\'); width: 12px; height: 12px;"></div></div>';
|
|
417 |
else
|
|
418 |
html += '<div id="' + id + '_resize" class="mceWindowResize"><img onmousedown="parent.mcWindows.windows[\'' + name + '\'].focus();" border="0" src="' + imgPath + '/window_resize.gif" /></div>';
|
|
419 |
}
|
|
420 |
|
|
421 |
html += '</div>';
|
|
422 |
}
|
|
423 |
|
|
424 |
html += '</div>';
|
|
425 |
|
|
426 |
html += '</body>';
|
|
427 |
html += '</html>';
|
|
428 |
|
|
429 |
// Create iframe
|
|
430 |
this.createFloatingIFrame(id, features['left'], features['top'], features['width'], features['height'], html);
|
|
431 |
};
|
|
432 |
|
|
433 |
// Blocks the document events by placing a image over the whole document
|
|
434 |
TinyMCE_Windows.prototype.setDocumentLock = function(state) {
|
|
435 |
var elm = document.getElementById('mcWindowEventBlocker');
|
|
436 |
|
|
437 |
if (state) {
|
|
438 |
if (elm == null) {
|
|
439 |
elm = document.createElement("div");
|
|
440 |
|
|
441 |
elm.id = "mcWindowEventBlocker";
|
|
442 |
elm.style.position = "absolute";
|
|
443 |
elm.style.left = "0";
|
|
444 |
elm.style.top = "0";
|
|
445 |
|
|
446 |
document.body.appendChild(elm);
|
|
447 |
}
|
|
448 |
|
|
449 |
elm.style.display = "none";
|
|
450 |
|
|
451 |
var imgPath = this.getParam("images_path");
|
|
452 |
var width = document.body.clientWidth;
|
|
453 |
var height = document.body.clientHeight;
|
|
454 |
|
|
455 |
elm.style.width = width;
|
|
456 |
elm.style.height = height;
|
|
457 |
elm.innerHTML = '<img src="' + imgPath + '/spacer.gif" width="' + width + '" height="' + height + '" />';
|
|
458 |
|
|
459 |
elm.style.zIndex = mcWindows.zindex-1;
|
|
460 |
elm.style.display = "block";
|
|
461 |
} else if (elm != null) {
|
|
462 |
if (mcWindows.windows.length == 0)
|
|
463 |
elm.parentNode.removeChild(elm);
|
|
464 |
else
|
|
465 |
elm.style.zIndex = mcWindows.zindex-1;
|
|
466 |
}
|
|
467 |
};
|
|
468 |
|
|
469 |
// Gets called when wrapper iframe is initialized
|
|
470 |
TinyMCE_Windows.prototype.onLoad = function(name) {
|
|
471 |
var win = mcWindows.windows[name];
|
|
472 |
var id = "mcWindow_" + name;
|
|
473 |
var wrapperIframe = window.frames[id + "_iframe"].frames[0];
|
|
474 |
var wrapperDoc = window.frames[id + "_iframe"].document;
|
|
475 |
var doc = window.frames[id + "_iframe"].document;
|
|
476 |
var winDiv = document.getElementById("mcWindow_" + name + "_div");
|
|
477 |
var realIframe = window.frames[id + "_iframe"].frames[0];
|
|
478 |
|
|
479 |
// Set window data
|
|
480 |
win.id = "mcWindow_" + name;
|
|
481 |
win.winElement = winDiv;
|
|
482 |
win.bodyElement = doc.getElementById(id + '_body');
|
|
483 |
win.iframeElement = doc.getElementById(id + '_iframe');
|
|
484 |
win.headElement = doc.getElementById(id + '_head');
|
|
485 |
win.titleElement = doc.getElementById(id + '_title');
|
|
486 |
win.resizeElement = doc.getElementById(id + '_resize');
|
|
487 |
win.containerElement = doc.getElementById(id + '_container');
|
|
488 |
win.left = win.features['left'];
|
|
489 |
win.top = win.features['top'];
|
|
490 |
win.frame = window.frames[id + '_iframe'].frames[0];
|
|
491 |
win.wrapperFrame = window.frames[id + '_iframe'];
|
|
492 |
win.wrapperIFrameElement = document.getElementById(id + "_iframe");
|
|
493 |
|
|
494 |
// Add event handlers
|
|
495 |
mcWindows.addEvent(win.headElement, "mousedown", mcWindows.eventDispatcher);
|
|
496 |
|
|
497 |
if (win.resizeElement != null)
|
|
498 |
mcWindows.addEvent(win.resizeElement, "mousedown", mcWindows.eventDispatcher);
|
|
499 |
|
|
500 |
if (mcWindows.isMSIE) {
|
|
501 |
mcWindows.addEvent(realIframe.document, "mousemove", mcWindows.eventDispatcher);
|
|
502 |
mcWindows.addEvent(realIframe.document, "mouseup", mcWindows.eventDispatcher);
|
|
503 |
} else {
|
|
504 |
mcWindows.addEvent(realIframe, "mousemove", mcWindows.eventDispatcher);
|
|
505 |
mcWindows.addEvent(realIframe, "mouseup", mcWindows.eventDispatcher);
|
|
506 |
mcWindows.addEvent(realIframe, "focus", mcWindows.eventDispatcher);
|
|
507 |
}
|
|
508 |
|
|
509 |
for (var i=0; i<window.frames.length; i++) {
|
|
510 |
if (!window.frames[i]._hasMouseHandlers) {
|
|
511 |
if (mcWindows.isMSIE) {
|
|
512 |
mcWindows.addEvent(window.frames[i].document, "mousemove", mcWindows.eventDispatcher);
|
|
513 |
mcWindows.addEvent(window.frames[i].document, "mouseup", mcWindows.eventDispatcher);
|
|
514 |
} else {
|
|
515 |
mcWindows.addEvent(window.frames[i], "mousemove", mcWindows.eventDispatcher);
|
|
516 |
mcWindows.addEvent(window.frames[i], "mouseup", mcWindows.eventDispatcher);
|
|
517 |
}
|
|
518 |
|
|
519 |
window.frames[i]._hasMouseHandlers = true;
|
|
520 |
}
|
|
521 |
}
|
|
522 |
|
|
523 |
if (mcWindows.isMSIE) {
|
|
524 |
mcWindows.addEvent(win.frame.document, "mousemove", mcWindows.eventDispatcher);
|
|
525 |
mcWindows.addEvent(win.frame.document, "mouseup", mcWindows.eventDispatcher);
|
|
526 |
} else {
|
|
527 |
mcWindows.addEvent(win.frame, "mousemove", mcWindows.eventDispatcher);
|
|
528 |
mcWindows.addEvent(win.frame, "mouseup", mcWindows.eventDispatcher);
|
|
529 |
mcWindows.addEvent(win.frame, "focus", mcWindows.eventDispatcher);
|
|
530 |
}
|
|
531 |
|
|
532 |
// Dispatch open window event
|
|
533 |
var func = this.getParam("on_open_window", "");
|
|
534 |
if (func != "")
|
|
535 |
eval(func + "(win);");
|
|
536 |
|
|
537 |
win.focus();
|
|
538 |
|
|
539 |
if (win.features['modal'] == "yes")
|
|
540 |
mcWindows.setDocumentLock(true);
|
|
541 |
};
|
|
542 |
|
|
543 |
TinyMCE_Windows.prototype.createFloatingIFrame = function(id_prefix, left, top, width, height, html) {
|
|
544 |
var iframe = document.createElement("iframe");
|
|
545 |
var div = document.createElement("div"), doc;
|
|
546 |
|
|
547 |
width = parseInt(width);
|
|
548 |
height = parseInt(height)+1;
|
|
549 |
|
|
550 |
// Create wrapper div
|
|
551 |
div.setAttribute("id", id_prefix + "_div");
|
|
552 |
div.setAttribute("width", width);
|
|
553 |
div.setAttribute("height", (height));
|
|
554 |
div.style.position = "absolute";
|
|
555 |
|
|
556 |
div.style.left = left + "px";
|
|
557 |
div.style.top = top + "px";
|
|
558 |
div.style.width = width + "px";
|
|
559 |
div.style.height = (height) + "px";
|
|
560 |
div.style.backgroundColor = "white";
|
|
561 |
div.style.display = "none";
|
|
562 |
|
|
563 |
if (this.isGecko) {
|
|
564 |
iframeWidth = width + 2;
|
|
565 |
iframeHeight = height + 2;
|
|
566 |
} else {
|
|
567 |
iframeWidth = width;
|
|
568 |
iframeHeight = height + 1;
|
|
569 |
}
|
|
570 |
|
|
571 |
// Create iframe
|
|
572 |
iframe.setAttribute("id", id_prefix + "_iframe");
|
|
573 |
iframe.setAttribute("name", id_prefix + "_iframe");
|
|
574 |
iframe.setAttribute("border", "0");
|
|
575 |
iframe.setAttribute("frameBorder", "0");
|
|
576 |
iframe.setAttribute("marginWidth", "0");
|
|
577 |
iframe.setAttribute("marginHeight", "0");
|
|
578 |
iframe.setAttribute("leftMargin", "0");
|
|
579 |
iframe.setAttribute("topMargin", "0");
|
|
580 |
iframe.setAttribute("width", iframeWidth);
|
|
581 |
iframe.setAttribute("height", iframeHeight);
|
|
582 |
// iframe.setAttribute("src", "../jscripts/tiny_mce/blank.htm");
|
|
583 |
// iframe.setAttribute("allowtransparency", "false");
|
|
584 |
iframe.setAttribute("scrolling", "no");
|
|
585 |
iframe.style.width = iframeWidth + "px";
|
|
586 |
iframe.style.height = iframeHeight + "px";
|
|
587 |
iframe.style.backgroundColor = "white";
|
|
588 |
div.appendChild(iframe);
|
|
589 |
|
|
590 |
document.body.appendChild(div);
|
|
591 |
|
|
592 |
// Fixed MSIE 5.0 issue
|
|
593 |
div.innerHTML = div.innerHTML;
|
|
594 |
|
|
595 |
if (this.isSafari) {
|
|
596 |
// Give Safari some time to setup
|
|
597 |
window.setTimeout(function() {
|
|
598 |
var doc = window.frames[id_prefix + '_iframe'].document;
|
|
599 |
doc.open();
|
|
600 |
doc.write(html);
|
|
601 |
doc.close();
|
|
602 |
}, 10);
|
|
603 |
} else {
|
|
604 |
doc = window.frames[id_prefix + '_iframe'].window.document;
|
|
605 |
doc.open();
|
|
606 |
doc.write(html);
|
|
607 |
doc.close();
|
|
608 |
}
|
|
609 |
|
|
610 |
div.style.display = "block";
|
|
611 |
|
|
612 |
return div;
|
|
613 |
};
|
|
614 |
|
|
615 |
// Window instance
|
|
616 |
function TinyMCE_Window() {
|
|
617 |
};
|
|
618 |
|
|
619 |
TinyMCE_Window.prototype.focus = function() {
|
|
620 |
if (this != mcWindows.selectedWindow) {
|
|
621 |
this.winElement.style.zIndex = ++mcWindows.zindex;
|
|
622 |
mcWindows.lastSelectedWindow = mcWindows.selectedWindow;
|
|
623 |
mcWindows.selectedWindow = this;
|
|
624 |
}
|
|
625 |
};
|
|
626 |
|
|
627 |
TinyMCE_Window.prototype.minimize = function() {
|
|
628 |
};
|
|
629 |
|
|
630 |
TinyMCE_Window.prototype.maximize = function() {
|
|
631 |
if (this.restoreSize) {
|
|
632 |
this.moveTo(this.restoreSize[0], this.restoreSize[1]);
|
|
633 |
this.resizeTo(this.restoreSize[2], this.restoreSize[3]);
|
|
634 |
this.updateClamping();
|
|
635 |
this.restoreSize = null;
|
|
636 |
} else {
|
|
637 |
var bounds = mcWindows.getBounds();
|
|
638 |
this.restoreSize = [
|
|
639 |
this.left, this.top,
|
|
640 |
this.winElement.scrollWidth,
|
|
641 |
this.winElement.scrollHeight
|
|
642 |
];
|
|
643 |
this.moveTo(bounds[0], bounds[1]);
|
|
644 |
this.resizeTo(
|
|
645 |
bounds[2] - bounds[0],
|
|
646 |
bounds[3] - bounds[1]
|
|
647 |
);
|
|
648 |
}
|
|
649 |
};
|
|
650 |
|
|
651 |
TinyMCE_Window.prototype.startResize = function() {
|
|
652 |
mcWindows.action = "resize";
|
|
653 |
};
|
|
654 |
|
|
655 |
TinyMCE_Window.prototype.startMove = function(e) {
|
|
656 |
mcWindows.action = "move";
|
|
657 |
};
|
|
658 |
|
|
659 |
TinyMCE_Window.prototype.close = function() {
|
|
660 |
if (this.frame && this.frame['tinyMCEPopup'])
|
|
661 |
this.frame['tinyMCEPopup'].restoreSelection();
|
|
662 |
|
|
663 |
if (mcWindows.lastSelectedWindow != null)
|
|
664 |
mcWindows.lastSelectedWindow.focus();
|
|
665 |
|
|
666 |
var mcWindowsNew = new Array();
|
|
667 |
for (var n in mcWindows.windows) {
|
|
668 |
var win = mcWindows.windows[n];
|
|
669 |
if (typeof(win) == 'function')
|
|
670 |
continue;
|
|
671 |
|
|
672 |
if (win.name != this.name)
|
|
673 |
mcWindowsNew[n] = win;
|
|
674 |
}
|
|
675 |
|
|
676 |
mcWindows.windows = mcWindowsNew;
|
|
677 |
|
|
678 |
// alert(mcWindows.doc.getElementById(this.id + "_iframe"));
|
|
679 |
|
|
680 |
var e = mcWindows.doc.getElementById(this.id + "_iframe");
|
|
681 |
e.parentNode.removeChild(e);
|
|
682 |
|
|
683 |
var e = mcWindows.doc.getElementById(this.id + "_div");
|
|
684 |
e.parentNode.removeChild(e);
|
|
685 |
|
|
686 |
mcWindows.setDocumentLock(false);
|
|
687 |
};
|
|
688 |
|
|
689 |
TinyMCE_Window.prototype.onMouseMove = function(e) {
|
|
690 |
var clamp;
|
|
691 |
// Calculate real X, Y
|
|
692 |
var dx = e.screenX - mcWindows.mouseDownScreenX;
|
|
693 |
var dy = e.screenY - mcWindows.mouseDownScreenY;
|
|
694 |
|
|
695 |
switch (mcWindows.action) {
|
|
696 |
case "resize":
|
|
697 |
clamp = mcWindows.clampBoxSize(
|
|
698 |
this.left, this.top,
|
|
699 |
mcWindows.mouseDownWidth + (e.screenX - mcWindows.mouseDownScreenX),
|
|
700 |
mcWindows.mouseDownHeight + (e.screenY - mcWindows.mouseDownScreenY),
|
|
701 |
this.features.minWidth, this.features.minHeight
|
|
702 |
);
|
|
703 |
|
|
704 |
this.resizeTo(clamp[2], clamp[3]);
|
|
705 |
|
|
706 |
mcWindows.cancelEvent(e);
|
|
707 |
break;
|
|
708 |
|
|
709 |
case "move":
|
|
710 |
this.left = mcWindows.mouseDownLayerX + (e.screenX - mcWindows.mouseDownScreenX);
|
|
711 |
this.top = mcWindows.mouseDownLayerY + (e.screenY - mcWindows.mouseDownScreenY);
|
|
712 |
this.updateClamping();
|
|
713 |
|
|
714 |
mcWindows.cancelEvent(e);
|
|
715 |
break;
|
|
716 |
}
|
|
717 |
};
|
|
718 |
|
|
719 |
TinyMCE_Window.prototype.moveTo = function (x, y) {
|
|
720 |
this.left = x;
|
|
721 |
this.top = y;
|
|
722 |
|
|
723 |
this.winElement.style.left = this.left + "px";
|
|
724 |
this.winElement.style.top = this.top + "px";
|
|
725 |
};
|
|
726 |
|
|
727 |
TinyMCE_Window.prototype.resizeTo = function (width, height) {
|
|
728 |
this.wrapperIFrameElement.style.width = (width+2) + 'px';
|
|
729 |
this.wrapperIFrameElement.style.height = (height+2) + 'px';
|
|
730 |
this.wrapperIFrameElement.width = width+2;
|
|
731 |
this.wrapperIFrameElement.height = height+2;
|
|
732 |
this.winElement.style.width = width + 'px';
|
|
733 |
this.winElement.style.height = height + 'px';
|
|
734 |
|
|
735 |
height = height - this.deltaHeight;
|
|
736 |
|
|
737 |
this.containerElement.style.width = width + 'px';
|
|
738 |
this.iframeElement.style.width = width + 'px';
|
|
739 |
this.iframeElement.style.height = height + 'px';
|
|
740 |
this.bodyElement.style.width = width + 'px';
|
|
741 |
this.bodyElement.style.height = height + 'px';
|
|
742 |
this.headElement.style.width = width + 'px';
|
|
743 |
//this.statusElement.style.width = width + 'px';
|
|
744 |
};
|
|
745 |
|
|
746 |
TinyMCE_Window.prototype.updateClamping = function () {
|
|
747 |
var clamp, oversize;
|
|
748 |
|
|
749 |
clamp = mcWindows.clampBoxPosition(
|
|
750 |
this.left, this.top,
|
|
751 |
this.winElement.scrollWidth,
|
|
752 |
this.winElement.scrollHeight,
|
|
753 |
this.features.minWidth, this.features.minHeight
|
|
754 |
);
|
|
755 |
oversize = (
|
|
756 |
clamp[2] != this.winElement.scrollWidth ||
|
|
757 |
clamp[3] != this.winElement.scrollHeight
|
|
758 |
) ? true : false;
|
|
759 |
|
|
760 |
this.moveTo(clamp[0], clamp[1]);
|
|
761 |
if (this.features.resizable == "yes" && oversize)
|
|
762 |
this.resizeTo(clamp[2], clamp[3]);
|
|
763 |
};
|
|
764 |
|
|
765 |
function debug(msg) {
|
|
766 |
document.getElementById('debug').value += msg + "\n";
|
|
767 |
}
|
|
768 |
|
|
769 |
TinyMCE_Window.prototype.onMouseUp = function(e) {
|
|
770 |
mcWindows.action = "none";
|
|
771 |
};
|
|
772 |
|
|
773 |
TinyMCE_Window.prototype.onFocus = function(e) {
|
|
774 |
// Gecko only handler
|
|
775 |
var winRef = e.currentTarget;
|
|
776 |
|
|
777 |
for (var n in mcWindows.windows) {
|
|
778 |
var win = mcWindows.windows[n];
|
|
779 |
if (typeof(win) == 'function')
|
|
780 |
continue;
|
|
781 |
|
|
782 |
if (winRef.name == win.id + "_iframe") {
|
|
783 |
win.focus();
|
|
784 |
return;
|
|
785 |
}
|
|
786 |
}
|
|
787 |
};
|
|
788 |
|
|
789 |
TinyMCE_Window.prototype.onMouseDown = function(e) {
|
|
790 |
var elm = mcWindows.isMSIE ? this.wrapperFrame.event.srcElement : e.target;
|
|
791 |
|
|
792 |
mcWindows.mouseDownScreenX = e.screenX;
|
|
793 |
mcWindows.mouseDownScreenY = e.screenY;
|
|
794 |
mcWindows.mouseDownLayerX = this.left;
|
|
795 |
mcWindows.mouseDownLayerY = this.top;
|
|
796 |
mcWindows.mouseDownWidth = parseInt(this.winElement.style.width);
|
|
797 |
mcWindows.mouseDownHeight = parseInt(this.winElement.style.height);
|
|
798 |
|
|
799 |
if (this.resizeElement != null && elm == this.resizeElement.firstChild)
|
|
800 |
this.startResize(e);
|
|
801 |
else
|
|
802 |
this.startMove(e);
|
|
803 |
|
|
804 |
mcWindows.cancelEvent(e);
|
|
805 |
};
|
|
806 |
|
|
807 |
// Global instance
|
|
808 |
var mcWindows = new TinyMCE_Windows();
|
|
809 |
|
|
810 |
// Initialize windows
|
|
811 |
mcWindows.init({
|
|
812 |
images_path : tinyMCE.baseURL + "/plugins/inlinepopups/images",
|
|
813 |
css_file : tinyMCE.baseURL + "/plugins/inlinepopups/css/inlinepopup.css"
|
|
814 |
});
|