Browse Source

Adjust tests

pull/36/head
Artur Arseniev 10 years ago
parent
commit
ece6393b3b
  1. 2
      bower.json
  2. 14
      dist/grapes.min.js
  3. 2
      package.json
  4. 14
      src/domain_abstract/ui/InputNumber.js
  5. 8
      src/style_manager/view/PropertyIntegerView.js
  6. 7
      test/specs/style_manager/model/Models.js
  7. 4
      test/specs/style_manager/view/PropertyIntegerView.js

2
bower.json

@ -1,7 +1,7 @@
{ {
"name": "grapesjs", "name": "grapesjs",
"description": "Open source Web Template Editor", "description": "Open source Web Template Editor",
"version": "0.3.36", "version": "0.3.37",
"author": "Artur Arseniev", "author": "Artur Arseniev",
"homepage": "http://grapesjs.com", "homepage": "http://grapesjs.com",
"main": [ "main": [

14
dist/grapes.min.js

File diff suppressed because one or more lines are too long

2
package.json

@ -1,7 +1,7 @@
{ {
"name": "grapesjs", "name": "grapesjs",
"description": "Open source Web Template Editor", "description": "Open source Web Template Editor",
"version": "0.3.36", "version": "0.3.37",
"author": "Artur Arseniev", "author": "Artur Arseniev",
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"homepage": "http://grapesjs.com", "homepage": "http://grapesjs.com",

14
src/domain_abstract/ui/InputNumber.js

@ -85,6 +85,7 @@ define(['backbone', 'text!./templates/inputNumber.html'],
getInputEl: function() { getInputEl: function() {
if(!this.inputEl) { if(!this.inputEl) {
this.inputEl = $('<input>', { this.inputEl = $('<input>', {
type: 'text',
class: this.inputCls, class: this.inputCls,
placeholder: this.model.get('defaults') placeholder: this.model.get('defaults')
}); });
@ -183,11 +184,12 @@ define(['backbone', 'text!./templates/inputNumber.html'],
* @return {Object} Validated string * @return {Object} Validated string
*/ */
validateInputValue: function(value, opts) { validateInputValue: function(value, opts) {
var unit = '';
var val = value;
var force = 0; var force = 0;
var opt = opts || {}; var opt = opts || {};
var model = this.model; var model = this.model;
var val = value || model.get('defaults');
var units = model.get('units') || [];
var unit = model.get('unit') || (units.length && units[0]) || '';
var max = model.get('max'); var max = model.get('max');
var min = model.get('min'); var min = model.get('min');
@ -202,13 +204,13 @@ define(['backbone', 'text!./templates/inputNumber.html'],
unit = ''; unit = '';
force = 1; force = 1;
} else { } else {
// Make it suitable for replace var valCopy = val + '';
val += ''; val += ''; // Make it suitable for replace
val = parseFloat(val.replace(',', '.')); val = parseFloat(val.replace(',', '.'));
val = !isNaN(val) ? val : model.get('defaults'); val = !isNaN(val) ? val : model.get('defaults');
var uN = value.replace(val, ''); var uN = valCopy.replace(val, '');
// Check if exists as unit // Check if exists as unit
if(_.indexOf(model.get('units'), uN) >= 0) if(_.indexOf(units, uN) >= 0)
unit = uN; unit = uN;
} }
} }

8
src/style_manager/view/PropertyIntegerView.js

@ -24,13 +24,17 @@ define(['backbone','./PropertyView', 'Abstract/ui/InputNumber'],
}); });
this.input = inputNumber.render(); this.input = inputNumber.render();
this.$el.append(this.input.$el); this.$el.append(this.input.$el);
this.$input = this.input.inputEl;
this.$unit = this.input.unitEl;
} }
this.input.setValue(this.componentValue, {silent: 1}); this.setValue(this.componentValue);
}, },
renderTemplate: function(){}, renderTemplate: function(){},
setValue: function() {}, setValue: function(value) {
this.input.setValue(value, {silent: 1});
},
}); });
}); });

7
test/specs/style_manager/model/Models.js

@ -315,11 +315,12 @@ define([path + 'Sector',
obj.build('left').should.deep.equal([res]); obj.build('left').should.deep.equal([res]);
}); });
it('Build width e height family', function() { it('Build width and height family', function() {
var res = { var res = {
type: 'integer', type: 'integer',
units: ['px','%'], units: ['px','%'],
defaults: 'auto', defaults: 'auto',
fixedValues: ['initial', 'inherit', 'auto'],
min: 0, min: 0,
} }
res.property = 'width'; res.property = 'width';
@ -375,21 +376,25 @@ define([path + 'Sector',
type: 'composite', type: 'composite',
properties:[{ properties:[{
property : 'padding-top', property : 'padding-top',
fixedValues: ['initial', 'inherit', 'auto'],
type : 'integer', type : 'integer',
units : ['px','%'], units : ['px','%'],
defaults : 0, defaults : 0,
},{ },{
property : 'padding-right', property : 'padding-right',
fixedValues: ['initial', 'inherit', 'auto'],
type : 'integer', type : 'integer',
units : ['px','%'], units : ['px','%'],
defaults : 0, defaults : 0,
},{ },{
property : 'padding-bottom', property : 'padding-bottom',
fixedValues: ['initial', 'inherit', 'auto'],
type : 'integer', type : 'integer',
units : ['px','%'], units : ['px','%'],
defaults : 0, defaults : 0,
},{ },{
property : 'padding-left', property : 'padding-left',
fixedValues: ['initial', 'inherit', 'auto'],
type : 'integer', type : 'integer',
units : ['px','%'], units : ['px','%'],
defaults : 0, defaults : 0,

4
test/specs/style_manager/view/PropertyIntegerView.js

@ -20,7 +20,7 @@ define([path + 'PropertyIntegerView', 'StyleManager/model/Property', 'DomCompone
var defValue = 'test2value'; var defValue = 'test2value';
var units = ['px', '%', 'em']; var units = ['px', '%', 'em'];
var minValue = -15; var minValue = -15;
var maxValue = 15; var maxValue = 75;
var unitsElSel = '.field-units select'; var unitsElSel = '.field-units select';
before(function () { before(function () {
@ -179,7 +179,7 @@ define([path + 'PropertyIntegerView', 'StyleManager/model/Property', 'DomCompone
}); });
it('Value as default', function() { it('Value as default', function() {
view.model.get('value').should.equal(intValue); view.model.get('value').should.equal(parseInt(intValue));
view.model.get('unit').should.equal(units[1]); view.model.get('unit').should.equal(units[1]);
}); });

Loading…
Cancel
Save