diff --git a/src/domain_abstract/ui/Input.js b/src/domain_abstract/ui/Input.js index ced1b8321..09c9f416f 100644 --- a/src/domain_abstract/ui/Input.js +++ b/src/domain_abstract/ui/Input.js @@ -6,21 +6,22 @@ module.exports = Backbone.View.extend({ 'change': 'handleChange', }, + template() { - const holderClass = this.holderClass; - return ``; + return ``; }, + initialize(opts = {}) { const ppfx = opts.ppfx || ''; + this.ppfx = ppfx; this.target = opts.target || {}; - this.inputClass = ppfx + 'field'; - this.inputHolderClass = ppfx + 'input-holder'; + this.inputClass = `${ppfx}field`; this.holderClass = `${ppfx}input-holder`; - this.ppfx = ppfx; this.listenTo(this.model, 'change:value', this.handleModelChange); }, + /** * Fired when the element of the property is updated */ @@ -28,6 +29,7 @@ module.exports = Backbone.View.extend({ this.model.trigger('el:change'); }, + /** * Handled when the view is changed */ @@ -37,6 +39,7 @@ module.exports = Backbone.View.extend({ this.elementUpdated(); }, + /** * Set value to the model * @param {string} value @@ -49,6 +52,7 @@ module.exports = Backbone.View.extend({ input && (input.value = val); }, + /** * Updates the view when the model is changed * */ @@ -56,26 +60,27 @@ module.exports = Backbone.View.extend({ this.setValue(value, opts); }, + /** * Get the input element * @return {HTMLElement} */ getInputEl() { - if(!this.inputEl) { + if (!this.inputEl) { const plh = this.model.get('defaults'); const cls = this.inputCls; this.inputEl = $(``); } + return this.inputEl.get(0); }, + render() { const el = this.$el; - const ppfx = this.ppfx; - const holderClass = this.holderClass; el.addClass(this.inputClass); el.html(this.template()); - el.find(`.${holderClass}`).append(this.getInputEl()); + el.find(`.${this.holderClass}`).append(this.getInputEl()); return this; } diff --git a/src/style_manager/model/PropertySlider.js b/src/style_manager/model/PropertySlider.js index c21975e71..51285c13a 100644 --- a/src/style_manager/model/PropertySlider.js +++ b/src/style_manager/model/PropertySlider.js @@ -2,8 +2,8 @@ const Property = require('./PropertyInteger'); module.exports = Property.extend({ - defaults: Object.assign({}, Property.prototype.defaults, { - showInput: 1, - }), + defaults: { ...Property.prototype.defaults, + showInput: 1, + }, }); diff --git a/src/style_manager/view/PropertySliderView.js b/src/style_manager/view/PropertySliderView.js index 7db84f2d7..0124dee8a 100644 --- a/src/style_manager/view/PropertySliderView.js +++ b/src/style_manager/view/PropertySliderView.js @@ -1,4 +1,3 @@ -const InputNumber = require('domain_abstract/ui/InputNumber'); const Property = require('./PropertyIntegerView'); module.exports = Property.extend({ @@ -31,6 +30,7 @@ module.exports = Property.extend({ inputValueChanged() { const model = this.model; const step = model.get('step'); + console.log('slider ', this.getSliderEl().value, ' input', this.getInputEl().value); this.getInputEl().value = this.getSliderEl().value; const value = this.getInputValue() - step; model.set('value', value, {avoidStore: 1}).set('value', value + step);