Initial commit
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
const CoreView = require('backbone/core-view');
|
||||
const template = require('./flash-message.tpl');
|
||||
const checkAndBuildOpts = require('builder/helpers/required-opts');
|
||||
|
||||
const REQUIRED_OPTS = [
|
||||
'model'
|
||||
];
|
||||
|
||||
/**
|
||||
* View for a flash message to be displayed at the header.
|
||||
*/
|
||||
module.exports = CoreView.extend({
|
||||
initialize: function (options) {
|
||||
checkAndBuildOpts(options, REQUIRED_OPTS, this);
|
||||
|
||||
this.listenTo(this.model, 'change', this.render);
|
||||
},
|
||||
|
||||
render: function () {
|
||||
this.$el.toggle(this.model.shouldDisplay());
|
||||
|
||||
this.$el.html(
|
||||
template({
|
||||
str: this.model.get('msg'),
|
||||
type: this.model.get('type')
|
||||
})
|
||||
);
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
<div class="FlashMessage FlashMessage--<%- type %> CDB-Text">
|
||||
<div class="u-inner">
|
||||
<p class="FlashMessage-info"><%- str %></p>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user