# HG changeset patch # User neko259 # Date 2016-05-07 12:27:42 # Node ID a5d6a1a7f9fc660fd296baab1c3d1d4c0f2e3016 # Parent ecaafe92346ac8c10edc6a1f9c98d4fccea1887e # Parent dd31aeacf0e6680d396a3ead14f4e9106be81be0 Merged with default branch 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 @@ -571,3 +571,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 @@ -67,12 +67,10 @@ function addQuickReply(postId) { if (getForm().prev().attr('id') == postId) { resetFormPosition(); } else { + var blockToInsert = null; + var textAreaJq = $('textarea'); var postLinkRaw = '[post]' + postId + '[/post]' - - var textToAdd = ''; - var blockToInsert = null; - - var textAreaJq = $('textarea'); + var textToAdd = ''; if (postId != null) { var post = $('#' + postId); @@ -83,27 +81,63 @@ function addQuickReply(postId) { textToAdd += postLinkRaw + '\n'; } + textAreaJq.val(textAreaJq.val()+ textToAdd); blockToInsert = post; } else { blockToInsert = $('.thread'); } - - var selection = window.getSelection().toString(); - if (selection.length > 0) { - textToAdd += '[quote]' + selection + '[/quote]\n'; - } + showFormAfter(blockToInsert); + + textAreaJq.focus(); - textAreaJq.val(textAreaJq.val()+ textToAdd); - - showFormAfter(blockToInsert); - - textAreaJq.focus(); var textarea = document.getElementsByTagName('textarea')[0]; moveCaretToEnd(textarea); } } +function addQuickQuote() { + var textToAdd = ''; + var textAreaJq = $('textarea'); + var selection = window.getSelection().toString(); + if (selection.length == 0) { + selection = $("#quote-button").attr('data-text'); + } + if (selection.length > 0) { + textToAdd += '[quote]' + selection + '[/quote]\n'; + } + + textAreaJq.val(textAreaJq.val()+ textToAdd); + + textAreaJq.focus(); + + var textarea = document.getElementsByTagName('textarea')[0]; + moveCaretToEnd(textarea); +} + 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/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 %} +
{% trans 'Quote' %}
+