]> BookStack Code Mirror - website/blob - themes/bookstack/static/js/script.js
Removed codemirror usage to make better usage of built-in code highliter
[website] / themes / bookstack / static / js / script.js
1
2 // Mobile menu
3
4 const menuButton = document.getElementById('menu-button');
5 const menuDropDown = document.querySelector('#header .main-nav');
6
7 menuButton.addEventListener('click', function(event) {
8   menuDropDown.classList.toggle('showing');
9   event.stopPropagation();
10 });
11
12 document.body.addEventListener('click', function(event) {
13   menuDropDown.classList.remove('showing');
14   event.stopPropagation();  
15 });
16
17
18 // Handle video click to play
19 const videos = document.querySelectorAll('video');
20 for (let i = 0; i < videos.length; i++) {
21     videos[i].addEventListener('click', videoClick)
22 }
23
24 function videoClick() {
25     if (typeof InstallTrigger !== 'undefined') return;
26     this.paused ? this.play() : this.pause();
27 }
28
29 // Header double click URL reference
30 document.body.addEventListener('dblclick', event => {
31   const isHeader = event.target.matches('h1, h2, h3, h4, h5, h6');
32   if (isHeader && event.target.id) {
33     window.location.hash = event.target.id;
34   }
35 });