ui: Add ability to hide ui feedback messages.

This adds the option to hide the container element after a given
duration in the message and success functions in the ui_report module.
This commit is contained in:
Armaan Ahluwalia
2018-03-30 05:52:33 +05:30
committed by Tim Abbott
parent 605916f6d7
commit 95634b9d17

View File

@@ -9,7 +9,7 @@ var exports = {};
type- used to define more complex logic for special cases
*/
exports.message = function (response, status_box, cls, type) {
exports.message = function (response, status_box, cls, type, remove_after) {
if (cls === undefined) {
cls = 'alert';
}
@@ -22,7 +22,11 @@ exports.message = function (response, status_box, cls, type) {
// via i18n.t when interpolating data.
status_box.removeClass(common.status_classes).addClass(cls)
.html(response).stop(true).fadeTo(0, 1);
if (remove_after) {
setTimeout(function () {
status_box.fadeTo(200, 0);
}, remove_after);
}
status_box.addClass("show");
};
@@ -45,8 +49,8 @@ exports.error = function (response, xhr, status_box, type) {
exports.message(response, status_box, 'alert-error', type);
};
exports.success = function (response, status_box, type) {
exports.message(response, status_box, 'alert-success', type);
exports.success = function (response, status_box, type, remove_after) {
exports.message(response, status_box, 'alert-success', type, remove_after);
};
exports.generic_embed_error = function (error) {