Introduction
Introduction Statistics Contact Development Disclaimer Help
datepicker: improve table popup positioning - jscancer - Javascript crap (relat…
git clone git://git.codemadness.org/jscancer
Log
Files
Refs
README
LICENSE
---
commit a7942f7578eae5031a1baa6867ee20631ac2226a
parent 39836e1d998366312bca5fe1f77400923fffd868
Author: Hiltjo Posthuma <[email protected]>
Date: Tue, 30 May 2017 19:38:23 +0200
datepicker: improve table popup positioning
Diffstat:
M datepicker/datepicker.js | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/datepicker/datepicker.js b/datepicker/datepicker.js
@@ -77,12 +77,18 @@ function datepicker_init(input) {
table.hidden = false;
table.style.display = "table";
table.style.position = "absolute";
- var left = 0;
+ var left = 0, top = 0;
for (var c = input; c; c = c.offsetParent) {
- if (["absolute", "fixed"].indexOf(c.style.position) ==…
- left += c.offsetLeft;
+ left += c.offsetLeft;
+ top += c.offsetTop;
+ if (c.style.position == "fixed") {
+ left += window.pageXOffset;
+ top += window.pageYOffset;
+ break;
+ }
}
table.style.left = String(left) + "px";
+ table.style.top = String(top + input.offsetHeight) + "px";
// scroll if outside window.
input.scrollIntoView();
};
@@ -194,7 +200,7 @@ function datepicker_init(input) {
datepicker_render();
datepicker_hide();
- input.parentNode.insertBefore(table, input.nextSibling);
+ document.body.appendChild(table);
}
// has native HTML5 date input type support? type is "text" if it isn't.
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.