From 274d02f71bbb37f458b307e696172ae3551f91cc Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Thu, 20 Oct 2016 10:15:30 +0200 Subject: [PATCH] xy: use inner faders' inputs instead of creating new ones --- src/browser/js/app/widgets/pads/_pads_base.js | 4 --- src/browser/js/app/widgets/pads/xy.js | 27 ++++--------------- 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/src/browser/js/app/widgets/pads/_pads_base.js b/src/browser/js/app/widgets/pads/_pads_base.js index c6f0cad3..0e283add 100644 --- a/src/browser/js/app/widgets/pads/_pads_base.js +++ b/src/browser/js/app/widgets/pads/_pads_base.js @@ -25,7 +25,3 @@ _pads_base.prototype.setValue = function(v,options={}) { if (typeof v != 'number') return } - -_pads_base.prototype.showValue = function() { - this.input.val(this.value + this.unit) -} diff --git a/src/browser/js/app/widgets/pads/xy.js b/src/browser/js/app/widgets/pads/xy.js index 33417859..9c3a697f 100644 --- a/src/browser/js/app/widgets/pads/xy.js +++ b/src/browser/js/app/widgets/pads/xy.js @@ -48,12 +48,6 @@ var Xy = module.exports.Xy = function(widgetData) { `) - this.inputs = [ - this.widget.find('.x').fakeInput({align:'center'}), - this.widget.find('.y').fakeInput({align:'center'}) - ] - - this.faders = { x: new Fader({ id:0, @@ -80,6 +74,11 @@ var Xy = module.exports.Xy = function(widgetData) { }) } + this.inputs = [ + this.widget.find('.x').replaceWith(this.faders.x.input), + this.widget.find('.y').replaceWith(this.faders.y.input) + ] + this.value = [this.faders.x.value, this.faders.y.value] this.wrapper.append(this.faders.x.widget) @@ -97,7 +96,6 @@ var Xy = module.exports.Xy = function(widgetData) { if (this.value[id] != v) { this.value[id] = v if (options.send) this.sendValue() - this.showValue(id) this.widget.trigger({type:'sync',id:this.widgetData.id,widget:this.widget, linkId:this.widgetData.linkId, options:options}) } }) @@ -111,16 +109,6 @@ var Xy = module.exports.Xy = function(widgetData) { this.faders.y.dragHandleProxy(e, data, traversing) }) - this.inputs[0].change(()=>{ - this.faders.x.setValue(parseFloat(this.inputs[0].val()),{sync:true,send:true}) - }) - this.inputs[1].change(()=>{ - this.faders.y.setValue(parseFloat(this.inputs[1].val()),{sync:true,send:true}) - }) - - this.showValue(0) - this.showValue(1) - this.widget.getValue = () => { return [this.value[0], this.value[1]] } @@ -142,11 +130,6 @@ Xy.prototype.setValue = function(v, options){ this.faders.y.setValue(v[1], {sync: true, send:options.send}) } - -Xy.prototype.showValue = function(i){ - this.inputs[i].val(this.value[i]) -} - module.exports.create = function(widgetData) { var xy = new Xy(widgetData) return xy.widget