Browse Source

Update parsing in property model

pull/312/head
Artur Arseniev 9 years ago
parent
commit
101d39c7ee
  1. 10
      src/style_manager/model/Property.js
  2. 11
      src/style_manager/view/PropertyFileView.js
  3. 21
      src/style_manager/view/PropertyStackView.js
  4. 4
      src/style_manager/view/PropertyView.js

10
src/style_manager/model/Property.js

@ -37,10 +37,18 @@ module.exports = require('backbone').Model.extend({
return value;
}
const args = [];
let valueStr = value + '';
let start = valueStr.indexOf('(') + 1;
let end = valueStr.lastIndexOf(')');
return valueStr.substring(start, end);
args.push(start);
// Will try even if the last closing parentheses is not found
if (end >= 0) {
args.push(end);
}
return String.prototype.substring.apply(valueStr, args);
},
/**

11
src/style_manager/view/PropertyFileView.js

@ -6,12 +6,13 @@ module.exports = PropertyView.extend({
templateField() {
const pfx = this.pfx;
const ppfx = this.ppfx;
const assetsLabel = this.config.assetsLabel || 'Images';
return `
<div class="${pfx}field ${pfx}file">
<div id='${pfx}input-holder'>
<div class="${pfx}btn-c">
<button class="${pfx}btn" id="${pfx}images" type="button">
${this.assets}
${assetsLabel}
</button>
</div>
<div style="clear:both;"></div>
@ -27,10 +28,10 @@ module.exports = PropertyView.extend({
initialize(options) {
PropertyView.prototype.initialize.apply(this, arguments);
this.assets = this.target.get('assets');
this.modal = this.target.get('Modal');
this.am = this.target.get('AssetManager');
this.className = this.className + ' '+ this.pfx +'file';
this.assets = this.target.get('assets');
this.modal = this.target.get('Modal');
this.am = this.target.get('AssetManager');
this.className = this.className + ' '+ this.pfx +'file';
this.events['click #'+this.pfx+'close'] = 'removeFile';
this.events['click #'+this.pfx+'images'] = 'openAssetManager';
this.delegateEvents();

21
src/style_manager/view/PropertyStackView.js

@ -19,11 +19,13 @@ module.exports = PropertyCompositeView.extend({
initialize(o) {
PropertyCompositeView.prototype.initialize.apply(this, arguments);
this.model.set('stackIndex', null);
this.className = this.pfx + 'property '+ this.pfx +'stack';
this.events['click #'+this.pfx+'add'] = 'addLayer';
this.listenTo( this.model ,'change:stackIndex', this.indexChanged);
this.listenTo( this.model ,'updateValue', this.valueUpdated);
const model = this.model;
const pfx = this.pfx;
model.set('stackIndex', null);
this.className = `${pfx}property ${pfx}stack`;
this.events[`click #${pfx}add`] = 'addLayer';
this.listenTo(model, 'change:stackIndex', this.indexChanged);
this.listenTo(model, 'updateValue', this.valueUpdated);
this.delegateEvents();
},
@ -111,16 +113,19 @@ module.exports = PropertyCompositeView.extend({
* @private
* */
valueOnIndex(index, propView) {
var result = null;
var layerIndex = this.model.get('stackIndex');
let result;
const model = this.model;
const layerIndex = model.get('stackIndex');
// If detached the value in this case is stacked, eg. substack-prop: 1px, 2px, 3px...
if (this.model.get('detached')) {
if (model.get('detached')) {
var targetValue = propView.getTargetValue({ignoreCustomValue: 1});
var valist = (targetValue + '').split(',');
result = valist[layerIndex];
result = result ? result.trim() : propView.getDefaultValue();
result = propView.model.parseValue(result);
//console.log('Value property', propView.model.get('property'), ': ', result, 'TARGET-VALUE', targetValue, valist);
} else {
var aStack = this.getStackValues();
var strVar = aStack[layerIndex];

4
src/style_manager/view/PropertyView.js

@ -231,6 +231,10 @@ module.exports = Backbone.View.extend({
}
result = target.getStyle()[model.get('property')];
// TODO when stack type asks the sub-property (in valueOnIndex method)
// to provide its target value and its detached, I should avoid parsing
// (at least is wrong applying 'functionName' cleaning)
result = model.parseValue(result);
if (!result && !opts.ignoreDefault) {

Loading…
Cancel
Save