aboutsummaryrefslogtreecommitdiff
path: root/static/script.ts
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2021-12-10 16:18:26 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2021-12-10 16:20:03 +0100
commit3afbb8e871af4e37965850bb59df3fcf2337d2a8 (patch)
tree0f5050fd9d4685e988315355f14a4e93d7099ac5 /static/script.ts
parent'.btn' no longer contains div. (diff)
downloadcalp-3afbb8e871af4e37965850bb59df3fcf2337d2a8.tar.gz
calp-3afbb8e871af4e37965850bb59df3fcf2337d2a8.tar.xz
Broke out setup of popup on event creation.
Diffstat (limited to 'static/script.ts')
-rw-r--r--static/script.ts50
1 files changed, 3 insertions, 47 deletions
diff --git a/static/script.ts b/static/script.ts
index f243dd67..cf92b24f 100644
--- a/static/script.ts
+++ b/static/script.ts
@@ -3,7 +3,7 @@ import { SmallcalCellHighlight, Timebar } from './clock'
import { makeElement } from './lib'
import { vcal_objects, event_calendar_mapping } from './globals'
import { EventCreator } from './event-creator'
-import { PopupElement } from './components/popup-element'
+import { PopupElement, setup_popup_element } from './components/popup-element'
import { initialize_components } from './elements'
/*
@@ -81,23 +81,9 @@ window.addEventListener('load', function() {
));
c.addEventListener('mouseup', eventCreator.create_event_finisher(
function(ev: VEvent) {
- // let popup = document.createElement('popup-element') as PopupElement;
-
let uid = ev.getProperty('uid');
-
vcal_objects.set(uid, ev);
-
- let popup = new PopupElement(uid);
- ev.register(popup);
- // console.log(popup);
- (document.querySelector('.days') as Element).appendChild(popup);
- let tabBtn = popup.querySelector('[role="tab"][title="Redigera"]') as HTMLButtonElement
- tabBtn.click()
- let tab = document.getElementById(tabBtn.getAttribute('aria-controls')!)!
- let input = tab.querySelector('input[name="summary"]') as HTMLInputElement
- popup.visible = true;
- input.select();
-
+ setup_popup_element(ev);
}));
}
@@ -112,39 +98,9 @@ window.addEventListener('load', function() {
);
c.onmouseup = eventCreator.create_event_finisher(
function(ev: VEvent) {
- // let popup = document.createElement('popup-element') as PopupElement;
-
let uid = ev.getProperty('uid');
-
vcal_objects.set(uid, ev);
-
- let popup = new PopupElement(uid);
- /* TODO these things fail, due to the event not being
- present in the global_events map */
- (document.querySelector('.days') as Element).appendChild(popup);
- ev.register(popup);
- popup.visible = true;
- console.log(popup);
- // (popup.querySelector("input[name='summary']") as HTMLInputElement).focus();
- // let popupElement = document.getElementById("popup" + event.id);
- // open_popup(popup_from_event(event));
-
- // popupElement.querySelector("input[name='summary']").focus();
-
-
- // ----------------------------------------------------------------------------------------------------
- // TODO restore this
- // let popupElement = document.getElementById("popup" + event.id);
- // open_popup(popupElement);
-
- // popupElement.querySelector("input[name='summary']").focus();
-
- // /* This assumes that it's unchecked beforehand.
- // Preferably we would just ensure that it's checked here,
- // But we also need to make sure that the proper handlers
- // are run then */
- // popupElement.querySelector("input[name='wholeday']").click();
-
+ setup_popup_element(ev);
});
}
}