summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/framework
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2015-09-01 10:43:23 +0200
committerAaron Bohy <aab@odoo.com>2015-09-01 20:06:03 +0200
commit5907be1f335dc21934619a34fc928a19e7885211 (patch)
tree7b31383d6c51eeb6edc8b3080633316d4d22c0d8 /addons/web/static/src/js/framework
parent294abae96874465cdc147e6d227ed17597f7e4d6 (diff)
[ADD] web: backport of function getPosition()
to compute the offset of a DOM element
Diffstat (limited to 'addons/web/static/src/js/framework')
-rw-r--r--addons/web/static/src/js/framework/misc.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/addons/web/static/src/js/framework/misc.js b/addons/web/static/src/js/framework/misc.js
index b61dee5862f..fd6bb6d6288 100644
--- a/addons/web/static/src/js/framework/misc.js
+++ b/addons/web/static/src/js/framework/misc.js
@@ -358,12 +358,28 @@ function prepend ($target, content, trigger) {
}
}
+/**
+ * Returns the distance between a DOM element and the top-left corner of the window
+ * @param {element} [e] the DOM element
+ * @return {Object} the left and top distances in pixels
+ */
+function getPosition(e) {
+ var position = {left: 0, top: 0};
+ while (e) {
+ position.left += e.offsetLeft;
+ position.top += e.offsetTop;
+ e = e.offsetParent;
+ }
+ return position;
+}
+
return {
blockUI: blockUI,
unblockUI: unblockUI,
redirect: redirect,
append: append,
prepend: prepend,
+ getPosition: getPosition,
};
});