|
|
|
@ -4,6 +4,7 @@ export class NavMenu extends HTMLElement {
|
|
|
|
this.attachShadow({mode: 'open'})
|
|
|
|
this.attachShadow({mode: 'open'})
|
|
|
|
this.language = navigator.language
|
|
|
|
this.language = navigator.language
|
|
|
|
this.pages = []
|
|
|
|
this.pages = []
|
|
|
|
|
|
|
|
this.handleLinks = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
connectedCallback() {
|
|
|
|
connectedCallback() {
|
|
|
|
@ -42,9 +43,16 @@ export class NavMenu extends HTMLElement {
|
|
|
|
this.renderPageList()
|
|
|
|
this.renderPageList()
|
|
|
|
this.shadowRoot.addEventListener('click', e => {
|
|
|
|
this.shadowRoot.addEventListener('click', e => {
|
|
|
|
if (e.target.classList.contains('page')) {
|
|
|
|
if (e.target.classList.contains('page')) {
|
|
|
|
|
|
|
|
if (this.handleLinks) {
|
|
|
|
|
|
|
|
e.preventDefault()
|
|
|
|
|
|
|
|
}
|
|
|
|
this.dispatchEvent(new CustomEvent(
|
|
|
|
this.dispatchEvent(new CustomEvent(
|
|
|
|
'close-menu', {bubbles: true}
|
|
|
|
'close-menu', {bubbles: true}
|
|
|
|
))
|
|
|
|
))
|
|
|
|
|
|
|
|
if (this.handleLinks) {
|
|
|
|
|
|
|
|
const hash = '#' + e.target.innerText
|
|
|
|
|
|
|
|
location.hash = hash
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|