Files
CRM/libraries/jquery/jquery.additions.js
BACHIR SOULDI 2794e62571 first commit
2025-09-28 08:49:37 +01:00

46 lines
1.2 KiB
JavaScript

/**
* jQuery additions
*/
;(function($){
/**
* Position the first element in the jQuery list near another element
* using absolute positioning. The element should already have the
* proper z-Index set.
*
* @param string align 'bottom' for bottom left, or 'right' for top right,
* 'left' for top left, 'top' for above left.
*/
$.fn.makePositioned = function(align, element) {
var first = this.eq(0);
var pos, height, width, left, top, thisHeight, thisWidth;
pos = element.offset();
height = element.outerHeight(), width = element.outerWidth();
left = pos.left, top = pos.top;
thisHeight = first.outerHeight(), thisWidth = first.outerWidth();
switch (align) {
case 'bottom':
top += height;
break;
case 'right':
left += width;
break;
case 'left':
left = left - thisWidth;
break;
case 'top':
top = top - thisHeight;
break;
}
first.css({
top: parseInt(top)+'px',
left: parseInt(left)+'px',
position: 'absolute'
});
return this;
}
})(jQuery);