* Re-added tiny_mce, this time with the language packs
[citadel.git] / webcit / tiny_mce / plugins / xhtmlxtras / editor_plugin_src.js
blobbef06f2d24e7abbda3a07d21b38c52e68dafdcf7
1 /**\r
2  * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $\r
3  *\r
4  * @author Moxiecode\r
5  * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.\r
6  */\r
7 \r
8 (function() {\r
9         tinymce.create('tinymce.plugins.XHTMLXtrasPlugin', {\r
10                 init : function(ed, url) {\r
11                         // Register commands\r
12                         ed.addCommand('mceCite', function() {\r
13                                 ed.windowManager.open({\r
14                                         file : url + '/cite.htm',\r
15                                         width : 350 + parseInt(ed.getLang('xhtmlxtras.cite_delta_width', 0)),\r
16                                         height : 250 + parseInt(ed.getLang('xhtmlxtras.cite_delta_height', 0)),\r
17                                         inline : 1\r
18                                 }, {\r
19                                         plugin_url : url\r
20                                 });\r
21                         });\r
23                         ed.addCommand('mceAcronym', function() {\r
24                                 ed.windowManager.open({\r
25                                         file : url + '/acronym.htm',\r
26                                         width : 350 + parseInt(ed.getLang('xhtmlxtras.acronym_delta_width', 0)),\r
27                                         height : 250 + parseInt(ed.getLang('xhtmlxtras.acronym_delta_width', 0)),\r
28                                         inline : 1\r
29                                 }, {\r
30                                         plugin_url : url\r
31                                 });\r
32                         });\r
34                         ed.addCommand('mceAbbr', function() {\r
35                                 ed.windowManager.open({\r
36                                         file : url + '/abbr.htm',\r
37                                         width : 350 + parseInt(ed.getLang('xhtmlxtras.abbr_delta_width', 0)),\r
38                                         height : 250 + parseInt(ed.getLang('xhtmlxtras.abbr_delta_width', 0)),\r
39                                         inline : 1\r
40                                 }, {\r
41                                         plugin_url : url\r
42                                 });\r
43                         });\r
45                         ed.addCommand('mceDel', function() {\r
46                                 ed.windowManager.open({\r
47                                         file : url + '/del.htm',\r
48                                         width : 340 + parseInt(ed.getLang('xhtmlxtras.del_delta_width', 0)),\r
49                                         height : 310 + parseInt(ed.getLang('xhtmlxtras.del_delta_width', 0)),\r
50                                         inline : 1\r
51                                 }, {\r
52                                         plugin_url : url\r
53                                 });\r
54                         });\r
56                         ed.addCommand('mceIns', function() {\r
57                                 ed.windowManager.open({\r
58                                         file : url + '/ins.htm',\r
59                                         width : 340 + parseInt(ed.getLang('xhtmlxtras.ins_delta_width', 0)),\r
60                                         height : 310 + parseInt(ed.getLang('xhtmlxtras.ins_delta_width', 0)),\r
61                                         inline : 1\r
62                                 }, {\r
63                                         plugin_url : url\r
64                                 });\r
65                         });\r
67                         ed.addCommand('mceAttributes', function() {\r
68                                 ed.windowManager.open({\r
69                                         file : url + '/attributes.htm',\r
70                                         width : 380,\r
71                                         height : 370,\r
72                                         inline : 1\r
73                                 }, {\r
74                                         plugin_url : url\r
75                                 });\r
76                         });\r
78                         // Register buttons\r
79                         ed.addButton('cite', {title : 'xhtmlxtras.cite_desc', cmd : 'mceCite'});\r
80                         ed.addButton('acronym', {title : 'xhtmlxtras.acronym_desc', cmd : 'mceAcronym'});\r
81                         ed.addButton('abbr', {title : 'xhtmlxtras.abbr_desc', cmd : 'mceAbbr'});\r
82                         ed.addButton('del', {title : 'xhtmlxtras.del_desc', cmd : 'mceDel'});\r
83                         ed.addButton('ins', {title : 'xhtmlxtras.ins_desc', cmd : 'mceIns'});\r
84                         ed.addButton('attribs', {title : 'xhtmlxtras.attribs_desc', cmd : 'mceAttributes'});\r
86                         if (tinymce.isIE) {\r
87                                 function fix(ed, o) {\r
88                                         if (o.set) {\r
89                                                 o.content = o.content.replace(/<abbr([^>]+)>/gi, '<html:abbr $1>');\r
90                                                 o.content = o.content.replace(/<\/abbr>/gi, '</html:abbr>');\r
91                                         }\r
92                                 };\r
94                                 ed.onBeforeSetContent.add(fix);\r
95                                 ed.onPostProcess.add(fix);\r
96                         }\r
98                         ed.onNodeChange.add(function(ed, cm, n, co) {\r
99                                 n = ed.dom.getParent(n, 'CITE,ACRONYM,ABBR,DEL,INS');\r
101                                 cm.setDisabled('cite', co);\r
102                                 cm.setDisabled('acronym', co);\r
103                                 cm.setDisabled('abbr', co);\r
104                                 cm.setDisabled('del', co);\r
105                                 cm.setDisabled('ins', co);\r
106                                 cm.setDisabled('attribs', n && n.nodeName == 'BODY');\r
107                                 cm.setActive('cite', 0);\r
108                                 cm.setActive('acronym', 0);\r
109                                 cm.setActive('abbr', 0);\r
110                                 cm.setActive('del', 0);\r
111                                 cm.setActive('ins', 0);\r
113                                 // Activate all\r
114                                 if (n) {\r
115                                         do {\r
116                                                 cm.setDisabled(n.nodeName.toLowerCase(), 0);\r
117                                                 cm.setActive(n.nodeName.toLowerCase(), 1);\r
118                                         } while (n = n.parentNode);\r
119                                 }\r
120                         });\r
121                 },\r
123                 getInfo : function() {\r
124                         return {\r
125                                 longname : 'XHTML Xtras Plugin',\r
126                                 author : 'Moxiecode Systems AB',\r
127                                 authorurl : 'http://tinymce.moxiecode.com',\r
128                                 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/xhtmlxtras',\r
129                                 version : tinymce.majorVersion + "." + tinymce.minorVersion\r
130                         };\r
131                 }\r
132         });\r
134         // Register plugin\r
135         tinymce.PluginManager.add('xhtmlxtras', tinymce.plugins.XHTMLXtrasPlugin);\r
136 })();