From 09872d462c4ff2dc5a710fd13042060531099c5e Mon Sep 17 00:00:00 2001 From: Roland van Laar Date: Mon, 14 Nov 2016 15:47:45 +0100 Subject: [PATCH] Move getBoundingClientRect to options. This moves the getBoundingClientRect to options. This gives to possibility to specify a different object below which the dropdown should show. --- auto-complete.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/auto-complete.js b/auto-complete.js index 2f5a88c..2b7f1b1 100644 --- a/auto-complete.js +++ b/auto-complete.js @@ -43,7 +43,10 @@ var autoComplete = (function(){ var re = new RegExp("(" + search.split(' ').join('|') + ")", "gi"); return '
' + item.replace(re, "$1") + '
'; }, - onSelect: function(e, term, item){} + onSelect: function(e, term, item){}, + getBoundingClientRect: function(that){ + return that.getBoundingClientRect(); + } }; for (var k in options) { if (options.hasOwnProperty(k)) o[k] = options[k]; } @@ -62,7 +65,7 @@ var autoComplete = (function(){ that.last_val = ''; that.updateSC = function(resize, next){ - var rect = that.getBoundingClientRect(); + var rect = o.getBoundingClientRect(); that.sc.style.left = Math.round(rect.left + (window.pageXOffset || document.documentElement.scrollLeft) + o.offsetLeft) + 'px'; that.sc.style.top = Math.round(rect.bottom + (window.pageYOffset || document.documentElement.scrollTop) + o.offsetTop) + 'px'; that.sc.style.width = Math.round(rect.right - rect.left) + 'px'; // outerWidth