From 7fa776a9c549717330ba7c2394bf520692b7308e Mon Sep 17 00:00:00 2001 From: Jordan Bates Date: Fri, 23 Aug 2013 10:52:33 -0700 Subject: [PATCH] Fix #162 --- builds/4chan-X.user.js | 17 ++++++++++++++++- builds/crx/script.js | 17 ++++++++++++++++- src/Posting/QuickReply.coffee | 11 ++++++++++- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 909d36944..cae9bba0e 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -5582,7 +5582,22 @@ } return post.setFile(file); }, - openFileInput: function() { + openFileInput: function(e) { + e.stopPropagation(); + if (e.shiftKey && e.type === 'click') { + return QR.selected.rmFile(); + } + if (e.ctrlKey && e.type === 'click') { + $.addClass(QR.nodes.filename, 'edit'); + QR.nodes.filename.focus(); + return $.on(QR.nodes.filename, 'blur', function() { + return $.rmClass(QR.nodes.filename, 'edit'); + }); + } + if (e.target.nodeName === 'INPUT' || (e.keyCode && ![32, 13].contains(e.keyCode)) || e.ctrlKey) { + return; + } + e.preventDefault(); return QR.nodes.fileInput.click(); }, posts: [], diff --git a/builds/crx/script.js b/builds/crx/script.js index d7a461a51..e18779f3b 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -5592,7 +5592,22 @@ } return post.setFile(file); }, - openFileInput: function() { + openFileInput: function(e) { + e.stopPropagation(); + if (e.shiftKey && e.type === 'click') { + return QR.selected.rmFile(); + } + if (e.ctrlKey && e.type === 'click') { + $.addClass(QR.nodes.filename, 'edit'); + QR.nodes.filename.focus(); + return $.on(QR.nodes.filename, 'blur', function() { + return $.rmClass(QR.nodes.filename, 'edit'); + }); + } + if (e.target.nodeName === 'INPUT' || (e.keyCode && ![32, 13].contains(e.keyCode)) || e.ctrlKey) { + return; + } + e.preventDefault(); return QR.nodes.fileInput.click(); }, posts: [], diff --git a/src/Posting/QuickReply.coffee b/src/Posting/QuickReply.coffee index 8cda679e2..4a9ad2e92 100755 --- a/src/Posting/QuickReply.coffee +++ b/src/Posting/QuickReply.coffee @@ -495,7 +495,16 @@ QR = post = new QR.post() post.setFile file - openFileInput: -> + openFileInput: (e) -> + e.stopPropagation() + if e.shiftKey and e.type is 'click' + return QR.selected.rmFile() + if e.ctrlKey and e.type is 'click' + $.addClass QR.nodes.filename, 'edit' + QR.nodes.filename.focus() + return $.on QR.nodes.filename, 'blur', -> $.rmClass QR.nodes.filename, 'edit' + return if e.target.nodeName is 'INPUT' or (e.keyCode and not [32, 13].contains e.keyCode) or e.ctrlKey + e.preventDefault() QR.nodes.fileInput.click() posts: []