Browse Source

Fix style fetching inside stack property

pull/36/head
Artur Arseniev 10 years ago
parent
commit
290f82e1bc
  1. 16
      src/demo.js
  2. 1
      src/dom_components/model/Components.js
  3. 2
      src/editor/model/Editor.js
  4. 11
      src/style_manager/view/PropertyStackView.js
  5. 11
      test/specs/style_manager/view/PropertyStackView.js

16
src/demo.js

@ -721,13 +721,6 @@ require(['config/require-config'], function() {
type : 'stack',
preview : true,
properties : [{
name: 'Shadow type',
property: 'shadow-type',
type: 'select',
defaults: '',
list: [ { value : '', name : 'Outside', },
{ value : 'inset', name : 'Inside', }],
},{
name: 'X position',
property: 'shadow-x',
type: 'integer',
@ -757,7 +750,14 @@ require(['config/require-config'], function() {
property: 'shadow-color',
type: 'color',
defaults: 'black',
},],
},{
name: 'Shadow type',
property: 'shadow-type',
type: 'select',
defaults: ' ',
list: [ { value : ' ', name : 'Outside', },
{ value : 'inset', name : 'Inside', }],
}],
},{
name : 'Background',
property : 'background',

1
src/dom_components/model/Components.js

@ -67,7 +67,6 @@ define([ 'backbone', 'require'],
cssC.addRule(rule);
rule.set('style', style);
}
console.log('After component add');
},
});

2
src/editor/model/Editor.js

@ -100,7 +100,7 @@ define([
this.cssc = new CssComposer(cfg);
this.CssComposer = this.cssc;
this.set('CssComposer', this.cssc);
console.log(this.cssc.getRules());
if(this.stm.isAutosave())
this.listenRules(this.cssc.getRules());
},

11
src/style_manager/view/PropertyStackView.js

@ -229,8 +229,17 @@ define(['backbone','./PropertyCompositeView', 'text!./../templates/propertyStack
a = this.getLayersFromTarget();
}else{
var v = this.getComponentValue();
if(v)
if(v){
// Remove spaces inside functions:
// eg:
// From: 1px 1px rgba(2px, 2px, 2px), 2px 2px rgba(3px, 3px, 3px)
// To: 1px 1px rgba(2px,2px,2px), 2px 2px rgba(3px,3px,3px)
v.replace(/\(([\w\s,.]*)\)/g, function(match){
var cleaned = match.replace(/,\s*/g, ',');
v = v.replace(match, cleaned);
});
a = v.split(', ');
}
}
_.each(a,function(e){ n.push({ value: e});},this);
this.$props.detach();

11
test/specs/style_manager/view/PropertyStackView.js

@ -231,6 +231,17 @@ define([path + 'PropertyStackView', 'StyleManager/model/Property', 'DomComponent
(view.valueOnIndex(2) === null).should.equal(true);
});
it('The value is correctly extracted from the string with functions', function() {
var style = {};
style[propName] = 'func(a1a, s2a,d3a) value1 value2, func(4ddb, aAS5b, sS.6b) value3';
component.set('style', style);
view.propTarget.trigger('update');
view.model.set('stackIndex', 1);
view.valueOnIndex(0).should.equal('func(4ddb,aAS5b,sS.6b)');
view.valueOnIndex(1).should.equal('value3');
(view.valueOnIndex(2) === null).should.equal(true);
});
it('Build value from properties', function() {
view.model.get('properties').at(0).set('value', propValue);
view.model.get('properties').at(2).set('value', prop3Val);

Loading…
Cancel
Save