diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-07-13 00:51:36 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-07-13 00:52:29 +0200 |
commit | 235316966e40ce2b28d94557a280f1bc3b9c2eef (patch) | |
tree | ae666a176f23b90374a3a6f8b8620df1c3475284 /static/script.js | |
parent | Fix Javascript part of event removal. (diff) | |
download | calp-235316966e40ce2b28d94557a280f1bc3b9c2eef.tar.gz calp-235316966e40ce2b28d94557a280f1bc3b9c2eef.tar.xz |
Add basic movement of popups.
Diffstat (limited to 'static/script.js')
-rw-r--r-- | static/script.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/static/script.js b/static/script.js index 008cc1e2..af0fba8f 100644 --- a/static/script.js +++ b/static/script.js @@ -324,6 +324,28 @@ window.onload = function () { } } + for (let nav of document.getElementsByClassName("popup-control")) { + nav.onmousedown = function (e) { + if (e.target != nav) return; + nav.style.cursor = "grabbing"; + nav.dataset.grabbed = "true"; + nav.dataset.grabPoint = e.layerX + ";" + e.layerY; + } + nav.onmousemove = function (e) { + if (nav.dataset.grabbed) { + let [x, y] = nav.dataset.grabPoint.split(";").map(Number); + let popup = nav.closest(".popup-container"); + + popup.style.left = popup.offsetLeft + (e.layerX - x) + "px"; + popup.style.top = popup.offsetTop + (e.layerY - y) + "px"; + } + } + nav.onmouseup = function () { + nav.dataset.grabbed = ""; + nav.style.cursor = ""; + } + } + for (let el of document.getElementsByClassName("event")) { /* Popup script replaces need for anchors to events. On mobile they also have the problem that they make |