grapesjs
Version:
Free and Open Source Web Builder Framework
33 lines (29 loc) • 867 B
JavaScript
import DomainViews from 'domain_abstract/view/DomainViews';
import TraitView from './TraitView';
export default DomainViews.extend({
ns: 'Traits',
itemView: TraitView,
reuseView: 1,
initialize(o = {}) {
const config = o.config || {};
this.config = config;
this.em = o.editor;
this.pfx = config.stylePrefix || '';
this.ppfx = config.pStylePrefix || '';
this.className = this.pfx + 'traits';
const toListen = 'component:toggled';
this.listenTo(this.em, toListen, this.updatedCollection);
this.updatedCollection();
},
/**
* Update view collection
* @private
*/
updatedCollection() {
const ppfx = this.ppfx;
const comp = this.em.getSelected();
this.el.className = `${this.className} ${ppfx}one-bg ${ppfx}two-color`;
this.collection = comp ? comp.get('traits') : [];
this.render();
}
});