Fix last file input bugs. #932
This commit is contained in:
parent
70fdb95586
commit
bdfcf60d8b
@ -661,9 +661,12 @@
|
||||
fd = new FormData();
|
||||
for (key in form) {
|
||||
val = form[key];
|
||||
if (val instanceof Blob) {
|
||||
if (!val) {
|
||||
continue;
|
||||
}
|
||||
if (val.size && val.name) {
|
||||
fd.append(key, val, val.name);
|
||||
} else if (val) {
|
||||
} else {
|
||||
fd.append(key, val);
|
||||
}
|
||||
}
|
||||
@ -6008,7 +6011,7 @@
|
||||
},
|
||||
fileInput: function(files) {
|
||||
var file, length, max, post, _i, _len, _ref, _ref1;
|
||||
if (files instanceof Event) {
|
||||
if (this instanceof Element) {
|
||||
files = __slice.call(this.files);
|
||||
QR.nodes.fileInput.value = null;
|
||||
}
|
||||
@ -6042,9 +6045,10 @@
|
||||
QR.error("" + file.name + ": File too large (file: " + ($.bytesToString(file.size)) + ", max: " + ($.bytesToString(max)) + ").");
|
||||
} else if (_ref1 = file.type, __indexOf.call(QR.mimeTypes, _ref1) < 0) {
|
||||
QR.error("" + file.name + ": Unsupported file type.");
|
||||
} else if ((post = QR.posts[QR.posts.length - 1]).file) {
|
||||
post = new QR.post();
|
||||
} else {
|
||||
if ((post = QR.posts[QR.posts.length - 1]).file) {
|
||||
post = new QR.post();
|
||||
}
|
||||
post.setFile(file);
|
||||
}
|
||||
}
|
||||
@ -6459,6 +6463,9 @@
|
||||
},
|
||||
load: function() {
|
||||
var challenge;
|
||||
if (!this.nodes.challenge.firstChild) {
|
||||
return;
|
||||
}
|
||||
this.timeout = Date.now() + $.unsafeWindow.RecaptchaState.timeout * $.SECOND - $.MINUTE;
|
||||
challenge = this.nodes.challenge.firstChild.value;
|
||||
this.nodes.img.alt = challenge;
|
||||
|
||||
@ -39,9 +39,12 @@ $.extend $,
|
||||
return new FormData form
|
||||
fd = new FormData()
|
||||
for key, val of form
|
||||
if val instanceof Blob
|
||||
continue unless val
|
||||
# XXX GM bug
|
||||
# if val instanceof Blob
|
||||
if val.size and val.name
|
||||
fd.append key, val, val.name
|
||||
else if val
|
||||
else
|
||||
fd.append key, val
|
||||
fd
|
||||
ajax: (url, callbacks, opts={}) ->
|
||||
|
||||
@ -310,7 +310,7 @@ QR =
|
||||
QR.open()
|
||||
QR.fileInput files
|
||||
fileInput: (files) ->
|
||||
if files instanceof Event # file input
|
||||
if @ instanceof Element #or files instanceof Event # file input
|
||||
files = [@files...]
|
||||
QR.nodes.fileInput.value = null # Don't hold the files from being modified on windows
|
||||
{length} = files
|
||||
@ -339,9 +339,9 @@ QR =
|
||||
QR.error "#{file.name}: File too large (file: #{$.bytesToString file.size}, max: #{$.bytesToString max})."
|
||||
else unless file.type in QR.mimeTypes
|
||||
QR.error "#{file.name}: Unsupported file type."
|
||||
else if (post = QR.posts[QR.posts.length - 1]).file
|
||||
post = new QR.post()
|
||||
else
|
||||
if (post = QR.posts[QR.posts.length - 1]).file
|
||||
post = new QR.post()
|
||||
post.setFile file
|
||||
$.addClass QR.nodes.el, 'dump'
|
||||
resetThreadSelector: ->
|
||||
@ -627,6 +627,7 @@ QR =
|
||||
@count()
|
||||
$.set 'captchas', @captchas
|
||||
load: ->
|
||||
return unless @nodes.challenge.firstChild
|
||||
# -1 minute to give upload some time.
|
||||
@timeout = Date.now() + $.unsafeWindow.RecaptchaState.timeout * $.SECOND - $.MINUTE
|
||||
challenge = @nodes.challenge.firstChild.value
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user