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
+3
SLGray
Draxion
Daemon
7 posters

    [Tutorial] Cite Specific Text

    Daemon
    Daemon
    Forumember


    Posts : 104
    Reputation : 91
    Language : PortuguĂŞs

    [Tutorial] Cite Specific Text Empty [Tutorial] Cite Specific Text

    Post by Daemon July 15th 2017, 8:43 pm

    With this code you can mention a specific text of a post.

    Image:
    [Tutorial] Cite Specific Text 70Onubx

    Create a new JS code with the following content:
    Code:
    /*
     *  Application: Cite specific text
     *  Date: 2016-09-08
     *  Version: 1.109052018
     *  Copyright (c) Daemon <help.forumotion.com>
     *  This work is free. You can redistribute it and/or modify it
     */
    (function() {
        quote = {
            initialize: function() {
                $(function() {
                    if (!$.sceditor && _userdata.session_logged_in < 1) return;
                    quote.setupQuote();
                });
            },
            setupQuote: function() {
                $("head").append(
                '<style type="text/css">' +
                '.quote-box {' +
                '  z-index: 999;' +
                '  margin-top: 16px;' +
                '  position: absolute;' +
                '  display: none;' +
                '  background-color: rgba(70,70,70,0.6);' +
                '  padding: 4px;' +
                '  -webkit-box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.7);' +
                '  -moz-box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.7);' +
                '  box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.7 );' +
                '  -moz-border-radius: 4px;' +
                '  -webkit-border-radius: 4px;' +
                '  border-radius: 4px;' +
                '}' +
                '.quote-box > div {' +
                '  background-color: #f7f7f7;' +
                '  padding: 5px;' +
                '}' +
                '.quote-box > input {' +
                '  margin: 0 3px;' +
                '  cursor: pointer;' +
                '  border-radius: 3px;' +
                '  -webkit-border-radius: 3px;' +
                '  -moz-border-radius: 3px;' +
                '}' +
                '.quote-box > .quote-stem {' +
                '  border-color: transparent transparent #000;' +
                '  opacity: 0.3;' +
                '  border-style: solid;' +
                '  border-width: 15px;' +
                '  display: block;' +
                '  height: 0;' +
                '  left: 5px;' +
                '  position: absolute;' +
                '  top: -30px;' +
                '  width: 0;' +
                '  z-index: 3;' +
                '}' +
                '</style>'
                );
               
                var el = $("<div>", {
                    class: "quote-box"
                }).append(
                '<div>' +
                '    <input type="button" onclick="quote.quoteText()" value="Quote">' +
                '    <input type="button" onclick="quote.mention()" value="@Mention">' +
                '    <input type="button" onclick="quote.hideQuote()" value="Ă—">' +
                '</div>' +
                '<span class="quote-stem"></span>'
                );

                $(el).appendTo("body");

                var selectedTxt, author;
                // VERSIONS:                PUNB    || PHPBB3 AND MODERNBB || PHPBB2 || INVISION
                $(document).on("mouseup", ".post-entry, .content, .postbody, .post-entry", function(e) {
                    var arr = {
                        'user': [],
                        'text': []
                    };
                    // VERSIONS:                                          PUNB  ||              PHPBB3              ||              MODERNBB            ||                  PHPBB2                ||        INVISION
                    author = $(this).parents("[class*='post--']").find(".username, .author > a, .postprofile strong > a, .postprofile-name, .comment-author, .name, .blog_comment-title > a[href^='/u'], .postprofile-head > a").text(),
                    selectedTxt = quote.getSelectionText();
                    if(selectedTxt) {
                        $(".quote-box").show().css({top: e.pageY + "px", left: e.pageX + "px"});
                        arr.user.push(author);
                        arr.text.push(selectedTxt);
                        sessionStorage.setItem("quote-box", JSON.stringify(arr));
                    } else {
                        quote.hideQuote();
                    }
                });
            },
            quoteText: function() {
                var stored = $.parseJSON(sessionStorage.getItem("quote-box"));
                if(stored) {
                    $("textarea").sceditor("instance").insert("[quote='" + stored.user + "']" + stored.text + "[/quote]");
                    quote.hideQuote();
                }
            },
            mention: function() {
                var stored = $.parseJSON(sessionStorage.getItem("quote-box"));
                if(stored) {
                    $("textarea").sceditor("instance").insert("@" + stored.user);
                    quote.hideQuote();
                }
            },
            getSelectionText: function() {
                var text;
                if (window.getSelection) {
                    text = window.getSelection().toString();
                } else if (document.selection && document.selection.type != "Control") {
                    text = document.selection.createRange().text;
                }
                return text;
            },
            hideQuote: function() {
                $(".quote-box").hide();
            }
        };
        quote.initialize()
    })();


    [Tutorial] Cite Specific Text 1f601


    Last edited by Daemon on June 3rd 2018, 3:58 pm; edited 3 times in total

    Sir Chivas™ likes this post

    Draxion
    Draxion
    Helper
    Helper


    Male Posts : 2518
    Reputation : 321
    Language : English
    Location : USA

    [Tutorial] Cite Specific Text Empty Re: [Tutorial] Cite Specific Text

    Post by Draxion July 15th 2017, 9:17 pm

    I can confirm this works well on phpbb3. Smile
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51498
    Reputation : 3523
    Language : English
    Location : United States

    [Tutorial] Cite Specific Text Empty Re: [Tutorial] Cite Specific Text

    Post by SLGray July 16th 2017, 5:27 am

    I can confirm it works in #ModernBB .



    [Tutorial] Cite Specific Text Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.
    Daemon
    Daemon
    Forumember


    Posts : 104
    Reputation : 91
    Language : PortuguĂŞs

    [Tutorial] Cite Specific Text Empty Re: [Tutorial] Cite Specific Text

    Post by Daemon May 10th 2018, 1:08 am

    The code has been fully updated! Any problems, please comment below...
    Landshark
    Landshark
    Forumember


    Posts : 59
    Reputation : 2
    Language : English, Spanish

    [Tutorial] Cite Specific Text Empty Re: [Tutorial] Cite Specific Text

    Post by Landshark April 2nd 2019, 10:58 pm

    Daemon wrote:The code has been fully updated! Any problems, please comment below...

    The code does not work on my forum. When I click the "quote" button, it doesn't go into post-mode.
    Jucarese
    Jucarese
    Hyperactive


    Male Posts : 2539
    Reputation : 118
    Language : spanish
    Location : SSF Admin

    [Tutorial] Cite Specific Text Empty Re: [Tutorial] Cite Specific Text

    Post by Jucarese April 3rd 2019, 11:15 am

    Quote the user 2 times so the quote does not work well
    [Tutorial] Cite Specific Text ToDbWdh
    Nefadar
    Nefadar
    Forumember


    Female Posts : 51
    Reputation : 3
    Language : hungarian, english

    [Tutorial] Cite Specific Text Empty Re: [Tutorial] Cite Specific Text

    Post by Nefadar May 31st 2019, 8:38 am

    jucarese wrote:Quote the user 2 times so the quote does not work well
    [Tutorial] Cite Specific Text ToDbWdh

    I have the same problem.
    Beyonder
    Beyonder
    Forumember


    Male Posts : 723
    Reputation : 29
    Language : English
    Location : Beyond Realm

    [Tutorial] Cite Specific Text Empty Re: [Tutorial] Cite Specific Text

    Post by Beyonder June 20th 2019, 6:03 pm

    Any updates for this? @Daemon

      Current date/time is September 22nd 2024, 8:28 pm