1 /** |
1 /** |
2 * $Id: editor_plugin_src.js 42 2006-08-08 14:32:24Z spocke $ |
2 * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ |
3 * |
3 * |
4 * @author Moxiecode |
4 * @author Moxiecode |
5 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. |
5 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. |
6 */ |
6 */ |
7 |
7 |
8 /* Import plugin specific language pack */ |
8 (function() { |
9 tinyMCE.importPluginLanguagePack('nonbreaking'); |
9 tinymce.create('tinymce.plugins.Nonbreaking', { |
|
10 init : function(ed, url) { |
|
11 var t = this; |
10 |
12 |
11 var TinyMCE_NonBreakingPlugin = { |
13 t.editor = ed; |
12 getInfo : function() { |
|
13 return { |
|
14 longname : 'Nonbreaking space', |
|
15 author : 'Moxiecode Systems AB', |
|
16 authorurl : 'http://tinymce.moxiecode.com', |
|
17 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/nonbreaking', |
|
18 version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion |
|
19 }; |
|
20 }, |
|
21 |
14 |
22 getControlHTML : function(cn) { |
15 // Register commands |
23 switch (cn) { |
16 ed.addCommand('mceNonBreaking', function() { |
24 case "nonbreaking": |
17 ed.execCommand('mceInsertContent', false, (ed.plugins.visualchars && ed.plugins.visualchars.state) ? '<span class="mceItemHiddenVisualChar">·</span>' : ' '); |
25 return tinyMCE.getButtonHTML(cn, 'lang_nonbreaking_desc', '{$pluginurl}/images/nonbreaking.gif', 'mceNonBreaking', false); |
18 }); |
|
19 |
|
20 // Register buttons |
|
21 ed.addButton('nonbreaking', {title : 'nonbreaking.nonbreaking_desc', cmd : 'mceNonBreaking'}); |
|
22 |
|
23 if (ed.getParam('nonbreaking_force_tab')) { |
|
24 ed.onKeyDown.add(function(ed, e) { |
|
25 if (tinymce.isIE && e.keyCode == 9) { |
|
26 ed.execCommand('mceNonBreaking'); |
|
27 ed.execCommand('mceNonBreaking'); |
|
28 ed.execCommand('mceNonBreaking'); |
|
29 tinymce.dom.Event.cancel(e); |
|
30 } |
|
31 }); |
|
32 } |
|
33 }, |
|
34 |
|
35 getInfo : function() { |
|
36 return { |
|
37 longname : 'Nonbreaking space', |
|
38 author : 'Moxiecode Systems AB', |
|
39 authorurl : 'http://tinymce.moxiecode.com', |
|
40 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/nonbreaking', |
|
41 version : tinymce.majorVersion + "." + tinymce.minorVersion |
|
42 }; |
26 } |
43 } |
27 |
44 |
28 return ""; |
45 // Private methods |
29 }, |
46 }); |
30 |
47 |
31 |
48 // Register plugin |
32 execCommand : function(editor_id, element, command, user_interface, value) { |
49 tinymce.PluginManager.add('nonbreaking', tinymce.plugins.Nonbreaking); |
33 var inst = tinyMCE.getInstanceById(editor_id), h; |
50 })(); |
34 |
|
35 switch (command) { |
|
36 case "mceNonBreaking": |
|
37 h = (inst.visualChars && inst.visualChars.state) ? '<span class="mceItemHiddenVisualChar">·</span>' : ' '; |
|
38 tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, h); |
|
39 return true; |
|
40 } |
|
41 |
|
42 return false; |
|
43 }, |
|
44 |
|
45 handleEvent : function(e) { |
|
46 var inst, h; |
|
47 |
|
48 if (!tinyMCE.isOpera && e.type == 'keydown' && e.keyCode == 9 && tinyMCE.getParam('nonbreaking_force_tab', false)) { |
|
49 inst = tinyMCE.selectedInstance; |
|
50 |
|
51 h = (inst.visualChars && inst.visualChars.state) ? '<span class="mceItemHiddenVisualChar">···</span>' : ' '; |
|
52 tinyMCE.execInstanceCommand(inst.editorId, 'mceInsertContent', false, h); |
|
53 |
|
54 tinyMCE.cancelEvent(e); |
|
55 return false; |
|
56 } |
|
57 |
|
58 return true; |
|
59 } |
|
60 }; |
|
61 |
|
62 tinyMCE.addPlugin("nonbreaking", TinyMCE_NonBreakingPlugin); |
|