mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 15:54:03 +02:00
js: Add jQuery plugin offsetTopRelativeTo($ancestor)
This commit is contained in:
parent
f4edcecca0
commit
f5ce5d42ef
@ -67,4 +67,25 @@
|
|||||||
return o;
|
return o;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$.fn.offsetTopRelativeTo = function($ancestor) {
|
||||||
|
if (typeof $ancestor === 'undefined') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var el = this[0];
|
||||||
|
var offset = el.offsetTop;
|
||||||
|
var $parent = $(el.offsetParent);
|
||||||
|
|
||||||
|
if ($parent.is('body') || $parent.is($ancestor)) {
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (el.tagName === 'TR') {
|
||||||
|
// TODO: Didn't found a better way, this will probably break sooner or later
|
||||||
|
return $parent.offsetTopRelativeTo($ancestor);
|
||||||
|
}
|
||||||
|
|
||||||
|
return offset + $parent.offsetTopRelativeTo($ancestor);
|
||||||
|
};
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user