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
4 posters

    How do you add a custom button for staff only to the message editor?

    ddoesmc
    ddoesmc
    Forumember


    Male Posts : 278
    Reputation : 11
    Language : Mainly english
    Location : New Jersey

    Solved How do you add a custom button for staff only to the message editor?

    Post by ddoesmc Wed 5 Mar 2014 - 12:58

    How do you add a custom button for staff only to the message editor?


    Last edited by ddoesmc on Thu 6 Mar 2014 - 21:39; edited 1 time in total
    Pizza Boi
    Pizza Boi
    Hyperactive


    Male Posts : 2016
    Reputation : 160
    Language : French
    Location : Pizza Hut!

    Solved Re: How do you add a custom button for staff only to the message editor?

    Post by Pizza Boi Wed 5 Mar 2014 - 13:51

    Ange Tuteur
    Ange Tuteur
    Forumaster


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

    Solved Re: How do you add a custom button for staff only to the message editor?

    Post by Ange Tuteur Wed 5 Mar 2014 - 21:00

    Hello ddoesmc,

    You can try this :
    It is a snippet from a project I was working on.

    Administration Panel > Modules > Javascript codes management > Create a new script

    Title : what you wish
    Placement : In all the pages
    Code:
    $(window).load(function() {
     Â   var settings = {
     Â      img : 'backgroud img for button',
     Â      title : 'title of button',
     Â      message : 'moderation message'
     Â   };
     Â   if (_userdata["user_level"] == '1' || _userdata["user_level"] == "2") {
     Â      $('.sceditor-group:last').after('<div class="sceditor-group"><a class="sceditor-button sceditor-button-message" title="'+settings["title"]+'"><div style="background:url('+settings["img"]+') no-repeat;"></div></a></div>');
     Â      $('.sceditor-button-message').click(function() {
     Â          $('#text_editor_textarea').sceditor('instance').insertText(settings["message"],'');
     Â      });
     Â   }
    });

    In the code are some settings you can modify :
    Code:
       var settings = {
     Â      img : 'backgroud img for button',
     Â      title : 'title of button',
     Â      message : 'moderation message'
     Â   };

    img : the url of the image that you want the button to show
    title : the title displayed when hovering over the button
    message : the message you want inserted into the editor on click
    ddoesmc
    ddoesmc
    Forumember


    Male Posts : 278
    Reputation : 11
    Language : Mainly english
    Location : New Jersey

    Solved Re: How do you add a custom button for staff only to the message editor?

    Post by ddoesmc Wed 5 Mar 2014 - 23:22

    Hi how do I add more then one moderation message?
    Ange Tuteur
    Ange Tuteur
    Forumaster


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

    Solved Re: How do you add a custom button for staff only to the message editor?

    Post by Ange Tuteur Thu 6 Mar 2014 - 1:10

    You would need to turn it into a dropdown list. You would then need to add to the html, and functions that input the messages.

    Example :
    Code:
    $(function() {
     Â   var settings = {
     Â      img : 'backgroud img for button',
     Â      title : 'title of button'
     Â   };
     Â   if (_userdata["user_level"] == '1' || _userdata["user_level"] == "2") {
     Â       $('.sceditor-group:last').after('<div class="sceditor-group"><a class="sceditor-button sceditor-button-message" title="'+settings["title"]+'"><div style="background:url('+settings["img"]+') no-repeat;"></div></a></div>');
     Â       $('body').append('<div id="messageList" style="z-index:15;display:none;position:absolute;background:#fff;border:1px solid #ccc;padding:3px;"><div id="M1" class="listItem" style="cursor:pointer;">Message 1</div><div id="M2" class="listItem" style="cursor:pointer;">Message 2</div><div id="M3" class="listItem" style="cursor:pointer;">Message 3</div></div>');
     Â     
           
     Â      $('.sceditor-button-message').click(function() {
     Â         var display = $('#messageList').css('display');
     Â         if (display == 'none') {
     Â            var Y = $(this).offset().top;
     Â            var X = $(this).offset().left;
     Â            $('#messageList').show().offset({top:Y + 25,left:X});
     Â         }
     Â          else { $('#messageList').hide(); }
     Â      });
     Â       
     Â      $('#M1').click(function() { $('#text_editor_textarea').sceditor('instance').insertText('Message 1',''); });
     Â      $('#M2').click(function() { $('#text_editor_textarea').sceditor('instance').insertText('Message 2',''); });
     Â      $('#M3').click(function() { $('#text_editor_textarea').sceditor('instance').insertText('Message 3',''); });
     Â      $('.listItem').click(function() { $(this).parent().hide(); });
     Â   }
    });
    ddoesmc
    ddoesmc
    Forumember


    Male Posts : 278
    Reputation : 11
    Language : Mainly english
    Location : New Jersey

    Solved Re: How do you add a custom button for staff only to the message editor?

    Post by ddoesmc Thu 6 Mar 2014 - 1:39

    I will try this
    Edit: I just want text no background
    Ange Tuteur
    Ange Tuteur
    Forumaster


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

    Solved Re: How do you add a custom button for staff only to the message editor?

    Post by Ange Tuteur Thu 6 Mar 2014 - 2:00

    ddoesmc wrote:I will try this
    Edit: I just want text no background
    I did not comprehend.

    Care to explain what you mean ?
    ddoesmc
    ddoesmc
    Forumember


    Male Posts : 278
    Reputation : 11
    Language : Mainly english
    Location : New Jersey

    Solved Re: How do you add a custom button for staff only to the message editor?

    Post by ddoesmc Thu 6 Mar 2014 - 2:20

    Just like a drop down with a list of texts no image etc.
    Ange Tuteur
    Ange Tuteur
    Forumaster


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

    Solved Re: How do you add a custom button for staff only to the message editor?

    Post by Ange Tuteur Thu 6 Mar 2014 - 2:24

    scratch

    add this :
    Code:
    $(window).load(function() {
     Â   var settings = {
     Â      img : 'backgroud img for button',
     Â      title : 'title of button'
     Â   };
     Â   if (_userdata["user_level"] == '1' || _userdata["user_level"] == "2") {
     Â       $('.sceditor-group:last').after('<div class="sceditor-group"><a class="sceditor-button sceditor-button-message" title="'+settings["title"]+'"><div style="background:url('+settings["img"]+') no-repeat;"></div></a></div>');
     Â       $('body').append('<div id="messageList" style="z-index:15;display:none;position:absolute;background:#fff;border:1px solid #ccc;padding:3px;"><div id="M1" class="listItem" style="cursor:pointer;">Message 1</div><div id="M2" class="listItem" style="cursor:pointer;">Message 2</div><div id="M3" class="listItem" style="cursor:pointer;">Message 3</div></div>');
     Â     
         
          $('.sceditor-button-message').click(function() {
     Â         var display = $('#messageList').css('display');
     Â         if (display == 'none') {
     Â            var Y = $(this).offset().top;
     Â            var X = $(this).offset().left;
     Â            $('#messageList').show().offset({top:Y + 25,left:X});
     Â         }
     Â          else { $('#messageList').hide(); }
     Â      });
     Â       
     Â      $('#M1').click(function() { $('#text_editor_textarea').sceditor('instance').insertText('Message 1',''); });
     Â      $('#M2').click(function() { $('#text_editor_textarea').sceditor('instance').insertText('Message 2',''); });
     Â      $('#M3').click(function() { $('#text_editor_textarea').sceditor('instance').insertText('Message 3',''); });
     Â      $('.listItem').click(function() { $(this).parent().hide(); });
     Â   }
    });

    How do you add a custom button for staff only to the message editor? Captu373
    ddoesmc
    ddoesmc
    Forumember


    Male Posts : 278
    Reputation : 11
    Language : Mainly english
    Location : New Jersey

    Solved Re: How do you add a custom button for staff only to the message editor?

    Post by ddoesmc Thu 6 Mar 2014 - 2:25

    What part do I edit to make the list of texts?  :/
    Ange Tuteur
    Ange Tuteur
    Forumaster


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

    Solved Re: How do you add a custom button for staff only to the message editor?

    Post by Ange Tuteur Thu 6 Mar 2014 - 2:28

    Replace your last code in javascripts management.

    At the bottom I have written the functions for when you click the list items. They're marked with the ID #M1, #M2, #M3. In the instance 'insertText' you'll see 'message 1' that is the texts you edit.

    You can also edit the list itself, it is appended from the body.
    Sir. Mayo
    Sir. Mayo
    Forumember


    Male Posts : 978
    Reputation : 90
    Language : English, Some french.
    Location : you can also reach me on snoonet's irc server. I idle in #Techsupport Username is Vault108

    Solved Re: How do you add a custom button for staff only to the message editor?

    Post by Sir. Mayo Thu 6 Mar 2014 - 16:08

    Does this work on all forum types? Or just phbb3?
    Ange Tuteur
    Ange Tuteur
    Forumaster


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

    Solved Re: How do you add a custom button for staff only to the message editor?

    Post by Ange Tuteur Thu 6 Mar 2014 - 16:13

    If the forum contains the SCEditor it should work. The list is a bit different from my actual project since I didn't include the full style for this.
    ddoesmc
    ddoesmc
    Forumember


    Male Posts : 278
    Reputation : 11
    Language : Mainly english
    Location : New Jersey

    Solved Re: How do you add a custom button for staff only to the message editor?

    Post by ddoesmc Thu 6 Mar 2014 - 21:40

    Topic Solved  :wouhou: 
    Thanks to all!
    Ange Tuteur
    Ange Tuteur
    Forumaster


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

    Solved Re: How do you add a custom button for staff only to the message editor?

    Post by Ange Tuteur Thu 6 Mar 2014 - 22:19

    Welcome Smile

    Topic solved and archived

      Current date/time is Sun 22 Sep 2024 - 18:42