diff --git a/boards/static/css/base.css b/boards/static/css/base.css --- a/boards/static/css/base.css +++ b/boards/static/css/base.css @@ -154,3 +154,8 @@ textarea, input { -webkit-filter: grayscale(100%); } +#quote-button { + position: absolute; + display: none; + cursor: pointer; +} \ No newline at end of file diff --git a/boards/static/css/md/base_page.css b/boards/static/css/md/base_page.css --- a/boards/static/css/md/base_page.css +++ b/boards/static/css/md/base_page.css @@ -566,3 +566,13 @@ ul { .post-blink { background-color: #000; } + +#quote-button { + background-color: black; + border: solid white 1px; + padding: 2px; +} + +#quote-button:hover { + background-color: #2d3955; +} \ No newline at end of file diff --git a/boards/static/css/pg/base_page.css b/boards/static/css/pg/base_page.css --- a/boards/static/css/pg/base_page.css +++ b/boards/static/css/pg/base_page.css @@ -381,3 +381,13 @@ input[type="submit"]:hover { .post-blink { background-color: #333; } + +#quote-button { + background-color: #e2c48f; + border: solid #000000 1px; + padding: 2px; +} + +#quote-button:hover { + background-color: #bde2a6; +} \ No newline at end of file diff --git a/boards/static/css/sw/base_page.css b/boards/static/css/sw/base_page.css --- a/boards/static/css/sw/base_page.css +++ b/boards/static/css/sw/base_page.css @@ -416,3 +416,13 @@ audio { .post-blink { background-color: #ccc; } + +#quote-button { + background-color: #99a3e2; + border: solid #000000 1px; + padding: 2px; +} + +#quote-button:hover { + background-color: #b9c4e2; +} \ No newline at end of file diff --git a/boards/static/js/thread.js b/boards/static/js/thread.js --- a/boards/static/js/thread.js +++ b/boards/static/js/thread.js @@ -95,15 +95,13 @@ function addQuickReply(postId) { } } -function addQuickQuote(postId) { - if (getForm().prev().attr('id') != postId) { - addQuickReply(postId); - } - +function addQuickQuote() { var textToAdd = ''; var textAreaJq = $('textarea'); - var postLinkRaw = '[post]' + postId + '[/post]' var selection = window.getSelection().toString(); + if (selection.length == 0) { + selection = $("#quote-button").attr('data-text'); + } if (selection.length > 0) { textToAdd += '[quote]' + selection + '[/quote]\n'; } @@ -120,3 +118,26 @@ function scrollToBottom() { $html.animate({scrollTop: $html.height()}, "fast"); } +function showQuoteButton() { + var selection = window.getSelection().getRangeAt(0).getBoundingClientRect(); + var quoteButton = $("#quote-button"); + if (selection.width > 0) { + // quoteButton.offset({ top: selection.top - selection.height, left: selection.left }); + quoteButton.css({top: selection.top + $(window).scrollTop() - 30, left: selection.left}); + quoteButton.show(); + + var text = window.getSelection().toString(); + quoteButton.attr('data-text', text); + } else { + quoteButton.hide(); + } +} + +$(document).ready(function() { + $('body').on('mouseup', function() { + showQuoteButton(); + }); + $("#quote-button").click(function() { + addQuickQuote(); + }) +}); \ No newline at end of file diff --git a/boards/templates/boards/post.html b/boards/templates/boards/post.html --- a/boards/templates/boards/post.html +++ b/boards/templates/boards/post.html @@ -42,8 +42,7 @@ {% endif %} {% endif %} {% if reply_link and not thread.is_archived %} - {% trans 'Reply' %} | - {% trans 'Quote' %} + {% trans 'Reply' %} {% endif %} {% if perms.boards.change_post or perms.boards.delete_post or perms.boards.change_thread or perms_boards.delete_thread %} diff --git a/boards/templates/boards/thread_normal.html b/boards/templates/boards/thread_normal.html --- a/boards/templates/boards/thread_normal.html +++ b/boards/templates/boards/thread_normal.html @@ -9,6 +9,8 @@ {% get_current_language as LANGUAGE_CODE %} {% get_current_timezone as TIME_ZONE %} +
+