reply quoting improvement

- multi line quoting
- ability to quote from board index
- works in Chrome
This commit is contained in:
marktaiwan 2015-01-25 22:08:25 +08:00
parent 3b5acb7df8
commit 5acdf16f5e

View File

@ -334,13 +334,18 @@ function citeReply(id, with_link) {
textarea.value += '>>' + id + '\n'; textarea.value += '>>' + id + '\n';
} }
if (typeof $ != 'undefined') { if (typeof $ != 'undefined') {
var select = document.getSelection().toString(); // multiline quotes
var select = sessionStorage.quoteClipboard;
if (select) { if (select) {
var body = $('#reply_' + id + ', #op_' + id).find('div.body'); // TODO: support for OPs select = select.split('\n');
var index = body.text().indexOf(select.replace('\n', '')); // for some reason this only works like this $(select).each(function () {
if (index > -1) { if (this !== '')
textarea.value += '>' + select + '\n'; var str = '>'+ this +'\n';
} else
var str = '\n';
textarea.value += str;
});
delete sessionStorage.quoteClipboard;
} }
$(window).trigger('cite', [id, with_link]); $(window).trigger('cite', [id, with_link]);
@ -403,6 +408,13 @@ var script_settings = function(script_name) {
function init() { function init() {
init_stylechooser(); init_stylechooser();
if (typeof $ != 'undefined') {
// store highlighted text for citeReply()
$('form[name="postcontrols"]').on('mouseup', function (e) {
sessionStorage.quoteClipboard = window.getSelection().toString();
});
}
{% endraw %} {% endraw %}
{% if config.allow_delete %} {% if config.allow_delete %}
if (document.forms.postcontrols) { if (document.forms.postcontrols) {