Skip to content

Commit

Permalink
final edits
Browse files Browse the repository at this point in the history
  • Loading branch information
eamahanna committed Oct 16, 2020
1 parent db01bfd commit 31dc8e0
Showing 1 changed file with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ define([
.on('addedfile', (file) => {
$dropzoneElem.find('#global-info').css({'display': 'inline'});
$dropzoneElem.find('#upload-message').text(this.makeUploadMessage());
console.log("ADDED FILE")

})
.on('success', (file, serverResponse) => {
Expand All @@ -100,12 +99,10 @@ define([
$($dropzoneElem.find('#total-progress')).fadeOut(1000, function() {
$($dropzoneElem.find('#total-progress .progress-bar')).css({'width': '0%'});
});
console.log("SUCCESS 1")
}
$(file.previewElement).fadeOut(1000, function() {
$(file.previewElement.querySelector('.btn')).trigger('click');
});
console.log("SUCCESS 2")
})
.on('sending', (file, xhr, data) => {
$dropzoneElem.find('#global-info').css({'display': 'inline'});
Expand All @@ -121,30 +118,38 @@ define([
}
$($dropzoneElem.find('#total-progress')).show();
$dropzoneElem.find('#upload-message').text(this.makeUploadMessage());
console.log("SENDING")
})
.on('reset', function() {
$dropzoneElem.find('#global-info').css({'display': 'none'});
$($dropzoneElem.find('#total-progress .progress-bar')).css({'width': '0%'});
console.log("RESET")
})
.on('error', (err) => {
let errorText = 'unable to upload file!';
if (err && err.xhr && err.xhr.responseText) {
errorText = err.xhr.responseText;
}
$dropzoneElem.find('.error.text-danger').text('Error: ' + errorText);
$dropzoneElem.append(this.makeClearAllButton());
$('#clear-all-btn').on('click', function(e){this.removeAllFiles()});
if (!$dropzoneElem.find('#clear-all-btn').length){
$dropzoneElem.append(this.makeClearAllButton());
} else {
$('#clear-all-btn-container').remove();
$('#clear-all-btn').remove();
$dropzoneElem.append(this.makeClearAllButton());
}
});
},

makeClearAllButton: () => {
makeClearAllButton: function() {
var $clearAllBtn = $('<button>')
.text('Clear All')
.addClass('text-button clear-all-dropzone')
.attr('aria-label', 'clear all files from the dropzone')
.attr('id', 'clear-all-btn');
.attr('id', 'clear-all-btn')
.click(function(){
this.dropzone.removeAllFiles();
$('#clear-all-btn-container').remove();
$('#clear-all-btn').remove();
}.bind(this));

var $buttonContainer = $('<div>')
.attr('id', 'clear-all-btn-container')
Expand All @@ -154,13 +159,6 @@ define([
return $buttonContainer;
},

removeAllFiles: () => {
this.dropzone.processQueue();
this.dropzone.removeFile();
$('#clear-all-btn-container').remove();
$('clear-all-btn').remove();
},

makeUploadMessage: function() {
if (!this.dropzone) {
return 'No files uploading.';
Expand Down

0 comments on commit 31dc8e0

Please sign in to comment.