summaryrefslogtreecommitdiff
path: root/source/features
diff options
context:
space:
mode:
Diffstat (limited to 'source/features')
-rw-r--r--source/features/stop-pjax-loading-with-esc.tsx50
1 files changed, 0 insertions, 50 deletions
diff --git a/source/features/stop-pjax-loading-with-esc.tsx b/source/features/stop-pjax-loading-with-esc.tsx
deleted file mode 100644
index c7743c45..00000000
--- a/source/features/stop-pjax-loading-with-esc.tsx
+++ /dev/null
@@ -1,50 +0,0 @@
-import select from 'select-dom';
-
-import features from '../feature-manager';
-
-let progressLoader: HTMLElement;
-const progressLoaderLoadingClass = 'is-loading';
-
-function keydownHandler(event: KeyboardEvent): void {
- if (event.key !== 'Escape' || !progressLoader.classList.contains(progressLoaderLoadingClass)) {
- return;
- }
-
- if (history.state && '_id' in history.state) {
- const pjaxContainer = select('#js-repo-pjax-container, #js-pjax-container, #gist-pjax-container');
-
- if (pjaxContainer) {
- // We need it for correct work of browser forward-button
- history.replaceState({
- url: location.href,
- title: '',
- container: `#${pjaxContainer.id}`,
- ...history.state,
- }, '', location.href);
- } else {
- features.log.error(import.meta.url, 'Pjax container not found.');
- }
- }
-
- window.addEventListener('pjax:error', pjaxErrorHandler, {once: true});
-
- history.back();
- progressLoader.classList.remove(progressLoaderLoadingClass);
-}
-
-function pjaxErrorHandler(event: CustomEvent): void {
- if (event.cancelable) {
- // Avoid location.replace() when AbortController.abort() throw an error
- event.preventDefault();
- }
-}
-
-// Do not use signal, these event must persist on unload
-function init(): void {
- progressLoader = select('.progress-pjax-loader')!;
- window.addEventListener('keydown', keydownHandler);
-}
-
-void features.add(import.meta.url, {
- init,
-});