2 * $Id: editor_plugin_src.js 42 2006-08-08 14:32:24Z spocke $
4 * @author Moxiecode - based on work by Andrew Tetlaw
5 * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
8 /* Import plugin specific language pack */
9 tinyMCE
.importPluginLanguagePack('xhtmlxtras');
11 var TinyMCE_XHTMLXtrasPlugin
= {
12 getInfo : function() {
14 longname
: 'XHTML Xtras Plugin',
15 author
: 'Moxiecode Systems AB',
16 authorurl
: 'http://tinymce.moxiecode.com',
17 infourl
: 'http://tinymce.moxiecode.com/tinymce/docs/plugin_xhtmlxtras.html',
18 version
: tinyMCE
.majorVersion
+ "." + tinyMCE
.minorVersion
22 initInstance : function(inst
) {
23 tinyMCE
.importCSS(inst
.getDoc(), tinyMCE
.baseURL
+ "/plugins/xhtmlxtras/css/xhtmlxtras.css");
26 getControlHTML : function(cn
) {
29 return tinyMCE
.getButtonHTML(cn
, 'lang_xhtmlxtras_cite_desc', '{$pluginurl}/images/cite.gif', 'mceCite', true);
32 return tinyMCE
.getButtonHTML(cn
, 'lang_xhtmlxtras_acronym_desc', '{$pluginurl}/images/acronym.gif', 'mceAcronym', true);
35 return tinyMCE
.getButtonHTML(cn
, 'lang_xhtmlxtras_abbr_desc', '{$pluginurl}/images/abbr.gif', 'mceAbbr', true);
38 return tinyMCE
.getButtonHTML(cn
, 'lang_xhtmlxtras_del_desc', '{$pluginurl}/images/del.gif', 'mceDel', true);
41 return tinyMCE
.getButtonHTML(cn
, 'lang_xhtmlxtras_ins_desc', '{$pluginurl}/images/ins.gif', 'mceIns', true);
47 execCommand : function(editor_id
, element
, command
, user_interface
, value
) {
52 if (!this._anySel(editor_id
))
55 template
= new Array();
56 template
['file'] = '../../plugins/xhtmlxtras/cite.htm';
57 template
['width'] = 350;
58 template
['height'] = 250;
59 tinyMCE
.openWindow(template
, {editor_id
: editor_id
});
63 if (!this._anySel(editor_id
))
66 template
= new Array();
67 template
['file'] = '../../plugins/xhtmlxtras/acronym.htm';
68 template
['width'] = 350;
69 template
['height'] = 250;
70 tinyMCE
.openWindow(template
, {editor_id
: editor_id
});
74 if (!this._anySel(editor_id
))
77 template
= new Array();
78 template
['file'] = '../../plugins/xhtmlxtras/abbr.htm';
79 template
['width'] = 350;
80 template
['height'] = 250;
81 tinyMCE
.openWindow(template
, {editor_id
: editor_id
});
85 if (!this._anySel(editor_id
))
88 template
= new Array();
89 template
['file'] = '../../plugins/xhtmlxtras/ins.htm';
90 template
['width'] = 350;
91 template
['height'] = 310;
92 tinyMCE
.openWindow(template
, {editor_id
: editor_id
});
96 if (!this._anySel(editor_id
))
99 template
= new Array();
100 template
['file'] = '../../plugins/xhtmlxtras/del.htm';
101 template
['width'] = 350;
102 template
['height'] = 310;
103 tinyMCE
.openWindow(template
, {editor_id
: editor_id
});
110 cleanup : function(type
, content
, inst
) {
111 if (type
== 'insert_to_editor' && tinyMCE
.isIE
&& !tinyMCE
.isOpera
) {
112 content
= content
.replace(/<abbr([^>]+)>/gi, '<html:ABBR $1>');
113 content
= content
.replace(/<\/abbr>/gi, '</html:ABBR>');
119 handleNodeChange : function(editor_id
, node
, undo_index
,undo_levels
, visual_aid
, any_selection
) {
123 if (!any_selection
) {
124 // Disable the buttons
125 tinyMCE
.switchClass(editor_id
+ '_cite', 'mceButtonDisabled');
126 tinyMCE
.switchClass(editor_id
+ '_acronym', 'mceButtonDisabled');
127 tinyMCE
.switchClass(editor_id
+ '_abbr', 'mceButtonDisabled');
128 tinyMCE
.switchClass(editor_id
+ '_del', 'mceButtonDisabled');
129 tinyMCE
.switchClass(editor_id
+ '_ins', 'mceButtonDisabled');
131 // A selection means the buttons should be active.
132 tinyMCE
.switchClass(editor_id
+ '_cite', 'mceButtonNormal');
133 tinyMCE
.switchClass(editor_id
+ '_acronym', 'mceButtonNormal');
134 tinyMCE
.switchClass(editor_id
+ '_abbr', 'mceButtonNormal');
135 tinyMCE
.switchClass(editor_id
+ '_del', 'mceButtonNormal');
136 tinyMCE
.switchClass(editor_id
+ '_ins', 'mceButtonNormal');
139 switch (node
.nodeName
) {
141 tinyMCE
.switchClass(editor_id
+ '_cite', 'mceButtonSelected');
145 tinyMCE
.switchClass(editor_id
+ '_acronym', 'mceButtonSelected');
149 case "HTML:ABBR": // FF
151 tinyMCE
.switchClass(editor_id
+ '_abbr', 'mceButtonSelected');
155 tinyMCE
.switchClass(editor_id
+ '_del', 'mceButtonSelected');
159 tinyMCE
.switchClass(editor_id
+ '_ins', 'mceButtonSelected');
166 _anySel : function(editor_id
) {
167 var inst
= tinyMCE
.getInstanceById(editor_id
), t
= inst
.selection
.getSelectedText(), pe
;
169 pe
= tinyMCE
.getParentElement(inst
.getFocusElement(), 'CITE,ACRONYM,ABBR,HTML:ABBR,DEL,INS');
171 return pe
|| inst
.getFocusElement().nodeName
== "IMG" || (t
&& t
.length
> 0);
175 tinyMCE
.addPlugin("xhtmlxtras", TinyMCE_XHTMLXtrasPlugin
);