diff --git a/app/browser/js/app/init.js b/app/browser/js/app/init.js
index 160ca58c..cf856242 100644
--- a/app/browser/js/app/init.js
+++ b/app/browser/js/app/init.js
@@ -65,10 +65,7 @@ init = function(session,callback) {
document.elementFromPoint(dd.originalEvent.changedTouches[0].clientX, dd.originalEvent.changedTouches[0].clientY)
:dd.target
- if ($('#sidepanel').has(dd.target)[0]) return
- dd.absolute=true
$(dd.target).trigger('draginit',[dd])
- if (target!=dd.target) $(dd.target).click()
target = dd.target
})
@@ -76,9 +73,7 @@ init = function(session,callback) {
});
$(document).keyup(function (e) {
if (e.keyCode == 16) {
- $('body').off('draginit')
$('body').off('drag')
- $('body').off('dragend')
}
});
diff --git a/app/browser/js/app/widgets.js b/app/browser/js/app/widgets.js
index 9a203b77..4f222b84 100644
--- a/app/browser/js/app/widgets.js
+++ b/app/browser/js/app/widgets.js
@@ -181,14 +181,28 @@ createWidget.toggle = function(widgetData) {
\
- `)
+ `),
+ $document = $(document)
widget.value = widget.find('span')
- widget.click(function(){
+ widget.on('drag',function(e){e.stopPropagation()})
+ widget.on('draginit.toggle',function(){
+ widget.off('draginit.toggle')
+ widget.fakeclick()
+ })
+
+ widget.fakeclick = function(){
var newVal = widget.hasClass('on')?widgetData.off:widgetData.on
widget.setValue(newVal,true)
- })
+ $document.on('dragend.toggle',function(){
+ $document.off('dragend.toggle')
+ widget.on('draginit.toggle',function(){
+ widget.off('draginit.toggle')
+ widget.fakeclick()
+ })
+ })
+ }
widget.getValue = function() {
@@ -232,8 +246,8 @@ createWidget.push = function(widgetData) {
widget.value = widget.find('span')
widget.on('drag',function(e){e.stopPropagation()})
- widget.on('draginit',function(){
- widget.off('draginit')
+ widget.on('draginit.push',function(){
+ widget.off('draginit.push')
widget.fakeclick()
})
@@ -285,7 +299,8 @@ createWidget.switch = function(widgetData) {
var widget = $(`
- `)
+ `),
+ $document = $(document)
if (widgetData.horizontal) {
widget.addClass('horizontal')
@@ -295,20 +310,24 @@ createWidget.switch = function(widgetData) {
widget.append(''+widgetData.values[v]+'
')
}
+ widget.value = false
- widget.find('.value').click(function(){
- if ($(this).hasClass('on')) return
- var newVal = $(this).data('value')
- widget.setValue(newVal,true,true)
+ 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.setValue(val,true,true)
})
+
widget.getValue = function() {
return widget.find('.on').data('value')
}
widget.setValue = function(v,send,sync) {
var e = widget.find('.value[data-value="'+v+'"]')
if (e.length) {
+ widget.value = v
widget.find('.on').removeClass('on')
e.addClass('on').ripple()
if (send) widget.sendValue(v)