Skip to content

Commit

Permalink
Update StyleManager status management
Browse files Browse the repository at this point in the history
  • Loading branch information
artf committed Nov 5, 2017
1 parent f5e8352 commit 266594f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
7 changes: 4 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@ <h1 class="heading">Insert title here</h1>
}
},
});*/

/*
bm.add('b1-2', {
label: 'Flex Block',
category: 'Basic',
Expand All @@ -1325,6 +1325,7 @@ <h1 class="heading">Insert title here</h1>
</style>
`
})
*/

var domc = editor.DomComponents;
var defaultType = domc.getType('default');
Expand Down Expand Up @@ -1354,12 +1355,12 @@ <h1 class="heading">Insert title here</h1>
console.log('STORE ', e);
})

editor.on('styleManager:change:padding-top', function(view) {
editor.on('styleManager:change:padding', function(view) {
var model = view.model;
let targetValue = view.getTargetValue({ignoreDefault: 1});
let computedValue = view.getComputedValue();
let defaultValue = view.model.getDefaultValue();
console.log('Style of ', model.get('property'), 'Target: ', targetValue, 'Computed:', computedValue, 'Default:', defaultValue);
//console.log('Style of ', model.get('property'), 'Target: ', targetValue, 'Computed:', computedValue, 'Default:', defaultValue);
});

editor.render();
Expand Down
16 changes: 12 additions & 4 deletions src/style_manager/view/PropertyView.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,19 @@ module.exports = Backbone.View.extend({
*/
elementUpdated() {
this.model.set('status', 'updated');
const parent = this.model.parent;
const parentView = parent && parent.view;
parentView && parentView.elementUpdated();
},


setStatus(value) {
this.model.set('status', value);
const parent = this.model.parent;
parent && parent.set('status', value);
},


/**
* Fired when the target is changed
* */
Expand Down Expand Up @@ -202,7 +213,7 @@ module.exports = Backbone.View.extend({
}

model.setValue(value, 0, { fromTarget: 1 });
model.set('status', status);
this.setStatus(status);

if (em) {
em.trigger('styleManager:change', this);
Expand Down Expand Up @@ -280,9 +291,6 @@ module.exports = Backbone.View.extend({
const notToSkip = avoid.indexOf(property) < 0;
const value = computed[property];
const valueDef = computedDef[camelCase(property)];
if (property == 'padding-top') {
console.log('value',value, 'valuedef', valueDef, computedDef);
}
return computed && notToSkip && valueDef !== value && value;
},

Expand Down

0 comments on commit 266594f

Please sign in to comment.