From 0575c175826a284801b0ab2886a9c1ff36f43256 Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 20 Apr 2011 00:16:32 -0700 Subject: [PATCH] qr.quote --- 4chan_x.js | 48 +++++++++++++++++++++++------------------------- script.coffee | 38 ++++++++++++++++++-------------------- 2 files changed, 41 insertions(+), 45 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 5a1c68b7c..ad9b012d5 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -684,16 +684,12 @@ } }, qr: function(thread, quote) { - var e, qrLink; + var qrLink; if (!(qrLink = $('td.replyhl span[id] a:not(:first-child)', thread))) { qrLink = $("span[id^=nothread] a:not(:first-child)", thread); } if (quote) { - e = { - preventDefault: function() {}, - target: qrLink - }; - return qr.cb.quote(e); + return qr.quote(qrLink); } else { if (!$('#qr')) { qr.dialog(qrLink); @@ -1027,28 +1023,30 @@ } }, quote: function(e) { - var dialog, id, s, selection, selectionID, ta, target, text, _ref; e.preventDefault(); - target = e.target; - if (dialog = $('#qr')) { - qr.autohide.unset(); - } else { - dialog = qr.dialog(target); - } - id = target.textContent; - text = ">>" + id + "\n"; - selection = window.getSelection(); - if (s = selection.toString()) { - selectionID = (_ref = $.x('preceding::input[@type="checkbox"][1]', selection.anchorNode)) != null ? _ref.name : void 0; - if (selectionID === id) { - text += ">" + s + "\n"; - } - } - ta = $('textarea', dialog); - ta.focus(); - return ta.value += text; + return qr.quote(e.target); } }, + quote: function(link) { + var dialog, id, s, selection, selectionID, ta, text, _ref; + if (dialog = $('#qr')) { + qr.autohide.unset(); + } else { + dialog = qr.dialog(link); + } + id = link.textContent; + text = ">>" + id + "\n"; + selection = window.getSelection(); + if (s = selection.toString()) { + selectionID = (_ref = $.x('preceding::input[@type="checkbox"][1]', selection.anchorNode)) != null ? _ref.name : void 0; + if (selectionID === id) { + text += ">" + s + "\n"; + } + } + ta = $('textarea', dialog); + ta.focus(); + return ta.value += text; + }, refresh: function(dialog) { var f; $('textarea', dialog).value = ''; diff --git a/script.coffee b/script.coffee index bf2a5e07f..022d00858 100644 --- a/script.coffee +++ b/script.coffee @@ -499,11 +499,7 @@ keybinds = qrLink = $ "span[id^=nothread] a:not(:first-child)", thread if quote - # qrLink.click() doesn't work, so use this hack - e = - preventDefault: -> - target: qrLink - qr.cb.quote e + qr.quote qrLink else unless $ '#qr' qr.dialog qrLink @@ -781,24 +777,26 @@ qr = quote: (e) -> e.preventDefault() - {target} = e - if dialog = $ '#qr' - qr.autohide.unset() - else - dialog = qr.dialog target + qr.quote e.target - id = target.textContent - text = ">>#{id}\n" + quote: (link) -> + if dialog = $ '#qr' + qr.autohide.unset() + else + dialog = qr.dialog link - selection = window.getSelection() - if s = selection.toString() - selectionID = $.x('preceding::input[@type="checkbox"][1]', selection.anchorNode)?.name - if selectionID == id - text += ">#{s}\n" + id = link.textContent + text = ">>#{id}\n" - ta = $ 'textarea', dialog - ta.focus() - ta.value += text + selection = window.getSelection() + if s = selection.toString() + selectionID = $.x('preceding::input[@type="checkbox"][1]', selection.anchorNode)?.name + if selectionID == id + text += ">#{s}\n" + + ta = $ 'textarea', dialog + ta.focus() + ta.value += text refresh: (dialog) -> $('textarea', dialog).value = ''