Aleksander Machniak
2012-06-09 db8110c70d40b4e8864292f94c19248bb5a63b67
program/js/tiny_mce/plugins/nonbreaking/editor_plugin_src.js
old mode 100755 new mode 100644
@@ -1,62 +1,54 @@
/**
 * $Id: editor_plugin_src.js 42 2006-08-08 14:32:24Z spocke $
 * editor_plugin_src.js
 *
 * @author Moxiecode
 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
 * Copyright 2009, Moxiecode Systems AB
 * Released under LGPL License.
 *
 * License: http://tinymce.moxiecode.com/license
 * Contributing: http://tinymce.moxiecode.com/contributing
 */
/* Import plugin specific language pack */
tinyMCE.importPluginLanguagePack('nonbreaking');
(function() {
   tinymce.create('tinymce.plugins.Nonbreaking', {
      init : function(ed, url) {
         var t = this;
var TinyMCE_NonBreakingPlugin = {
   getInfo : function() {
      return {
         longname : 'Nonbreaking space',
         author : 'Moxiecode Systems AB',
         authorurl : 'http://tinymce.moxiecode.com',
         infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/nonbreaking',
         version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
      };
   },
         t.editor = ed;
   getControlHTML : function(cn) {
      switch (cn) {
         case "nonbreaking":
            return tinyMCE.getButtonHTML(cn, 'lang_nonbreaking_desc', '{$pluginurl}/images/nonbreaking.gif', 'mceNonBreaking', false);
         // Register commands
         ed.addCommand('mceNonBreaking', function() {
            ed.execCommand('mceInsertContent', false, (ed.plugins.visualchars && ed.plugins.visualchars.state) ? '<span data-mce-bogus="1" class="mceItemHidden mceItemNbsp">&nbsp;</span>' : '&nbsp;');
         });
         // Register buttons
         ed.addButton('nonbreaking', {title : 'nonbreaking.nonbreaking_desc', cmd : 'mceNonBreaking'});
         if (ed.getParam('nonbreaking_force_tab')) {
            ed.onKeyDown.add(function(ed, e) {
               if (e.keyCode == 9) {
                  e.preventDefault();
                  ed.execCommand('mceNonBreaking');
                  ed.execCommand('mceNonBreaking');
                  ed.execCommand('mceNonBreaking');
               }
            });
         }
      },
      getInfo : function() {
         return {
            longname : 'Nonbreaking space',
            author : 'Moxiecode Systems AB',
            authorurl : 'http://tinymce.moxiecode.com',
            infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/nonbreaking',
            version : tinymce.majorVersion + "." + tinymce.minorVersion
         };
      }
      return "";
   },
      // Private methods
   });
   execCommand : function(editor_id, element, command, user_interface, value) {
      var inst = tinyMCE.getInstanceById(editor_id), h;
      switch (command) {
         case "mceNonBreaking":
            h = (inst.visualChars && inst.visualChars.state) ? '<span class="mceItemHiddenVisualChar">&middot;</span>' : '&nbsp;';
            tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, h);
            return true;
      }
      return false;
   },
   handleEvent : function(e) {
      var inst, h;
      if (!tinyMCE.isOpera && e.type == 'keydown' && e.keyCode == 9 && tinyMCE.getParam('nonbreaking_force_tab', false)) {
         inst = tinyMCE.selectedInstance;
         h = (inst.visualChars && inst.visualChars.state) ? '<span class="mceItemHiddenVisualChar">&middot;&middot;&middot;</span>' : '&nbsp;&nbsp;&nbsp;';
         tinyMCE.execInstanceCommand(inst.editorId, 'mceInsertContent', false, h);
         tinyMCE.cancelEvent(e);
         return false;
      }
      return true;
   }
};
tinyMCE.addPlugin("nonbreaking", TinyMCE_NonBreakingPlugin);
   // Register plugin
   tinymce.PluginManager.add('nonbreaking', tinymce.plugins.Nonbreaking);
})();