From f3e4c5b64a6c509e9652f69805a99fe14acd786b Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 6 Mar 2012 20:29:13 +0100 Subject: [PATCH] Use shift+click to remove the selected file. Close #281. --- 4chan_x.user.js | 14 +++++++++++++- changelog | 3 ++- script.coffee | 10 +++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index e3d87e523..7692da4b6 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1602,6 +1602,15 @@ return img.src = fileUrl; }; + _Class.prototype.rmFile = function() { + qr.resetFileInput(); + delete this.file; + this.el.title = null; + this.el.style.backgroundImage = null; + if (qr.spoiler) $('label', this.el).hidden = true; + return (window.URL || window.webkitURL).revokeObjectURL(this.url); + }; + _Class.prototype.select = function() { var data, rectEl, rectList, _i, _len, _ref, _ref2; if ((_ref = qr.selected) != null) _ref.el.id = null; @@ -1760,7 +1769,7 @@
\
\
\ -
\ +
\ \
\ '); @@ -1816,6 +1825,9 @@ return qr.selected.el.lastChild.textContent = this.value; }); $.on(fileInput, 'change', qr.fileInput); + $.on(fileInput, 'click', function(e) { + if (e.shiftKey) return qr.selected.rmFile() || e.preventDefault(); + }); $.on(spoiler.firstChild, 'change', function() { return $('input', qr.selected.el).click(); }); diff --git a/changelog b/changelog index db392fa3b..76770c09f 100644 --- a/changelog +++ b/changelog @@ -3,7 +3,8 @@ master General performance improvements. Threads will now be updated instantly after posting through the QR. Your own posts will not count toward the unread count after posting through the QR. - QR thumbnails of high-res pictures will not slow down anymore. + Performance issues are now lessened with QR thumbnails of high-res pictures. + You can now use Shift+Click on the file input to remove the selected reply's file. Reply navigation keybinds will now scroll as you navigate. - noface Add unique ID to filter. diff --git a/script.coffee b/script.coffee index f8a03c54a..37ed65d13 100644 --- a/script.coffee +++ b/script.coffee @@ -1327,6 +1327,13 @@ qr = url.revokeObjectURL fileUrl img.src = fileUrl + rmFile: -> + qr.resetFileInput() + delete @file + @el.title = null + @el.style.backgroundImage = null + $('label', @el).hidden = true if qr.spoiler + (window.URL or window.webkitURL).revokeObjectURL @url select: -> qr.selected?.el.id = null qr.selected = @ @@ -1442,7 +1449,7 @@ qr =
-
+
' @@ -1488,6 +1495,7 @@ qr = $.on $('form', qr.el), 'submit', qr.submit $.on $('textarea', qr.el), 'keyup', -> qr.selected.el.lastChild.textContent = @value $.on fileInput, 'change', qr.fileInput + $.on fileInput, 'click', (e) -> if e.shiftKey then qr.selected.rmFile() or e.preventDefault() $.on spoiler.firstChild, 'change', -> $('input', qr.selected.el).click() $.on $('.warning', qr.el), 'click', qr.cleanError