X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/a66f9e26487c560245ef9cd17d7e87c0cbb650af..refs/tags/wordpress-2.5.1:/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..0766b49a 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'));}mdf=Event.add(id,'mousedown',function(e){var n=e.target,w,vp;w=t.windows[id];t.focus(id);if(n.nodeName=='A'||n.nodeName=='a'){if(n.className=='mceMax'){w.oldPos=w.element.getXY();w.oldSize=w.element.getSize();vp=DOM.getViewPort();vp.w-=2;vp.h-=2;w.element.moveTo(vp.x,vp.y);w.element.resizeTo(vp.w,vp.h);DOM.setStyles(id+'_ifr',{width:vp.w-w.deltaWidth,height:vp.h-w.deltaHeight});DOM.addClass(id+'_wrapper','mceMaximized');}else if(n.className=='mceMed'){w.element.moveTo(w.oldPos.x,w.oldPos.y);w.element.resizeTo(w.oldSize.w,w.oldSize.h);w.iframeElement.resizeTo(w.oldSize.w-w.deltaWidth,w.oldSize.h-w.deltaHeight);DOM.removeClass(id+'_wrapper','mceMaximized');}else if(n.className=='mceMove')return t._startDrag(id,e,n.className);else if(DOM.hasClass(n,'mceResize'))return t._startDrag(id,e,n.className.substring(13));}});clf=Event.add(id,'click',function(e){var n=e.target;t.focus(id);if(n.nodeName=='A'||n.nodeName=='a'){switch(n.className){case'mceClose':t.close(null,id);return Event.cancel(e);case'mceButton mceOk':case'mceButton mceCancel':f.button_func(n.className=='mceButton mceOk');return Event.cancel(e);}}});t.windows=t.windows||{};w=t.windows[id]={id:id,mousedown_func:mdf,click_func:clf,element:new Element(id,{blocker:1,container:ed.getContainer()}),iframeElement:new Element(id+'_ifr'),features:f,deltaWidth:dw,deltaHeight:dh};w.iframeElement.on('focus',function(){t.focus(id);});if(t.count==0&&t.editor.getParam('dialog_type')=='modal'){DOM.add(DOM.doc.body,'div',{id:'mceModalBlocker','class':(t.editor.settings.inlinepopups_skin||'clearlooks2')+'_modalBlocker',style:{left:vp.x,top:vp.y,zIndex:t.zIndex-1}});DOM.show('mceModalBlocker');}else DOM.setStyle('mceModalBlocker','z-index',t.zIndex-1);t.focus(id);t._fixIELayout(id,1);if(DOM.get(id+'_ok'))DOM.get(id+'_ok').focus();t.count++;return w;},focus:function(id){var t=this,w=t.windows[id];w.zIndex=this.zIndex++;w.element.setStyle('zIndex',w.zIndex);w.element.update();id=id+'_wrapper';DOM.removeClass(t.lastId,'mceFocus');DOM.addClass(id,'mceFocus');t.lastId=id;},_addAll:function(te,ne){var i,n,t=this,dom=tinymce.DOM;if(is(ne,'string'))te.appendChild(dom.doc.createTextNode(ne));else if(ne.length){te=te.appendChild(dom.create(ne[0],ne[1]));for(i=2;iix){fw=w;ix=w.zIndex;}});if(fw)t.focus(fw.id);}},setTitle:function(ti,id){var e;if(e=DOM.get(id+'_title'))e.innerHTML=DOM.encode(ti);},alert:function(txt,cb,s){var t=this,w;w=t.open({title:t,type:'alert',button_func:function(s){if(cb)cb.call(s||t,s);t.close(null,w.id);},content:DOM.encode(t.editor.getLang(txt,txt)),inline:1,width:400,height:130});},confirm:function(txt,cb,s){var t=this,w;w=t.open({title:t,type:'confirm',button_func:function(s){if(cb)cb.call(s||t,s);t.close(null,w.id);},content:DOM.encode(t.editor.getLang(txt,txt)),inline:1,width:400,height:130});},_fixIELayout:function(id,s){var w,img;if(!tinymce.isIE6)return;each(['n','s','w','e','nw','ne','sw','se'],function(v){var e=DOM.get(id+'_resize_'+v);DOM.setStyles(e,{width:s?e.clientWidth:'',height:s?e.clientHeight:'',cursor:DOM.getStyle(e,'cursor',1)});DOM.setStyle(id+"_bottom",'bottom','-1px');e=0;});if(w=this.windows[id]){w.element.hide();w.element.show();each(DOM.select('div,a',id),function(e,i){if(e.currentStyle.backgroundImage!='none'){img=new Image();img.src=e.currentStyle.backgroundImage.replace(/url\(\"(.+)\"\)/,'$1');}});DOM.get(id).style.filter='';}}});tinymce.PluginManager.add('inlinepopups',tinymce.plugins.InlinePopups);})(); \ No newline at end of file