From 72792b048e6bbdd06ba3c775c8b870d64dcd856d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 26 Apr 2020 18:50:41 +0200 Subject: Sidebar event code now reusable for popups. --- static/script.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'static/script.js') diff --git a/static/script.js b/static/script.js index a5a5093d..274bcb86 100644 --- a/static/script.js +++ b/static/script.js @@ -128,9 +128,14 @@ function max(a, b) { /* https://stackoverflow.com/questions/21064101/understanding-offsetwidth-clientwidth-scrollwidth-and-height-respectively */ -function new_popup () { +function new_popup (event) { - popup = this.children[0].children[0] + console.log(event.target); + console.log(this); + // if (event.target !== this) return; + + /* popup = this.children[0].children[0] */ + popup = this.parentElement.getElementsByClassName("popup")[0]; popup.classList.toggle("show") /* x-axis fix */ @@ -197,7 +202,7 @@ window.onload = function () { // } days = document.getElementsByClassName("days")[0] - for (let e of days.getElementsByClassName("event")) { + for (let e of days.getElementsByClassName("body")) { e.onclick = new_popup; } -- cgit v1.2.3