[Tutorial] Cite Specific Text

Go down

modernbb - [Tutorial] Cite Specific Text Empty [Tutorial] Cite Specific Text

Post by Daemon on Sat Jul 15, 2017 7:43 pm

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

Image:
modernbb - [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()
})();


modernbb - [Tutorial] Cite Specific Text 1f601


Last edited by Daemon on Sun Jun 03, 2018 2:58 pm; edited 3 times in total
Daemon
Daemon
Forumember

Posts : 101
Reputation : 86
Language : Português

Back to top Go down

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

Post by Draxion on Sat Jul 15, 2017 8:17 pm

I can confirm this works well on phpbb3. Smile


NEVER provide your founder's account or email
Please provide forum's URL when dealing with design and appearance issues
Don't forget to mark the topic as modernbb - [Tutorial] Cite Specific Text Solved11 when the issue is resolved. This helps the staff greatly.
PM Support is prohibited!
TOS | General Rules | FAQ | Tricks & Tips | Latest Updates | Introduce Yourself

modernbb - [Tutorial] Cite Specific Text Draxio14
Draxion
Draxion
Support Moderator
Support Moderator

Male Posts : 2424
Reputation : 306
Language : English
Location : USA

https://www.talesoftellene.com/

Back to top Go down

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

Post by SLGray on Sun Jul 16, 2017 4:27 am

I can confirm it works in #ModernBB .


modernbb - [Tutorial] Cite Specific Text Slgray10

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

Male Posts : 47010
Reputation : 3285
Language : English
Location : United States

https://help.forumotion.com/

Back to top Go down

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

Post by Daemon on Thu May 10, 2018 12:08 am

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

Posts : 101
Reputation : 86
Language : Português

Back to top Go down

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

Post by Landshark on Tue Apr 02, 2019 9: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.
Landshark
Landshark
Forumember

Posts : 48
Reputation : 2
Language : English, Spanish

Back to top Go down

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

Post by jucarese on Wed Apr 03, 2019 10:15 am

Quote the user 2 times so the quote does not work well
modernbb - [Tutorial] Cite Specific Text ToDbWdh
jucarese
jucarese
Active Poster

Male Posts : 1592
Reputation : 57
Language : spanish
Location : SSF Admin

http://asistencia.foroactivo.com/u23082

Back to top Go down

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

Post by Nefadar on Fri May 31, 2019 7:38 am

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

I have the same problem.
Nefadar
Nefadar
Forumember

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

http://xmenreneszansz.hungarianforum.net/

Back to top Go down

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

Post by Beyonder on Thu Jun 20, 2019 5:03 pm

Any updates for this? @Daemon
Beyonder
Beyonder
Forumember

Male Posts : 631
Reputation : 25
Language : English
Location : Beyond Realm

http://fictionalomniverse.forumotion.com/

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum