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

    Quick quote

    Ange Tuteur
    Ange Tuteur
    Forumaster


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

    Tutorial Quick quote

    Post by Ange Tuteur August 11th 2014, 5:21 pm

    Quick quote


    This tutorial will allow you to perform a quick quote of a word or phrase that you have highlighted previously, by adding a new button or using the current quote button.
    Quick quote Captur75

    Result :
    Quick quote Captur76


    Installing

    To install this we must go to Administration Panel > Modules > JavaScript codes management and create a new script.

    Title : Your choice
    Placement : In all the pages
    Code:
    $(function(){
     Â var forum_version = 1,
     Â new_button = false,
     Â quote_image = 'https://i39.servimg.com/u/f39/18/21/60/73/quick10.png';

     Â if (forum_version == 0) n = [".postbody div",".name strong a"];
     Â if (forum_version == 1) n = [".postbody .content div",".postprofile dl dt strong a"];
     Â if (forum_version == 2) n = [".entry-content div",".username a"];
     Â if (forum_version == 3) n = [".post-entry div",".postprofile-details dt a + br + a"];
     Â if (new_button == true) { q = ".quickquote"; $(forum_version==1?"li:has(.i_icon_quote)":"a:has(.i_icon_quote)").after($('<li style="display:inline-block;list-style:none;"><a href="#quick_reply"><img src="'+quote_image+'" class="quickquote" alt="Quick quote" title="Quick quote" /></a></li>')) }
     Â if (new_button == false) { q = "a:has(.i_icon_quote)"; $("a:has(.i_icon_quote)").attr("href", "#quick_reply"); $(".i_icon_quote").attr("title", "Reply with quote") }
     Â 
     Â $(document).on('mouseup',n[0],function(e){
     Â   qtext = $(this).parents(".post");
     Â   if (window.getSelection) theSelection = window.getSelection().toString();
     Â   else if (document.getSelection) theSelection = document.getSelection();
     Â   else if (document.selection) theSelection = document.selection.createRange().text;
     Â });  
     Â 
     Â $(q).click(function () {
     Â   if (typeof qtext == 'undefined') return;
     Â   uname = qtext.find(n[1]).text();
     Â   $("div.sceditor-toolbar + iframe").contents().find("body").append('<blockquote><cite>' + uname + '</cite>' + theSelection + '</blockquote> <br />');
     Â   $('.sceditor-container textarea')[0].value += '[quote="' + uname + '"]' + theSelection + '[/quote]'
     Â });
     Â var n,q;
    });


    Modifications
    Below are some variables you can modify in the script.

    To ensure that this tutorial works for you, you must change the value of forum_version to the version of your forum :
    0 = phpbb2
    1 = phpbb3
    2 = punbb
    3 = invision


    To keep the regular quote button and add a new button for the quick quote you must change the value of new_button :
    true = create a new button
    false = use the current quote button

    Result :
    Quick quote Captur78

    To change the quick quote image, simply replace https://i.servimg.com/u/f39/18/21/60/73/quick10.png by the URL of your image. The current image can be found at the top of the script in the quote_image variable.



    skouliki
    skouliki
    Manager
    Manager


    Female Posts : 15311
    Reputation : 1705
    Language : English,Greek
    Location : Greece

    Tutorial Re: Quick quote

    Post by skouliki February 13th 2020, 8:31 am

    This code was updated to fit in with the new HTTPS address

    updated 13.02.2020 by skouliki


      Current date/time is September 23rd 2024, 12:38 am