Manage file drag and drop into the window. It will open the QR if it's closed.
This commit is contained in:
parent
4e2f3efef6
commit
9cf6aa1079
@ -1260,6 +1260,16 @@
|
|||||||
ta.focus();
|
ta.focus();
|
||||||
return ta.selectionEnd = ta.selectionStart = caretPos + text.length;
|
return ta.selectionEnd = ta.selectionStart = caretPos + text.length;
|
||||||
},
|
},
|
||||||
|
fileDrop: function(e) {
|
||||||
|
if (!e.dataTransfer.files.length) return;
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
e.dataTransfer.dropEffect = 'copy';
|
||||||
|
if (e.type === 'drop') {
|
||||||
|
qr.open();
|
||||||
|
return qr.fileInput.call(e.dataTransfer);
|
||||||
|
}
|
||||||
|
},
|
||||||
fileInput: function() {
|
fileInput: function() {
|
||||||
var file, _i, _len, _ref;
|
var file, _i, _len, _ref;
|
||||||
qr.cleanError();
|
qr.cleanError();
|
||||||
@ -1321,6 +1331,9 @@
|
|||||||
return qr.el.classList.toggle('dump');
|
return qr.el.classList.toggle('dump');
|
||||||
});
|
});
|
||||||
$.on($('form', qr.el), 'submit', qr.submit);
|
$.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 = {
|
qr.inputs = {
|
||||||
name: $('[name=name]', qr.el),
|
name: $('[name=name]', qr.el),
|
||||||
email: $('[name=email]', qr.el)
|
email: $('[name=email]', qr.el)
|
||||||
@ -1337,7 +1350,6 @@
|
|||||||
return qr.inputs[match[1]].value = JSON.parse(e.newValue);
|
return qr.inputs[match[1]].value = JSON.parse(e.newValue);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$.on($('[type=file]', qr.el), 'change', qr.fileInput);
|
|
||||||
return $.add(d.body, qr.el);
|
return $.add(d.body, qr.el);
|
||||||
},
|
},
|
||||||
submit: function(e) {
|
submit: function(e) {
|
||||||
|
|||||||
@ -926,6 +926,14 @@ qr =
|
|||||||
#move the caret to the end of the new quote
|
#move the caret to the end of the new quote
|
||||||
ta.selectionEnd = ta.selectionStart = caretPos + text.length
|
ta.selectionEnd = ta.selectionStart = caretPos + text.length
|
||||||
|
|
||||||
|
fileDrop: (e) ->
|
||||||
|
return unless e.dataTransfer.files.length # let it only drop files
|
||||||
|
e.preventDefault()
|
||||||
|
e.stopPropagation()
|
||||||
|
e.dataTransfer.dropEffect = 'copy' # cursor feedback
|
||||||
|
if e.type is 'drop'
|
||||||
|
qr.open()
|
||||||
|
qr.fileInput.call e.dataTransfer
|
||||||
fileInput: ->
|
fileInput: ->
|
||||||
qr.cleanError()
|
qr.cleanError()
|
||||||
if @files.length is 1
|
if @files.length is 1
|
||||||
@ -1067,11 +1075,14 @@ textarea.field {
|
|||||||
<div class=error></div>
|
<div class=error></div>
|
||||||
</form>"
|
</form>"
|
||||||
unless g.REPLY
|
unless g.REPLY
|
||||||
$.on $('select', qr.el), 'mousedown', (e) -> e.stopPropagation()
|
$.on $('select', qr.el), 'mousedown', (e) -> e.stopPropagation()
|
||||||
$.on $('#autohide', qr.el), 'click', qr.hide
|
$.on $('#autohide', qr.el), 'click', qr.hide
|
||||||
$.on $('.close', qr.el), 'click', qr.close
|
$.on $('.close', qr.el), 'click', qr.close
|
||||||
$.on $('#dump', qr.el), 'click', -> qr.el.classList.toggle 'dump'
|
$.on $('#dump', qr.el), 'click', -> qr.el.classList.toggle 'dump'
|
||||||
$.on $('form', qr.el), 'submit', qr.submit
|
$.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
|
# save & load inputs' value with localStorage
|
||||||
qr.inputs =
|
qr.inputs =
|
||||||
@ -1085,8 +1096,6 @@ textarea.field {
|
|||||||
if match = e.key.match /qr_(.+)$/
|
if match = e.key.match /qr_(.+)$/
|
||||||
qr.inputs[match[1]].value = JSON.parse e.newValue
|
qr.inputs[match[1]].value = JSON.parse e.newValue
|
||||||
|
|
||||||
$.on $('[type=file]', qr.el), 'change', qr.fileInput
|
|
||||||
|
|
||||||
$.add d.body, qr.el
|
$.add d.body, qr.el
|
||||||
|
|
||||||
submit: (e) ->
|
submit: (e) ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user