diff --git a/src/block_manager/view/BlocksView.js b/src/block_manager/view/BlocksView.js index e978ee896..45a113176 100644 --- a/src/block_manager/view/BlocksView.js +++ b/src/block_manager/view/BlocksView.js @@ -69,7 +69,7 @@ function(Backbone, BlockView) { el.className += ' ' + this.ppfx + 'bdrag'; this.helper = el; document.body.appendChild(el); - $(this.em.get('Canvas').getBody()).on('mousemove', this.moveHelper); + $(this.em.get('Canvas').getBody().ownerDocument).on('mousemove', this.moveHelper); $(document).on('mousemove', this.moveHelper); }, @@ -137,4 +137,4 @@ function(Backbone, BlockView) { }, }); -}); \ No newline at end of file +}); diff --git a/src/editor/config/config.js b/src/editor/config/config.js index 92aa38019..67f46a4b6 100644 --- a/src/editor/config/config.js +++ b/src/editor/config/config.js @@ -242,7 +242,7 @@ define(function () { width: '615px', } }, - }/*,{ + },{ id: 'table', label: 'Table', attributes: {class:'fa fa-table'}, @@ -252,7 +252,7 @@ define(function () { rows: 5, style: {height: '150px', width: '100%'} }, - }*/], + }], }, }; diff --git a/src/style_manager/model/Property.js b/src/style_manager/model/Property.js index 161d0c094..355d13859 100644 --- a/src/style_manager/model/Property.js +++ b/src/style_manager/model/Property.js @@ -4,7 +4,7 @@ define(['backbone', './Layers', 'require'], return Backbone.Model.extend({ defaults: { - name : '', + name: '', property: '', type: '', units: [], @@ -15,10 +15,11 @@ define(['backbone', './Layers', 'require'], icon: '', preview: false, detached: false, - functionName: '', + functionName: '', properties: [], layers: [], list: [], + fixedValues: ['initial', 'inherit'], }, initialize: function(opt) { @@ -48,7 +49,7 @@ define(['backbone', './Layers', 'require'], * @return {string} Value * @private */ - getValue: function(){ + getValue: function() { var result = ''; var type = this.get('type'); diff --git a/src/style_manager/model/PropertyFactory.js b/src/style_manager/model/PropertyFactory.js index 378eaa4d9..0d4152ab5 100644 --- a/src/style_manager/model/PropertyFactory.js +++ b/src/style_manager/model/PropertyFactory.js @@ -11,6 +11,7 @@ define(['backbone'], */ build: function(props){ var objs = []; + var dftFixedValues = ['initial', 'inherit']; if(typeof props === 'string') props = [props]; @@ -27,6 +28,13 @@ define(['backbone'], break; } + // Fixed values + switch(prop){ + case 'margin-top': case 'margin-right': case 'margin-bottom': case 'margin-left': + obj.fixedValues = ['initial', 'inherit', 'auto']; + break; + } + // Type switch(prop){ case 'float': case 'position': @@ -448,4 +456,4 @@ define(['backbone'], }; }; -}); \ No newline at end of file +}); diff --git a/src/style_manager/view/PropertyIntegerView.js b/src/style_manager/view/PropertyIntegerView.js index e60411c3f..cab36af8a 100644 --- a/src/style_manager/view/PropertyIntegerView.js +++ b/src/style_manager/view/PropertyIntegerView.js @@ -150,18 +150,27 @@ define(['backbone','./PropertyView', 'text!./../templates/propertyInteger.html'] /** @inheritdoc */ setValue: function(value){ - var u = this.unit, - v = this.model.get('value') || this.defaultValue; - - if(value){ - // Make it suitable for replace - value += ''; - v = parseFloat(value.replace(',', '.')); - v = !isNaN(v) ? v : this.defaultValue; - var uN = value.replace(v,''); - // Check if exists as unit - if(_.indexOf(this.units, uN) > -1) - u = uN; + var model = this.model; + var u = this.unit; + var v = model.get('value') || this.defaultValue; + var fixed = model.get('fixedValues') || []; + + if (value) { + // If the value is one of the fixed values I leave it as it is + var regFixed = new RegExp('^' + fixed.join('|'), 'g'); + if (fixed.length && regFixed.test(value)) { + v = value.match(regFixed)[0]; + u = ''; + } else { + // Make it suitable for replace + value += ''; + v = parseFloat(value.replace(',', '.')); + v = !isNaN(v) ? v : this.defaultValue; + var uN = value.replace(v, ''); + // Check if exists as unit + if(_.indexOf(this.units, uN) > -1) + u = uN; + } } if(this.$input) @@ -169,7 +178,7 @@ define(['backbone','./PropertyView', 'text!./../templates/propertyInteger.html'] if(this.$unit) this.$unit.val(u); - this.model.set({value: v, unit: u,}, {silent: true}); + model.set({value: v, unit: u,}, {silent: true}); }, }); diff --git a/src/style_manager/view/PropertyView.js b/src/style_manager/view/PropertyView.js index 09e51611d..a9fdb1787 100644 --- a/src/style_manager/view/PropertyView.js +++ b/src/style_manager/view/PropertyView.js @@ -215,11 +215,11 @@ define(['backbone', 'text!./../templates/propertyLabel.html', 'text!./../templat * @param {Boolean} force * */ setValue: function(value, force){ - var f = force === 0 ? 0 : 1; + var f = force === 0 ? 0 : 1; var def = this.model.get('defaults'); - var v = this.model.get('value') || def; + var v = this.model.get('value') || def; if(value || f){ - v = value; + v = value; } if(this.$input) this.$input.val(v);