X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Ftiny_mce%2Fplugins%2Flayer%2Feditor_plugin_src.js;h=a8ac5a72fcbc01f9eefa40d732564085d01d882a;hb=b05f4eef4014db3885787ef15107cba93c932ac9;hp=28feff2a2473f049803b7f7f0f3002e04428cf0d;hpb=932f4feaa7b2afe4553e5e669e2312614d3f6140;p=citadel.git diff --git a/webcit/tiny_mce/plugins/layer/editor_plugin_src.js b/webcit/tiny_mce/plugins/layer/editor_plugin_src.js old mode 100755 new mode 100644 index 28feff2a2..a8ac5a72f --- a/webcit/tiny_mce/plugins/layer/editor_plugin_src.js +++ b/webcit/tiny_mce/plugins/layer/editor_plugin_src.js @@ -1,248 +1,214 @@ /** - * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ + * editor_plugin_src.js * - * @author Moxiecode - * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. + * Copyright 2009, Moxiecode Systems AB + * Released under LGPL License. + * + * License: http://tinymce.moxiecode.com/license + * Contributing: http://tinymce.moxiecode.com/contributing */ -/* Import plugin specific language pack */ -tinyMCE.importPluginLanguagePack('layer'); - -var TinyMCE_LayerPlugin = { - getInfo : function() { - return { - longname : 'Layer', - author : 'Moxiecode Systems AB', - authorurl : 'http://tinymce.moxiecode.com', - infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/layer', - version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion - }; - }, - - initInstance : function(inst) { - if (tinyMCE.isMSIE && !tinyMCE.isOpera) - inst.getDoc().execCommand('2D-Position'); - }, - - handleEvent : function(e) { - var inst = tinyMCE.selectedInstance; - var w = inst.getWin(), le = inst._lastStyleElm, e; - - if (tinyMCE.isGecko) { - e = this._getParentLayer(inst.getFocusElement()); - - if (e) { - if (!inst._lastStyleElm) { - e.style.overflow = 'auto'; - inst._lastStyleElm = e; - } - } else if (le) { - le = inst._lastStyleElm; - le.style.width = le.scrollWidth + 'px'; - le.style.height = le.scrollHeight + 'px'; - le.style.overflow = ''; - inst._lastStyleElm = null; - } - } - - return true; - }, - - handleVisualAid : function(el, deep, state, inst) { - var nl = inst.getDoc().getElementsByTagName("div"), i; - - for (i=0; i -1) { - nl[ci].style.zIndex = z[fi]; - nl[fi].style.zIndex = z[ci]; - } else { - if (z[ci] > 0) - nl[ci].style.zIndex = z[ci] - 1; - } - } else { - // Move forward - - // Try find a higher one - for (i=0; i z[ci]) { - fi = i; - break; + if (fi > -1) { + nl[ci].style.zIndex = z[fi]; + nl[fi].style.zIndex = z[ci]; + } else { + if (z[ci] > 0) + nl[ci].style.zIndex = z[ci] - 1; } - } - - if (fi > -1) { - nl[ci].style.zIndex = z[fi]; - nl[fi].style.zIndex = z[ci]; - } else - nl[ci].style.zIndex = z[ci] + 1; - } - - inst.repaint(); - }, - - _getParentLayer : function(n) { - return tinyMCE.getParentNode(n, function(n) { - return n.nodeType == 1 && new RegExp('absolute|relative|static', 'gi').test(n.style.position); - }); - }, - - _insertLayer : function() { - var inst = tinyMCE.selectedInstance; - var e = tinyMCE.getParentElement(inst.getFocusElement()); - var p = tinyMCE.getAbsPosition(e); - var d = inst.getDoc(); - var ne = d.createElement('div'); - var h = inst.selection.getSelectedHTML(); - - // Move div - ne.style.position = 'absolute'; - ne.style.left = p.absLeft + 'px'; - ne.style.top = (p.absTop > 20 ? p.absTop : 20) + 'px'; - ne.style.width = '100px'; - ne.style.height = '100px'; - ne.className = 'mceVisualAid'; - - if (!h) - h = tinyMCE.getLang('lang_layer_content'); - - ne.innerHTML = h; - - // Add it - d.body.appendChild(ne); - }, - - _toggleAbsolute : function() { - var inst = tinyMCE.selectedInstance; - var le = this._getParentLayer(inst.getFocusElement()); - - if (le == null) - le = tinyMCE.getParentElement(inst.getFocusElement(), 'div,p,img'); - - if (le) { - if (le.style.position.toLowerCase() == "absolute") { - le.style.position = ""; - le.style.left = ""; - le.style.top = ""; } else { - le.style.position = "absolute"; - - if (le.style.left == "") - le.style.left = 20 + 'px'; - - if (le.style.top == "") - le.style.top = 20 + 'px'; + // Move forward + + // Try find a higher one + for (i=0; i z[ci]) { + fi = i; + break; + } + } - if (le.style.width == "") - le.style.width = le.width ? (le.width + 'px') : '100px'; + if (fi > -1) { + nl[ci].style.zIndex = z[fi]; + nl[fi].style.zIndex = z[ci]; + } else + nl[ci].style.zIndex = z[ci] + 1; + } - if (le.style.height == "") - le.style.height = le.height ? (le.height + 'px') : '100px'; + ed.execCommand('mceRepaint'); + }, + + _getParentLayer : function(n) { + return this.editor.dom.getParent(n, function(n) { + return n.nodeType == 1 && /^(absolute|relative|static)$/i.test(n.style.position); + }); + }, + + _insertLayer : function() { + var ed = this.editor, p = ed.dom.getPos(ed.dom.getParent(ed.selection.getNode(), '*')); + + ed.dom.add(ed.getBody(), 'div', { + style : { + position : 'absolute', + left : p.x, + top : (p.y > 20 ? p.y : 20), + width : 100, + height : 100 + }, + 'class' : 'mceItemVisualAid' + }, ed.selection.getContent() || ed.getLang('layer.content')); + }, + + _toggleAbsolute : function() { + var ed = this.editor, le = this._getParentLayer(ed.selection.getNode()); + + if (!le) + le = ed.dom.getParent(ed.selection.getNode(), 'DIV,P,IMG'); + + if (le) { + if (le.style.position.toLowerCase() == "absolute") { + ed.dom.setStyles(le, { + position : '', + left : '', + top : '', + width : '', + height : '' + }); + + ed.dom.removeClass(le, 'mceItemVisualAid'); + } else { + if (le.style.left == "") + le.style.left = 20 + 'px'; + + if (le.style.top == "") + le.style.top = 20 + 'px'; + + if (le.style.width == "") + le.style.width = le.width ? (le.width + 'px') : '100px'; + + if (le.style.height == "") + le.style.height = le.height ? (le.height + 'px') : '100px'; + + le.style.position = "absolute"; + + ed.dom.setAttrib(le, 'data-mce-style', ''); + ed.addVisual(ed.getBody()); + } - tinyMCE.handleVisualAid(inst.getBody(), true, inst.visualAid, inst); + ed.execCommand('mceRepaint'); + ed.nodeChanged(); } - - inst.repaint(); - tinyMCE.triggerNodeChange(); } - } -}; + }); -tinyMCE.addPlugin("layer", TinyMCE_LayerPlugin); + // Register plugin + tinymce.PluginManager.add('layer', tinymce.plugins.Layer); +})(); \ No newline at end of file