Fix some compatibility issues with file drag'n'drop. Close #181.
This commit is contained in:
parent
aa5cb8007b
commit
86f0bd6193
@ -1231,8 +1231,10 @@
|
||||
qr.dialog();
|
||||
if (conf['Auto Hide QR']) qr.hide();
|
||||
}
|
||||
$.on(d, 'dragover', qr.fileDrop);
|
||||
$.on(d, 'drop', qr.fileDrop);
|
||||
$.on(d, 'dragover', qr.dragOver);
|
||||
$.on(d, 'drop', qr.dropFile);
|
||||
$.on(d, 'dragstart', qr.drag);
|
||||
$.on(d, 'dragend', qr.drag);
|
||||
return window.location = 'javascript:void(Recaptcha.focus_response_field=function(){})';
|
||||
},
|
||||
open: function() {
|
||||
@ -1355,17 +1357,22 @@
|
||||
ta.focus();
|
||||
return ta.selectionEnd = ta.selectionStart = caretPos + text.length;
|
||||
},
|
||||
fileDrop: function(e) {
|
||||
if (/TEXTAREA|INPUT/.test(e.target.nodeName)) return;
|
||||
drag: function(e) {
|
||||
var i;
|
||||
i = e.type === 'dragstart' ? 'off' : 'on';
|
||||
$[i](d, 'dragover', qr.dragOver);
|
||||
return $[i](d, 'drop', qr.dropFile);
|
||||
},
|
||||
dragOver: function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
e.dataTransfer.dropEffect = 'copy';
|
||||
if (e.type === 'drop') {
|
||||
if (!e.dataTransfer.files.length) return;
|
||||
qr.open();
|
||||
qr.fileInput.call(e.dataTransfer);
|
||||
return $.addClass(qr.el, 'dump');
|
||||
}
|
||||
return e.dataTransfer.dropEffect = 'copy';
|
||||
},
|
||||
dropFile: function(e) {
|
||||
if (!e.dataTransfer.files.length) return;
|
||||
e.preventDefault();
|
||||
qr.open();
|
||||
qr.fileInput.call(e.dataTransfer);
|
||||
return $.addClass(qr.el, 'dump');
|
||||
},
|
||||
fileInput: function() {
|
||||
var file, _i, _len, _ref;
|
||||
|
||||
@ -5,6 +5,7 @@ master
|
||||
Increase Sauce linking possibilites:
|
||||
Thumbnails, full images, MD5 hashes.
|
||||
Unread Favicon is now optional, independent of Unread Count.
|
||||
Fix some compatibility issues with file drag and drop, notably with QuickDrag extension.
|
||||
|
||||
2.25.5
|
||||
- Mayhem
|
||||
|
||||
@ -889,8 +889,10 @@ qr =
|
||||
if conf['Persistent QR']
|
||||
qr.dialog()
|
||||
qr.hide() if conf['Auto Hide QR']
|
||||
$.on d, 'dragover', qr.fileDrop
|
||||
$.on d, 'drop', qr.fileDrop
|
||||
$.on d, 'dragover', qr.dragOver
|
||||
$.on d, 'drop', qr.dropFile
|
||||
$.on d, 'dragstart', qr.drag
|
||||
$.on d, 'dragend', qr.drag
|
||||
# prevent original captcha input from being focused on reload
|
||||
window.location = 'javascript:void(Recaptcha.focus_response_field=function(){})'
|
||||
|
||||
@ -1000,16 +1002,21 @@ qr =
|
||||
# Move the caret to the end of the new quote.
|
||||
ta.selectionEnd = ta.selectionStart = caretPos + text.length
|
||||
|
||||
fileDrop: (e) ->
|
||||
return if /TEXTAREA|INPUT/.test e.target.nodeName
|
||||
drag: (e) ->
|
||||
# Let it drag anything from the page.
|
||||
i = if e.type is 'dragstart' then 'off' else 'on'
|
||||
$[i] d, 'dragover', qr.dragOver
|
||||
$[i] d, 'drop', qr.dropFile
|
||||
dragOver: (e) ->
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
e.dataTransfer.dropEffect = 'copy' # cursor feedback
|
||||
if e.type is 'drop'
|
||||
return unless e.dataTransfer.files.length # let it only drop files
|
||||
qr.open()
|
||||
qr.fileInput.call e.dataTransfer
|
||||
$.addClass qr.el, 'dump'
|
||||
dropFile: (e) ->
|
||||
# Let it only handle files from the desktop.
|
||||
return unless e.dataTransfer.files.length
|
||||
e.preventDefault()
|
||||
qr.open()
|
||||
qr.fileInput.call e.dataTransfer
|
||||
$.addClass qr.el, 'dump'
|
||||
fileInput: ->
|
||||
qr.cleanError()
|
||||
# Set or change current reply's file.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user