diff --git a/js/quick-reply.js b/js/quick-reply.js index 7156b224..9ac1a593 100644 --- a/js/quick-reply.js +++ b/js/quick-reply.js @@ -278,7 +278,13 @@ } }); - $postForm.find('textarea[name="body"]').removeAttr('id').removeAttr('cols').attr('placeholder', _('Comment')); + $postForm.find('textarea[name="body"]').removeAttr('id').removeAttr('cols').attr('placeholder', _('Comment')) + .on('keydown', function (e) { + //close quick reply when esc is prssed + if (e.which === 27) { + $('.close-btn').trigger('click'); + } + }); $postForm.find('textarea:not([name="body"]),input[type="hidden"]:not(.captcha_cookie)').removeAttr('id').appendTo($dummyStuff); @@ -373,7 +379,8 @@ } else { $postForm.show(); } - + + $postForm.find('textarea[name="body"]').focus(); $(window).on('stylesheet', function() { do_css(); if ($('link#stylesheet').attr('href')) { diff --git a/templates/main.js b/templates/main.js index 254e12c0..a7e3445d 100644 --- a/templates/main.js +++ b/templates/main.js @@ -333,16 +333,23 @@ function citeReply(id, with_link) { // ??? textarea.value += '>>' + id + '\n'; } - if (typeof $ != 'undefined') { - var select = document.getSelection().toString(); - if (select) { - var body = $('#reply_' + id + ', #op_' + id).find('div.body'); // TODO: support for OPs - var index = body.text().indexOf(select.replace('\n', '')); // for some reason this only works like this - if (index > -1) { - textarea.value += '>' + select + '\n'; - } - } + // multiline quotes + var select = sessionStorage.quoteClipboard; + if (select) { + select = select.split('\n'); + select.forEach(function (str) { + if (str !== '') { + str = '>' + str + '\n'; + } else { + str = '\n'; + } + textarea.value += str; + }); + delete sessionStorage.quoteClipboard; + } + + if (typeof $ != 'undefined') { $(window).trigger('cite', [id, with_link]); $(textarea).change(); } @@ -403,6 +410,11 @@ var script_settings = function(script_name) { function init() { init_stylechooser(); + // store highlighted text for citeReply() + document.querySelector('form[name="postcontrols"]').addEventListener('mouseup', function (e) { + sessionStorage.quoteClipboard = window.getSelection().toString(); + }); + {% endraw %} {% if config.allow_delete %} if (document.forms.postcontrols) {