Menu

#53 CharsCounter (and MaxLength) plugin(VER 2.3 fix)

open
nobody
None
5
2015-01-14
2006-06-22
Tamir
No

CharsCounter (and MaxLength) plugin
This is a simple plugin based on plugins submitted by
ctebah and xenden.

You can define an optional MaxLength parameter and an
optional external CounterName (a input type=text tag
placed in the same form of the textarea being
replaced), to dislplay the amount of charachters still
available.

You can also place a button called 'CharsCounter' to
display in the toolbar the current amount of
text/HTML/left chars (as in the ctebah's plugin)

For example:

<form name="myform" action=... method=...>
<textarea name="text_1" id="text_1"></textarea>
<input type="text" name="text_1_cnt" id="text_1_cnt"
value="255">
<script type="text/javascript">
var oFCKeditor_1 = new FCKeditor('testo_1');
oFCKeditor_1.BasePath = '../FCKeditor/';
oFCKeditor_1.Config['MaxLength'] = 255;
oFCKeditor_1.Config['CounterName'] = 'text_1_cnt';
oFCKeditor_1.ReplaceTextarea();
</script>
</form>

I tried to keep the code as clear as possible, using
the 'interface' provided by fredck, without rewriting
many functions again. It should be simple to add/modify
some features/behaviours as you require.

I tested thi splugin with the 2.2 version, on IE and FF
browsers.
Let me know what do you think of this plugin, any
suggestion will be appreciated!

gi_gio
---------
this is the same charcounter plugin but with fix for
the FCKEDITOR ver 2.3
I hope that other will follow me and post a fixed
plugins for VER 2.3

Discussion

  • Tamir

    Tamir - 2006-06-22

    char counter(for ver2.3)

     
  • phpdev

    phpdev - 2006-07-03

    Logged In: YES
    user_id=1549488

    Cant get this to work. Is there an example using the PHP
    class? Also adding to toolbar throws js alert.

     
  • phpdev

    phpdev - 2006-07-03

    Logged In: YES
    user_id=1549488

    Cant get this to work. Is there an example using the PHP
    class? Also adding to toolbar throws js alert.

     
  • dioh

    dioh - 2007-01-19

    Logged In: YES
    user_id=1127417
    Originator: NO

    The toolbar buttom of this plugins print the label and dont work rigth, somebody have this problem too?... im using FCKeditor 2.3.1

     
  • Henning Bredel

    Henning Bredel - 2007-05-05

    Logged In: YES
    user_id=1665661
    Originator: NO

    yes -- unfortunately, the button looks raw html: <label id="CharsCounterLabel">0 / 0 / *the Count* </label>.

    I guess the reason is, that my FCK is integrated with jsp and no document.getElementbyId could be used. But I am a Newbie in this, so I am not sure.

     
  • phunkk

    phunkk - 2007-08-24

    Logged In: YES
    user_id=1874854
    Originator: NO

    I am trying to implement your plugin, but im having a lot of trouble. I'd really appreciate it if you could give me a hint in the right direction (:

    Here's what i've done so far:
    1. Extracted the CharsCounter.zip to fckeditor\editor\plugins\CharsCounter ;
    2. Implemented the editor in my code, with the following snippet:
    _________
    <textarea name="ses_messageText" id="fckeditor">
    <xsl:value-of select="//HEADER/ses_messageText"/>
    </textarea>
    <input type="text" name="text_1_cnt" id="text_1_cnt" value="255"/>
    <script type="text/javascript">
    var sBasePath = 'site/js/fckeditor/' ;
    var oFCKeditor = new FCKeditor( 'fckeditor' ) ;
    oFCKeditor.ToolbarSet = 'Berichtwizard' ;
    oFCKeditor.BasePath = sBasePath ;
    oFCKeditor.Height = "350";
    oFCKeditor.Config['MaxLength'] = 2;
    oFCKeditor.Config['CounterName'] = 'text_1_cnt';
    oFCKeditor.ReplaceTextarea() ;
    </script>
    ________

    It seems the FCKEditor isn't loading your plugin. I've added a simple alert(); to the plugin and i dont get a popup. Do you have any idea what im doing wrong? Thanks a lot in advance!

     
  • Gray Loon

    Gray Loon - 2008-10-09

    I have added the CharsCounter plugin to my FCKeditor installation, but the toolbar button isn't working. It displays:
    <label id="CharsCounterLabel">0 / 0 / 10</label>

    Does anyone have a suggestion?

     
  • John Joseph M

    John Joseph M - 2011-02-24

    Hi all,

    Sorry... I am too late in this forum.
    The work done by Tamir Mordo is goood.

    I have made a few corrections to the plugin and now it works well.

    Added these lines::

    Line: 168
    FCK.Events.AttachEvent( 'OnAfterSetHTML', CharsCounter_CheckEditorStatus ) ;

    Line 56 :
    updateToolbar(this.LeftChars);

    Added this method from the original script
    function updateToolbar(LeftChars){
    if(!document.all && LeftChars != 0)
    LeftChars++;
    FCK.ToolbarSet.ToolbarItems.LoadedItems.CharsCounter._UIButton.MainElement.innerHTML = '<table cellpadding="0" cellspacing="0"><tbody><tr><td><img src="images/spacer.gif" class="TB_Button_Padding"></td><td class="TB_Button_Text" nowrap="nowrap">Left Chars:' + LeftChars + '</td><td><img src="images/spacer.gif" class="TB_Button_Padding"></td></tr></tbody></table>';
    }

    Please try this

    Cheers
    John

     
  • John Joseph M

    John Joseph M - 2011-02-24

    and Yes i modified line 97 to remove the html label content

    var oCharsCounterItem = new FCKToolbarButton( 'CharsCounter', FCK.Config['MaxLength'] , 'Text length / HTML length / Left chars', FCK_TOOLBARITEM_ONLYTEXT, false, true ) ;

     
  • mijsoot

    mijsoot - 2011-06-20

    Hello everybody !
    Thanks a lot to mjohnjoseph, i can tell you that it woks too on version 2.6.6

    :-)

     

Log in to post a comment.

Monday.com Logo