Browse Source

Add `component:toggled` event and update OpenTraitManager

multiple-select
Artur Arseniev 8 years ago
parent
commit
b6d1b9f4b8
  1. 4
      src/commands/view/OpenTraitManager.js
  2. 9
      src/dom_components/index.js
  3. 1
      src/editor/index.js

4
src/commands/view/OpenTraitManager.js

@ -34,7 +34,7 @@ module.exports = {
.trigger('change:appendContent');
this.target = editor.getModel();
this.listenTo(this.target, 'change:selectedComponent', this.toggleTm);
this.listenTo(this.target, 'component:toggled', this.toggleTm);
}
this.toggleTm();
@ -48,7 +48,7 @@ module.exports = {
const sender = this.sender;
if (sender && sender.get && !sender.get('active')) return;
if (this.target.get('selectedComponent')) {
if (this.target.getSelected()) {
this.$cn2.show();
this.$header.hide();
} else {

9
src/dom_components/index.js

@ -526,18 +526,23 @@ module.exports = () => {
component.set({
status: 'selected'
});
this.em.trigger('component:selected', component, opts);
['component:selected', 'component:toggled'].forEach(event =>
this.em.trigger(event, component, opts)
);
}
},
selectRemove(component, opts = {}) {
console.log('REMOVED', component);
if (component) {
const { em } = this;
component.set({
status: '',
state: ''
});
this.em.trigger('component:deselected', component, opts);
['component:deselected', 'component:toggled'].forEach(event =>
this.em.trigger(event, component, opts)
);
}
},

1
src/editor/index.js

@ -18,6 +18,7 @@
* * `component:styleUpdate:{propertyName}` - Listen for a specific style property change, the model is passed as an argument to the callback
* * `component:selected` - New component selected, the selected model is passed as an argument to the callback
* * `component:deselected` - Component deselected, the deselected model is passed as an argument to the callback
* * `component:toggled` - Component selection changed, toggled model is passed as an argument to the callback
* ## Blocks
* * `block:add` - New block added
* * `block:remove` - Block removed

Loading…
Cancel
Save