summaryrefslogtreecommitdiff
path: root/common/content/buffer.js
diff options
context:
space:
mode:
authorDoug Kearns <dougkearns@gmail.com>2009-05-30 20:29:23 +1000
committerDoug Kearns <dougkearns@gmail.com>2009-06-02 16:58:20 +1000
commit95dffaf95a3653e55a34e090b800f9a79e9a8fd5 (patch)
treed0f9fda36528a196ff3acaf112965d89bde8c709 /common/content/buffer.js
parent3e984c776d7b3a3c90fab6a68f4997ed6c0edfb6 (diff)
downloadpentadactyl-95dffaf95a3653e55a34e090b800f9a79e9a8fd5.tar.gz
Add util.Math.constrain.
Diffstat (limited to 'common/content/buffer.js')
-rw-r--r--common/content/buffer.js10
1 files changed, 3 insertions, 7 deletions
diff --git a/common/content/buffer.js b/common/content/buffer.js
index 762b0e10..ac10e134 100644
--- a/common/content/buffer.js
+++ b/common/content/buffer.js
@@ -72,8 +72,7 @@ function Buffer() //{{{
{
let values = ZoomManager.zoomValues;
let cur = values.indexOf(ZoomManager.snap(ZoomManager.zoom));
- let i = cur + steps;
- i = Math.max(0, Math.min(values.length - 1, i));
+ let i = util.Math.constrain(cur + steps, 0, values.length - 1);
if (i == cur && fullZoom == ZoomManager.useFullZoom)
liberator.beep();
@@ -361,7 +360,7 @@ function Buffer() //{{{
if (elements.length > 0)
{
- count = Math.min(Math.max(count, 1), elements.length);
+ count = util.Math.constrain(count, 1, elements.length);
buffer.focusElement(elements[count - 1]);
}
else
@@ -649,10 +648,7 @@ function Buffer() //{{{
level = buffer.textZoom + parseInt(arg, 10);
// relative args shouldn't take us out of range
- if (level < ZOOM_MIN)
- level = ZOOM_MIN;
- if (level > ZOOM_MAX)
- level = ZOOM_MAX;
+ level = util.Math.constrain(level, ZOOM_MIN, ZOOM_MAX);
}
else
return void liberator.echoerr("E488: Trailing characters");