From 5f72fb8e10f5d432900926746ff19c97b977e6e4 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Thu, 18 Jun 2015 08:13:57 +0200 Subject: [IMP] web: pager: editable feature + documentation Pager's state can now be edited (mainly to change the limit, but the range of values as well). --- addons/web/static/src/js/framework/utils.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'addons/web/static/src/js/framework') diff --git a/addons/web/static/src/js/framework/utils.js b/addons/web/static/src/js/framework/utils.js index 50a35fbbbea..f99d99ccc14 100644 --- a/addons/web/static/src/js/framework/utils.js +++ b/addons/web/static/src/js/framework/utils.js @@ -341,6 +341,17 @@ function float_is_zero (value, decimals) { return Math.abs(round_precision(value, epsilon)) < epsilon; }; +/** + * Confines a value inside an interval + * @param {Number} [val] the value to confine + * @param {Number} [min] the minimum of the interval + * @param {Number} [max] the maximum of the interval + * @return val if val is in [min, max], min if val < min and max otherwise + */ +function confine (val, min, max) { + return Math.max(min, Math.min(max, val)); +} + function assert (bool) { if (!bool) { throw new Error("AssertionError"); @@ -413,6 +424,7 @@ return { round_precision: round_precision, round_decimals: round_decimals, float_is_zero: float_is_zero, + confine: confine, assert: assert, xor: xor, DropMisordered: DropMisordered, -- cgit v1.2.3