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