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