0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Merge pull request #6147 from garyc40/bug-uploader-bind

Properly binds "this" in uploader.js
This commit is contained in:
Kevin Ansfield 2015-12-01 13:08:00 +00:00
commit 063f2c318c

View file

@ -16,8 +16,8 @@ let UploadUi = function ($dropzone, settings) {
})); }));
$.extend(this, { $.extend(this, {
complete(result) { complete: (result) => {
function showImage(width, height) { let showImage = (width, height) => {
$dropzone.find('img.js-upload-target').attr({width, height}).css({display: 'block'}); $dropzone.find('img.js-upload-target').attr({width, height}).css({display: 'block'});
$dropzone.find('.fileupload-loading').remove(); $dropzone.find('.fileupload-loading').remove();
$dropzone.css({height: 'auto'}); $dropzone.css({height: 'auto'});
@ -25,9 +25,9 @@ let UploadUi = function ($dropzone, settings) {
$('.js-button-accept').prop('disabled', false); $('.js-button-accept').prop('disabled', false);
this.init(); this.init();
}); });
} };
function animateDropzone($img) { let animateDropzone = ($img) => {
$dropzone.animate({opacity: 0}, 250, () => { $dropzone.animate({opacity: 0}, 250, () => {
$dropzone.removeClass('image-uploader').addClass('pre-image-uploader'); $dropzone.removeClass('image-uploader').addClass('pre-image-uploader');
$dropzone.css({minHeight: 0}); $dropzone.css({minHeight: 0});
@ -36,9 +36,9 @@ let UploadUi = function ($dropzone, settings) {
showImage($img.width(), $img.height()); showImage($img.width(), $img.height());
}); });
}); });
} };
function preLoadImage() { let preLoadImage = () => {
let $img = $dropzone.find('img.js-upload-target') let $img = $dropzone.find('img.js-upload-target')
.attr({src: '', width: 'auto', height: 'auto'}); .attr({src: '', width: 'auto', height: 'auto'});
@ -49,7 +49,7 @@ let UploadUi = function ($dropzone, settings) {
$dropzone.trigger('uploadsuccess', [result]); $dropzone.trigger('uploadsuccess', [result]);
animateDropzone($img); animateDropzone($img);
}).attr('src', result); }).attr('src', result);
} };
preLoadImage(); preLoadImage();
}, },
@ -82,7 +82,7 @@ let UploadUi = function ($dropzone, settings) {
$progress.find('.js-upload-progress-bar').css('width', `${progress}%`); $progress.find('.js-upload-progress-bar').css('width', `${progress}%`);
} }
}, },
fail(e, data) { fail: (e, data) => {
/*jshint unused:false*/ /*jshint unused:false*/
$('.js-button-accept').prop('disabled', false); $('.js-button-accept').prop('disabled', false);
$dropzone.trigger('uploadfailure', [data.result]); $dropzone.trigger('uploadfailure', [data.result]);
@ -102,7 +102,7 @@ let UploadUi = function ($dropzone, settings) {
this.init(); this.init();
}); });
}, },
done(e, data) { done: (e, data) => {
/*jshint unused:false*/ /*jshint unused:false*/
this.complete(data.result); this.complete(data.result);
} }