2 * $Id: editor_plugin_src.js 42 2006-08-08 14:32:24Z spocke $
\r
4 * @author Moxiecode - based on work by Andrew Tetlaw
\r
5 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
\r
8 /* Import plugin specific language pack */
\r
9 tinyMCE.importPluginLanguagePack('xhtmlxtras');
\r
11 var TinyMCE_XHTMLXtrasPlugin = {
\r
12 getInfo : function() {
\r
14 longname : 'XHTML Xtras Plugin',
\r
15 author : 'Moxiecode Systems AB',
\r
16 authorurl : 'http://tinymce.moxiecode.com',
\r
17 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/xhtmlxtras',
\r
18 version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
\r
22 initInstance : function(inst) {
\r
23 tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/plugins/xhtmlxtras/css/xhtmlxtras.css");
\r
26 getControlHTML : function(cn) {
\r
29 return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_cite_desc', '{$pluginurl}/images/cite.gif', 'mceCite', true);
\r
32 return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_acronym_desc', '{$pluginurl}/images/acronym.gif', 'mceAcronym', true);
\r
35 return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_abbr_desc', '{$pluginurl}/images/abbr.gif', 'mceAbbr', true);
\r
38 return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_del_desc', '{$pluginurl}/images/del.gif', 'mceDel', true);
\r
41 return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_ins_desc', '{$pluginurl}/images/ins.gif', 'mceIns', true);
\r
44 return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_attribs_desc', '{$pluginurl}/images/attribs.gif', 'mceAttributes', true);
\r
50 execCommand : function(editor_id, element, command, user_interface, value) {
\r
51 var template, inst, elm;
\r
55 if (!this._anySel(editor_id))
\r
58 template = new Array();
\r
59 template['file'] = '../../plugins/xhtmlxtras/cite.htm';
\r
60 template['width'] = 350;
\r
61 template['height'] = 250;
\r
62 tinyMCE.openWindow(template, {editor_id : editor_id});
\r
66 if (!this._anySel(editor_id))
\r
69 template = new Array();
\r
70 template['file'] = '../../plugins/xhtmlxtras/acronym.htm';
\r
71 template['width'] = 350;
\r
72 template['height'] = 250;
\r
73 tinyMCE.openWindow(template, {editor_id : editor_id});
\r
77 if (!this._anySel(editor_id))
\r
80 template = new Array();
\r
81 template['file'] = '../../plugins/xhtmlxtras/abbr.htm';
\r
82 template['width'] = 350;
\r
83 template['height'] = 250;
\r
84 tinyMCE.openWindow(template, {editor_id : editor_id});
\r
88 if (!this._anySel(editor_id))
\r
91 template = new Array();
\r
92 template['file'] = '../../plugins/xhtmlxtras/ins.htm';
\r
93 template['width'] = 350;
\r
94 template['height'] = 310;
\r
95 tinyMCE.openWindow(template, {editor_id : editor_id});
\r
99 if (!this._anySel(editor_id))
\r
102 template = new Array();
\r
103 template['file'] = '../../plugins/xhtmlxtras/del.htm';
\r
104 template['width'] = 350;
\r
105 template['height'] = 310;
\r
106 tinyMCE.openWindow(template, {editor_id : editor_id});
\r
109 case "mceAttributes":
\r
110 inst = tinyMCE.getInstanceById(editor_id);
\r
111 elm = inst.getFocusElement();
\r
113 if (elm && elm.nodeName !== 'BODY' && elm.className.indexOf('mceItem') == -1) {
\r
114 tinyMCE.openWindow({
\r
115 file : '../../plugins/xhtmlxtras/attributes.htm',
\r
118 }, {editor_id : editor_id});
\r
127 cleanup : function(type, content, inst) {
\r
128 if (type == 'insert_to_editor' && tinyMCE.isIE && !tinyMCE.isOpera) {
\r
129 content = content.replace(/<abbr([^>]+)>/gi, '<html:ABBR $1>');
\r
130 content = content.replace(/<\/abbr>/gi, '</html:ABBR>');
\r
136 handleNodeChange : function(editor_id, node, undo_index,undo_levels, visual_aid, any_selection) {
\r
137 var elm = tinyMCE.getParentElement(node);
\r
142 tinyMCE.switchClass(editor_id + '_attribs', 'mceButtonDisabled');
\r
144 if (!any_selection) {
\r
145 // Disable the buttons
\r
146 tinyMCE.switchClass(editor_id + '_cite', 'mceButtonDisabled');
\r
147 tinyMCE.switchClass(editor_id + '_acronym', 'mceButtonDisabled');
\r
148 tinyMCE.switchClass(editor_id + '_abbr', 'mceButtonDisabled');
\r
149 tinyMCE.switchClass(editor_id + '_del', 'mceButtonDisabled');
\r
150 tinyMCE.switchClass(editor_id + '_ins', 'mceButtonDisabled');
\r
152 // A selection means the buttons should be active.
\r
153 tinyMCE.switchClass(editor_id + '_cite', 'mceButtonNormal');
\r
154 tinyMCE.switchClass(editor_id + '_acronym', 'mceButtonNormal');
\r
155 tinyMCE.switchClass(editor_id + '_abbr', 'mceButtonNormal');
\r
156 tinyMCE.switchClass(editor_id + '_del', 'mceButtonNormal');
\r
157 tinyMCE.switchClass(editor_id + '_ins', 'mceButtonNormal');
\r
160 if (elm && elm.nodeName != 'BODY' && elm.className.indexOf('mceItem') == -1)
\r
161 tinyMCE.switchClass(editor_id + '_attribs', 'mceButtonNormal');
\r
163 switch (node.nodeName) {
\r
165 tinyMCE.switchClass(editor_id + '_cite', 'mceButtonSelected');
\r
169 tinyMCE.switchClass(editor_id + '_acronym', 'mceButtonSelected');
\r
173 case "HTML:ABBR": // FF
\r
175 tinyMCE.switchClass(editor_id + '_abbr', 'mceButtonSelected');
\r
179 tinyMCE.switchClass(editor_id + '_del', 'mceButtonSelected');
\r
183 tinyMCE.switchClass(editor_id + '_ins', 'mceButtonSelected');
\r
190 _anySel : function(editor_id) {
\r
191 var inst = tinyMCE.getInstanceById(editor_id), t = inst.selection.getSelectedText(), pe;
\r
193 pe = tinyMCE.getParentElement(inst.getFocusElement(), 'CITE,ACRONYM,ABBR,HTML:ABBR,DEL,INS');
\r
195 return pe || inst.getFocusElement().nodeName == "IMG" || (t && t.length > 0);
\r
199 tinyMCE.addPlugin("xhtmlxtras", TinyMCE_XHTMLXtrasPlugin);
\r