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