From 66648b0f17e5064d93b73ef0822d87bd8ed1e854 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 28 Sep 2011 14:18:13 +0200 Subject: [PATCH] Fix quoting text selection when a quote is inlined. close #268 --- 4chan_x.user.js | 5 +++-- script.coffee | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 4374cb9b7..e0b830fb5 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1628,7 +1628,7 @@ return QR.submit(); }, quote: function(e, blank) { - var i, id, qr, s, sel, ss, ta, text, tid, v, _base, _ref, _ref2; + var bq, i, id, qr, s, sel, ss, ta, text, tid, v, _base, _ref; if (e != null) { e.preventDefault(); } @@ -1636,7 +1636,8 @@ id = this.textContent; text = ">>" + id + "\n"; sel = getSelection(); - if (id === ((_ref2 = $.x('preceding::input[@type="checkbox"][1]', sel.anchorNode)) != null ? _ref2.name : void 0)) { + bq = $.x('ancestor::blockquote', sel.anchorNode); + if (id === $.x('preceding-sibling::input', bq).name) { if (s = sel.toString().replace(/\n/g, '\n>')) { text += ">" + s + "\n"; } diff --git a/script.coffee b/script.coffee index c4ffcbdeb..29f4aa5ae 100644 --- a/script.coffee +++ b/script.coffee @@ -1215,7 +1215,8 @@ QR = id = @textContent text = ">>#{id}\n" sel = getSelection() - if id == $.x('preceding::input[@type="checkbox"][1]', sel.anchorNode)?.name + bq = $.x('ancestor::blockquote', sel.anchorNode) + if id == $.x('preceding-sibling::input', bq).name if s = sel.toString().replace /\n/g, '\n>' text += ">#{s}\n" {qr} = QR