|
|
|
@ -118,6 +118,24 @@ const Component = Backbone.Model.extend(Styleable).extend( |
|
|
|
toolbar: null |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* Hook method, called once the model is created |
|
|
|
*/ |
|
|
|
init() {}, |
|
|
|
|
|
|
|
/** |
|
|
|
* Hook method, called when the model has been updated (eg. updated some model's property) |
|
|
|
* @param {String} property Property name, if triggered after some property update |
|
|
|
* @param {*} value Property value, if triggered after some property update |
|
|
|
* @param {*} previous Property previous value, if triggered after some property update |
|
|
|
*/ |
|
|
|
updated(property, value, previous) {}, |
|
|
|
|
|
|
|
/** |
|
|
|
* Hook method, called once the model has been removed |
|
|
|
*/ |
|
|
|
removed() {}, |
|
|
|
|
|
|
|
initialize(props = {}, opt = {}) { |
|
|
|
const em = opt.em; |
|
|
|
|
|
|
|
@ -170,10 +188,7 @@ const Component = Backbone.Model.extend(Styleable).extend( |
|
|
|
); |
|
|
|
}); |
|
|
|
this.init(); |
|
|
|
|
|
|
|
if (em) { |
|
|
|
em.trigger('component:create', this); |
|
|
|
} |
|
|
|
em && em.trigger('component:create', this); |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
@ -508,8 +523,6 @@ const Component = Backbone.Model.extend(Styleable).extend( |
|
|
|
return this; |
|
|
|
}, |
|
|
|
|
|
|
|
init() {}, |
|
|
|
|
|
|
|
/** |
|
|
|
* Add new component children |
|
|
|
* @param {Component|String} components Component to add |
|
|
|
@ -941,6 +954,13 @@ const Component = Backbone.Model.extend(Styleable).extend( |
|
|
|
emitUpdate(property, ...args) { |
|
|
|
const em = this.em; |
|
|
|
const event = 'component:update' + (property ? `:${property}` : ''); |
|
|
|
this.updated( |
|
|
|
property, |
|
|
|
property && this.get(property), |
|
|
|
property && this.previous(property), |
|
|
|
...args |
|
|
|
); |
|
|
|
this.trigger(event, ...args); |
|
|
|
em && em.trigger(event, this, ...args); |
|
|
|
}, |
|
|
|
|
|
|
|
|