Commit 7791a7c4 by Lyla Fischer Committed by Calen Pennington

slight refactoring of the javascript

parent d35ff48e
...@@ -233,30 +233,33 @@ function showFileSelectionMenu(e) { ...@@ -233,30 +233,33 @@ function showFileSelectionMenu(e) {
function startUpload(e) { function startUpload(e) {
$('.upload-modal h1').html('Uploading…'); $('.upload-modal h1').html('Uploading…');
$('.upload-modal .file-name').html($('.file-input').val()); $('.upload-modal .file-name').html($('.file-input').val());
var bar = $('.upload-modal .progress-fill');
$('.upload-modal .file-chooser').ajaxSubmit({ $('.upload-modal .file-chooser').ajaxSubmit({
beforeSend: function() { beforeSend: resetUploadBar,
uploadProgress: showUploadFeedback,
complete: displayFinishedUpload
});
$('.upload-modal .choose-file-button').hide();
$('.upload-modal .progress-bar').removeClass('loaded').show();
}
function resetUploadBar(){
var percentVal = '0%'; var percentVal = '0%';
bar.width(percentVal) $('.upload-modal .progress-fill').width(percentVal)
bar.html(percentVal); $('.upload-modal .progress-fill').html(percentVal);
}, }
uploadProgress: function(event, position, total, percentComplete) {
function showUploadFeedback(event, position, total, percentComplete) {
var percentVal = percentComplete + '%'; var percentVal = percentComplete + '%';
bar.width(percentVal) $('.upload-modal .progress-fill').width(percentVal);
bar.html(percentVal); $('.upload-modal .progress-fill').html(percentVal);
}, }
complete: function(xhr) {
function displayFinishedUpload(xhr) {
if(xhr.status = 200){ if(xhr.status = 200){
markAsLoaded(); markAsLoaded();
} }
bar.html(xhr.responseText); $('.upload-modal .progress-fill').html(xhr.responseText);
$('.upload-modal .choose-file-button').html('Load Another File').show(); $('.upload-modal .choose-file-button').html('Load Another File').show();
}
});
$('.upload-modal .choose-file-button').hide();
$('.upload-modal .progress-bar').removeClass('loaded').show();
} }
function markAsLoaded() { function markAsLoaded() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment