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) {
|
if (options) {
|
||||||
this.alert = options.alert || "info";
|
this.alert = options.alert || "info";
|
||||||
this.message = options.message || "";
|
this.message = options.message || "";
|
||||||
|
this.delay = parseInt(options.delay, 10) || 0;
|
||||||
}
|
}
|
||||||
// remove view when alert is closed
|
// remove view when alert is closed
|
||||||
this.$el.bind("closed", function () {
|
this.$el.bind("closed", function () {
|
||||||
@@ -30,12 +31,17 @@ define([
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
|
var self = this;
|
||||||
var template = _.template($("#alert_template").html(), {
|
var template = _.template($("#alert_template").html(), {
|
||||||
msg: this.message
|
msg: this.message
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$el.addClass("alert-" + this.alert).html(template).alert();
|
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);
|
$(".block-alert").empty().append(this.$el);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
@@ -59,7 +59,8 @@ define([
|
|||||||
|
|
||||||
new AlertView({
|
new AlertView({
|
||||||
alert: "success",
|
alert: "success",
|
||||||
message: i18n.t("fields_save")
|
message: i18n.t("fields_save"),
|
||||||
|
delay: 2000
|
||||||
}).render();
|
}).render();
|
||||||
},
|
},
|
||||||
error: function(xhr, textStatus, errorThrown) {
|
error: function(xhr, textStatus, errorThrown) {
|
||||||
|
Reference in New Issue
Block a user