Indicate filesize and max filesize in case of too large selected files.
This commit is contained in:
parent
c746f9b7e6
commit
4fb824c304
@ -4395,7 +4395,7 @@
|
|||||||
if (this.files.length === 1) {
|
if (this.files.length === 1) {
|
||||||
file = this.files[0];
|
file = this.files[0];
|
||||||
if (file.size > this.max) {
|
if (file.size > this.max) {
|
||||||
QR.error('File too large.');
|
QR.error("File too large (file: " + ($.bytesToString(file.size)) + ", max: " + ($.bytesToString(this.max)) + ").");
|
||||||
QR.resetFileInput();
|
QR.resetFileInput();
|
||||||
} else if (-1 === QR.mimeTypes.indexOf(file.type)) {
|
} else if (-1 === QR.mimeTypes.indexOf(file.type)) {
|
||||||
QR.error('Unsupported file type.');
|
QR.error('Unsupported file type.');
|
||||||
@ -4409,7 +4409,7 @@
|
|||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
file = _ref[_i];
|
file = _ref[_i];
|
||||||
if (file.size > this.max) {
|
if (file.size > this.max) {
|
||||||
QR.error("File " + file.name + " is too large (" + ($.bytesToString(file.size)) + ").");
|
QR.error("File " + file.name + " is too large (file: " + ($.bytesToString(file.size)) + ", max: " + ($.bytesToString(this.max)) + ").");
|
||||||
} else if (-1 === QR.mimeTypes.indexOf(file.type)) {
|
} else if (-1 === QR.mimeTypes.indexOf(file.type)) {
|
||||||
QR.error("" + file.name + ": Unsupported file type.");
|
QR.error("" + file.name + ": Unsupported file type.");
|
||||||
}
|
}
|
||||||
@ -4472,7 +4472,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
_Class.prototype.setFile = function(file) {
|
_Class.prototype.setFile = function(file) {
|
||||||
var fileUrl, img,
|
var fileURL, img,
|
||||||
_this = this;
|
_this = this;
|
||||||
this.file = file;
|
this.file = file;
|
||||||
this.el.title = "" + file.name + " (" + ($.bytesToString(file.size)) + ")";
|
this.el.title = "" + file.name + " (" + ($.bytesToString(file.size)) + ")";
|
||||||
@ -4487,13 +4487,13 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
URL.revokeObjectURL(this.url);
|
URL.revokeObjectURL(this.url);
|
||||||
fileUrl = url.createObjectURL(file);
|
fileURL = URL.createObjectURL(file);
|
||||||
img = $.el('img');
|
img = $.el('img');
|
||||||
$.on(img, 'load', function() {
|
$.on(img, 'load', function() {
|
||||||
var c, data, i, l, s, ui8a, _i;
|
var c, data, i, l, s, ui8a, _i;
|
||||||
s = 90 * 3;
|
s = 90 * 3;
|
||||||
if (img.height < s || img.width < s) {
|
if (img.height < s || img.width < s) {
|
||||||
_this.url = fileUrl;
|
_this.url = fileURL;
|
||||||
_this.el.style.backgroundImage = "url(" + _this.url + ")";
|
_this.el.style.backgroundImage = "url(" + _this.url + ")";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -4518,9 +4518,9 @@
|
|||||||
type: 'image/png'
|
type: 'image/png'
|
||||||
}));
|
}));
|
||||||
_this.el.style.backgroundImage = "url(" + _this.url + ")";
|
_this.el.style.backgroundImage = "url(" + _this.url + ")";
|
||||||
return URL.revokeObjectURL(fileUrl);
|
return URL.revokeObjectURL(fileURL);
|
||||||
});
|
});
|
||||||
return img.src = fileUrl;
|
return img.src = fileURL;
|
||||||
};
|
};
|
||||||
|
|
||||||
_Class.prototype.rmFile = function() {
|
_Class.prototype.rmFile = function() {
|
||||||
|
|||||||
@ -290,7 +290,7 @@ QR =
|
|||||||
if @files.length is 1
|
if @files.length is 1
|
||||||
file = @files[0]
|
file = @files[0]
|
||||||
if file.size > @max
|
if file.size > @max
|
||||||
QR.error 'File too large.'
|
QR.error "File too large (file: #{$.bytesToString file.size}, max: #{$.bytesToString @max})."
|
||||||
QR.resetFileInput()
|
QR.resetFileInput()
|
||||||
else if -1 is QR.mimeTypes.indexOf file.type
|
else if -1 is QR.mimeTypes.indexOf file.type
|
||||||
QR.error 'Unsupported file type.'
|
QR.error 'Unsupported file type.'
|
||||||
@ -301,7 +301,7 @@ QR =
|
|||||||
# Create new replies with these files.
|
# Create new replies with these files.
|
||||||
for file in @files
|
for file in @files
|
||||||
if file.size > @max
|
if file.size > @max
|
||||||
QR.error "File #{file.name} is too large (#{$.bytesToString file.size})."
|
QR.error "File #{file.name} is too large (file: #{$.bytesToString file.size}, max: #{$.bytesToString @max})."
|
||||||
else if -1 is QR.mimeTypes.indexOf file.type
|
else if -1 is QR.mimeTypes.indexOf file.type
|
||||||
QR.error "#{file.name}: Unsupported file type."
|
QR.error "#{file.name}: Unsupported file type."
|
||||||
unless QR.replies[QR.replies.length - 1].file
|
unless QR.replies[QR.replies.length - 1].file
|
||||||
@ -361,7 +361,7 @@ QR =
|
|||||||
URL.revokeObjectURL @url
|
URL.revokeObjectURL @url
|
||||||
|
|
||||||
# Create a redimensioned thumbnail.
|
# Create a redimensioned thumbnail.
|
||||||
fileUrl = url.createObjectURL file
|
fileURL = URL.createObjectURL file
|
||||||
img = $.el 'img'
|
img = $.el 'img'
|
||||||
|
|
||||||
$.on img, 'load', =>
|
$.on img, 'load', =>
|
||||||
@ -371,7 +371,7 @@ QR =
|
|||||||
# to avoid crappy resized quality.
|
# to avoid crappy resized quality.
|
||||||
s = 90*3
|
s = 90*3
|
||||||
if img.height < s or img.width < s
|
if img.height < s or img.width < s
|
||||||
@url = fileUrl
|
@url = fileURL
|
||||||
@el.style.backgroundImage = "url(#{@url})"
|
@el.style.backgroundImage = "url(#{@url})"
|
||||||
return
|
return
|
||||||
if img.height <= img.width
|
if img.height <= img.width
|
||||||
@ -395,9 +395,9 @@ QR =
|
|||||||
|
|
||||||
@url = URL.createObjectURL new Blob [ui8a], type: 'image/png'
|
@url = URL.createObjectURL new Blob [ui8a], type: 'image/png'
|
||||||
@el.style.backgroundImage = "url(#{@url})"
|
@el.style.backgroundImage = "url(#{@url})"
|
||||||
URL.revokeObjectURL fileUrl
|
URL.revokeObjectURL fileURL
|
||||||
|
|
||||||
img.src = fileUrl
|
img.src = fileURL
|
||||||
rmFile: ->
|
rmFile: ->
|
||||||
QR.resetFileInput()
|
QR.resetFileInput()
|
||||||
delete @file
|
delete @file
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user