add dev-toc javascripts
This commit is contained in:
23
javascripts/dev-toc.js
Normal file
23
javascripts/dev-toc.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
const expandText = 'Expand All'
|
||||||
|
const closeText = 'Close All'
|
||||||
|
|
||||||
|
export default function devToc () {
|
||||||
|
const expandButton = document.querySelector('.js-expand')
|
||||||
|
if (!expandButton) return
|
||||||
|
|
||||||
|
expandButton.addEventListener('click', () => {
|
||||||
|
// on click, toggle the button text
|
||||||
|
expandButton.textContent === expandText
|
||||||
|
? expandButton.textContent = closeText
|
||||||
|
: expandButton.textContent = expandText
|
||||||
|
|
||||||
|
// on click, toggle all the details elements open or closed
|
||||||
|
const detailsElements = document.querySelectorAll('details')
|
||||||
|
|
||||||
|
for (const detailsElement of detailsElements) {
|
||||||
|
detailsElement.open
|
||||||
|
? detailsElement.removeAttribute('open')
|
||||||
|
: detailsElement.open = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -17,23 +17,28 @@ import { fillCsrf } from './get-csrf'
|
|||||||
import initializeEvents from './events'
|
import initializeEvents from './events'
|
||||||
import filterCodeExamples from './filter-code-examples'
|
import filterCodeExamples from './filter-code-examples'
|
||||||
import allArticles from './all-articles'
|
import allArticles from './all-articles'
|
||||||
|
import devToc from './dev-toc'
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', async () => {
|
if (location.pathname.endsWith('/dev-toc')) {
|
||||||
displayPlatformSpecificContent()
|
devToc()
|
||||||
explorer()
|
} else {
|
||||||
search()
|
document.addEventListener('DOMContentLoaded', async () => {
|
||||||
nav()
|
displayPlatformSpecificContent()
|
||||||
browserDateFormatter()
|
explorer()
|
||||||
deprecationBanner()
|
search()
|
||||||
sidebar()
|
nav()
|
||||||
wrapCodeTerms()
|
browserDateFormatter()
|
||||||
print()
|
deprecationBanner()
|
||||||
localization()
|
sidebar()
|
||||||
await fillCsrf() // this must complete before any POST calls
|
wrapCodeTerms()
|
||||||
helpfulness()
|
print()
|
||||||
experiment()
|
localization()
|
||||||
copyCode()
|
await fillCsrf() // this must complete before any POST calls
|
||||||
initializeEvents()
|
helpfulness()
|
||||||
filterCodeExamples()
|
experiment()
|
||||||
allArticles()
|
copyCode()
|
||||||
})
|
initializeEvents()
|
||||||
|
filterCodeExamples()
|
||||||
|
allArticles()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user