-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
102 additions
and
119 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
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
5 changes: 2 additions & 3 deletions
5
assets/src/js/app/action/audio.js → assets/src/js/app/action/stream.js
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
This file was deleted.
Oops, something went wrong.
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
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
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
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
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
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,12 @@ | ||
import av from '../lib/av'; | ||
av(async function() { | ||
const self = this; | ||
const themeSelector = (await import('../lib/themeSelector')).themeSelector; | ||
themeSelector(this.querySelector('[data-toggle-theme]')); | ||
window.addEventListener('auth', function() { | ||
self.reload(); | ||
}, { once: true }); | ||
}); | ||
|
||
export {} | ||
|
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
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
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
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,5 @@ | ||
export default function (init, destroy = null) { | ||
const target = document.currentScript.parentElement; | ||
window.av = window.av || []; | ||
window.av.push([target, init, destroy]); | ||
} |
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 |
---|---|---|
@@ -1,51 +1,40 @@ | ||
import executeScriptElements from "./executeScriptElements"; | ||
function loadAsyncView(target, body, template) { | ||
const nodes = target.querySelectorAll('.async-view'); | ||
const els = []; | ||
for (const n of nodes) { | ||
els.push(n); | ||
} | ||
let counter = 0; | ||
function loadAsyncView(target, body) { | ||
const els = target.querySelectorAll('[data-async-view]'); | ||
for (const el of els) { | ||
const t = el.getAttribute('async-template'); | ||
if (!t) continue; | ||
const listener = () => { | ||
counter++; | ||
if (counter === els.length) { | ||
renderBody(target, body, template); | ||
} | ||
} | ||
window.addEventListener(`async:${t}_destroyed`, listener, { once: true }); | ||
const view = el.getAttribute('data-async-view'); | ||
const detail = { | ||
target: el, | ||
}; | ||
const event = new CustomEvent(`async:${t}_destroy`, { detail }); | ||
const event = new CustomEvent(`async:${view}_destroy`, { detail }); | ||
window.dispatchEvent(event); | ||
} | ||
if (els.length === 0) { | ||
renderBody(target, body, template); | ||
} | ||
renderBody(target, body); | ||
} | ||
function renderBody(target, body, template) { | ||
function renderBody(target, body) { | ||
target.innerHTML = body; | ||
target.classList.add('async-loaded'); | ||
target.setAttribute('async-template', template); | ||
|
||
executeScriptElements(target); | ||
const detail = { | ||
target, | ||
template, | ||
}; | ||
// Update async elements | ||
const event = new CustomEvent('async', { detail }); | ||
window.dispatchEvent(event); | ||
|
||
// Process async views | ||
if (template) { | ||
const event = new CustomEvent('async:' + template, { detail }); | ||
const scripts = target.getElementsByTagName('script'); | ||
for (const script of scripts) { | ||
if (script.src === "") continue; | ||
const url = new URL(script.src); | ||
const name = url.pathname.replace(/\.js$/, ''); | ||
const event = new CustomEvent('async:' + name, { detail }); | ||
window.dispatchEvent(event); | ||
} | ||
target.scrollIntoView(); | ||
|
||
// Process async views | ||
const yOffset = -100; | ||
const y = target.getBoundingClientRect().top + window.scrollY + yOffset; | ||
|
||
window.scrollTo({ top: y }); | ||
} | ||
|
||
export default loadAsyncView; |
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
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
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
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
Oops, something went wrong.