[ Index ] |
|
Code source de TinyMCE 2.1.0 |
1 /** 2 * $Id: editor_plugin_src.js 42 2006-08-08 14:32:24Z spocke $ 3 * 4 * @author Moxiecode - based on work by Andrew Tetlaw 5 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. 6 */ 7 8 /* Import plugin specific language pack */ 9 tinyMCE.importPluginLanguagePack('xhtmlxtras'); 10 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://wiki.moxiecode.com/index.php/TinyMCE:Plugins/xhtmlxtras', 18 version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion 19 }; 20 }, 21 22 initInstance : function(inst) { 23 tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/plugins/xhtmlxtras/css/xhtmlxtras.css"); 24 }, 25 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); 30 31 case "acronym": 32 return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_acronym_desc', '{$pluginurl}/images/acronym.gif', 'mceAcronym', true); 33 34 case "abbr": 35 return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_abbr_desc', '{$pluginurl}/images/abbr.gif', 'mceAbbr', true); 36 37 case "del": 38 return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_del_desc', '{$pluginurl}/images/del.gif', 'mceDel', true); 39 40 case "ins": 41 return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_ins_desc', '{$pluginurl}/images/ins.gif', 'mceIns', true); 42 43 case "attribs": 44 return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_attribs_desc', '{$pluginurl}/images/attribs.gif', 'mceAttributes', true); 45 } 46 47 return ""; 48 }, 49 50 execCommand : function(editor_id, element, command, user_interface, value) { 51 var template, inst, elm; 52 53 switch (command) { 54 case "mceCite": 55 if (!this._anySel(editor_id)) 56 return true; 57 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}); 63 return true; 64 65 case "mceAcronym": 66 if (!this._anySel(editor_id)) 67 return true; 68 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}); 74 return true; 75 76 case "mceAbbr": 77 if (!this._anySel(editor_id)) 78 return true; 79 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}); 85 return true; 86 87 case "mceIns": 88 if (!this._anySel(editor_id)) 89 return true; 90 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}); 96 return true; 97 98 case "mceDel": 99 if (!this._anySel(editor_id)) 100 return true; 101 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}); 107 return true; 108 109 case "mceAttributes": 110 inst = tinyMCE.getInstanceById(editor_id); 111 elm = inst.getFocusElement(); 112 113 if (elm && elm.nodeName !== 'BODY' && elm.className.indexOf('mceItem') == -1) { 114 tinyMCE.openWindow({ 115 file : '../../plugins/xhtmlxtras/attributes.htm', 116 width : 380, 117 height : 370 118 }, {editor_id : editor_id}); 119 } 120 121 return true; 122 } 123 124 return false; 125 }, 126 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>'); 131 } 132 133 return content; 134 }, 135 136 handleNodeChange : function(editor_id, node, undo_index,undo_levels, visual_aid, any_selection) { 137 var elm = tinyMCE.getParentElement(node); 138 139 if (node == null) 140 return; 141 142 tinyMCE.switchClass(editor_id + '_attribs', 'mceButtonDisabled'); 143 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'); 151 } else { 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'); 158 } 159 160 if (elm && elm.nodeName != 'BODY' && elm.className.indexOf('mceItem') == -1) 161 tinyMCE.switchClass(editor_id + '_attribs', 'mceButtonNormal'); 162 163 switch (node.nodeName) { 164 case "CITE": 165 tinyMCE.switchClass(editor_id + '_cite', 'mceButtonSelected'); 166 return true; 167 168 case "ACRONYM": 169 tinyMCE.switchClass(editor_id + '_acronym', 'mceButtonSelected'); 170 return true; 171 172 case "abbr": // IE 173 case "HTML:ABBR": // FF 174 case "ABBR": 175 tinyMCE.switchClass(editor_id + '_abbr', 'mceButtonSelected'); 176 return true; 177 178 case "DEL": 179 tinyMCE.switchClass(editor_id + '_del', 'mceButtonSelected'); 180 return true; 181 182 case "INS": 183 tinyMCE.switchClass(editor_id + '_ins', 'mceButtonSelected'); 184 return true; 185 } 186 187 return true; 188 }, 189 190 _anySel : function(editor_id) { 191 var inst = tinyMCE.getInstanceById(editor_id), t = inst.selection.getSelectedText(), pe; 192 193 pe = tinyMCE.getParentElement(inst.getFocusElement(), 'CITE,ACRONYM,ABBR,HTML:ABBR,DEL,INS'); 194 195 return pe || inst.getFocusElement().nodeName == "IMG" || (t && t.length > 0); 196 } 197 }; 198 199 tinyMCE.addPlugin("xhtmlxtras", TinyMCE_XHTMLXtrasPlugin);
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 15:23:03 2007 | par Balluche grâce à PHPXref 0.7 |