# HG changeset patch # User neko259 # Date 2017-01-17 08:36:22 # Node ID 5502a65383d3e984411132f993a22d51f7ce99bb # Parent ffa6e90da3c5c634c51f734570c6c955c391b209 Do not close the form when clicking 'reply' again on the same post 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 @@ -57,40 +57,35 @@ function showFormAfter(blockToInsertAfte } function addQuickReply(postId) { - // If we click "reply" on the same post, it means "cancel" - if (getForm().prev().attr('id') == postId) { - resetFormPosition(); - } else { - var blockToInsert = null; - var textAreaJq = getPostTextarea(); - var postLinkRaw = '[post]' + postId + '[/post]' - var textToAdd = ''; + var blockToInsert = null; + var textAreaJq = getPostTextarea(); + var postLinkRaw = '[post]' + postId + '[/post]' + var textToAdd = ''; - if (postId != null) { - var post = $('#' + postId); + if (postId != null) { + var post = $('#' + postId); - // If this is not OP, add reflink to the post. If there already is - // the same reflink, don't add it again. - var postText = textAreaJq.val(); - if (!post.is(':first-child') && postText.indexOf(postLinkRaw) < 0) { - // Insert line break if none is present. - if (postText.length > 0 && !postText.endsWith('\n') && !postText.endsWith('\r')) { - textToAdd += '\n'; - } - textToAdd += postLinkRaw + '\n'; + // If this is not OP, add reflink to the post. If there already is + // the same reflink, don't add it again. + var postText = textAreaJq.val(); + if (!post.is(':first-child') && postText.indexOf(postLinkRaw) < 0) { + // Insert line break if none is present. + if (postText.length > 0 && !postText.endsWith('\n') && !postText.endsWith('\r')) { + textToAdd += '\n'; } + textToAdd += postLinkRaw + '\n'; + } - textAreaJq.val(textAreaJq.val()+ textToAdd); - blockToInsert = post; - } else { - blockToInsert = $('.thread'); - } - showFormAfter(blockToInsert); - - textAreaJq.focus(); + textAreaJq.val(textAreaJq.val()+ textToAdd); + blockToInsert = post; + } else { + blockToInsert = $('.thread'); + } + showFormAfter(blockToInsert); - moveCaretToEnd(textAreaJq); - } + textAreaJq.focus(); + + moveCaretToEnd(textAreaJq); } function addQuickQuote() { @@ -98,7 +93,7 @@ function addQuickQuote() { var quoteButton = $("#quote-button"); var postId = quoteButton.attr('data-post-id'); - if (postId != null && getForm().prev().attr('id') != postId) { + if (postId != null) { addQuickReply(postId); }