29 lines
625 B
JavaScript
29 lines
625 B
JavaScript
|
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')
|
||
|
});
|
||
|
}
|
||
|
});
|