slight refactoring of the javascript
This commit is contained in:
committed by
Calen Pennington
parent
d35ff48e5b
commit
7791a7c4aa
@@ -233,32 +233,35 @@ function showFileSelectionMenu(e) {
|
||||
function startUpload(e) {
|
||||
$('.upload-modal h1').html('Uploading…');
|
||||
$('.upload-modal .file-name').html($('.file-input').val());
|
||||
|
||||
var bar = $('.upload-modal .progress-fill');
|
||||
|
||||
$('.upload-modal .file-chooser').ajaxSubmit({
|
||||
beforeSend: function() {
|
||||
var percentVal = '0%';
|
||||
bar.width(percentVal)
|
||||
bar.html(percentVal);
|
||||
},
|
||||
uploadProgress: function(event, position, total, percentComplete) {
|
||||
var percentVal = percentComplete + '%';
|
||||
bar.width(percentVal)
|
||||
bar.html(percentVal);
|
||||
},
|
||||
complete: function(xhr) {
|
||||
if(xhr.status = 200){
|
||||
markAsLoaded();
|
||||
}
|
||||
bar.html(xhr.responseText);
|
||||
$('.upload-modal .choose-file-button').html('Load Another File').show();
|
||||
}
|
||||
beforeSend: resetUploadBar,
|
||||
uploadProgress: showUploadFeedback,
|
||||
complete: displayFinishedUpload
|
||||
});
|
||||
$('.upload-modal .choose-file-button').hide();
|
||||
$('.upload-modal .progress-bar').removeClass('loaded').show();
|
||||
}
|
||||
|
||||
function resetUploadBar(){
|
||||
var percentVal = '0%';
|
||||
$('.upload-modal .progress-fill').width(percentVal)
|
||||
$('.upload-modal .progress-fill').html(percentVal);
|
||||
}
|
||||
|
||||
function showUploadFeedback(event, position, total, percentComplete) {
|
||||
var percentVal = percentComplete + '%';
|
||||
$('.upload-modal .progress-fill').width(percentVal);
|
||||
$('.upload-modal .progress-fill').html(percentVal);
|
||||
}
|
||||
|
||||
function displayFinishedUpload(xhr) {
|
||||
if(xhr.status = 200){
|
||||
markAsLoaded();
|
||||
}
|
||||
$('.upload-modal .progress-fill').html(xhr.responseText);
|
||||
$('.upload-modal .choose-file-button').html('Load Another File').show();
|
||||
}
|
||||
|
||||
function markAsLoaded() {
|
||||
$('.upload-modal .copy-button').css('display', 'inline-block');
|
||||
$('.upload-modal .progress-bar').addClass('loaded');
|
||||
|
||||
Reference in New Issue
Block a user