cartodb-4.42/lib/assets/javascripts/cartodb/common/flash_message_view.js

29 lines
625 B
JavaScript
Raw Normal View History

2024-04-06 13:25:13 +08:00
var cdb = require('cartodb.js-v3');
/**
* View for a flash message to be displayed at the header.
*/
module.exports = cdb.core.View.extend({
initialize: function () {
if (!this.model) throw new Error('model is required');
this._template = cdb.templates.getTemplate('common/flash_message');
this.model.on('change', this.render, this);
},
render: function () {
this.$el.toggle(this.model.shouldDisplay());
this.$el.html(this._html());
return this;
},
_html: function () {
return this._template({
str: this.model.get('msg'),
type: this.model.get('type')
});
}
});