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