The forum of the forums

Would you like to react to this message? Create an account in a few clicks or log in to continue.
The forum of the forums
2 posters

    Fast BBCodes for Staff in posts on editor

    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6916
    Reputation : 795
    Language : Greek, English

    Solved Fast BBCodes for Staff in posts on editor

    Post by TheCrow December 30th 2014, 12:49 am

    Hello,

    I am currently using this code in my Javascript for the Fast BBCode @Ange Tuteur gave me!
    Code:
    $(function() {
      if (!document.getElementById('text_editor_textarea')) return;
     
     
      userTag(1,'Luffy', 'http://i39.servimg.com/u/f39/19/06/26/04/pcode210.png', '<div class="Luffy">', '</div>');
     
     
      function userTag(id, tagname, image, htmlStart, htmlEnd) {
        var breg = new RegExp('\\['+tagname+'\\](.+?)\\[\\/'+tagname+'\\]','gi');
        if (_userdata.user_id === id) {
          $("#text_editor_textarea").before("<img src='"+image+"'id='"+tagname+"-b'/>");
          $('#'+tagname+'-b').click(function(){$('#text_editor_textarea').sceditor('instance').insertText('['+tagname+']','[/'+tagname+']')});
        }
        $('div.postbody div').each(function () {if ($(this).text().indexOf('['+tagname+']') != -1) $(this).html($(this).html().replace(breg, htmlStart + '$1' + htmlEnd))});
      }
    });

    How can i make it appear as a button to the editor? A Simple button with a crown but be visible and usable only by the member as it is now?


    Luffy
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Fast BBCodes for Staff in posts on editor

    Post by Ange Tuteur December 30th 2014, 12:59 am

    Hi @Luffy,

    Change your script to :
    Code:
    $(function() {
     Â if (!document.getElementById('text_editor_textarea')) return;
     Â $('.sceditor-group:last').after('<div id="st-boutons" class="sceditor-group"></div>');
     
     
     Â userTag(1,'Luffy', 'http://i39.servimg.com/u/f39/19/06/26/04/pcode210.png', '<div class="Luffy">', '</div>');
     
     
     Â function userTag(id, tagname, image, htmlStart, htmlEnd) {
     Â   var breg = new RegExp('\\['+tagname+'\\](.+?)\\[\\/'+tagname+'\\]','gi');
     Â   if (_userdata.user_id === id) {
     Â     $("#st-boutons").append("<a id='"+tagname+"-b' class='sceditor-button'><div style='background-image:url("+image+")'></div></a>");
     Â     $('#'+tagname+'-b').click(function(){$('#text_editor_textarea').sceditor('instance').insertText('['+tagname+']','[/'+tagname+']')});
     Â   }
     Â   $('div.postbody div').each(function () {if ($(this).text().indexOf('['+tagname+']') != -1) $(this).html($(this).html().replace(breg, htmlStart + '$1' + htmlEnd))});
     Â }
    });
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6916
    Reputation : 795
    Language : Greek, English

    Solved Re: Fast BBCodes for Staff in posts on editor

    Post by TheCrow December 30th 2014, 1:01 am

    @Ange Tuteur this doesn't work! Let me remind you that my forum is Phpbb3 in case you haven't noticed! Also this deleted the button completely!



    Fast BBCodes for Staff in posts on editor Thecro10
     Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Fast BBCodes for Staff in posts on editor

    Post by Ange Tuteur December 30th 2014, 1:05 am

    Try now. I forgot you had to wait for the editor.
    Code:
    $(function(){$(function(){
      if (!document.getElementById('text_editor_textarea')) return;
      $('.sceditor-group:last').after('<div id="st-boutons" class="sceditor-group"></div>');
     
     
      userTag(1,'Luffy', 'http://i39.servimg.com/u/f39/19/06/26/04/pcode210.png', '<div class="Luffy">', '</div>');
     
     
      function userTag(id, tagname, image, htmlStart, htmlEnd) {
        var breg = new RegExp('\\['+tagname+'\\](.+?)\\[\\/'+tagname+'\\]','gi');
        if (_userdata.user_id === id) {
          $("#st-boutons").append("<a id='"+tagname+"-b' class='sceditor-button'><div style='background-image:url("+image+")'></div></a>");
          $('#'+tagname+'-b').click(function(){$('#text_editor_textarea').sceditor('instance').insertText('['+tagname+']','[/'+tagname+']')});
        }
        $('div.postbody div').each(function () {if ($(this).text().indexOf('['+tagname+']') != -1) $(this).html($(this).html().replace(breg, htmlStart + '$1' + htmlEnd))});
      }
    })});
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6916
    Reputation : 795
    Language : Greek, English

    Solved Re: Fast BBCodes for Staff in posts on editor

    Post by TheCrow December 30th 2014, 1:10 am

    Yes now it works! Thank you very much!
    Problem Solved!


    Luffy



    Fast BBCodes for Staff in posts on editor Thecro10
     Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Fast BBCodes for Staff in posts on editor

    Post by Ange Tuteur December 30th 2014, 1:12 am

    You're welcome ^^

    Topic archived

    Have a nice day. Smile

      Current date/time is September 22nd 2024, 6:34 pm