From 6dce1fdbacdbd6f771461be019c3bf720d3d5a6d Mon Sep 17 00:00:00 2001 From: barisgul15 Date: Mon, 18 Dec 2023 20:08:07 +0100 Subject: [PATCH] popup chat close when esc pressed func. is added --- web/template/popup-chat.gohtml | 4 ++++ web/ts/components/popup.ts | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/web/template/popup-chat.gohtml b/web/template/popup-chat.gohtml index ba0c9f442..ecc9d1b03 100644 --- a/web/template/popup-chat.gohtml +++ b/web/template/popup-chat.gohtml @@ -1,6 +1,7 @@ {{- /*gotype: github.com/TUM-Dev/gocast/web.ChatData*/ -}} {{$course := .IndexData.TUMLiveContext.Course}} {{$stream := .IndexData.TUMLiveContext.Stream}} +{{- $closeChatFunction := `closeChatOnEscapePressed();` -}} @@ -19,4 +20,7 @@ {{template "chat-component" .}} + diff --git a/web/ts/components/popup.ts b/web/ts/components/popup.ts index 568f18a89..146b12fd0 100644 --- a/web/ts/components/popup.ts +++ b/web/ts/components/popup.ts @@ -13,3 +13,11 @@ export function popupContext(streamId: number): AlpineComponent { }, } as AlpineComponent; } + +export function closeChatOnEscapePressed() { + document.addEventListener('keyup', function(event) { + if (event.key === 'Escape') { + window.close(); + } + }); +}