diff --git a/app/browser/js/app/widgets.js b/app/browser/js/app/widgets.js
index 5036c847..5181849f 100644
--- a/app/browser/js/app/widgets.js
+++ b/app/browser/js/app/widgets.js
@@ -112,7 +112,7 @@ widgetOptions = {
separator2:'osc',
- values:[0,1],
+ values:{"Value 1":1,"Value 2":2},
path:'auto',
target:[]
},
@@ -404,8 +404,11 @@ createWidget.switch = function(widgetData) {
widget.addClass('horizontal')
}
- for (v in widgetData.values) {
- widget.append('
'+widgetData.values[v]+'
')
+ widget.values = []
+
+ for (k in widgetData.values) {
+ widget.values.push(widgetData.values[k])
+ $(''+k+'
').data({value:widgetData.values[k]}).appendTo(widget)
}
widget.value = undefined
@@ -413,8 +416,8 @@ createWidget.switch = function(widgetData) {
widget.on('drag',function(e){e.stopPropagation()})
widget.on('draginit',function(e,dd){
- var val = dd.target.getAttribute('data-value')
- if (val!=widget.value || widget.value===undefined) widget.setValue(val,true,true)
+ var data = $(dd.target).data()
+ if (data.value!=widget.value || widget.value===undefined) widget.setValue(data.value,true,true)
})
@@ -423,12 +426,11 @@ createWidget.switch = function(widgetData) {
return widget.value
}
widget.setValue = function(v,send,sync) {
- var e = widget.find('.value[data-value="'+v+'"]'),
- i = e.index()
- if (e.length) {
- widget.value = widgetData.values[i]
+ var i = widget.values.indexOf(v)
+ if (i!=-1) {
+ widget.value = widget.values[i]
widget.find('.on').removeClass('on')
- e.addClass('on').ripple()
+ widget.find('.value').eq(i).addClass('on').ripple()
if (send) widget.sendValue(widget.value)
if (sync) widget.trigger('sync')
}