mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 04:25:55 +01:00
fix upload error messages
This commit is contained in:
@@ -13,7 +13,8 @@ define('uploader', function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
module.open = function(route, params, fileSize, callback) {
|
module.open = function(route, params, fileSize, callback) {
|
||||||
$('#upload-picture-modal').modal('show').removeClass('hide');
|
var uploadModal = $('#upload-picture-modal');
|
||||||
|
uploadModal.modal('show').removeClass('hide');
|
||||||
module.hideAlerts();
|
module.hideAlerts();
|
||||||
var uploadForm = $('#uploadForm');
|
var uploadForm = $('#uploadForm');
|
||||||
uploadForm[0].reset();
|
uploadForm[0].reset();
|
||||||
@@ -29,30 +30,30 @@ define('uploader', function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$('#pictureUploadSubmitBtn').off('click').on('click', function() {
|
$('#pictureUploadSubmitBtn').off('click').on('click', function() {
|
||||||
$('#uploadForm').submit();
|
uploadForm.submit();
|
||||||
});
|
});
|
||||||
|
|
||||||
uploadForm.off('submit').submit(function() {
|
uploadForm.off('submit').submit(function() {
|
||||||
|
|
||||||
function status(message) {
|
function status(message) {
|
||||||
module.hideAlerts();
|
module.hideAlerts();
|
||||||
$('#alert-status').text(message).removeClass('hide');
|
uploadModal.find('#alert-status').text(message).removeClass('hide');
|
||||||
}
|
}
|
||||||
|
|
||||||
function success(message) {
|
function success(message) {
|
||||||
module.hideAlerts();
|
module.hideAlerts();
|
||||||
$('#alert-success').text(message).removeClass('hide');
|
uploadModal.find('#alert-success').text(message).removeClass('hide');
|
||||||
}
|
}
|
||||||
|
|
||||||
function error(message) {
|
function error(message) {
|
||||||
module.hideAlerts();
|
module.hideAlerts();
|
||||||
$('#alert-error').text(message).removeClass('hide');
|
uploadModal.find('#alert-error').text(message).removeClass('hide');
|
||||||
}
|
}
|
||||||
|
|
||||||
status('uploading the file ...');
|
status('uploading the file ...');
|
||||||
|
|
||||||
$('#upload-progress-bar').css('width', '0%');
|
uploadModal.find('#upload-progress-bar').css('width', '0%');
|
||||||
$('#upload-progress-box').show().removeClass('hide');
|
uploadModal.find('#upload-progress-box').show().removeClass('hide');
|
||||||
|
|
||||||
if (!$('#userPhotoInput').val()) {
|
if (!$('#userPhotoInput').val()) {
|
||||||
error('select an image to upload!');
|
error('select an image to upload!');
|
||||||
@@ -66,7 +67,7 @@ define('uploader', function() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
uploadProgress: function(event, position, total, percent) {
|
uploadProgress: function(event, position, total, percent) {
|
||||||
$('#upload-progress-bar').css('width', percent + '%');
|
uploadModal.find('#upload-progress-bar').css('width', percent + '%');
|
||||||
},
|
},
|
||||||
|
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
@@ -81,7 +82,7 @@ define('uploader', function() {
|
|||||||
success('File uploaded successfully!');
|
success('File uploaded successfully!');
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
module.hideAlerts();
|
module.hideAlerts();
|
||||||
$('#upload-picture-modal').modal('hide');
|
uploadModal.modal('hide');
|
||||||
}, 750);
|
}, 750);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -91,10 +92,11 @@ define('uploader', function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
module.hideAlerts = function() {
|
module.hideAlerts = function() {
|
||||||
$('#alert-status').addClass('hide');
|
var uploadModal = $('#upload-picture-modal');
|
||||||
$('#alert-success').addClass('hide');
|
uploadModal.find('#alert-status').addClass('hide');
|
||||||
$('#alert-error').addClass('hide');
|
uploadModal.find('#alert-success').addClass('hide');
|
||||||
$('#upload-progress-box').addClass('hide');
|
uploadModal.find('#alert-error').addClass('hide');
|
||||||
|
uploadModal.find('#upload-progress-box').addClass('hide');
|
||||||
};
|
};
|
||||||
|
|
||||||
return module;
|
return module;
|
||||||
|
|||||||
Reference in New Issue
Block a user