From 439422d65579f1f6afe7b44312a75b49e906c81f Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 2 Jan 2012 14:01:33 +0100 Subject: [PATCH] Let it drop files before first opening the QR. Enable dump class on drop. --- 4chan_x.user.js | 9 +++++---- script.coffee | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 38ba6339e..7762539df 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1206,8 +1206,10 @@ }); if (conf['Persistent QR']) { qr.dialog(); - if (conf['Auto Hide QR']) return $.id('autohide').click(); + if (conf['Auto Hide QR']) $.id('autohide').click(); } + $.on(d, 'dragover', qr.fileDrop); + return $.on(d, 'drop', qr.fileDrop); }, open: function() { if (qr.el) { @@ -1267,7 +1269,8 @@ e.dataTransfer.dropEffect = 'copy'; if (e.type === 'drop') { qr.open(); - return qr.fileInput.call(e.dataTransfer); + qr.fileInput.call(e.dataTransfer); + return $.addClass(qr.el, 'dump'); } }, fileInput: function() { @@ -1332,8 +1335,6 @@ }); $.on($('form', qr.el), 'submit', qr.submit); $.on($('[type=file]', qr.el), 'change', qr.fileInput); - $.on(d, 'dragover', qr.fileDrop); - $.on(d, 'drop', qr.fileDrop); qr.inputs = { name: $('[name=name]', qr.el), email: $('[name=email]', qr.el) diff --git a/script.coffee b/script.coffee index 3b9965215..c1736cbe2 100644 --- a/script.coffee +++ b/script.coffee @@ -878,6 +878,8 @@ qr = if conf['Persistent QR'] qr.dialog() $.id('autohide').click() if conf['Auto Hide QR'] + $.on d, 'dragover', qr.fileDrop + $.on d, 'drop', qr.fileDrop open: -> if qr.el @@ -934,6 +936,7 @@ qr = if e.type is 'drop' qr.open() qr.fileInput.call e.dataTransfer + $.addClass qr.el, 'dump' fileInput: -> qr.cleanError() if @files.length is 1 @@ -1081,8 +1084,6 @@ textarea.field { $.on $('#dump', qr.el), 'click', -> qr.el.classList.toggle 'dump' $.on $('form', qr.el), 'submit', qr.submit $.on $('[type=file]', qr.el), 'change', qr.fileInput - $.on d, 'dragover', qr.fileDrop - $.on d, 'drop', qr.fileDrop # save & load inputs' value with localStorage qr.inputs =