From 02f7a3307fd03613984115f4c4f056939a8fa2fb Mon Sep 17 00:00:00 2001 From: saleh mosleh Date: Thu, 22 Mar 2018 01:45:13 +0430 Subject: [PATCH] adding setEnable method adding setEnable method --- js/seekbar.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/js/seekbar.js b/js/seekbar.js index 926e0d4..abd56d7 100644 --- a/js/seekbar.js +++ b/js/seekbar.js @@ -63,6 +63,7 @@ $.extend(Seekbar.Seekbar.prototype, { valueListener: undefined, + enable: true, render: function () { this.el = $('
'); @@ -79,7 +80,6 @@ $.extend(Seekbar.Seekbar.prototype, { this.elPositive = $('
'); - if (this.negativeColor != undefined) { this.elNegative.css("background-color", this.negativeColor); } @@ -103,8 +103,6 @@ $.extend(Seekbar.Seekbar.prototype, { this.thumb.append(this.thumbInner); this.thumb.append(this.thumbOuter); - - this.el.append(this.elNegative); this.el.append(this.elPositive); this.el.append(this.thumb); @@ -126,6 +124,8 @@ $.extend(Seekbar.Seekbar.prototype, { }, clickOnBar: function (e) { + if(!this.enable) return; + var pos = this.orientation == "vertical" ? this.area.size - e.offsetY - e.currentTarget.offsetTop : e.offsetX; pos -= (this.thumbSize / 2); @@ -141,6 +141,10 @@ $.extend(Seekbar.Seekbar.prototype, { } }, + setEnable: function (value) { + this.enable = value; + }, + setValue: function (value) { this.value = Math.max(this.minValue, value); this.value = Math.min(this.maxValue, this.value); @@ -239,6 +243,9 @@ $.extend(Seekbar.Seekbar.prototype, { }, startDragging: function (e) { + + if(!this.enable) return; + this.thumbOuter.css("opacity", ""); this.thumbOuter.addClass("seekbar-thumb-over"); this.active = true; @@ -259,6 +266,7 @@ $.extend(Seekbar.Seekbar.prototype, { }, drag: function (e) { + if(!this.enable) return; if (!this.active)return; var x = e.pageX; @@ -310,6 +318,7 @@ $.extend(Seekbar.Seekbar.prototype, { }, endDrag: function () { + if(!this.enable) return; if (!this.active)return; this.updateAlpha(); @@ -320,4 +329,4 @@ $.extend(Seekbar.Seekbar.prototype, { } -}); \ No newline at end of file +});