summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/framework/utils.js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2015-06-18 08:13:57 +0200
committerAaron Bohy <aab@odoo.com>2015-06-18 13:51:56 +0200
commit5f72fb8e10f5d432900926746ff19c97b977e6e4 (patch)
treea0187bdaeba2c5dc3c8b3ef3b6e98dae6491becb /addons/web/static/src/js/framework/utils.js
parent6070dc201e632c9553138edd138762ac910f0834 (diff)
[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).
Diffstat (limited to 'addons/web/static/src/js/framework/utils.js')
-rw-r--r--addons/web/static/src/js/framework/utils.js12
1 files changed, 12 insertions, 0 deletions
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,