Let it drop files before first opening the QR. Enable dump class on drop.

This commit is contained in:
Nicolas Stepien 2012-01-02 14:01:33 +01:00
parent 9cf6aa1079
commit 439422d655
2 changed files with 8 additions and 6 deletions

View File

@ -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)

View File

@ -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 =