From 3d58a03a4dda90f2b6f17ba48657f39e1267e270 Mon Sep 17 00:00:00 2001 From: Bui Date: Tue, 30 Sep 2014 14:45:02 +0900 Subject: [PATCH 1/2] quote selected text on cite --- templates/main.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/templates/main.js b/templates/main.js index 9437c5ca..41d4cd27 100644 --- a/templates/main.js +++ b/templates/main.js @@ -214,6 +214,15 @@ function citeReply(id, with_link) { textarea.value += '>>' + id + '\n'; } if (typeof $ != 'undefined') { + var select = document.getSelection().toString(); + if (select) { + var body = $('#reply_' + 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'; + } + } + $(window).trigger('cite', [id, with_link]); $(textarea).change(); } From 312ccf6c4e4fc18bdc14b8b93fbbf7408e5a4c86 Mon Sep 17 00:00:00 2001 From: Bui Date: Tue, 30 Sep 2014 15:24:12 +0900 Subject: [PATCH 2/2] give OPs IDs --- templates/main.js | 2 +- templates/post_thread.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/main.js b/templates/main.js index 41d4cd27..242ba3a3 100644 --- a/templates/main.js +++ b/templates/main.js @@ -216,7 +216,7 @@ function citeReply(id, with_link) { if (typeof $ != 'undefined') { var select = document.getSelection().toString(); if (select) { - var body = $('#reply_' + id).find('div.body'); // TODO: support for OPs + 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'; diff --git a/templates/post_thread.html b/templates/post_thread.html index aa0f1f78..08b4c4c1 100644 --- a/templates/post_thread.html +++ b/templates/post_thread.html @@ -5,7 +5,7 @@ {% if not index %}{% endif %} {% include 'post/fileinfo.html' %} -
1%}style='clear:both'{%endif%}>

+

1%}style='clear:both'{%endif%}>