Skip to content

Commit

Permalink
Properly binds "this" in uploader.js
Browse files Browse the repository at this point in the history
  • Loading branch information
garyc40 committed Dec 1, 2015
1 parent c884e67 commit e4c10c9
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions core/client/app/assets/lib/uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ let UploadUi = function ($dropzone, settings) {
}));

$.extend(this, {
complete(result) {
function showImage(width, height) {
complete: (result) => {
let showImage = (width, height) => {
$dropzone.find('img.js-upload-target').attr({width, height}).css({display: 'block'});
$dropzone.find('.fileupload-loading').remove();
$dropzone.css({height: 'auto'});
$dropzone.delay(250).animate({opacity: 100}, 1000, () => {
$('.js-button-accept').prop('disabled', false);
this.init();
});
}
};

function animateDropzone($img) {
let animateDropzone = ($img) => {
$dropzone.animate({opacity: 0}, 250, () => {
$dropzone.removeClass('image-uploader').addClass('pre-image-uploader');
$dropzone.css({minHeight: 0});
Expand All @@ -36,9 +36,9 @@ let UploadUi = function ($dropzone, settings) {
showImage($img.width(), $img.height());
});
});
}
};

function preLoadImage() {
let preLoadImage = () => {
let $img = $dropzone.find('img.js-upload-target')
.attr({src: '', width: 'auto', height: 'auto'});

Expand All @@ -49,7 +49,7 @@ let UploadUi = function ($dropzone, settings) {
$dropzone.trigger('uploadsuccess', [result]);
animateDropzone($img);
}).attr('src', result);
}
};
preLoadImage();
},

Expand Down Expand Up @@ -82,7 +82,7 @@ let UploadUi = function ($dropzone, settings) {
$progress.find('.js-upload-progress-bar').css('width', `${progress}%`);
}
},
fail(e, data) {
fail: (e, data) => {
/*jshint unused:false*/
$('.js-button-accept').prop('disabled', false);
$dropzone.trigger('uploadfailure', [data.result]);
Expand All @@ -102,7 +102,7 @@ let UploadUi = function ($dropzone, settings) {
this.init();
});
},
done(e, data) {
done: (e, data) => {
/*jshint unused:false*/
this.complete(data.result);
}
Expand Down

0 comments on commit e4c10c9

Please sign in to comment.