From: Joey Schulze Date: Thu, 27 Jul 2017 21:08:08 +0000 (+0200) Subject: Include code to position one element over another X-Git-Url: https://git.infodrom.org/?p=infodrom.org%2Fservice.infodrom.org;a=commitdiff_plain;h=2cf206afe826d8e7aaaffa013a95203cac76a46d;hp=fbb98827f0cd6926ecd0f12ba33dc88d1f03f85e Include code to position one element over another --- diff --git a/src/infodrom.js b/src/infodrom.js index 1190b40..6325fc0 100644 --- a/src/infodrom.js +++ b/src/infodrom.js @@ -80,6 +80,29 @@ function make_editable(selector) return this; }; + $.fn.positionOn = function(element, align) { + return this.each(function() { + var target = $(this); + var position = element.offset(); + + var x = position.left; + var y = position.top; + + if(align == 'right') { + x -= (target.outerWidth() - element.outerWidth()); + } else if(align == 'center') { + x -= target.outerWidth() / 2 - element.outerWidth() / 2; + } + + target.css({ + position: 'absolute', + zIndex: 5000, + top: y, + left: x + }); + }); + }; + $.invoke = function(name, parms, callback) { if (typeof(parms) == 'string' && parms.length) parms = 'route='+name+'&'+parms;