33 lines
869 B
JavaScript
33 lines
869 B
JavaScript
const _ = require('underscore');
|
|
const Backbone = require('backbone');
|
|
|
|
const templates = require('./templates');
|
|
|
|
const EventItemView = Backbone.View.extend({
|
|
'tagName': 'div',
|
|
'className': 'itemRow mui-row',
|
|
'template': _.template('<div>Not set</div>'),
|
|
'initialize': function() {
|
|
if (templates.hasOwnProperty(this.model.get('type')))
|
|
this.template = templates[this.model.get('type')];
|
|
this.listenTo(this.model, 'change', this.onChange);
|
|
|
|
this.render();
|
|
},
|
|
'onChange': function() {
|
|
this.render();
|
|
},
|
|
'render': function() {
|
|
this.$el.html(this.template(this.model.toJSON()));
|
|
},
|
|
'updateVisibility': function() {
|
|
let visibleClass = '';
|
|
if (active !== null)
|
|
visibleClass = (active === true) ? 'active' : 'notActive' ;
|
|
|
|
this.model.set('visibleClass', visibleClass) ;
|
|
}
|
|
});
|
|
|
|
module.exports = EventItemView;
|