Browse Source

Returns in Style Manager only styleable selectors

pull/261/head
Artur Arseniev 9 years ago
parent
commit
28b8d0ab0a
  1. 5
      src/selector_manager/model/Selectors.js
  2. 19
      src/style_manager/view/SectorsView.js

5
src/selector_manager/model/Selectors.js

@ -3,4 +3,9 @@ var Selector = require('./Selector');
module.exports = Backbone.Collection.extend({ module.exports = Backbone.Collection.extend({
model: Selector, model: Selector,
getStyleable() {
return _.filter(this.models, item =>
item.get('active') && !item.get('private'));
}
}); });

19
src/style_manager/view/SectorsView.js

@ -56,26 +56,25 @@ module.exports = Backbone.View.extend({
pt.computed = window.getComputedStyle(view.el, stateStr); pt.computed = window.getComputedStyle(view.el, stateStr);
} }
if(classes.length){ if (classes.length) {
var cssC = em.get('CssComposer'); var cssC = em.get('CssComposer');
var valid = _.filter(classes.models, item => item.get('active')); var valid = classes.getStyleable();
var iContainer = cssC.get(valid, state, mediaText); var iContainer = cssC.get(valid, state, mediaText);
if(!iContainer){ if (!iContainer && valid.length) {
iContainer = cssC.add(valid, state, mediaText); iContainer = cssC.add(valid, state, mediaText);
// Get styles from the component
iContainer.set('style', el.get('style')); iContainer.set('style', el.get('style'));
//cssC.addRule(iContainer);
el.set('style', {}); el.set('style', {});
}else{ } else {
// Ensure to clean element // In this case it's just a Component without any valid selector
//if(classes.length == 1) pt.model = el;
//el.set('style', {}); pt.trigger('update');
return;
} }
// If the state is not empty, there should be a helper rule in play // If the state is not empty, there should be a helper rule in play
// The helper rule will get the same style of the iContainer // The helper rule will get the same style of the iContainer
if(state){ if (state) {
var clm = em.get('SelectorManager'); var clm = em.get('SelectorManager');
var helperClass = clm.add('hc-state'); var helperClass = clm.add('hc-state');
var helperRule = cssC.get([helperClass]); var helperRule = cssC.get([helperClass]);

Loading…
Cancel
Save