diff --git a/plugins/Sidebar/media/Sidebar.coffee b/plugins/Sidebar/media/Sidebar.coffee index eded3043..0cc71906 100644 --- a/plugins/Sidebar/media/Sidebar.coffee +++ b/plugins/Sidebar/media/Sidebar.coffee @@ -26,19 +26,23 @@ class Sidebar extends Class initFixbutton: -> # Detect dragging - @fixbutton.on "mousedown", (e) => + @fixbutton.on "mousedown touchstart", (e) => e.preventDefault() # Disable previous listeners - @fixbutton.off "click" - @fixbutton.off "mousemove" + @fixbutton.off "click touchstop touchcancel" + @fixbutton.off "mousemove touchmove" # Make sure its not a click @dragStarted = (+ new Date) - @fixbutton.one "mousemove", (e) => - @fixbutton_addx = @fixbutton.offset().left-e.pageX + @fixbutton.one "mousemove touchmove", (e) => + mousex = e.pageX + if not mousex + mousex = e.originalEvent.touches[0].pageX + + @fixbutton_addx = @fixbutton.offset().left-mousex @startDrag() - @fixbutton.parent().on "click", (e) => + @fixbutton.parent().on "click touchstop touchcancel", (e) => @stopDrag() @resized() $(window).on "resize", @resized @@ -76,11 +80,11 @@ class Sidebar extends Class e.preventDefault() # Animate drag - @fixbutton.parents().on "mousemove", @animDrag - @fixbutton.parents().on "mousemove" ,@waitMove + @fixbutton.parents().on "mousemove touchmove", @animDrag + @fixbutton.parents().on "mousemove touchmove" ,@waitMove # Stop dragging listener - @fixbutton.parents().on "mouseup", (e) => + @fixbutton.parents().on "mouseup touchstop touchend touchcancel", (e) => e.preventDefault() @stopDrag() @@ -89,7 +93,7 @@ class Sidebar extends Class waitMove: (e) => if Math.abs(@fixbutton.offset().left - @fixbutton_targetx) > 10 and (+ new Date)-@dragStarted > 100 @moved() - @fixbutton.parents().off "mousemove" ,@waitMove + @fixbutton.parents().off "mousemove touchmove" ,@waitMove moved: -> @log "Moved" @@ -152,11 +156,13 @@ class Sidebar extends Class animDrag: (e) => mousex = e.pageX + if not mousex + mousex = e.originalEvent.touches[0].pageX overdrag = @fixbutton_initx-@width-mousex if overdrag > 0 # Overdragged overdrag_percent = 1+overdrag/300 - mousex = (e.pageX + (@fixbutton_initx-@width)*overdrag_percent)/(1+overdrag_percent) + mousex = (mousex + (@fixbutton_initx-@width)*overdrag_percent)/(1+overdrag_percent) targetx = @fixbutton_initx-mousex-@fixbutton_addx @fixbutton[0].style.left = (mousex+@fixbutton_addx)+"px" @@ -173,8 +179,8 @@ class Sidebar extends Class # Stop dragging the fixbutton stopDrag: -> - @fixbutton.parents().off "mousemove" - @fixbutton.off "mousemove" + @fixbutton.parents().off "mousemove touchmove" + @fixbutton.off "mousemove touchmove" @fixbutton.css("pointer-events", "") $(".drag-bg").remove() if not @fixbutton.hasClass("dragging") diff --git a/plugins/Sidebar/media/all.js b/plugins/Sidebar/media/all.js index e4013f58..8ff26922 100644 --- a/plugins/Sidebar/media/all.js +++ b/plugins/Sidebar/media/all.js @@ -224,19 +224,24 @@ window.initScrollable = function () { } Sidebar.prototype.initFixbutton = function() { - this.fixbutton.on("mousedown", (function(_this) { + this.fixbutton.on("mousedown touchstart", (function(_this) { return function(e) { e.preventDefault(); - _this.fixbutton.off("click"); - _this.fixbutton.off("mousemove"); + _this.fixbutton.off("click touchstop touchcancel"); + _this.fixbutton.off("mousemove touchmove"); _this.dragStarted = +(new Date); - return _this.fixbutton.one("mousemove", function(e) { - _this.fixbutton_addx = _this.fixbutton.offset().left - e.pageX; + return _this.fixbutton.one("mousemove touchmove", function(e) { + var mousex; + mousex = e.pageX; + if (!mousex) { + mousex = e.originalEvent.touches[0].pageX; + } + _this.fixbutton_addx = _this.fixbutton.offset().left - mousex; return _this.startDrag(); }); }; })(this)); - this.fixbutton.parent().on("click", (function(_this) { + this.fixbutton.parent().on("click touchstop touchcancel", (function(_this) { return function(e) { return _this.stopDrag(); }; @@ -276,9 +281,9 @@ window.initScrollable = function () { } }; })(this)); - this.fixbutton.parents().on("mousemove", this.animDrag); - this.fixbutton.parents().on("mousemove", this.waitMove); - return this.fixbutton.parents().on("mouseup", (function(_this) { + this.fixbutton.parents().on("mousemove touchmove", this.animDrag); + this.fixbutton.parents().on("mousemove touchmove", this.waitMove); + return this.fixbutton.parents().on("mouseup touchstop touchend touchcancel", (function(_this) { return function(e) { e.preventDefault(); return _this.stopDrag(); @@ -289,7 +294,7 @@ window.initScrollable = function () { Sidebar.prototype.waitMove = function(e) { if (Math.abs(this.fixbutton.offset().left - this.fixbutton_targetx) > 10 && (+(new Date)) - this.dragStarted > 100) { this.moved(); - return this.fixbutton.parents().off("mousemove", this.waitMove); + return this.fixbutton.parents().off("mousemove touchmove", this.waitMove); } }; @@ -367,10 +372,13 @@ window.initScrollable = function () { Sidebar.prototype.animDrag = function(e) { var mousex, overdrag, overdrag_percent, targetx; mousex = e.pageX; + if (!mousex) { + mousex = e.originalEvent.touches[0].pageX; + } overdrag = this.fixbutton_initx - this.width - mousex; if (overdrag > 0) { overdrag_percent = 1 + overdrag / 300; - mousex = (e.pageX + (this.fixbutton_initx - this.width) * overdrag_percent) / (1 + overdrag_percent); + mousex = (mousex + (this.fixbutton_initx - this.width) * overdrag_percent) / (1 + overdrag_percent); } targetx = this.fixbutton_initx - mousex - this.fixbutton_addx; this.fixbutton[0].style.left = (mousex + this.fixbutton_addx) + "px"; @@ -386,8 +394,8 @@ window.initScrollable = function () { Sidebar.prototype.stopDrag = function() { var targetx; - this.fixbutton.parents().off("mousemove"); - this.fixbutton.off("mousemove"); + this.fixbutton.parents().off("mousemove touchmove"); + this.fixbutton.off("mousemove touchmove"); this.fixbutton.css("pointer-events", ""); $(".drag-bg").remove(); if (!this.fixbutton.hasClass("dragging")) { diff --git a/src/Config.py b/src/Config.py index b82c80b1..4bd2a88f 100644 --- a/src/Config.py +++ b/src/Config.py @@ -8,7 +8,7 @@ class Config(object): def __init__(self, argv): self.version = "0.3.7" - self.rev = 1278 + self.rev = 1279 self.argv = argv self.action = None self.config_file = "zeronet.conf"