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.

[Tutorial] Cite Specific Text

+3
SLGray
Draxion
Daemon
7 posters

Go down

[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
Daemon
Daemon
Forumember

Posts : 104
Reputation : 91
Language : Português

Sir Chivas™ likes this post

Back to top Go down

[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
Draxion
Draxion
Helper
Helper

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

https://www.talesoftellene.com/

Back to top Go down

[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.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51495
Reputation : 3519
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

[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...
Daemon
Daemon
Forumember

Posts : 104
Reputation : 91
Language : Português

Back to top Go down

[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.
Landshark
Landshark
Forumember

Posts : 59
Reputation : 2
Language : English, Spanish

Back to top Go down

[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
jucarese
jucarese
Hyperactive

Male Posts : 2448
Reputation : 116
Language : spanish
Location : SSF Admin

http://asistencia.foroactivo.com/u23082

Back to top Go down

[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.
Nefadar
Nefadar
Forumember

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

http://xmenreneszansz.hungarianforum.net/

Back to top Go down

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

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

Any updates for this? @Daemon
Beyonder
Beyonder
Forumember

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

http://fictionalomniverse.forumotion.com/

Back to top Go down

Back to top

- Similar topics

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