This shouldn't have worked.

This commit is contained in:
Zixaphir 2014-12-12 03:14:14 -07:00
parent 70d10d8655
commit 2aa77d2207
3 changed files with 87 additions and 87 deletions

View File

@ -10238,23 +10238,24 @@
var el, fileURL, isVideo; var el, fileURL, isVideo;
isVideo = /^video\//.test(this.file.type); isVideo = /^video\//.test(this.file.type);
el = $.el((isVideo ? 'video' : 'img')); el = $.el((isVideo ? 'video' : 'img'));
$.on(el, (isVideo ? 'loadeddata' : 'load'), function() { $.on(el, (isVideo ? 'loadeddata' : 'load'), (function(_this) {
return function() {
var cv, error, errors, height, s, width, _i, _len; var cv, error, errors, height, s, width, _i, _len;
errors = this.checkDimensions(el, isVideo); errors = _this.checkDimensions(el, isVideo);
if (errors.length) { if (errors.length) {
for (_i = 0, _len = errors.length; _i < _len; _i++) { for (_i = 0, _len = errors.length; _i < _len; _i++) {
error = errors[_i]; error = errors[_i];
QR.error(error); QR.error(error);
} }
this.URL = fileURL; _this.URL = fileURL;
if ((QR.posts.length === 1) || (this.com && this.com.length)) { if ((QR.posts.length === 1) || (_this.com && _this.com.length)) {
return this.rmFile(); return _this.rmFile();
} else { } else {
return this.rm(); return _this.rm();
} }
} }
s = 90 * 2 * window.devicePixelRatio; s = 90 * 2 * window.devicePixelRatio;
if (this.file.type === 'image/gif') { if (_this.file.type === 'image/gif') {
s *= 3; s *= 3;
} }
if (isVideo) { if (isVideo) {
@ -10263,8 +10264,8 @@
} else { } else {
height = el.height, width = el.width; height = el.height, width = el.width;
if (height < s || width < s) { if (height < s || width < s) {
this.URL = fileURL; _this.URL = fileURL;
this.nodes.el.style.backgroundImage = "url(" + this.URL + ")"; _this.nodes.el.style.backgroundImage = "url(" + _this.URL + ")";
return; return;
} }
} }
@ -10280,13 +10281,12 @@
cv.width = el.width = width; cv.width = el.width = width;
cv.getContext('2d').drawImage(el, 0, 0, width, height); cv.getContext('2d').drawImage(el, 0, 0, width, height);
URL.revokeObjectURL(fileURL); URL.revokeObjectURL(fileURL);
return cv.toBlob((function(_this) { return cv.toBlob(function(blob) {
return function(blob) {
_this.URL = URL.createObjectURL(blob); _this.URL = URL.createObjectURL(blob);
return _this.nodes.el.style.backgroundImage = "url(" + _this.URL + ")"; return _this.nodes.el.style.backgroundImage = "url(" + _this.URL + ")";
});
}; };
})(this)); })(this));
});
fileURL = URL.createObjectURL(this.file); fileURL = URL.createObjectURL(this.file);
return el.src = fileURL; return el.src = fileURL;
}; };

View File

@ -10252,23 +10252,24 @@
var el, fileURL, isVideo; var el, fileURL, isVideo;
isVideo = /^video\//.test(this.file.type); isVideo = /^video\//.test(this.file.type);
el = $.el((isVideo ? 'video' : 'img')); el = $.el((isVideo ? 'video' : 'img'));
$.on(el, (isVideo ? 'loadeddata' : 'load'), function() { $.on(el, (isVideo ? 'loadeddata' : 'load'), (function(_this) {
return function() {
var cv, error, errors, height, s, width, _i, _len; var cv, error, errors, height, s, width, _i, _len;
errors = this.checkDimensions(el, isVideo); errors = _this.checkDimensions(el, isVideo);
if (errors.length) { if (errors.length) {
for (_i = 0, _len = errors.length; _i < _len; _i++) { for (_i = 0, _len = errors.length; _i < _len; _i++) {
error = errors[_i]; error = errors[_i];
QR.error(error); QR.error(error);
} }
this.URL = fileURL; _this.URL = fileURL;
if ((QR.posts.length === 1) || (this.com && this.com.length)) { if ((QR.posts.length === 1) || (_this.com && _this.com.length)) {
return this.rmFile(); return _this.rmFile();
} else { } else {
return this.rm(); return _this.rm();
} }
} }
s = 90 * 2 * window.devicePixelRatio; s = 90 * 2 * window.devicePixelRatio;
if (this.file.type === 'image/gif') { if (_this.file.type === 'image/gif') {
s *= 3; s *= 3;
} }
if (isVideo) { if (isVideo) {
@ -10277,8 +10278,8 @@
} else { } else {
height = el.height, width = el.width; height = el.height, width = el.width;
if (height < s || width < s) { if (height < s || width < s) {
this.URL = fileURL; _this.URL = fileURL;
this.nodes.el.style.backgroundImage = "url(" + this.URL + ")"; _this.nodes.el.style.backgroundImage = "url(" + _this.URL + ")";
return; return;
} }
} }
@ -10294,13 +10295,12 @@
cv.width = el.width = width; cv.width = el.width = width;
cv.getContext('2d').drawImage(el, 0, 0, width, height); cv.getContext('2d').drawImage(el, 0, 0, width, height);
URL.revokeObjectURL(fileURL); URL.revokeObjectURL(fileURL);
return cv.toBlob((function(_this) { return cv.toBlob(function(blob) {
return function(blob) {
_this.URL = URL.createObjectURL(blob); _this.URL = URL.createObjectURL(blob);
return _this.nodes.el.style.backgroundImage = "url(" + _this.URL + ")"; return _this.nodes.el.style.backgroundImage = "url(" + _this.URL + ")";
});
}; };
})(this)); })(this));
});
fileURL = URL.createObjectURL(this.file); fileURL = URL.createObjectURL(this.file);
return el.src = fileURL; return el.src = fileURL;
}; };

View File

@ -182,7 +182,7 @@ QR.post = class
isVideo = /^video\//.test @file.type isVideo = /^video\//.test @file.type
el = $.el (if isVideo then 'video' else 'img') el = $.el (if isVideo then 'video' else 'img')
$.on el, (if isVideo then 'loadeddata' else 'load'), -> $.on el, (if isVideo then 'loadeddata' else 'load'), =>
# Verify element dimensions. # Verify element dimensions.
errors = @checkDimensions el, isVideo errors = @checkDimensions el, isVideo
if errors.length if errors.length