X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/3e7fab96d7874067884348df10bbdcdefa4a89ad..fef8173b8c3bad08f495551e43cfdeac1cae6021:/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js b/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js index 69170320..e57c9438 100644 --- a/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js +++ b/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js @@ -1,826 +1 @@ -/** - * $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'; - html += ''; - html += ''; - - html += '
'; - html += '
'; - html += '
'; - if (features['resizable'] == "yes" && features['maximizable'] == "yes") - html += ' '; - // html += ' '; - html += '
'; - html += '
'; - html += '
'; - - if (features['statusbar'] == "yes") { - html += '
'; - - if (features['resizable'] == "yes") { - if (this.isGecko) - html += '
'; - else - html += '
'; - } - - html += '
'; - } - - html += '
'; - - 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 = ''; - - 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"))}n=a.add(i,"mousedown",function(t){var u=t.target,f,p;f=y.windows[i];y.focus(i);if(u.nodeName=="A"||u.nodeName=="a"){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 y._startDrag(i,t,u.className)}else{if(d.hasClass(u,"mceResize")){return y._startDrag(i,t,u.className.substring(13))}}}}}});o=a.add(i,"click",function(f){var p=f.target;y.focus(i);if(p.nodeName=="A"||p.nodeName=="a"){switch(p.className){case"mceClose":y.close(null,i);return a.cancel(f);case"mceButton mceOk":case"mceButton mceCancel":r.button_func(p.className=="mceButton mceOk");return a.cancel(f)}}});v=y.windows[i]={id:i,mousedown_func:n,click_func:o,element:new b(i,{blocker:1,container:q.getContainer()}),iframeElement:new b(i+"_ifr"),features:r,deltaWidth:g,deltaHeight:s};v.iframeElement.on("focus",function(){y.focus(i)});if(y.count==0&&y.editor.getParam("dialog_type","modal")=="modal"){d.add(d.doc.body,"div",{id:"mceModalBlocker","class":(y.editor.settings.inlinepopups_skin||"clearlooks2")+"_modalBlocker",style:{zIndex:y.zIndex-1}});d.show("mceModalBlocker")}else{d.setStyle("mceModalBlocker","z-index",y.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})}y.focus(i);y._fixIELayout(i,1);if(d.get(i+"_ok")){d.get(i+"_ok").focus()}y.count++;return v},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}},_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;gf){i=m;f=m.zIndex}});if(i){h.focus(i.id)}}},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