From: Michael M Slusarz Date: Wed, 18 Nov 2009 02:27:25 +0000 (-0700) Subject: Fix potential divide-by-zero and negative value cases X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=f6f42879bfdf559df94872f5f0ca6755ad3e1b56;p=horde.git Fix potential divide-by-zero and negative value cases --- diff --git a/imp/js/DimpSlider.js b/imp/js/DimpSlider.js index 65de92d54..93206f29c 100644 --- a/imp/js/DimpSlider.js +++ b/imp/js/DimpSlider.js @@ -191,7 +191,7 @@ var DimpSlider = Class.create({ _setScrollPosition: function(type, data) { this.value = (type == 'val') - ? Math.min(Math.max(0, data), this.options.totalsize - this.options.pagesize) + ? Math.min(Math.max(0, data), Math.max(0, this.options.totalsize - this.options.pagesize)) : Math.max(0, Math.round(Math.min(data, this.handletop) / this.handletop * (this.options.totalsize - this.options.pagesize))); if (type == 'px') { @@ -201,7 +201,9 @@ var DimpSlider = Class.create({ /* Always make sure there is at least 1 pixel if we are not at the * absolute bottom or top. */ - if (this.handlevalue == 0 && this.value != 0) { + if (isNaN(this.handlevalue)) { + this.handlevalue = 0; + } else if (this.handlevalue == 0 && this.value != 0) { this.handlevalue += 1; } else if (this.handlevalue == this.handletop && ((this.options.totalsize - this.options.pagesize) != this.value)) {