-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from FutureProofHomes/develop
Develop
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
(() => { | ||
function event_handler(event) { | ||
event.stopPropagation(); | ||
} | ||
|
||
// Function to disable MkDocs Material keyboard shortcuts | ||
function disableKeyboardShortcuts() { | ||
document.addEventListener('keydown', event_handler, true); | ||
console.log('Keyboard Shortcuts disabled 🖖') | ||
} | ||
|
||
// Function to enable MkDocs Material keyboard shortcuts | ||
function enableKeyboardShortcuts() { | ||
document.removeEventListener('keydown', event_handler, true); | ||
console.log('Keyboard Shortcuts enabled') | ||
} | ||
|
||
// Create a MutationObserver to watch for changes in the document | ||
const observer = new MutationObserver(() => { | ||
const installDialog = document.querySelector('body > ewt-install-dialog'); | ||
|
||
if (installDialog) { | ||
// If the install dialog is present, disable keyboard shortcuts | ||
disableKeyboardShortcuts(); | ||
} else { | ||
// If the install dialog is not present, enable keyboard shortcuts | ||
enableKeyboardShortcuts(); | ||
} | ||
}); | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
// Start observing the document body for child additions/removals | ||
observer.observe(document.body, { childList: true }); | ||
}); | ||
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters