diff --git a/src/style_manager/index.js b/src/style_manager/index.js index 5d11c66a1..06269eda9 100644 --- a/src/style_manager/index.js +++ b/src/style_manager/index.js @@ -53,6 +53,11 @@ import Properties from './model/Properties'; import PropertyFactory from './model/PropertyFactory'; import SectorsView from './view/SectorsView'; +export const evAll = 'style'; +export const evPfx = `${evAll}:`; +export const evPropUp = `${evPfx}property:update`; +export const evCustom = `${evPfx}custom`; + export default () => { var c = {}; let properties; @@ -65,11 +70,12 @@ export default () => { PropertyFactory: PropertyFactory(), - /** - * Name of the module - * @type {String} - * @private - */ + events: { + all: evAll, + propertyUpdate: evPropUp, + custom: evCustom + }, + name: 'StyleManager', /** @@ -101,13 +107,21 @@ export default () => { toListen, debounce((...args) => { this.select(em.getSelectedAll()); - em.trigger('style:custom'); + this.__trgCustom(); }) ); return this; }, + __trgCustom() { + this.em.trigger(this.events.custom); + }, + + __trgEv(event, ...data) { + this.em.trigger(event, ...data); + }, + onLoad() { // Use silent as sectors' view will be created and rendered on StyleManager.render sectors.add(c.sectors, { silent: true }); diff --git a/src/style_manager/model/Property.js b/src/style_manager/model/Property.js index 78dd71eaf..61e02b61a 100644 --- a/src/style_manager/model/Property.js +++ b/src/style_manager/model/Property.js @@ -23,13 +23,13 @@ export default class Property extends Model { const name = this.getName(); const value = this.getFullValue(); - const changed = this.changedAttributes(); - const previous = keys(changed).reduce((a, i) => { + const to = this.changedAttributes(); + const from = keys(to).reduce((a, i) => { a[i] = this.previous(i); return a; }, {}); - console.log('Update targets', { name, value, changed, previous, opts }); + sm.__trgEv(sm.events.propertyUpdate, { property: this, from, to }); !opts.__up && sm.addStyleTargets({ [name]: value }); }