aboutsummaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2021-12-12 23:29:41 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2021-12-12 23:30:34 +0100
commita5c4962f1b3c9b2e4c23a7e3912af2dfcb4f0507 (patch)
tree9223166e6522b20f3e77474066729d4c3fd0d304 /static
parentAdd TODO about broken color files. (diff)
downloadcalp-a5c4962f1b3c9b2e4c23a7e3912af2dfcb4f0507.tar.gz
calp-a5c4962f1b3c9b2e4c23a7e3912af2dfcb4f0507.tar.xz
Merge draggable into popup-element.
Diffstat (limited to 'static')
-rw-r--r--static/components/popup-element.ts38
-rw-r--r--static/dragable.ts46
-rw-r--r--static/script.ts4
3 files changed, 37 insertions, 51 deletions
diff --git a/static/components/popup-element.ts b/static/components/popup-element.ts
index 4d5545fc..35c966ac 100644
--- a/static/components/popup-element.ts
+++ b/static/components/popup-element.ts
@@ -1,7 +1,6 @@
export { PopupElement, setup_popup_element }
import { VEvent } from '../vevent'
-import { bind_popup_control } from '../dragable'
import { find_block, vcal_objects } from '../globals'
import { ComponentVEvent } from './vevent'
@@ -160,3 +159,40 @@ function setup_popup_element(ev: VEvent): PopupElement {
input.select();
return popup;
}
+
+/*
+ Given the navbar of a popup, make it dragable.
+ */
+function bind_popup_control(nav: HTMLElement) {
+
+ // if (!nav.closest('popup-element')) {
+ // console.log(nav);
+ // throw TypeError('not a popup container');
+ // }
+
+ nav.addEventListener('mousedown', function(e) {
+ /* Ignore mousedown on children */
+ if (e.target != nav) return;
+ nav.style.cursor = "grabbing";
+ nav.dataset.grabbed = "true";
+ nav.dataset.grabPoint = e.clientX + ";" + e.clientY;
+ // let popup = nav.closest(".popup-container");
+ let popup = nav.closest("popup-element") as HTMLElement;
+ nav.dataset.startPoint = popup.offsetLeft + ";" + popup.offsetTop;
+ })
+ window.addEventListener('mousemove', function(e) {
+ if (nav.dataset.grabbed) {
+ let [x, y] = nav.dataset.grabPoint!.split(";").map(Number);
+ let [startX, startY] = nav.dataset.startPoint!.split(";").map(Number);
+ // let popup = nav.closest(".popup-container");
+ let popup = nav.closest("popup-element") as HTMLElement;
+
+ popup.style.left = startX + (e.clientX - x) + "px";
+ popup.style.top = startY + (e.clientY - y) + "px";
+ }
+ });
+ window.addEventListener('mouseup', function() {
+ nav.dataset.grabbed = "";
+ nav.style.cursor = "";
+ });
+}
diff --git a/static/dragable.ts b/static/dragable.ts
deleted file mode 100644
index b32bb608..00000000
--- a/static/dragable.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-export { bind_popup_control }
-
-/*
- Apply to a given component to make it draggable.
- Drag area (usually a title bar) should be be the only argument.
- It is REQUIRED that the object which should be moved have the class
- 'popup-container';
-*/
-
-
-/*
- Given the navbar of a popup, make it dragable.
- */
-function bind_popup_control(nav: HTMLElement) {
-
- // if (!nav.closest('popup-element')) {
- // console.log(nav);
- // throw TypeError('not a popup container');
- // }
-
- nav.addEventListener('mousedown', function(e) {
- /* Ignore mousedown on children */
- if (e.target != nav) return;
- nav.style.cursor = "grabbing";
- nav.dataset.grabbed = "true";
- nav.dataset.grabPoint = e.clientX + ";" + e.clientY;
- // let popup = nav.closest(".popup-container");
- let popup = nav.closest("popup-element") as HTMLElement;
- nav.dataset.startPoint = popup.offsetLeft + ";" + popup.offsetTop;
- })
- window.addEventListener('mousemove', function(e) {
- if (nav.dataset.grabbed) {
- let [x, y] = nav.dataset.grabPoint!.split(";").map(Number);
- let [startX, startY] = nav.dataset.startPoint!.split(";").map(Number);
- // let popup = nav.closest(".popup-container");
- let popup = nav.closest("popup-element") as HTMLElement;
-
- popup.style.left = startX + (e.clientX - x) + "px";
- popup.style.top = startY + (e.clientY - y) + "px";
- }
- });
- window.addEventListener('mouseup', function() {
- nav.dataset.grabbed = "";
- nav.style.cursor = "";
- });
-}
diff --git a/static/script.ts b/static/script.ts
index cf92b24f..895b0081 100644
--- a/static/script.ts
+++ b/static/script.ts
@@ -105,10 +105,6 @@ window.addEventListener('load', function() {
}
}
- // for (let nav of document.getElementsByClassName("popup-control")) {
- // bind_popup_control(nav);
- // }
-
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