Consolidate report_{message,success,error}

(imported from commit 21deb6a41438bf7697bd8a3c46a428ca0034f2b0)
This commit is contained in:
Keegan McAllister 2012-10-31 18:38:34 -04:00
parent 807fab6760
commit ca25c4d4a5
1 changed files with 11 additions and 12 deletions

View File

@ -39,6 +39,15 @@ function show_email(message_id) {
rows.get(message_id).find('.sender_email').removeClass('invisible');
}
function report_message(response, status_box, cls) {
if (cls === undefined)
cls = 'alert';
status_box.removeClass(status_classes).addClass(cls)
.text(response).stop(true).fadeTo(0, 1);
status_box.show();
}
function report_error(response, xhr, status_box) {
if (xhr.status.toString().charAt(0) === "4") {
// Only display the error response for 4XX, where we've crafted
@ -46,21 +55,11 @@ function report_error(response, xhr, status_box) {
response += ": " + $.parseJSON(xhr.responseText).msg;
}
status_box.removeClass(status_classes).addClass('alert-error')
.text(response).stop(true).fadeTo(0, 1);
status_box.show();
report_message(response, status_box, 'alert-error');
}
function report_success(response, status_box) {
status_box.removeClass(status_classes).addClass('alert-success')
.text(response).stop(true).fadeTo(0, 1);
status_box.show();
}
function report_message(response, status_box) {
status_box.removeClass(status_classes).addClass('alert')
.text(response).stop(true).fadeTo(0, 1);
status_box.show();
report_message(response, status_box, 'alert-success');
}
var clicking = false;