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 @@ -68,13 +68,27 @@ function make_table_dom() ); } +function moveCaretToEnd(el) { + if (typeof el.selectionStart == "number") { + el.selectionStart = el.selectionEnd = el.value.length; + } else if (typeof el.createTextRange != "undefined") { + el.focus(); + var range = el.createTextRange(); + range.collapse(false); + range.select(); + } +} + function addQuickReply(postId) { var textToAdd = '>>' + postId + '\n\n'; $('#id_text').val($('#id_text').val()+ textToAdd); + var textarea = document.getElementById('id_text'); + moveCaretToEnd(textarea); + $("html, body").animate({ scrollTop: $('#id_text').offset().top }, "slow"); } $(document).ready(function(){ add_panel('.navigation_panel'); -}); \ No newline at end of file +});