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,55 +10238,55 @@
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) {
var cv, error, errors, height, s, width, _i, _len; return function() {
errors = this.checkDimensions(el, isVideo); var cv, error, errors, height, s, width, _i, _len;
if (errors.length) { errors = _this.checkDimensions(el, isVideo);
for (_i = 0, _len = errors.length; _i < _len; _i++) { if (errors.length) {
error = errors[_i]; for (_i = 0, _len = errors.length; _i < _len; _i++) {
QR.error(error); error = errors[_i];
QR.error(error);
}
_this.URL = fileURL;
if ((QR.posts.length === 1) || (_this.com && _this.com.length)) {
return _this.rmFile();
} else {
return _this.rm();
}
} }
this.URL = fileURL; s = 90 * 2 * window.devicePixelRatio;
if ((QR.posts.length === 1) || (this.com && this.com.length)) { if (_this.file.type === 'image/gif') {
return this.rmFile(); s *= 3;
}
if (isVideo) {
height = el.videoHeight;
width = el.videoWidth;
} else { } else {
return this.rm(); height = el.height, width = el.width;
if (height < s || width < s) {
_this.URL = fileURL;
_this.nodes.el.style.backgroundImage = "url(" + _this.URL + ")";
return;
}
} }
} if (height <= width) {
s = 90 * 2 * window.devicePixelRatio; width = s / height * width;
if (this.file.type === 'image/gif') { height = s;
s *= 3; } else {
} height = s / width * height;
if (isVideo) { width = s;
height = el.videoHeight;
width = el.videoWidth;
} else {
height = el.height, width = el.width;
if (height < s || width < s) {
this.URL = fileURL;
this.nodes.el.style.backgroundImage = "url(" + this.URL + ")";
return;
} }
} cv = $.el('canvas');
if (height <= width) { cv.height = el.height = height;
width = s / height * width; cv.width = el.width = width;
height = s; cv.getContext('2d').drawImage(el, 0, 0, width, height);
} else { URL.revokeObjectURL(fileURL);
height = s / width * height; return cv.toBlob(function(blob) {
width = s;
}
cv = $.el('canvas');
cv.height = el.height = height;
cv.width = el.width = width;
cv.getContext('2d').drawImage(el, 0, 0, width, height);
URL.revokeObjectURL(fileURL);
return cv.toBlob((function(_this) {
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,55 +10252,55 @@
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) {
var cv, error, errors, height, s, width, _i, _len; return function() {
errors = this.checkDimensions(el, isVideo); var cv, error, errors, height, s, width, _i, _len;
if (errors.length) { errors = _this.checkDimensions(el, isVideo);
for (_i = 0, _len = errors.length; _i < _len; _i++) { if (errors.length) {
error = errors[_i]; for (_i = 0, _len = errors.length; _i < _len; _i++) {
QR.error(error); error = errors[_i];
QR.error(error);
}
_this.URL = fileURL;
if ((QR.posts.length === 1) || (_this.com && _this.com.length)) {
return _this.rmFile();
} else {
return _this.rm();
}
} }
this.URL = fileURL; s = 90 * 2 * window.devicePixelRatio;
if ((QR.posts.length === 1) || (this.com && this.com.length)) { if (_this.file.type === 'image/gif') {
return this.rmFile(); s *= 3;
}
if (isVideo) {
height = el.videoHeight;
width = el.videoWidth;
} else { } else {
return this.rm(); height = el.height, width = el.width;
if (height < s || width < s) {
_this.URL = fileURL;
_this.nodes.el.style.backgroundImage = "url(" + _this.URL + ")";
return;
}
} }
} if (height <= width) {
s = 90 * 2 * window.devicePixelRatio; width = s / height * width;
if (this.file.type === 'image/gif') { height = s;
s *= 3; } else {
} height = s / width * height;
if (isVideo) { width = s;
height = el.videoHeight;
width = el.videoWidth;
} else {
height = el.height, width = el.width;
if (height < s || width < s) {
this.URL = fileURL;
this.nodes.el.style.backgroundImage = "url(" + this.URL + ")";
return;
} }
} cv = $.el('canvas');
if (height <= width) { cv.height = el.height = height;
width = s / height * width; cv.width = el.width = width;
height = s; cv.getContext('2d').drawImage(el, 0, 0, width, height);
} else { URL.revokeObjectURL(fileURL);
height = s / width * height; return cv.toBlob(function(blob) {
width = s;
}
cv = $.el('canvas');
cv.height = el.height = height;
cv.width = el.width = width;
cv.getContext('2d').drawImage(el, 0, 0, width, height);
URL.revokeObjectURL(fileURL);
return cv.toBlob((function(_this) {
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