mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 11:33:17 +00:00
Fix #1335 Auto close alert after delay
This commit is contained in:
@@ -23,6 +23,7 @@ define([
|
||||
if (options) {
|
||||
this.alert = options.alert || "info";
|
||||
this.message = options.message || "";
|
||||
this.delay = parseInt(options.delay, 10) || 0;
|
||||
}
|
||||
// remove view when alert is closed
|
||||
this.$el.bind("closed", function () {
|
||||
@@ -30,12 +31,17 @@ define([
|
||||
});
|
||||
},
|
||||
render: function() {
|
||||
var self = this;
|
||||
var template = _.template($("#alert_template").html(), {
|
||||
msg: this.message
|
||||
});
|
||||
|
||||
this.$el.addClass("alert-" + this.alert).html(template).alert();
|
||||
|
||||
if (this.delay > 0) {
|
||||
window.setTimeout(function() { self.$el.alert('close') }, this.delay);
|
||||
}
|
||||
|
||||
$(".block-alert").empty().append(this.$el);
|
||||
|
||||
return this;
|
||||
|
@@ -59,7 +59,8 @@ define([
|
||||
|
||||
new AlertView({
|
||||
alert: "success",
|
||||
message: i18n.t("fields_save")
|
||||
message: i18n.t("fields_save"),
|
||||
delay: 2000
|
||||
}).render();
|
||||
},
|
||||
error: function(xhr, textStatus, errorThrown) {
|
||||
|
Reference in New Issue
Block a user