includes/clientside/tinymce/plugins/nonbreaking/editor_plugin_src.js
changeset 1 fe660c52c48f
equal deleted inserted replaced
0:902822492a68 1:fe660c52c48f
       
     1 /**
       
     2  * $Id: editor_plugin_src.js 42 2006-08-08 14:32:24Z spocke $
       
     3  *
       
     4  * @author Moxiecode
       
     5  * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
       
     6  */
       
     7 
       
     8 /* Import plugin specific language pack */
       
     9 tinyMCE.importPluginLanguagePack('nonbreaking');
       
    10 
       
    11 var TinyMCE_NonBreakingPlugin = {
       
    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 
       
    22 	getControlHTML : function(cn) {
       
    23 		switch (cn) {
       
    24 			case "nonbreaking":
       
    25 				return tinyMCE.getButtonHTML(cn, 'lang_nonbreaking_desc', '{$pluginurl}/images/nonbreaking.gif', 'mceNonBreaking', false);
       
    26 		}
       
    27 
       
    28 		return "";
       
    29 	},
       
    30 
       
    31 
       
    32 	execCommand : function(editor_id, element, command, user_interface, value) {
       
    33 		var inst = tinyMCE.getInstanceById(editor_id), h;
       
    34 
       
    35 		switch (command) {
       
    36 			case "mceNonBreaking":
       
    37 				h = (inst.visualChars && inst.visualChars.state) ? '<span class="mceItemHiddenVisualChar">&middot;</span>' : '&nbsp;';
       
    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">&middot;&middot;&middot;</span>' : '&nbsp;&nbsp;&nbsp;';
       
    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);