Cleanup before 1.0 release
This commit is contained in:
parent
e89074b986
commit
900371cc83
74 changed files with 3309 additions and 2415 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -82,7 +82,7 @@ const samplesAreEnabled = () => {
|
|||
|
||||
|
||||
const initHidingLeftNavigation = () => {
|
||||
document.getElementById("leftToggler").onclick = function (event) {
|
||||
document.getElementById("menu-toggle").onclick = function (event) {
|
||||
//Events need to be prevented from bubbling since they will trigger next handler
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
@ -129,22 +129,39 @@ function handleAnchor() {
|
|||
highlightedAnchor = null;
|
||||
}
|
||||
|
||||
let searchForTab = function (element) {
|
||||
let searchForContentTarget = function (element) {
|
||||
if (element && element.hasAttribute) {
|
||||
if (element.hasAttribute("data-togglable")) return element;
|
||||
else return searchForTab(element.parentNode)
|
||||
if (element.hasAttribute("data-togglable")) return element.getAttribute("data-togglable");
|
||||
else return searchForContentTarget(element.parentNode)
|
||||
} else return null
|
||||
}
|
||||
|
||||
let findAnyTab = function (target) {
|
||||
let result = null
|
||||
document.querySelectorAll('div[tabs-section] > button[data-togglable]')
|
||||
.forEach(node => {
|
||||
if(node.getAttribute("data-togglable").split(",").includes(target)) {
|
||||
result = node
|
||||
}
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
let anchor = window.location.hash
|
||||
if (anchor != "") {
|
||||
anchor = anchor.substring(1)
|
||||
let element = document.querySelector('a[data-name="' + anchor + '"]')
|
||||
|
||||
if (element) {
|
||||
let tab = searchForTab(element)
|
||||
if (tab) {
|
||||
toggleSections(tab)
|
||||
}
|
||||
const content = element.nextElementSibling
|
||||
const contentStyle = window.getComputedStyle(content)
|
||||
if(contentStyle.display == 'none') {
|
||||
let tab = findAnyTab(searchForContentTarget(content))
|
||||
if (tab) {
|
||||
toggleSections(tab)
|
||||
}
|
||||
}
|
||||
|
||||
if (content) {
|
||||
content.classList.add('anchor-highlight')
|
||||
highlightedAnchor = content
|
||||
|
@ -174,10 +191,7 @@ function initTabs() {
|
|||
function showCorrespondingTabBody(element) {
|
||||
const buttonWithKey = element.querySelector("button[data-active]")
|
||||
if (buttonWithKey) {
|
||||
const key = buttonWithKey.getAttribute("data-togglable")
|
||||
document.querySelector(".tabs-section-body")
|
||||
.querySelector("div[data-togglable='" + key + "']")
|
||||
.setAttribute("data-active", "")
|
||||
toggleSections(buttonWithKey)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -249,7 +263,6 @@ function removeSourcesetFilterFromCache(sourceset) {
|
|||
}
|
||||
|
||||
function toggleSections(target) {
|
||||
localStorage.setItem('active-tab', JSON.stringify(target.getAttribute("data-togglable")))
|
||||
const activateTabs = (containerClass) => {
|
||||
for (const element of document.getElementsByClassName(containerClass)) {
|
||||
for (const child of element.children) {
|
||||
|
@ -261,13 +274,24 @@ function toggleSections(target) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
const toggleTargets = target.getAttribute("data-togglable").split(",")
|
||||
const activateTabsBody = (containerClass) => {
|
||||
document.querySelectorAll("." + containerClass + " *[data-togglable]")
|
||||
.forEach(child => {
|
||||
if (toggleTargets.includes(child.getAttribute("data-togglable"))) {
|
||||
child.setAttribute("data-active", "")
|
||||
} else if(!child.classList.contains("sourceset-dependent-content")) { // data-togglable is used to switch source set as well, ignore it
|
||||
child.removeAttribute("data-active")
|
||||
}
|
||||
})
|
||||
}
|
||||
activateTabs("tabs-section")
|
||||
activateTabs("tabs-section-body")
|
||||
activateTabsBody("tabs-section-body")
|
||||
}
|
||||
|
||||
function toggleSectionsEventHandler(evt) {
|
||||
if (!evt.target.getAttribute("data-togglable")) return
|
||||
localStorage.setItem('active-tab', JSON.stringify(evt.target.getAttribute("data-togglable")))
|
||||
toggleSections(evt.target)
|
||||
}
|
||||
|
||||
|
@ -298,13 +322,23 @@ function refreshFiltering() {
|
|||
document.querySelectorAll("[data-filterable-set]")
|
||||
.forEach(
|
||||
elem => {
|
||||
let platformList = elem.getAttribute("data-filterable-set").split(' ').filter(v => -1 !== sourcesetList.indexOf(v))
|
||||
elem.setAttribute("data-filterable-current", platformList.join(' '))
|
||||
let platformList = elem.getAttribute("data-filterable-set").split(',').filter(v => -1 !== sourcesetList.indexOf(v))
|
||||
elem.setAttribute("data-filterable-current", platformList.join(','))
|
||||
}
|
||||
)
|
||||
refreshFilterButtons()
|
||||
refreshPlatformTabs()
|
||||
refreshNoContentNotification()
|
||||
refreshPlaygroundSamples()
|
||||
}
|
||||
|
||||
function refreshPlaygroundSamples() {
|
||||
document.querySelectorAll('code.runnablesample').forEach(node => {
|
||||
const playground = node.KotlinPlayground;
|
||||
/* Some samples may be hidden by filter, they have 0px height for visible code area
|
||||
* after rendering. Call this method for re-calculate code area height */
|
||||
playground && playground.view.codemirror.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
function refreshNoContentNotification() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue