-/**
- * $Id: editor_plugin_src.js 268 2007-04-28 15:52:59Z spocke $
- *
- * Moxiecode DHTML Windows script.
- *
- * @author Moxiecode
- * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
- */
-
-// Patch openWindow, closeWindow TinyMCE functions
-
-var TinyMCE_InlinePopupsPlugin = {
- getInfo : function() {
- return {
- longname : 'Inline Popups',
- author : 'Moxiecode Systems AB',
- authorurl : 'http://tinymce.moxiecode.com',
- infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/inlinepopups',
- version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
- };
- }
-};
-
-tinyMCE.addPlugin("inlinepopups", TinyMCE_InlinePopupsPlugin);
-
-// Patch openWindow, closeWindow TinyMCE functions
-
-TinyMCE_Engine.prototype.orgOpenWindow = TinyMCE_Engine.prototype.openWindow;
-TinyMCE_Engine.prototype.orgCloseWindow = TinyMCE_Engine.prototype.closeWindow;
-
-TinyMCE_Engine.prototype.openWindow = function(template, args) {
- // Does the caller support inline
- if (args['inline'] != "yes" || tinyMCE.isOpera || tinyMCE.getParam("plugins").indexOf('inlinepopups') == -1) {
- mcWindows.selectedWindow = null;
- args['mce_inside_iframe'] = false;
- this.orgOpenWindow(template, args);
- return;
- }
-
- var url, resizable, scrollbars;
-
- args['mce_inside_iframe'] = true;
- tinyMCE.windowArgs = args;
-
- if (template['file'].charAt(0) != '/' && template['file'].indexOf('://') == -1)
- url = tinyMCE.baseURL + "/themes/" + tinyMCE.getParam("theme") + "/" + template['file'];
- else
- url = template['file'];
-
- if (!(width = parseInt(template['width'])))
- width = 320;
-
- if (!(height = parseInt(template['height'])))
- height = 200;
-
- if (!(minWidth = parseInt(template['minWidth'])))
- minWidth = 100;
-
- if (!(minHeight = parseInt(template['minHeight'])))
- minHeight = 100;
-
- resizable = (args && args['resizable']) ? args['resizable'] : "no";
- scrollbars = (args && args['scrollbars']) ? args['scrollbars'] : "no";
-
- height += 18;
-
- // Replace all args as variables in URL
- for (var name in args) {
- if (typeof(args[name]) == 'function')
- continue;
-
- url = tinyMCE.replaceVar(url, name, escape(args[name]));
- }
-
- var elm = document.getElementById(this.selectedInstance.editorId + '_parent');
-
- if (tinyMCE.hasPlugin('fullscreen') && this.selectedInstance.getData('fullscreen').enabled)
- pos = { absLeft: 0, absTop: 0 };
- else
- pos = tinyMCE.getAbsPosition(elm);
-
- // Center div in editor area
- pos.absLeft += Math.round((elm.firstChild.clientWidth / 2) - (width / 2));
- pos.absTop += Math.round((elm.firstChild.clientHeight / 2) - (height / 2));
-
- // WordPress cache buster
- url += tinyMCE.settings['imp_version'] ? (url.indexOf('?')==-1?'?':'&') + 'ver=' + tinyMCE.settings['imp_version'] : '';
-
- 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 );
-};
-
-TinyMCE_Engine.prototype.closeWindow = function(win) {
- var gotit = false, n, w;
-
- for (n in mcWindows.windows) {
- w = mcWindows.windows[n];
-
- if (typeof(w) == 'function')
- continue;
-
- if (win.name == w.id + '_iframe') {
- w.close();
- gotit = true;
- }
- }
-
- if (!gotit)
- this.orgCloseWindow(win);
-
- tinyMCE.selectedInstance.getWin().focus();
-};
-
-TinyMCE_Engine.prototype.setWindowTitle = function(win_ref, title) {
- for (var n in mcWindows.windows) {
- var win = mcWindows.windows[n];
- if (typeof(win) == 'function')
- continue;
-
- if (win_ref.name == win.id + "_iframe")
- window.frames[win.id + "_iframe"].document.getElementById(win.id + '_title').innerHTML = title;
- }
-};
-
-// * * * * * TinyMCE_Windows classes below
-
-// Windows handler
-function TinyMCE_Windows() {
- this.settings = new Array();
- this.windows = new Array();
- this.isMSIE = (navigator.appName == "Microsoft Internet Explorer");
- this.isGecko = navigator.userAgent.indexOf('Gecko') != -1;
- this.isSafari = navigator.userAgent.indexOf('Safari') != -1;
- this.isMac = navigator.userAgent.indexOf('Mac') != -1;
- this.isMSIE5_0 = this.isMSIE && (navigator.userAgent.indexOf('MSIE 5.0') != -1);
- this.action = "none";
- this.selectedWindow = null;
- this.lastSelectedWindow = null;
- this.zindex = 1001;
- this.mouseDownScreenX = 0;
- this.mouseDownScreenY = 0;
- this.mouseDownLayerX = 0;
- this.mouseDownLayerY = 0;
- this.mouseDownWidth = 0;
- this.mouseDownHeight = 0;
- this.idCounter = 0;
-};
-
-TinyMCE_Windows.prototype.init = function(settings) {
- this.settings = settings;
-
- if (this.isMSIE)
- this.addEvent(document, "mousemove", mcWindows.eventDispatcher);
- else
- this.addEvent(window, "mousemove", mcWindows.eventDispatcher);
-
- this.addEvent(document, "mouseup", mcWindows.eventDispatcher);
-
- this.addEvent(window, "resize", mcWindows.eventDispatcher);
- this.addEvent(document, "scroll", mcWindows.eventDispatcher);
-
- this.doc = document;
-};
-
-TinyMCE_Windows.prototype.getBounds = function() {
- if (!this.bounds) {
- var vp = tinyMCE.getViewPort(window);
- var top, left, bottom, right, docEl = this.doc.documentElement;
-
- top = vp.top;
- left = vp.left;
- bottom = vp.height + top - 2;
- right = vp.width + left - 22; // TODO this number is platform dependant
- // x1, y1, x2, y2
- this.bounds = [left, top, right, bottom];
- }
- return this.bounds;
-};
-
-TinyMCE_Windows.prototype.clampBoxPosition = function(x, y, w, h, minW, minH) {
- var bounds = this.getBounds();
-
- x = Math.max(bounds[0], Math.min(bounds[2], x + w) - w);
- y = Math.max(bounds[1], Math.min(bounds[3], y + h) - h);
-
- return this.clampBoxSize(x, y, w, h, minW, minH);
-};
-
-TinyMCE_Windows.prototype.clampBoxSize = function(x, y, w, h, minW, minH) {
- var bounds = this.getBounds();
-
- return [
- x, y,
- Math.max(minW, Math.min(bounds[2], x + w) - x),
- Math.max(minH, Math.min(bounds[3], y + h) - y)
- ];
-};
-
-TinyMCE_Windows.prototype.getParam = function(name, default_value) {
- var value = null;
-
- value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];
-
- // Fix bool values
- if (value == "true" || value == "false")
- return (value == "true");
-
- return value;
-};
-
-TinyMCE_Windows.prototype.eventDispatcher = function(e) {
- e = typeof(e) == "undefined" ? window.event : e;
-
- if (mcWindows.selectedWindow == null)
- return;
-
- // Switch focus
- if (mcWindows.isGecko && e.type == "mousedown") {
- var elm = e.currentTarget;
-
- for (var n in mcWindows.windows) {
- var win = mcWindows.windows[n];
-
- if (win.headElement == elm || win.resizeElement == elm) {
- win.focus();
- break;
- }
- }
- }
-
- switch (e.type) {
- case "mousemove":
- mcWindows.selectedWindow.onMouseMove(e);
- break;
-
- case "mouseup":
- mcWindows.selectedWindow.onMouseUp(e);
- break;
-
- case "mousedown":
- mcWindows.selectedWindow.onMouseDown(e);
- break;
-
- case "focus":
- mcWindows.selectedWindow.onFocus(e);
- break;
- case "scroll":
- case "resize":
- if (mcWindows.clampUpdateTimeout)
- clearTimeout(mcWindows.clampUpdateTimeout);
- mcWindows.clampEventType = e.type;
- mcWindows.clampUpdateTimeout =
- setTimeout(function () {mcWindows.updateClamping()}, 100);
- break;
- }
-};
-
-TinyMCE_Windows.prototype.updateClamping = function () {
- var clamp, oversize, etype = mcWindows.clampEventType;
-
- this.bounds = null; // Recalc window bounds on resize/scroll
- this.clampUpdateTimeout = null;
-
- for (var n in this.windows) {
- win = this.windows[n];
- if (typeof(win) == 'function' || ! win.winElement) continue;
-
- clamp = mcWindows.clampBoxPosition(
- win.left, win.top,
- win.winElement.scrollWidth,
- win.winElement.scrollHeight,
- win.features.minWidth,
- win.features.minHeight
- );
- oversize = (
- clamp[2] != win.winElement.scrollWidth ||
- clamp[3] != win.winElement.scrollHeight
- ) ? true : false;
-
- if (!oversize || win.features.resizable == "yes" || etype != "scroll")
- win.moveTo(clamp[0], clamp[1]);
- if (oversize && win.features.resizable == "yes")
- win.resizeTo(clamp[2], clamp[3]);
- }
-};
-
-TinyMCE_Windows.prototype.addEvent = function(obj, name, handler) {
- if (this.isMSIE)
- obj.attachEvent("on" + name, handler);
- else
- obj.addEventListener(name, handler, false);
-};
-
-TinyMCE_Windows.prototype.cancelEvent = function(e) {
- if (this.isMSIE) {
- e.returnValue = false;
- e.cancelBubble = true;
- } else
- e.preventDefault();
-};
-
-TinyMCE_Windows.prototype.parseFeatures = function(opts) {
- // Cleanup the options
- opts = opts.toLowerCase();
- opts = opts.replace(/;/g, ",");
- opts = opts.replace(/[^0-9a-z=,]/g, "");
-
- var optionChunks = opts.split(',');
- var options = new Array();
-
- options['left'] = "10";
- options['top'] = "10";
- options['width'] = "300";
- options['height'] = "300";
- options['minwidth'] = "100";
- options['minheight'] = "100";
- options['resizable'] = "yes";
- options['minimizable'] = "yes";
- options['maximizable'] = "yes";
- options['close'] = "yes";
- options['movable'] = "yes";
- options['statusbar'] = "yes";
- options['scrollbars'] = "auto";
- options['modal'] = "no";
-
- if (opts == "")
- return options;
-
- for (var i=0; i<optionChunks.length; i++) {
- var parts = optionChunks[i].split('=');
-
- if (parts.length == 2)
- options[parts[0]] = parts[1];
- }
-
- options['left'] = parseInt(options['left']);
- options['top'] = parseInt(options['top']);
- options['width'] = parseInt(options['width']);
- options['height'] = parseInt(options['height']);
- options['minWidth'] = parseInt(options['minwidth']);
- options['minHeight'] = parseInt(options['minheight']);
-
- return options;
-};
-
-TinyMCE_Windows.prototype.open = function(url, name, features) {
- this.lastSelectedWindow = this.selectedWindow;
-
- var win = new TinyMCE_Window();
- var winDiv, html = "", id;
- var imgPath = this.getParam("images_path");
-
- features = this.parseFeatures(features);
-
- // Clamp specified dimensions
- var clamp = mcWindows.clampBoxPosition(
- features['left'], features['top'],
- features['width'], features['height'],
- features['minWidth'], features['minHeight']
- );
-
- features['left'] = clamp[0];
- features['top'] = clamp[1];
-
- if (features['resizable'] == "yes") {
- features['width'] = clamp[2];
- features['height'] = clamp[3];
- }
-
- // Create div
- id = "mcWindow_" + name;
- win.deltaHeight = 18;
-
- if (features['statusbar'] == "yes") {
- win.deltaHeight += 13;
-
- if (this.isMSIE)
- win.deltaHeight += 1;
- }
-
- width = parseInt(features['width']);
- height = parseInt(features['height'])-win.deltaHeight;
-
- if (this.isMSIE)
- width -= 2;
-
- // Setup first part of window
- win.id = id;
- win.url = url;
- win.name = name;
- win.features = features;
- this.windows[name] = win;
-
- iframeWidth = width;
- iframeHeight = height;
-
- // Create inner content
- html += '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';
- html += '<html>';
- html += '<head>';
- html += '<title>Wrapper iframe</title>';
-
- // WordPress: put the window buttons on the left as in Macs
- 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>';
-
- html += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
- html += '<link href="' + this.getParam("css_file") + '" rel="stylesheet" type="text/css" />';
- html += '</head>';
- html += '<body onload="parent.mcWindows.onLoad(\'' + name + '\');">';
-
- html += '<div id="' + id + '_container" class="mceWindow">';
- html += '<div id="' + id + '_head" class="mceWindowHead" onmousedown="parent.mcWindows.windows[\'' + name + '\'].focus();">';
- html += ' <div id="' + id + '_title" class="mceWindowTitle"';
- html += ' onselectstart="return false;" unselectable="on" style="-moz-user-select: none !important;"></div>';
- html += ' <div class="mceWindowHeadTools">';
- 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>';
- if (features['resizable'] == "yes" && features['maximizable'] == "yes")
- 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>';
- // html += ' <a href="javascript:mcWindows.windows[\'' + name + '\'].minimize();" target="_self" onmousedown="return false;" class="mceWindowMinimize"></a>';
- html += ' </div>';
- html += '</div><div id="' + id + '_body" class="mceWindowBody" style="width: ' + width + 'px; height: ' + height + 'px;">';
- html += '<iframe id="' + id + '_iframe" name="' + id + '_iframe" frameborder="0" width="' + iframeWidth + '" height="' + iframeHeight + '" src="' + url + '" class="mceWindowBodyIframe" scrolling="' + features['scrollbars'] + '"></iframe></div>';
-
- if (features['statusbar'] == "yes") {
- html += '<div id="' + id + '_statusbar" class="mceWindowStatusbar" onmousedown="parent.mcWindows.windows[\'' + name + '\'].focus();">';
-
- if (features['resizable'] == "yes") {
- if (this.isGecko)
- html += '<div id="' + id + '_resize" class="mceWindowResize"><div style="background-image: url(\'' + imgPath + '/window_resize.gif\'); width: 12px; height: 12px;"></div></div>';
- else
- html += '<div id="' + id + '_resize" class="mceWindowResize"><img onmousedown="parent.mcWindows.windows[\'' + name + '\'].focus();" border="0" src="' + imgPath + '/window_resize.gif" /></div>';
- }
-
- html += '</div>';
- }
-
- html += '</div>';
-
- html += '</body>';
- html += '</html>';
-
- // Create iframe
- this.createFloatingIFrame(id, features['left'], features['top'], features['width'], features['height'], html);
-};
-
-// Blocks the document events by placing a image over the whole document
-TinyMCE_Windows.prototype.setDocumentLock = function(state) {
- var elm = document.getElementById('mcWindowEventBlocker');
-
- if (state) {
- if (elm == null) {
- elm = document.createElement("div");
-
- elm.id = "mcWindowEventBlocker";
- elm.style.position = "absolute";
- elm.style.left = "0";
- elm.style.top = "0";
-
- document.body.appendChild(elm);
- }
-
- elm.style.display = "none";
-
- var imgPath = this.getParam("images_path");
- var width = document.body.clientWidth;
- var height = document.body.clientHeight;
-
- elm.style.width = width;
- elm.style.height = height;
- elm.innerHTML = '<img src="' + imgPath + '/spacer.gif" width="' + width + '" height="' + height + '" />';
-
- elm.style.zIndex = mcWindows.zindex-1;
- elm.style.display = "block";
- } else if (elm != null) {
- if (mcWindows.windows.length == 0)
- elm.parentNode.removeChild(elm);
- else
- elm.style.zIndex = mcWindows.zindex-1;
- }
-};
-
-// Gets called when wrapper iframe is initialized
-TinyMCE_Windows.prototype.onLoad = function(name) {
- var win = mcWindows.windows[name];
- var id = "mcWindow_" + name;
- var wrapperIframe = window.frames[id + "_iframe"].frames[0];
- var wrapperDoc = window.frames[id + "_iframe"].document;
- var doc = window.frames[id + "_iframe"].document;
- var winDiv = document.getElementById("mcWindow_" + name + "_div");
- var realIframe = window.frames[id + "_iframe"].frames[0];
-
- // Set window data
- win.id = "mcWindow_" + name;
- win.winElement = winDiv;
- win.bodyElement = doc.getElementById(id + '_body');
- win.iframeElement = doc.getElementById(id + '_iframe');
- win.headElement = doc.getElementById(id + '_head');
- win.titleElement = doc.getElementById(id + '_title');
- win.resizeElement = doc.getElementById(id + '_resize');
- win.containerElement = doc.getElementById(id + '_container');
- win.left = win.features['left'];
- win.top = win.features['top'];
- win.frame = window.frames[id + '_iframe'].frames[0];
- win.wrapperFrame = window.frames[id + '_iframe'];
- win.wrapperIFrameElement = document.getElementById(id + "_iframe");
-
- // Add event handlers
- mcWindows.addEvent(win.headElement, "mousedown", mcWindows.eventDispatcher);
-
- if (win.resizeElement != null)
- mcWindows.addEvent(win.resizeElement, "mousedown", mcWindows.eventDispatcher);
-
- if (mcWindows.isMSIE) {
- mcWindows.addEvent(realIframe.document, "mousemove", mcWindows.eventDispatcher);
- mcWindows.addEvent(realIframe.document, "mouseup", mcWindows.eventDispatcher);
- } else {
- mcWindows.addEvent(realIframe, "mousemove", mcWindows.eventDispatcher);
- mcWindows.addEvent(realIframe, "mouseup", mcWindows.eventDispatcher);
- mcWindows.addEvent(realIframe, "focus", mcWindows.eventDispatcher);
- }
-
- for (var i=0; i<window.frames.length; i++) {
- if (!window.frames[i]._hasMouseHandlers) {
- if (mcWindows.isMSIE) {
- mcWindows.addEvent(window.frames[i].document, "mousemove", mcWindows.eventDispatcher);
- mcWindows.addEvent(window.frames[i].document, "mouseup", mcWindows.eventDispatcher);
- } else {
- mcWindows.addEvent(window.frames[i], "mousemove", mcWindows.eventDispatcher);
- mcWindows.addEvent(window.frames[i], "mouseup", mcWindows.eventDispatcher);
- }
-
- window.frames[i]._hasMouseHandlers = true;
- }
- }
-
- if (mcWindows.isMSIE) {
- mcWindows.addEvent(win.frame.document, "mousemove", mcWindows.eventDispatcher);
- mcWindows.addEvent(win.frame.document, "mouseup", mcWindows.eventDispatcher);
- } else {
- mcWindows.addEvent(win.frame, "mousemove", mcWindows.eventDispatcher);
- mcWindows.addEvent(win.frame, "mouseup", mcWindows.eventDispatcher);
- mcWindows.addEvent(win.frame, "focus", mcWindows.eventDispatcher);
- }
-
- // Dispatch open window event
- var func = this.getParam("on_open_window", "");
- if (func != "")
- eval(func + "(win);");
-
- win.focus();
-
- if (win.features['modal'] == "yes")
- mcWindows.setDocumentLock(true);
-};
-
-TinyMCE_Windows.prototype.createFloatingIFrame = function(id_prefix, left, top, width, height, html) {
- var iframe = document.createElement("iframe");
- var div = document.createElement("div"), doc;
-
- width = parseInt(width);
- height = parseInt(height)+1;
-
- // Create wrapper div
- div.setAttribute("id", id_prefix + "_div");
- div.setAttribute("width", width);
- div.setAttribute("height", (height));
- div.style.position = "absolute";
-
- div.style.left = left + "px";
- div.style.top = top + "px";
- div.style.width = width + "px";
- div.style.height = (height) + "px";
- div.style.backgroundColor = "white";
- div.style.display = "none";
-
- if (this.isGecko) {
- iframeWidth = width + 2;
- iframeHeight = height + 2;
- } else {
- iframeWidth = width;
- iframeHeight = height + 1;
- }
-
- // Create iframe
- iframe.setAttribute("id", id_prefix + "_iframe");
- iframe.setAttribute("name", id_prefix + "_iframe");
- iframe.setAttribute("border", "0");
- iframe.setAttribute("frameBorder", "0");
- iframe.setAttribute("marginWidth", "0");
- iframe.setAttribute("marginHeight", "0");
- iframe.setAttribute("leftMargin", "0");
- iframe.setAttribute("topMargin", "0");
- iframe.setAttribute("width", iframeWidth);
- iframe.setAttribute("height", iframeHeight);
- // iframe.setAttribute("src", "../jscripts/tiny_mce/blank.htm");
- // iframe.setAttribute("allowtransparency", "false");
- iframe.setAttribute("scrolling", "no");
- iframe.style.width = iframeWidth + "px";
- iframe.style.height = iframeHeight + "px";
- iframe.style.backgroundColor = "white";
- div.appendChild(iframe);
-
- document.body.appendChild(div);
-
- // Fixed MSIE 5.0 issue
- div.innerHTML = div.innerHTML;
-
- if (this.isSafari) {
- // Give Safari some time to setup
- window.setTimeout(function() {
- var doc = window.frames[id_prefix + '_iframe'].document;
- doc.open();
- doc.write(html);
- doc.close();
- }, 10);
- } else {
- doc = window.frames[id_prefix + '_iframe'].window.document;
- doc.open();
- doc.write(html);
- doc.close();
- }
-
- div.style.display = "block";
-
- return div;
-};
-
-// Window instance
-function TinyMCE_Window() {
-};
-
-TinyMCE_Window.prototype.focus = function() {
- if (this != mcWindows.selectedWindow) {
- this.winElement.style.zIndex = ++mcWindows.zindex;
- mcWindows.lastSelectedWindow = mcWindows.selectedWindow;
- mcWindows.selectedWindow = this;
- }
-};
-
-TinyMCE_Window.prototype.minimize = function() {
-};
-
-TinyMCE_Window.prototype.maximize = function() {
- if (this.restoreSize) {
- this.moveTo(this.restoreSize[0], this.restoreSize[1]);
- this.resizeTo(this.restoreSize[2], this.restoreSize[3]);
- this.updateClamping();
- this.restoreSize = null;
- } else {
- var bounds = mcWindows.getBounds();
- this.restoreSize = [
- this.left, this.top,
- this.winElement.scrollWidth,
- this.winElement.scrollHeight
- ];
- this.moveTo(bounds[0], bounds[1]);
- this.resizeTo(
- bounds[2] - bounds[0],
- bounds[3] - bounds[1]
- );
- }
-};
-
-TinyMCE_Window.prototype.startResize = function() {
- mcWindows.action = "resize";
-};
-
-TinyMCE_Window.prototype.startMove = function(e) {
- mcWindows.action = "move";
-};
-
-TinyMCE_Window.prototype.close = function() {
- if (this.frame && this.frame['tinyMCEPopup'])
- this.frame['tinyMCEPopup'].restoreSelection();
-
- if (mcWindows.lastSelectedWindow != null)
- mcWindows.lastSelectedWindow.focus();
-
- var mcWindowsNew = new Array();
- for (var n in mcWindows.windows) {
- var win = mcWindows.windows[n];
- if (typeof(win) == 'function')
- continue;
-
- if (win.name != this.name)
- mcWindowsNew[n] = win;
- }
-
- mcWindows.windows = mcWindowsNew;
-
- // alert(mcWindows.doc.getElementById(this.id + "_iframe"));
-
- var e = mcWindows.doc.getElementById(this.id + "_iframe");
- e.parentNode.removeChild(e);
-
- var e = mcWindows.doc.getElementById(this.id + "_div");
- e.parentNode.removeChild(e);
-
- mcWindows.setDocumentLock(false);
-};
-
-TinyMCE_Window.prototype.onMouseMove = function(e) {
- var clamp;
- // Calculate real X, Y
- var dx = e.screenX - mcWindows.mouseDownScreenX;
- var dy = e.screenY - mcWindows.mouseDownScreenY;
-
- switch (mcWindows.action) {
- case "resize":
- clamp = mcWindows.clampBoxSize(
- this.left, this.top,
- mcWindows.mouseDownWidth + (e.screenX - mcWindows.mouseDownScreenX),
- mcWindows.mouseDownHeight + (e.screenY - mcWindows.mouseDownScreenY),
- this.features.minWidth, this.features.minHeight
- );
-
- this.resizeTo(clamp[2], clamp[3]);
-
- mcWindows.cancelEvent(e);
- break;
-
- case "move":
- this.left = mcWindows.mouseDownLayerX + (e.screenX - mcWindows.mouseDownScreenX);
- this.top = mcWindows.mouseDownLayerY + (e.screenY - mcWindows.mouseDownScreenY);
- this.updateClamping();
-
- mcWindows.cancelEvent(e);
- break;
- }
-};
-
-TinyMCE_Window.prototype.moveTo = function (x, y) {
- this.left = x;
- this.top = y;
-
- this.winElement.style.left = this.left + "px";
- this.winElement.style.top = this.top + "px";
-};
-
-TinyMCE_Window.prototype.resizeTo = function (width, height) {
- this.wrapperIFrameElement.style.width = (width+2) + 'px';
- this.wrapperIFrameElement.style.height = (height+2) + 'px';
- this.wrapperIFrameElement.width = width+2;
- this.wrapperIFrameElement.height = height+2;
- this.winElement.style.width = width + 'px';
- this.winElement.style.height = height + 'px';
-
- height = height - this.deltaHeight;
-
- this.containerElement.style.width = width + 'px';
- this.iframeElement.style.width = width + 'px';
- this.iframeElement.style.height = height + 'px';
- this.bodyElement.style.width = width + 'px';
- this.bodyElement.style.height = height + 'px';
- this.headElement.style.width = width + 'px';
- //this.statusElement.style.width = width + 'px';
-};
-
-TinyMCE_Window.prototype.updateClamping = function () {
- var clamp, oversize;
-
- clamp = mcWindows.clampBoxPosition(
- this.left, this.top,
- this.winElement.scrollWidth,
- this.winElement.scrollHeight,
- this.features.minWidth, this.features.minHeight
- );
- oversize = (
- clamp[2] != this.winElement.scrollWidth ||
- clamp[3] != this.winElement.scrollHeight
- ) ? true : false;
-
- this.moveTo(clamp[0], clamp[1]);
- if (this.features.resizable == "yes" && oversize)
- this.resizeTo(clamp[2], clamp[3]);
-};
-
-function debug(msg) {
- document.getElementById('debug').value += msg + "\n";
-}
-
-TinyMCE_Window.prototype.onMouseUp = function(e) {
- mcWindows.action = "none";
-};
-
-TinyMCE_Window.prototype.onFocus = function(e) {
- // Gecko only handler
- var winRef = e.currentTarget;
-
- for (var n in mcWindows.windows) {
- var win = mcWindows.windows[n];
- if (typeof(win) == 'function')
- continue;
-
- if (winRef.name == win.id + "_iframe") {
- win.focus();
- return;
- }
- }
-};
-
-TinyMCE_Window.prototype.onMouseDown = function(e) {
- var elm = mcWindows.isMSIE ? this.wrapperFrame.event.srcElement : e.target;
-
- mcWindows.mouseDownScreenX = e.screenX;
- mcWindows.mouseDownScreenY = e.screenY;
- mcWindows.mouseDownLayerX = this.left;
- mcWindows.mouseDownLayerY = this.top;
- mcWindows.mouseDownWidth = parseInt(this.winElement.style.width);
- mcWindows.mouseDownHeight = parseInt(this.winElement.style.height);
-
- if (this.resizeElement != null && elm == this.resizeElement.firstChild)
- this.startResize(e);
- else
- this.startMove(e);
-
- mcWindows.cancelEvent(e);
-};
-
-// Global instance
-var mcWindows = new TinyMCE_Windows();
-
-// Initialize windows
-mcWindows.init({
- images_path : tinyMCE.baseURL + "/plugins/inlinepopups/images",
- css_file : tinyMCE.baseURL + "/plugins/inlinepopups/css/inlinepopup.css"
-});
+(function(){var d=tinymce.DOM,b=tinymce.dom.Element,a=tinymce.dom.Event,e=tinymce.each,c=tinymce.is;tinymce.create("tinymce.plugins.InlinePopups",{init:function(f,g){f.onBeforeRenderUI.add(function(){f.windowManager=new tinymce.InlineWindowManager(f);d.loadCSS(g+"/skins/"+(f.settings.inlinepopups_skin||"clearlooks2")+"/window.css")})},getInfo:function(){return{longname:"InlinePopups",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/inlinepopups",version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.create("tinymce.InlineWindowManager:tinymce.WindowManager",{InlineWindowManager:function(f){var g=this;g.parent(f);g.zIndex=300000;g.count=0;g.windows={}},open:function(s,j){var z=this,i,k="",r=z.editor,g=0,v=0,h,m,o,q,l,x,y,n;s=s||{};j=j||{};if(!s.inline){return z.parent(s,j)}n=z._frontWindow();if(n&&d.get(n.id+"_ifr")){n.focussedElement=d.get(n.id+"_ifr").contentWindow.document.activeElement}if(!s.type){z.bookmark=r.selection.getBookmark(1)}i=d.uniqueId();h=d.getViewPort();s.width=parseInt(s.width||320);s.height=parseInt(s.height||240)+(tinymce.isIE?8:0);s.min_width=parseInt(s.min_width||150);s.min_height=parseInt(s.min_height||100);s.max_width=parseInt(s.max_width||2000);s.max_height=parseInt(s.max_height||2000);s.left=s.left||Math.round(Math.max(h.x,h.x+(h.w/2)-(s.width/2)));s.top=s.top||Math.round(Math.max(h.y,h.y+(h.h/2)-(s.height/2)));s.movable=s.resizable=true;j.mce_width=s.width;j.mce_height=s.height;j.mce_inline=true;j.mce_window_id=i;j.mce_auto_focus=s.auto_focus;z.features=s;z.params=j;z.onOpen.dispatch(z,s,j);if(s.type){k+=" mceModal";if(s.type){k+=" mce"+s.type.substring(0,1).toUpperCase()+s.type.substring(1)}s.resizable=false}if(s.statusbar){k+=" mceStatusbar"}if(s.resizable){k+=" mceResizable"}if(s.minimizable){k+=" mceMinimizable"}if(s.maximizable){k+=" mceMaximizable"}if(s.movable){k+=" mceMovable"}z._addAll(d.doc.body,["div",{id:i,role:"dialog","aria-labelledby":s.type?i+"_content":i+"_title","class":(r.settings.inlinepopups_skin||"clearlooks2")+(tinymce.isIE&&window.getSelection?" ie9":""),style:"width:100px;height:100px"},["div",{id:i+"_wrapper","class":"mceWrapper"+k},["div",{id:i+"_top","class":"mceTop"},["div",{"class":"mceLeft"}],["div",{"class":"mceCenter"}],["div",{"class":"mceRight"}],["span",{id:i+"_title"},s.title||""]],["div",{id:i+"_middle","class":"mceMiddle"},["div",{id:i+"_left","class":"mceLeft",tabindex:"0"}],["span",{id:i+"_content"}],["div",{id:i+"_right","class":"mceRight",tabindex:"0"}]],["div",{id:i+"_bottom","class":"mceBottom"},["div",{"class":"mceLeft"}],["div",{"class":"mceCenter"}],["div",{"class":"mceRight"}],["span",{id:i+"_status"},"Content"]],["a",{"class":"mceMove",tabindex:"-1",href:"javascript:;"}],["a",{"class":"mceMin",tabindex:"-1",href:"javascript:;",onmousedown:"return false;"}],["a",{"class":"mceMax",tabindex:"-1",href:"javascript:;",onmousedown:"return false;"}],["a",{"class":"mceMed",tabindex:"-1",href:"javascript:;",onmousedown:"return false;"}],["a",{"class":"mceClose",tabindex:"-1",href:"javascript:;",onmousedown:"return false;"}],["a",{id:i+"_resize_n","class":"mceResize mceResizeN",tabindex:"-1",href:"javascript:;"}],["a",{id:i+"_resize_s","class":"mceResize mceResizeS",tabindex:"-1",href:"javascript:;"}],["a",{id:i+"_resize_w","class":"mceResize mceResizeW",tabindex:"-1",href:"javascript:;"}],["a",{id:i+"_resize_e","class":"mceResize mceResizeE",tabindex:"-1",href:"javascript:;"}],["a",{id:i+"_resize_nw","class":"mceResize mceResizeNW",tabindex:"-1",href:"javascript:;"}],["a",{id:i+"_resize_ne","class":"mceResize mceResizeNE",tabindex:"-1",href:"javascript:;"}],["a",{id:i+"_resize_sw","class":"mceResize mceResizeSW",tabindex:"-1",href:"javascript:;"}],["a",{id:i+"_resize_se","class":"mceResize mceResizeSE",tabindex:"-1",href:"javascript:;"}]]]);d.setStyles(i,{top:-10000,left:-10000});if(tinymce.isGecko){d.setStyle(i,"overflow","auto")}if(!s.type){g+=d.get(i+"_left").clientWidth;g+=d.get(i+"_right").clientWidth;v+=d.get(i+"_top").clientHeight;v+=d.get(i+"_bottom").clientHeight}d.setStyles(i,{top:s.top,left:s.left,width:s.width+g,height:s.height+v});y=s.url||s.file;if(y){if(tinymce.relaxedDomain){y+=(y.indexOf("?")==-1?"?":"&")+"mce_rdomain="+tinymce.relaxedDomain}y=tinymce._addVer(y)}if(!s.type){d.add(i+"_content","iframe",{id:i+"_ifr",src:'javascript:""',frameBorder:0,style:"border:0;width:10px;height:10px"});d.setStyles(i+"_ifr",{width:s.width,height:s.height});d.setAttrib(i+"_ifr","src",y)}else{d.add(i+"_wrapper","a",{id:i+"_ok","class":"mceButton mceOk",href:"javascript:;",onmousedown:"return false;"},"Ok");if(s.type=="confirm"){d.add(i+"_wrapper","a",{"class":"mceButton mceCancel",href:"javascript:;",onmousedown:"return false;"},"Cancel")}d.add(i+"_middle","div",{"class":"mceIcon"});d.setHTML(i+"_content",s.content.replace("\n","<br />"));a.add(i,"keyup",function(f){var p=27;if(f.keyCode===p){s.button_func(false);return a.cancel(f)}});a.add(i,"keydown",function(f){var t,p=9;if(f.keyCode===p){t=d.select("a.mceCancel",i+"_wrapper")[0];if(t&&t!==f.target){t.focus()}else{d.get(i+"_ok").focus()}return a.cancel(f)}})}o=a.add(i,"mousedown",function(t){var u=t.target,f,p;f=z.windows[i];z.focus(i);if(u.nodeName=="A"||u.nodeName=="a"){if(u.className=="mceClose"){z.close(null,i);return a.cancel(t)}else{if(u.className=="mceMax"){f.oldPos=f.element.getXY();f.oldSize=f.element.getSize();p=d.getViewPort();p.w-=2;p.h-=2;f.element.moveTo(p.x,p.y);f.element.resizeTo(p.w,p.h);d.setStyles(i+"_ifr",{width:p.w-f.deltaWidth,height:p.h-f.deltaHeight});d.addClass(i+"_wrapper","mceMaximized")}else{if(u.className=="mceMed"){f.element.moveTo(f.oldPos.x,f.oldPos.y);f.element.resizeTo(f.oldSize.w,f.oldSize.h);f.iframeElement.resizeTo(f.oldSize.w-f.deltaWidth,f.oldSize.h-f.deltaHeight);d.removeClass(i+"_wrapper","mceMaximized")}else{if(u.className=="mceMove"){return z._startDrag(i,t,u.className)}else{if(d.hasClass(u,"mceResize")){return z._startDrag(i,t,u.className.substring(13))}}}}}}});q=a.add(i,"click",function(f){var p=f.target;z.focus(i);if(p.nodeName=="A"||p.nodeName=="a"){switch(p.className){case"mceClose":z.close(null,i);return a.cancel(f);case"mceButton mceOk":case"mceButton mceCancel":s.button_func(p.className=="mceButton mceOk");return a.cancel(f)}}});a.add([i+"_left",i+"_right"],"focus",function(p){var t=d.get(i+"_ifr");if(t){var f=t.contentWindow.document.body;var u=d.select(":input:enabled,*[tabindex=0]",f);if(p.target.id===(i+"_left")){u[u.length-1].focus()}else{u[0].focus()}}else{d.get(i+"_ok").focus()}});x=z.windows[i]={id:i,mousedown_func:o,click_func:q,element:new b(i,{blocker:1,container:r.getContainer()}),iframeElement:new b(i+"_ifr"),features:s,deltaWidth:g,deltaHeight:v};x.iframeElement.on("focus",function(){z.focus(i)});if(z.count==0&&z.editor.getParam("dialog_type","modal")=="modal"){d.add(d.doc.body,"div",{id:"mceModalBlocker","class":(z.editor.settings.inlinepopups_skin||"clearlooks2")+"_modalBlocker",style:{zIndex:z.zIndex-1}});d.show("mceModalBlocker");d.setAttrib(d.doc.body,"aria-hidden","true")}else{d.setStyle("mceModalBlocker","z-index",z.zIndex-1)}if(tinymce.isIE6||/Firefox\/2\./.test(navigator.userAgent)||(tinymce.isIE&&!d.boxModel)){d.setStyles("mceModalBlocker",{position:"absolute",left:h.x,top:h.y,width:h.w-2,height:h.h-2})}d.setAttrib(i,"aria-hidden","false");z.focus(i);z._fixIELayout(i,1);if(d.get(i+"_ok")){d.get(i+"_ok").focus()}z.count++;return x},focus:function(h){var g=this,f;if(f=g.windows[h]){f.zIndex=this.zIndex++;f.element.setStyle("zIndex",f.zIndex);f.element.update();h=h+"_wrapper";d.removeClass(g.lastId,"mceFocus");d.addClass(h,"mceFocus");g.lastId=h;if(f.focussedElement){f.focussedElement.focus()}else{if(d.get(h+"_ok")){d.get(f.id+"_ok").focus()}else{if(d.get(f.id+"_ifr")){d.get(f.id+"_ifr").focus()}}}}},_addAll:function(k,h){var g,l,f=this,j=tinymce.DOM;if(c(h,"string")){k.appendChild(j.doc.createTextNode(h))}else{if(h.length){k=k.appendChild(j.create(h[0],h[1]));for(g=2;g<h.length;g++){f._addAll(k,h[g])}}}},_startDrag:function(v,G,E){var o=this,u,z,C=d.doc,f,l=o.windows[v],h=l.element,y=h.getXY(),x,q,F,g,A,s,r,j,i,m,k,n,B;g={x:0,y:0};A=d.getViewPort();A.w-=2;A.h-=2;j=G.screenX;i=G.screenY;m=k=n=B=0;u=a.add(C,"mouseup",function(p){a.remove(C,"mouseup",u);a.remove(C,"mousemove",z);if(f){f.remove()}h.moveBy(m,k);h.resizeBy(n,B);q=h.getSize();d.setStyles(v+"_ifr",{width:q.w-l.deltaWidth,height:q.h-l.deltaHeight});o._fixIELayout(v,1);return a.cancel(p)});if(E!="Move"){D()}function D(){if(f){return}o._fixIELayout(v,0);d.add(C.body,"div",{id:"mceEventBlocker","class":"mceEventBlocker "+(o.editor.settings.inlinepopups_skin||"clearlooks2"),style:{zIndex:o.zIndex+1}});if(tinymce.isIE6||(tinymce.isIE&&!d.boxModel)){d.setStyles("mceEventBlocker",{position:"absolute",left:A.x,top:A.y,width:A.w-2,height:A.h-2})}f=new b("mceEventBlocker");f.update();x=h.getXY();q=h.getSize();s=g.x+x.x-A.x;r=g.y+x.y-A.y;d.add(f.get(),"div",{id:"mcePlaceHolder","class":"mcePlaceHolder",style:{left:s,top:r,width:q.w,height:q.h}});F=new b("mcePlaceHolder")}z=a.add(C,"mousemove",function(w){var p,H,t;D();p=w.screenX-j;H=w.screenY-i;switch(E){case"ResizeW":m=p;n=0-p;break;case"ResizeE":n=p;break;case"ResizeN":case"ResizeNW":case"ResizeNE":if(E=="ResizeNW"){m=p;n=0-p}else{if(E=="ResizeNE"){n=p}}k=H;B=0-H;break;case"ResizeS":case"ResizeSW":case"ResizeSE":if(E=="ResizeSW"){m=p;n=0-p}else{if(E=="ResizeSE"){n=p}}B=H;break;case"mceMove":m=p;k=H;break}if(n<(t=l.features.min_width-q.w)){if(m!==0){m+=n-t}n=t}if(B<(t=l.features.min_height-q.h)){if(k!==0){k+=B-t}B=t}n=Math.min(n,l.features.max_width-q.w);B=Math.min(B,l.features.max_height-q.h);m=Math.max(m,A.x-(s+A.x));k=Math.max(k,A.y-(r+A.y));m=Math.min(m,(A.w+A.x)-(s+q.w+A.x));k=Math.min(k,(A.h+A.y)-(r+q.h+A.y));if(m+k!==0){if(s+m<0){m=0}if(r+k<0){k=0}F.moveTo(s+m,r+k)}if(n+B!==0){F.resizeTo(q.w+n,q.h+B)}return a.cancel(w)});return a.cancel(G)},resizeBy:function(g,h,i){var f=this.windows[i];if(f){f.element.resizeBy(g,h);f.iframeElement.resizeBy(g,h)}},close:function(i,k){var g=this,f,j=d.doc,h,k;k=g._findId(k||i);if(!g.windows[k]){g.parent(i);return}g.count--;if(g.count==0){d.remove("mceModalBlocker");d.setAttrib(d.doc.body,"aria-hidden","false");g.editor.focus()}if(f=g.windows[k]){g.onClose.dispatch(g);a.remove(j,"mousedown",f.mousedownFunc);a.remove(j,"click",f.clickFunc);a.clear(k);a.clear(k+"_ifr");d.setAttrib(k+"_ifr","src",'javascript:""');f.element.remove();delete g.windows[k];h=g._frontWindow();if(h){g.focus(h.id)}}},_frontWindow:function(){var g,f=0;e(this.windows,function(h){if(h.zIndex>f){g=h;f=h.zIndex}});return g},setTitle:function(f,g){var h;f=this._findId(f);if(h=d.get(f+"_title")){h.innerHTML=d.encode(g)}},alert:function(g,f,j){var i=this,h;h=i.open({title:i,type:"alert",button_func:function(k){if(f){f.call(k||i,k)}i.close(null,h.id)},content:d.encode(i.editor.getLang(g,g)),inline:1,width:400,height:130})},confirm:function(g,f,j){var i=this,h;h=i.open({title:i,type:"confirm",button_func:function(k){if(f){f.call(k||i,k)}i.close(null,h.id)},content:d.encode(i.editor.getLang(g,g)),inline:1,width:400,height:130})},_findId:function(f){var g=this;if(typeof(f)=="string"){return f}e(g.windows,function(h){var i=d.get(h.id+"_ifr");if(i&&f==i.contentWindow){f=h.id;return false}});return f},_fixIELayout:function(i,h){var f,g;if(!tinymce.isIE6){return}e(["n","s","w","e","nw","ne","sw","se"],function(j){var k=d.get(i+"_resize_"+j);d.setStyles(k,{width:h?k.clientWidth:"",height:h?k.clientHeight:"",cursor:d.getStyle(k,"cursor",1)});d.setStyle(i+"_bottom","bottom","-1px");k=0});if(f=this.windows[i]){f.element.hide();f.element.show();e(d.select("div,a",i),function(k,j){if(k.currentStyle.backgroundImage!="none"){g=new Image();g.src=k.currentStyle.backgroundImage.replace(/url\(\"(.+)\"\)/,"$1")}});d.get(i).style.filter=""}}});tinymce.PluginManager.add("inlinepopups",tinymce.plugins.InlinePopups)})();
\ No newline at end of file