applied my changes - initial import
[boxroom-stian.git] / public / javascripts / tiny_mce / plugins / xhtmlxtras / editor_plugin_src.js
blob7fce54b958917f6a78fa063c9f3d97e75f4568a3
1 /**
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.
6 */
8 /* Import plugin specific language pack */
9 tinyMCE.importPluginLanguagePack('xhtmlxtras');
11 var TinyMCE_XHTMLXtrasPlugin = {
12 getInfo : function() {
13 return {
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) {
27 switch (cn) {
28 case "cite":
29 return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_cite_desc', '{$pluginurl}/images/cite.gif', 'mceCite', true);
31 case "acronym":
32 return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_acronym_desc', '{$pluginurl}/images/acronym.gif', 'mceAcronym', true);
34 case "abbr":
35 return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_abbr_desc', '{$pluginurl}/images/abbr.gif', 'mceAbbr', true);
37 case "del":
38 return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_del_desc', '{$pluginurl}/images/del.gif', 'mceDel', true);
40 case "ins":
41 return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_ins_desc', '{$pluginurl}/images/ins.gif', 'mceIns', true);
44 return "";
47 execCommand : function(editor_id, element, command, user_interface, value) {
48 var template;
50 switch (command) {
51 case "mceCite":
52 if (!this._anySel(editor_id))
53 return true;
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});
60 return true;
62 case "mceAcronym":
63 if (!this._anySel(editor_id))
64 return true;
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});
71 return true;
73 case "mceAbbr":
74 if (!this._anySel(editor_id))
75 return true;
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});
82 return true;
84 case "mceIns":
85 if (!this._anySel(editor_id))
86 return true;
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});
93 return true;
95 case "mceDel":
96 if (!this._anySel(editor_id))
97 return true;
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});
104 return true;
107 return false;
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>');
116 return content;
119 handleNodeChange : function(editor_id, node, undo_index,undo_levels, visual_aid, any_selection) {
120 if (node == null)
121 return;
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');
130 } else {
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) {
140 case "CITE":
141 tinyMCE.switchClass(editor_id + '_cite', 'mceButtonSelected');
142 return true;
144 case "ACRONYM":
145 tinyMCE.switchClass(editor_id + '_acronym', 'mceButtonSelected');
146 return true;
148 case "abbr": // IE
149 case "HTML:ABBR": // FF
150 case "ABBR":
151 tinyMCE.switchClass(editor_id + '_abbr', 'mceButtonSelected');
152 return true;
154 case "DEL":
155 tinyMCE.switchClass(editor_id + '_del', 'mceButtonSelected');
156 return true;
158 case "INS":
159 tinyMCE.switchClass(editor_id + '_ins', 'mceButtonSelected');
160 return true;
163 return true;
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);