Files
Phraseanet/www/scripts/apps/admin/fields/views/alert.js
Nicolas Le Goff b52e4ee8c0 Address PR comment's
Fix tests
2013-05-27 23:26:49 +02:00

47 lines
1.1 KiB
JavaScript

/*
* This file is part of Phraseanet
*
* (c) 2005-2013 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
define([
"jquery",
"underscore",
"backbone",
"i18n",
"bootstrap"
], function($, _, Backbone, i18n, bootstrap) {
var AlertView = Backbone.View.extend({
tagName: "div",
className: "alert",
initialize: function(options) {
var self = this;
if (options) {
this.alert = options.alert || "info";
this.message = options.message || "";
}
// remove view when alert is closed
this.$el.bind("closed", function () {
self.remove();
});
},
render: function() {
var template = _.template($("#alert_template").html(), {
msg: this.message
});
this.$el.addClass("alert-" + this.alert).html(template).alert();
$(".block-alert").empty().append(this.$el);
return this;
}
});
return AlertView;
});