From 2cf206afe826d8e7aaaffa013a95203cac76a46d Mon Sep 17 00:00:00 2001 From: Joey Schulze Date: Thu, 27 Jul 2017 23:08:08 +0200 Subject: [PATCH] Include code to position one element over another --- src/infodrom.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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; -- 2.20.1