aboutsummaryrefslogtreecommitdiff
path: root/static/script.ts
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2021-12-10 00:16:25 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2021-12-10 00:48:09 +0100
commitde593cf0d4a6a082f0c42e00be395e0f6cf49e96 (patch)
tree578e4d10aabc3bfac98d9962ea4644b357fbb044 /static/script.ts
parentRemove vcal.js. (diff)
downloadcalp-de593cf0d4a6a082f0c42e00be395e0f6cf49e96.tar.gz
calp-de593cf0d4a6a082f0c42e00be395e0f6cf49e96.tar.xz
Remove popup.ts, migrating all functionality elsewhere.
The simple procedures - close_popup - open_popup - toggle_popup - find_popup Were mostly here for legacy. The procedures - popup_from_event - event_from_popup where holdovers from the old way of finding popups, and should be done through the VEvent objects now. close_all_popups was used only once, so the code was moved inline. Finally, moving the last hovered over popup to the top, along with tab switch keybings were restored, and moved to propper places.
Diffstat (limited to 'static/script.ts')
-rw-r--r--static/script.ts31
1 files changed, 26 insertions, 5 deletions
diff --git a/static/script.ts b/static/script.ts
index f378ced1..34443b16 100644
--- a/static/script.ts
+++ b/static/script.ts
@@ -1,9 +1,7 @@
-import { close_all_popups } from './popup'
import { VEvent, xml_to_vcal } from './vevent'
import { SmallcalCellHighlight, Timebar } from './clock'
import { makeElement } from './lib'
import { vcal_objects, event_calendar_mapping } from './globals'
-import { open_popup } from './popup'
import { EventCreator } from './event-creator'
import { PopupElement } from './components/popup-element'
import { initialize_components } from './elements'
@@ -97,7 +95,7 @@ window.addEventListener('load', function() {
tabBtn.click()
let tab = document.getElementById(tabBtn.getAttribute('aria-controls')!)!
let input = tab.querySelector('input[name="summary"]') as HTMLInputElement
- open_popup(popup);
+ popup.visible = true;
input.select();
}));
@@ -125,7 +123,7 @@ window.addEventListener('load', function() {
present in the global_events map */
(document.querySelector('.days') as Element).appendChild(popup);
ev.register(popup);
- open_popup(popup);
+ popup.visible = true;
console.log(popup);
// (popup.querySelector("input[name='summary']") as HTMLInputElement).focus();
// let popupElement = document.getElementById("popup" + event.id);
@@ -181,7 +179,9 @@ window.addEventListener('load', function() {
evt = evt || window.event;
if (!evt.key) return;
if (evt.key.startsWith("Esc")) {
- close_all_popups();
+ for (let popup of document.querySelectorAll("popup-element[visible]")) {
+ popup.removeAttribute('visible')
+ }
}
}
@@ -232,6 +232,27 @@ window.addEventListener('load', function() {
// init_input_list();
+ document.addEventListener('keydown', function(event) {
+ /* Physical key position, names are what that key would
+ be in QWERTY */
+ let i = ({
+ 'KeyQ': 0,
+ 'KeyW': 1,
+ 'KeyE': 2,
+ 'KeyR': 3,
+ 'KeyT': 4,
+ 'KeyY': 5,
+ })[event.code];
+ if (i === undefined) return
+ if (!PopupElement.activePopup) return;
+ let element = PopupElement
+ .activePopup
+ .querySelectorAll("[role=tab]")[i] as HTMLInputElement | undefined
+ if (!element) return;
+ /* don't switch tab if event was fired while writing */
+ if ('value' in (event.target as any)) return;
+ element.click();
+ });
document.addEventListener('keydown', function(event) {
if (event.key == '/') {