mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-09-04 23:59:29 +00:00
deploy: ea497ea488
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -18,8 +18,6 @@ const samplesLightThemeName = 'idea'
|
||||
window.addEventListener('load', () => {
|
||||
document.querySelectorAll("div[data-platform-hinted]")
|
||||
.forEach(elem => elem.addEventListener('click', (event) => togglePlatformDependent(event, elem)))
|
||||
document.querySelectorAll("div[tabs-section]")
|
||||
.forEach(elem => elem.addEventListener('click', (event) => toggleSectionsEventHandler(event)))
|
||||
const filterSection = document.getElementById('filter-section')
|
||||
if (filterSection) {
|
||||
filterSection.addEventListener('click', (event) => filterButtonHandler(event))
|
||||
@@ -177,19 +175,30 @@ function handleAnchor() {
|
||||
}
|
||||
|
||||
function initTabs() {
|
||||
document.querySelectorAll("div[tabs-section]")
|
||||
.forEach(element => {
|
||||
showCorrespondingTabBody(element)
|
||||
element.addEventListener('click', (event) => toggleSectionsEventHandler(event))
|
||||
})
|
||||
let cached = localStorage.getItem("active-tab")
|
||||
if (cached) {
|
||||
let parsed = JSON.parse(cached)
|
||||
let tab = document.querySelector('div[tabs-section] > button[data-togglable="' + parsed + '"]')
|
||||
if (tab) {
|
||||
toggleSections(tab)
|
||||
}
|
||||
}
|
||||
// we could have only a single type of data - classlike or package
|
||||
const mainContent = document.querySelector('.main-content');
|
||||
const type = mainContent ? mainContent.getAttribute("data-page-type") : null;
|
||||
const localStorageKey = "active-tab-" + type;
|
||||
document.querySelectorAll('div[tabs-section]').forEach(element => {
|
||||
showCorrespondingTabBody(element);
|
||||
element.addEventListener('click', ({target}) => {
|
||||
const togglable = target ? target.getAttribute("data-togglable") : null;
|
||||
if (!togglable) return;
|
||||
|
||||
localStorage.setItem(localStorageKey, JSON.stringify(togglable));
|
||||
toggleSections(target);
|
||||
});
|
||||
});
|
||||
|
||||
const cached = localStorage.getItem(localStorageKey);
|
||||
if (!cached) return;
|
||||
|
||||
const tab = document.querySelector(
|
||||
'div[tabs-section] > button[data-togglable="' + JSON.parse(cached) + '"]'
|
||||
);
|
||||
if (!tab) return;
|
||||
|
||||
toggleSections(tab);
|
||||
}
|
||||
|
||||
function showCorrespondingTabBody(element) {
|
||||
@@ -293,12 +302,6 @@ function toggleSections(target) {
|
||||
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)
|
||||
}
|
||||
|
||||
function togglePlatformDependent(e, container) {
|
||||
let target = e.target
|
||||
if (target.tagName != 'BUTTON') return;
|
||||
|
Reference in New Issue
Block a user