X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Ftiny_mce%2Fplugins%2Fxhtmlxtras%2Feditor_plugin_src.js;h=f24057211c4ce2059912fec74c80bd3835914349;hb=eb5fb3f6c3b3e1d4d3d7ebbb92b8c60d70d13254;hp=7e73466ab05d26bacee9e58061c3ad027d6ea954;hpb=932f4feaa7b2afe4553e5e669e2312614d3f6140;p=citadel.git diff --git a/webcit/tiny_mce/plugins/xhtmlxtras/editor_plugin_src.js b/webcit/tiny_mce/plugins/xhtmlxtras/editor_plugin_src.js old mode 100755 new mode 100644 index 7e73466ab..f24057211 --- a/webcit/tiny_mce/plugins/xhtmlxtras/editor_plugin_src.js +++ b/webcit/tiny_mce/plugins/xhtmlxtras/editor_plugin_src.js @@ -1,199 +1,132 @@ - /** - * $Id: editor_plugin_src.js 42 2006-08-08 14:32:24Z spocke $ +/** + * editor_plugin_src.js * - * @author Moxiecode - based on work by Andrew Tetlaw - * @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('xhtmlxtras'); - -var TinyMCE_XHTMLXtrasPlugin = { - getInfo : function() { - return { - longname : 'XHTML Xtras Plugin', - author : 'Moxiecode Systems AB', - authorurl : 'http://tinymce.moxiecode.com', - infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/xhtmlxtras', - version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion - }; - }, - - initInstance : function(inst) { - tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/plugins/xhtmlxtras/css/xhtmlxtras.css"); - }, - - getControlHTML : function(cn) { - switch (cn) { - case "cite": - return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_cite_desc', '{$pluginurl}/images/cite.gif', 'mceCite', true); - - case "acronym": - return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_acronym_desc', '{$pluginurl}/images/acronym.gif', 'mceAcronym', true); - - case "abbr": - return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_abbr_desc', '{$pluginurl}/images/abbr.gif', 'mceAbbr', true); - - case "del": - return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_del_desc', '{$pluginurl}/images/del.gif', 'mceDel', true); - - case "ins": - return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_ins_desc', '{$pluginurl}/images/ins.gif', 'mceIns', true); - - case "attribs": - return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_attribs_desc', '{$pluginurl}/images/attribs.gif', 'mceAttributes', true); - } - - return ""; - }, - - execCommand : function(editor_id, element, command, user_interface, value) { - var template, inst, elm; - - switch (command) { - case "mceCite": - if (!this._anySel(editor_id)) - return true; - - template = new Array(); - template['file'] = '../../plugins/xhtmlxtras/cite.htm'; - template['width'] = 350; - template['height'] = 250; - tinyMCE.openWindow(template, {editor_id : editor_id}); - return true; - - case "mceAcronym": - if (!this._anySel(editor_id)) - return true; - - template = new Array(); - template['file'] = '../../plugins/xhtmlxtras/acronym.htm'; - template['width'] = 350; - template['height'] = 250; - tinyMCE.openWindow(template, {editor_id : editor_id}); - return true; - - case "mceAbbr": - if (!this._anySel(editor_id)) - return true; - - template = new Array(); - template['file'] = '../../plugins/xhtmlxtras/abbr.htm'; - template['width'] = 350; - template['height'] = 250; - tinyMCE.openWindow(template, {editor_id : editor_id}); - return true; - - case "mceIns": - if (!this._anySel(editor_id)) - return true; - - template = new Array(); - template['file'] = '../../plugins/xhtmlxtras/ins.htm'; - template['width'] = 350; - template['height'] = 310; - tinyMCE.openWindow(template, {editor_id : editor_id}); - return true; - - case "mceDel": - if (!this._anySel(editor_id)) - return true; - - template = new Array(); - template['file'] = '../../plugins/xhtmlxtras/del.htm'; - template['width'] = 350; - template['height'] = 310; - tinyMCE.openWindow(template, {editor_id : editor_id}); - return true; - - case "mceAttributes": - inst = tinyMCE.getInstanceById(editor_id); - elm = inst.getFocusElement(); - - if (elm && elm.nodeName !== 'BODY' && elm.className.indexOf('mceItem') == -1) { - tinyMCE.openWindow({ - file : '../../plugins/xhtmlxtras/attributes.htm', - width : 380, - height : 370 - }, {editor_id : editor_id}); +(function() { + tinymce.create('tinymce.plugins.XHTMLXtrasPlugin', { + init : function(ed, url) { + // Register commands + ed.addCommand('mceCite', function() { + ed.windowManager.open({ + file : url + '/cite.htm', + width : 350 + parseInt(ed.getLang('xhtmlxtras.cite_delta_width', 0)), + height : 250 + parseInt(ed.getLang('xhtmlxtras.cite_delta_height', 0)), + inline : 1 + }, { + plugin_url : url + }); + }); + + ed.addCommand('mceAcronym', function() { + ed.windowManager.open({ + file : url + '/acronym.htm', + width : 350 + parseInt(ed.getLang('xhtmlxtras.acronym_delta_width', 0)), + height : 250 + parseInt(ed.getLang('xhtmlxtras.acronym_delta_height', 0)), + inline : 1 + }, { + plugin_url : url + }); + }); + + ed.addCommand('mceAbbr', function() { + ed.windowManager.open({ + file : url + '/abbr.htm', + width : 350 + parseInt(ed.getLang('xhtmlxtras.abbr_delta_width', 0)), + height : 250 + parseInt(ed.getLang('xhtmlxtras.abbr_delta_height', 0)), + inline : 1 + }, { + plugin_url : url + }); + }); + + ed.addCommand('mceDel', function() { + ed.windowManager.open({ + file : url + '/del.htm', + width : 340 + parseInt(ed.getLang('xhtmlxtras.del_delta_width', 0)), + height : 310 + parseInt(ed.getLang('xhtmlxtras.del_delta_height', 0)), + inline : 1 + }, { + plugin_url : url + }); + }); + + ed.addCommand('mceIns', function() { + ed.windowManager.open({ + file : url + '/ins.htm', + width : 340 + parseInt(ed.getLang('xhtmlxtras.ins_delta_width', 0)), + height : 310 + parseInt(ed.getLang('xhtmlxtras.ins_delta_height', 0)), + inline : 1 + }, { + plugin_url : url + }); + }); + + ed.addCommand('mceAttributes', function() { + ed.windowManager.open({ + file : url + '/attributes.htm', + width : 380 + parseInt(ed.getLang('xhtmlxtras.attr_delta_width', 0)), + height : 370 + parseInt(ed.getLang('xhtmlxtras.attr_delta_height', 0)), + inline : 1 + }, { + plugin_url : url + }); + }); + + // Register buttons + ed.addButton('cite', {title : 'xhtmlxtras.cite_desc', cmd : 'mceCite'}); + ed.addButton('acronym', {title : 'xhtmlxtras.acronym_desc', cmd : 'mceAcronym'}); + ed.addButton('abbr', {title : 'xhtmlxtras.abbr_desc', cmd : 'mceAbbr'}); + ed.addButton('del', {title : 'xhtmlxtras.del_desc', cmd : 'mceDel'}); + ed.addButton('ins', {title : 'xhtmlxtras.ins_desc', cmd : 'mceIns'}); + ed.addButton('attribs', {title : 'xhtmlxtras.attribs_desc', cmd : 'mceAttributes'}); + + ed.onNodeChange.add(function(ed, cm, n, co) { + n = ed.dom.getParent(n, 'CITE,ACRONYM,ABBR,DEL,INS'); + + cm.setDisabled('cite', co); + cm.setDisabled('acronym', co); + cm.setDisabled('abbr', co); + cm.setDisabled('del', co); + cm.setDisabled('ins', co); + cm.setDisabled('attribs', n && n.nodeName == 'BODY'); + cm.setActive('cite', 0); + cm.setActive('acronym', 0); + cm.setActive('abbr', 0); + cm.setActive('del', 0); + cm.setActive('ins', 0); + + // Activate all + if (n) { + do { + cm.setDisabled(n.nodeName.toLowerCase(), 0); + cm.setActive(n.nodeName.toLowerCase(), 1); + } while (n = n.parentNode); } - - return true; - } - - return false; - }, - - cleanup : function(type, content, inst) { - if (type == 'insert_to_editor' && tinyMCE.isIE && !tinyMCE.isOpera) { - content = content.replace(/]+)>/gi, ''); - content = content.replace(/<\/abbr>/gi, ''); - } - - return content; - }, - - handleNodeChange : function(editor_id, node, undo_index,undo_levels, visual_aid, any_selection) { - var elm = tinyMCE.getParentElement(node); - - if (node == null) - return; - - tinyMCE.switchClass(editor_id + '_attribs', 'mceButtonDisabled'); - - if (!any_selection) { - // Disable the buttons - tinyMCE.switchClass(editor_id + '_cite', 'mceButtonDisabled'); - tinyMCE.switchClass(editor_id + '_acronym', 'mceButtonDisabled'); - tinyMCE.switchClass(editor_id + '_abbr', 'mceButtonDisabled'); - tinyMCE.switchClass(editor_id + '_del', 'mceButtonDisabled'); - tinyMCE.switchClass(editor_id + '_ins', 'mceButtonDisabled'); - } else { - // A selection means the buttons should be active. - tinyMCE.switchClass(editor_id + '_cite', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_acronym', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_abbr', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_del', 'mceButtonNormal'); - tinyMCE.switchClass(editor_id + '_ins', 'mceButtonNormal'); + }); + + ed.onPreInit.add(function() { + // Fixed IE issue where it can't handle these elements correctly + ed.dom.create('abbr'); + }); + }, + + getInfo : function() { + return { + longname : 'XHTML Xtras Plugin', + author : 'Moxiecode Systems AB', + authorurl : 'http://tinymce.moxiecode.com', + infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/xhtmlxtras', + version : tinymce.majorVersion + "." + tinymce.minorVersion + }; } + }); - if (elm && elm.nodeName != 'BODY' && elm.className.indexOf('mceItem') == -1) - tinyMCE.switchClass(editor_id + '_attribs', 'mceButtonNormal'); - - switch (node.nodeName) { - case "CITE": - tinyMCE.switchClass(editor_id + '_cite', 'mceButtonSelected'); - return true; - - case "ACRONYM": - tinyMCE.switchClass(editor_id + '_acronym', 'mceButtonSelected'); - return true; - - case "abbr": // IE - case "HTML:ABBR": // FF - case "ABBR": - tinyMCE.switchClass(editor_id + '_abbr', 'mceButtonSelected'); - return true; - - case "DEL": - tinyMCE.switchClass(editor_id + '_del', 'mceButtonSelected'); - return true; - - case "INS": - tinyMCE.switchClass(editor_id + '_ins', 'mceButtonSelected'); - return true; - } - - return true; - }, - - _anySel : function(editor_id) { - var inst = tinyMCE.getInstanceById(editor_id), t = inst.selection.getSelectedText(), pe; - - pe = tinyMCE.getParentElement(inst.getFocusElement(), 'CITE,ACRONYM,ABBR,HTML:ABBR,DEL,INS'); - - return pe || inst.getFocusElement().nodeName == "IMG" || (t && t.length > 0); - } -}; - -tinyMCE.addPlugin("xhtmlxtras", TinyMCE_XHTMLXtrasPlugin); + // Register plugin + tinymce.PluginManager.add('xhtmlxtras', tinymce.plugins.XHTMLXtrasPlugin); +})(); \ No newline at end of file