Browse Source

Add setValue to the property model

pull/487/head
Artur Arseniev 8 years ago
parent
commit
ecf22d66c9
  1. 21
      src/style_manager/model/Property.js

21
src/style_manager/model/Property.js

@ -14,6 +14,7 @@ module.exports = require('backbone').Model.extend({
fixedValues: ['initial', 'inherit'],
},
initialize(opt) {
var o = opt || {};
var name = this.get('name');
@ -27,6 +28,24 @@ module.exports = require('backbone').Model.extend({
init && init();
},
/**
* Update value
* @param {any} value
* @param {Boolen} [complete=true] Indicates if it's a final state
* @param {Object} [opts={}] Options
*/
setValue(value, complete = 1, opts = {}) {
this.set('value', value, { ...opts, avoidStore: 1});
// It's important to set an empty value, otherwise the
// UndoManager won't see the change
if (complete) {
this.set('value', '', opts);
this.set('value', value, opts);
}
},
/**
* Parse a raw value, generally fetched from the target, for this property
* @param {string} value
@ -51,6 +70,7 @@ module.exports = require('backbone').Model.extend({
return String.prototype.substring.apply(valueStr, args);
},
/**
* Get the default value
* @return {string}
@ -60,6 +80,7 @@ module.exports = require('backbone').Model.extend({
return this.get('defaults');
},
/**
* Get a complete value of the property.
* This probably will replace the getValue when all

Loading…
Cancel
Save