1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

refactor: migrate most non-chart-related js logic to petite-vue (resolve #282)

This commit is contained in:
Ferdinand Mütsch
2021-12-16 19:30:09 +01:00
parent 6a5f08dc95
commit 26825b07de
7 changed files with 144 additions and 173 deletions

View File

@@ -1,10 +1,4 @@
<script type="module">
function findParentAttribute(el, attrName) {
if (el.attributes[attrName]) return el.attributes[attrName]
if (!el.parentNode || !el.parentNode.attributes) return null
return findParentAttribute(el.parentNode, attrName)
}
PetiteVue.createApp({
$delimiters: ['${', '}'],
state: {
@@ -15,9 +9,7 @@
mounted() {
window.addEventListener('click', (e) => {
const skip = findParentAttribute(e.target, 'data-trigger-for')?.value
Object.keys(this.state).forEach(k => {
if (k !== skip) this.state[k] = false
})
Object.keys(this.state).filter(k => k !== skip).forEach(k => this.state[k] = false)
})
}
}).mount('#main-menu')