Browse Source

Normalize Component's properties from strings to array

pull/79/merge
Artur Arseniev 9 years ago
parent
commit
65c2734a61
  1. 14
      src/dom_components/model/Component.js
  2. 4
      src/style_manager/view/PropertyView.js

14
src/dom_components/model/Component.js

@ -107,6 +107,20 @@ define(['backbone','./Components', 'SelectorManager/model/Selectors', 'TraitMana
traits.add(this.get('traits'));
this.set('traits', traits);
this.initToolbar();
// Normalize few properties from strings to arrays
var toNormalize = ['stylable'];
toNormalize.forEach(function(name) {
var value = this.get(name);
if (typeof value == 'string') {
var newValue = value.split(',').map(function(prop) {
return prop.trim();
});
this.set(name, newValue);
}
}, this);
this.init();
},

4
src/style_manager/view/PropertyView.js

@ -159,11 +159,13 @@ define(['backbone', 'text!./../templates/propertyLabel.html', 'text!./../templat
// Check if component is allowed to be styled
var hideNoStyle = this.config.hideNotStylable;
if (!this.isTargetStylable() || !this.isComponentStylable()) {
console.log('not stylable ', this.property);
if (hideNoStyle) {
this.hide();
}
return;
} else {
console.log('stylable ', this.property);
this.show();
}
@ -240,10 +242,10 @@ define(['backbone', 'text!./../templates/propertyLabel.html', 'text!./../templat
}
var stylable = component.get('stylable');
console.log('ST', stylable);
// Stylable could also be an array indicating with which property
// the target could be styled
if(stylable instanceof Array){
console.log(this.property, stylable, _.indexOf(stylable, this.property));
stylable = _.indexOf(stylable, this.property) >= 0;
}

Loading…
Cancel
Save