Skip to content

Commit

Permalink
popup chat close when esc pressed func. is added
Browse files Browse the repository at this point in the history
  • Loading branch information
barisgul15 committed Dec 18, 2023
1 parent eff714b commit 6dce1fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions web/template/popup-chat.gohtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{- /*gotype: github.com/TUM-Dev/gocast/web.ChatData*/ -}}
{{$course := .IndexData.TUMLiveContext.Course}}
{{$stream := .IndexData.TUMLiveContext.Stream}}
{{- $closeChatFunction := `closeChatOnEscapePressed();` -}}
<!DOCTYPE html>
<html lang="en" class="h-full dark">
<head>
Expand All @@ -19,4 +20,7 @@
</head>
<body class="bg-white dark:bg-secondary h-screen" x-data="interaction.popupContext({{$stream.ID}})">
{{template "chat-component" .}}
<script>
interaction.closeChatOnEscapePressed();
</script>
</body>
8 changes: 8 additions & 0 deletions web/ts/components/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});
}

0 comments on commit 6dce1fd

Please sign in to comment.