[pLog-svn] r4470 - plog/trunk/js/tinymce/plugins/more

Oscar Renalias oscar at renalias.net
Wed Jan 3 07:24:23 GMT 2007


This looks really good now, I will take care of checking in the rest
of the changes (remove the second text area, adding the extra button
below, etc)

On 1/3/07, jondaley at devel.lifetype.net <jondaley at devel.lifetype.net> wrote:
> Author: jondaley
> Date: 2007-01-03 03:26:36 +0000 (Wed, 03 Jan 2007)
> New Revision: 4470
>
> Modified:
>    plog/trunk/js/tinymce/plugins/more/editor_plugin.js
> Log:
> removed a bunch of unused code.  highlight the more button if the more image is currently being used (doesn't work if you manually erase it, but since Oscar is going to change this button to text or whatever, I'll leave it like this for now).  When pushing the 'more' button the second time, the separator will be removed.
>
> Modified: plog/trunk/js/tinymce/plugins/more/editor_plugin.js
> ===================================================================
> --- plog/trunk/js/tinymce/plugins/more/editor_plugin.js 2007-01-03 02:37:24 UTC (rev 4469)
> +++ plog/trunk/js/tinymce/plugins/more/editor_plugin.js 2007-01-03 03:26:36 UTC (rev 4470)
> @@ -22,7 +22,7 @@
>      getControlHTML : function(control_name) {
>          switch (control_name) {
>              case "more":
> -            return tinyMCE.getButtonHTML(control_name,
> +              return tinyMCE.getButtonHTML(control_name,
>                                           'lang_more_more_button',
>                                           '{$pluginurl}/images/more.gif',
>                                           'mcemoremore');
> @@ -78,41 +78,48 @@
>          return attributes;
>      },
>
> -    _getAttrib : function(elm, name) {
> -       return elm.getAttribute(name) ? elm.getAttribute(name) : "";
> +    _getMoreTag : function(){
> +       return "[@more@]";
>      },
>
>      execCommand : function(editor_id, element, command, user_interface, value){
> -        var inst = tinyMCE.getInstanceById(editor_id);
> -        var focusElm = inst.getFocusElement();
> -        var doc = inst.getDoc();
> -
>              // Handle commands
>          switch (command) {
> -                       case "mcemoremore":
> -            var flag = "";
> -            var template = new Array();
> -            var altMore = tinyMCE.getLang('lang_more_more_alt');
> +          case "mcemoremore":
> +            var content = tinyMCE.getContent(editor_id);
> +            var bFound = 0;
> +                       var startPos = 0;
> +              // Parse all img tags and remove any 'more' tags
> +                       while((startPos = content.indexOf(this._getMoreTag(),
> +                                              startPos)) != -1)
> +            {
> +              var contentAfter = content.substring(startPos +
> +                                                   this._getMoreTag().length);
> +              content = content.substring(0, startPos) + contentAfter;
> +              startPos++;
> +              bFound = 1;
> +                       }
>
> -                               // Is selection a image
> -            if (focusElm != null && focusElm.nodeName.toLowerCase() == "img"){
> -                flag = _getAttrib(focusElm, 'class');
> -
> -                if (flag != 'mce_plugin_more_more') // Not a more
> -                    return true;
> -
> -                action = "update";
> +            if(bFound){
> +              tinyMCE.execCommand("mceSetContent", true, content);
> +              tinyMCE.switchClass(editor_id + '_more', 'mceButtonNormal');
>              }
> -
> -            html = ''
> -            + '<img src="' + (tinyMCE.getParam("theme_href") +
> -                              "/images/spacer.gif") + '" '
> -            + ' width="100%" height="10px" '
> -            + 'alt="'+altMore+'" title="'+altMore+'" '
> -            + 'class="mce_plugin_more_more" name="mce_plugin_more_more" />';
> -            tinyMCE.execCommand("mceInsertContent",true,html);
> -            tinyMCE.selectedInstance.repaint();
> -            return true;
> +            else{
> +              var altMore = tinyMCE.getLang('lang_more_more_alt');
> +              html = '<img src="'
> +                     + (tinyMCE.getParam("theme_href")
> +                     + "/images/spacer.gif") + '" '
> +                     + ' width="100%" height="10px" '
> +                     + 'alt="'+altMore+'" title="'+altMore+'" '
> +                     + 'class="mce_plugin_more_more" '
> +                     + 'name="mce_plugin_more_more" />';
> +              tinyMCE.execCommand("mceInsertContent", true, html);
> +              tinyMCE.switchClass(editor_id + '_more',
> +                                  'mceButtonSelected');
> +           }
> +
> +           tinyMCE.selectedInstance.repaint();
> +           return true;
>          }
>
>              // Pass to next handler in chain
> @@ -120,20 +127,19 @@
>      },
>
>      cleanup : function(type, content) {
> -        var LifeTypeMoreTag = "[@more@]";
> +        var bFound = 0;
>
>          switch (type) {
>                  // move from html editor to wysiwyg editor
>            case "insert_to_editor":
> -            var bFound = 0;
>                         var startPos = 0;
>                         var altMore = tinyMCE.getLang('lang_more_more_alt');
>
>                  // Parse all tags and replace them with images
> -                       while((startPos=content.indexOf(LifeTypeMoreTag,startPos)) != -1)
> +                       while((startPos=content.indexOf(this._getMoreTag(),startPos)) != -1)
>              {
>                var contentAfter = content.substring(startPos +
> -                                                   LifeTypeMoreTag.length);
> +                                                   this._getMoreTag().length);
>                content = content.substring(0, startPos);
>                if(!bFound){
>                      // Insert image
> @@ -151,7 +157,6 @@
>
>                  // move from wysiwyg editor to html editor
>            case "get_from_editor":
> -            var bFound = 0;
>                // Parse all img tags and replace the
>                // first "more" image with tag
>              var startPos = -1;
> @@ -170,7 +175,7 @@
>
>                      content = chunkBefore;
>                                         if(!bFound)
> -                      content += LifeTypeMoreTag;
> +                      content += this._getMoreTag();
>                      content += chunkAfter;
>                      bFound = 1;
>                                 }
> @@ -180,25 +185,6 @@
>
>              // Pass through to next handler in chain
>          return content;
> -    },
> -
> -    handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
> -
> -        tinyMCE.switchClass(editor_id + '_more_more', 'mceButtonNormal');
> -
> -        if (node == null)
> -               return;
> -
> -        do {
> -            if (node.nodeName.toLowerCase() == "img" &&
> -                _getAttrib(node, 'class').indexOf('mce_plugin_more_more') == 0)
> -            {
> -                tinyMCE.switchClass(editor_id + '_more_more',
> -                                    'mceButtonSelected');
> -            }
> -        } while ((node = node.parentNode));
> -
> -        return true;
>      }
>  };
>
>
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://devel.lifetype.net/mailman/listinfo/plog-svn
>


More information about the pLog-svn mailing list