b2evolution PHP Cross Reference Blogging Systems

Source: /plugins/tinymce_plugin/tiny_mce/plugins/more/editor_plugin_src.js - 108 lines - 3200 bytes - Text - Print

   1  /**
   2   * $Id: editor_plugin_src.js 9 2011-10-24 22:32:00Z fplanque $
   3   *
   4   * @author Moxiecode
   5   * @author Francois Planque
   6   * @copyright Copyright  2004-2009, Moxiecode Systems AB, All rights reserved.
   7   * @copyright Copyright  2009, Francois Planque -- http://fplanque.com/
   8   */
   9  
  10  (function() {
  11      tinymce.create('tinymce.plugins.MorePlugin',
  12      {
  13          /**
  14           * Initializes the plugin, this will be executed after the plugin has been created.
  15           * This call is done before the editor instance has finished it's initialization so use the onInit event
  16           * of the editor instance to intercept that event.
  17           *
  18           * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
  19           * @param {string} url Absolute URL to where the plugin is located.
  20           */
  21          init : function(ed, url)
  22          {
  23              var pb = '<img src="' + url + '/img/trans.gif" class="mceMore mceItemNoResize" />',
  24              cls = 'mceMore',
  25              sep = ed.getParam('More_separator', '<!--more-->'),
  26              pbRE;
  27  
  28              pbRE = new RegExp(sep.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g, function(a) {return '\\' + a;}), 'g');
  29  
  30              // Register commands
  31              ed.addCommand('mceMore', function() {
  32                  ed.execCommand('mceInsertContent', 0, pb);
  33              });
  34  
  35              // Register button
  36              ed.addButton('morebtn', {
  37                  title : 'moreseparator.desc',
  38                  cmd : cls,
  39                  image : url+'/img/morebtn.gif'
  40              });
  41  
  42              ed.onInit.add(function() {
  43                  if (ed.settings.content_css !== false)
  44                      ed.dom.loadCSS(url + "/css/content.css");
  45  
  46                  if (ed.theme.onResolveName) {
  47                      ed.theme.onResolveName.add(function(th, o) {
  48                          if (o.node.nodeName == 'IMG' && ed.dom.hasClass(o.node, cls))
  49                              o.name = 'more';
  50                      });
  51                  }
  52              });
  53  
  54              ed.onClick.add(function(ed, e) {
  55                  e = e.target;
  56  
  57                  if (e.nodeName === 'IMG' && ed.dom.hasClass(e, cls))
  58                      ed.selection.select(e);
  59              });
  60  
  61              ed.onNodeChange.add(function(ed, cm, n) {
  62                  cm.setActive('more', n.nodeName === 'IMG' && ed.dom.hasClass(n, cls));
  63              });
  64  
  65              ed.onBeforeSetContent.add(function(ed, o) {
  66                  o.content = o.content.replace(pbRE, pb);
  67              });
  68  
  69              ed.onPostProcess.add(function(ed, o) {
  70                  if (o.get)
  71                      o.content = o.content.replace(/<img[^>]+>/g, function(im) {
  72                          if (im.indexOf('class="mceMore') !== -1)
  73                              im = sep;
  74  
  75                          return im;
  76                      });
  77              });
  78          },
  79  
  80          /**
  81           * Creates control instances based in the incomming name. This method is normally not
  82           * needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
  83           * but you sometimes need to create more complex controls like listboxes, split buttons etc then this
  84           * method can be used to create those.
  85           *
  86           * @param {String} n Name of the control to create.
  87           * @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
  88           * @return {tinymce.ui.Control} New control instance or null if no control was created.
  89           */
  90          createControl : function(n, cm) {
  91              return null;
  92          },
  93  
  94          getInfo : function()
  95          {
  96              return {
  97                  longname : 'More',
  98                  author : 'Francois Planque',
  99                  authorurl : 'http://fplanque.com',
 100                  infourl : 'http://b2evolution.net',
 101                  version : '0.1'
 102              };
 103          }
 104      });
 105  
 106      // Register plugin
 107      tinymce.PluginManager.add('more', tinymce.plugins.MorePlugin);
 108  })();

title

Description

title

Description

title

Description

title

title

Body