Browse Source

Move unnecessary stuff from PropertyView

pull/36/head
Artur Arseniev 10 years ago
parent
commit
8af6f75202
  1. 4
      src/style_manager/view/PropertyIntegerView.js
  2. 23
      src/style_manager/view/PropertyRadioView.js
  3. 5
      src/style_manager/view/PropertySelectView.js
  4. 16
      src/style_manager/view/PropertyView.js

4
src/style_manager/view/PropertyIntegerView.js

@ -10,6 +10,10 @@ define(['backbone','./PropertyView', 'text!./../templates/propertyInteger.html']
initialize: function(options) {
PropertyView.prototype.initialize.apply(this, arguments);
_.bindAll(this, 'moveIncrement', 'upIncrement');
this.min = this.model.get('min') || this.model.get('min')===0 ? this.model.get('min') : -5000;
this.max = this.model.get('max') || this.model.get('max')===0 ? this.model.get('max') : 5000;
this.units = this.model.get('units');
this.unit = this.model.get('unit') ? this.model.get('unit') : (this.units.length ? this.units[0] : '');
this.events['click .'+this.pfx+'u-arrow'] = 'upArrowClick';
this.events['click .'+this.pfx+'d-arrow'] = 'downArrowClick';
this.events['mousedown .'+this.pfx+'int-arrows'] = 'downIncrement';

23
src/style_manager/view/PropertyRadioView.js

@ -1,17 +1,26 @@
define(['backbone','./PropertyView', 'text!./../templates/propertyRadio.html'],
define(['backbone','./PropertyView', 'text!./../templates/propertyRadio.html'],
function (Backbone, PropertyView, propertyTemplate) {
/**
/**
* @class PropertyRadioView
* */
return PropertyView.extend({
template: _.template(propertyTemplate),
initialize: function(options) {
PropertyView.prototype.initialize.apply(this, arguments);
this.className = this.className + ' '+ this.pfx +'list';
this.list = this.model.get('list');
this.className = this.className + ' '+ this.pfx +'list';
},
/**
* Fired when the input value is updated
*/
valueUpdated: function(){
if(this.$input)
this.model.set('value', this.$el.find('input:checked').val());
},
/** @inheritdoc */
renderInput: function() {
var pfx = this.pfx;
@ -33,7 +42,7 @@ define(['backbone','./PropertyView', 'text!./../templates/propertyRadio.html'],
}
this.setValue(this.componentValue);
},
/** @inheritdoc */
setValue: function(value){
var v = this.model.get('value') || this.defaultValue;

5
src/style_manager/view/PropertySelectView.js

@ -7,6 +7,11 @@ define(['backbone','./PropertyView', 'text!./../templates/propertySelect.html'],
template: _.template(propertyTemplate),
initialize: function(options) {
PropertyView.prototype.initialize.apply(this, arguments);
this.list = this.model.get('list');
},
/** @inheritdoc */
renderInput: function() {
var pfx = this.pfx;

16
src/style_manager/view/PropertyView.js

@ -8,9 +8,7 @@ define(['backbone', 'text!./../templates/propertyLabel.html', 'text!./../templat
template: _.template(propertyTemplate),
templateLabel: _.template(propertyLabel),
events: {
'change': 'valueUpdated',
},
events: {'change': 'valueUpdated'},
initialize: function(o) {
this.config = o.config || {};
@ -23,11 +21,6 @@ define(['backbone', 'text!./../templates/propertyLabel.html', 'text!./../templat
this.func = this.model.get('functionName');
this.defaultValue = this.model.get('defaults');
this.property = this.model.get('property');
this.units = this.model.get('units');
this.min = this.model.get('min') || this.model.get('min')===0 ? this.model.get('min') : -5000;
this.max = this.model.get('max') || this.model.get('max')===0 ? this.model.get('max') : 5000;
this.unit = this.model.get('unit') ? this.model.get('unit') : (this.units.length ? this.units[0] : '');
this.list = this.model.get('list');
this.input = this.$input = null;
this.className = this.pfx + 'property';
this.inputHolderId = '#' + this.pfx + 'input-holder';
@ -66,9 +59,6 @@ define(['backbone', 'text!./../templates/propertyLabel.html', 'text!./../templat
* @return {Boolean}
* */
sameValue: function(){
if(this.property == 'test'){
console.log('compoVal: ' + this.getComponentValue() + ' modelVal: ' + (this.model.get('value') + this.model.get('unit')));
}
return this.getComponentValue() == (this.model.get('value') + this.model.get('unit'));
},
@ -86,7 +76,7 @@ define(['backbone', 'text!./../templates/propertyLabel.html', 'text!./../templat
if(targetProp)
this.componentValue = targetProp;
else
this.componentValue = this.defaultValue + (this.unit || '');
this.componentValue = this.defaultValue + (this.unit || ''); // todo model
// Check if wrap inside function is required
if(this.func){
@ -118,7 +108,7 @@ define(['backbone', 'text!./../templates/propertyLabel.html', 'text!./../templat
},
/**
* Returns value from necessary inputs
* Returns value from inputs
* @return {string}
*/
getValueForTarget: function(){

Loading…
Cancel
Save