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-2007, 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://wiki.moxiecode.com/index.php/TinyMCE:Plugins/xhtmlxtras',
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);
44
return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_attribs_desc', '{$pluginurl}/images/attribs.gif', 'mceAttributes', true);
50
execCommand : function(editor_id, element, command, user_interface, value) {
51
var template, inst, elm;
55
if (!this._anySel(editor_id))
58
template = new Array();
59
template['file'] = '../../plugins/xhtmlxtras/cite.htm';
60
template['width'] = 350;
61
template['height'] = 250;
62
tinyMCE.openWindow(template, {editor_id : editor_id});
66
if (!this._anySel(editor_id))
69
template = new Array();
70
template['file'] = '../../plugins/xhtmlxtras/acronym.htm';
71
template['width'] = 350;
72
template['height'] = 250;
73
tinyMCE.openWindow(template, {editor_id : editor_id});
77
if (!this._anySel(editor_id))
80
template = new Array();
81
template['file'] = '../../plugins/xhtmlxtras/abbr.htm';
82
template['width'] = 350;
83
template['height'] = 250;
84
tinyMCE.openWindow(template, {editor_id : editor_id});
88
if (!this._anySel(editor_id))
91
template = new Array();
92
template['file'] = '../../plugins/xhtmlxtras/ins.htm';
93
template['width'] = 350;
94
template['height'] = 310;
95
tinyMCE.openWindow(template, {editor_id : editor_id});
99
if (!this._anySel(editor_id))
102
template = new Array();
103
template['file'] = '../../plugins/xhtmlxtras/del.htm';
104
template['width'] = 350;
105
template['height'] = 310;
106
tinyMCE.openWindow(template, {editor_id : editor_id});
109
case "mceAttributes":
110
inst = tinyMCE.getInstanceById(editor_id);
111
elm = inst.getFocusElement();
113
if (elm && elm.nodeName !== 'BODY' && elm.className.indexOf('mceItem') == -1) {
115
file : '../../plugins/xhtmlxtras/attributes.htm',
118
}, {editor_id : editor_id});
127
cleanup : function(type, content, inst) {
128
if (type == 'insert_to_editor' && tinyMCE.isIE && !tinyMCE.isOpera) {
129
content = content.replace(/<abbr([^>]+)>/gi, '<html:ABBR $1>');
130
content = content.replace(/<\/abbr>/gi, '</html:ABBR>');
136
handleNodeChange : function(editor_id, node, undo_index,undo_levels, visual_aid, any_selection) {
137
var elm = tinyMCE.getParentElement(node);
142
tinyMCE.switchClass(editor_id + '_attribs', 'mceButtonDisabled');
144
if (!any_selection) {
145
// Disable the buttons
146
tinyMCE.switchClass(editor_id + '_cite', 'mceButtonDisabled');
147
tinyMCE.switchClass(editor_id + '_acronym', 'mceButtonDisabled');
148
tinyMCE.switchClass(editor_id + '_abbr', 'mceButtonDisabled');
149
tinyMCE.switchClass(editor_id + '_del', 'mceButtonDisabled');
150
tinyMCE.switchClass(editor_id + '_ins', 'mceButtonDisabled');
152
// A selection means the buttons should be active.
153
tinyMCE.switchClass(editor_id + '_cite', 'mceButtonNormal');
154
tinyMCE.switchClass(editor_id + '_acronym', 'mceButtonNormal');
155
tinyMCE.switchClass(editor_id + '_abbr', 'mceButtonNormal');
156
tinyMCE.switchClass(editor_id + '_del', 'mceButtonNormal');
157
tinyMCE.switchClass(editor_id + '_ins', 'mceButtonNormal');
160
if (elm && elm.nodeName != 'BODY' && elm.className.indexOf('mceItem') == -1)
161
tinyMCE.switchClass(editor_id + '_attribs', 'mceButtonNormal');
163
switch (node.nodeName) {
165
tinyMCE.switchClass(editor_id + '_cite', 'mceButtonSelected');
169
tinyMCE.switchClass(editor_id + '_acronym', 'mceButtonSelected');
173
case "HTML:ABBR": // FF
175
tinyMCE.switchClass(editor_id + '_abbr', 'mceButtonSelected');
179
tinyMCE.switchClass(editor_id + '_del', 'mceButtonSelected');
183
tinyMCE.switchClass(editor_id + '_ins', 'mceButtonSelected');
190
_anySel : function(editor_id) {
191
var inst = tinyMCE.getInstanceById(editor_id), t = inst.selection.getSelectedText(), pe;
193
pe = tinyMCE.getParentElement(inst.getFocusElement(), 'CITE,ACRONYM,ABBR,HTML:ABBR,DEL,INS');
195
return pe || inst.getFocusElement().nodeName == "IMG" || (t && t.length > 0);
199
tinyMCE.addPlugin("xhtmlxtras", TinyMCE_XHTMLXtrasPlugin);