Files
hextra_mirror/assets/js/tabs.js

58 lines
1.9 KiB
JavaScript
Raw Normal View History

feat(tabs): implement synchronized tabs switching (#700) * Sync tabs across groups * feat(tabs): add optional synchronization * Move tabs sync setting under page params * fix: spacing between title and site title (#704) * docs: document configure opengraph image (#706) * [Docs] document using og:image * Make example title page match others * clarify wording * chore: update tailwind css to latest version 4.1.8 (#703) * fix: wrong SRI hash for katex.css (#702) * Correct URL given in 'dev.toml' * stylesheet 'katex.css': fix SRI hash * fix(build): run npm update to fix postcss complaint * feat(tags): improve usability of tags (#698) * feat(tags): improve usability of tags * Tags can be shown also at docs * Documented tag-related config flags * Added example tags to the site * Made rendered tags active * Move tags listing to ToC * Hide tags section on no tags * feat(math): add optional MathJax support (#707) * feat: add MathJax option * docs: move math engine note * refactor: update LaTeX documentation and improve MathJax integration - Adjusted LaTeX documentation for clarity and formatting. - Enhanced MathJax configuration in the templates to support both KaTeX and MathJax rendering. - Removed deprecated comments and streamlined the script loading process for MathJax. - Updated the passthrough extension settings in the Hugo configuration for better compatibility with LaTeX math expressions. * docs: simplify LaTeX documentation and clarify configuration steps - Updated LaTeX documentation to reflect that KaTeX is enabled by default, removing the need for manual activation. - Added examples for using LaTeX math expressions and clarified the configuration for the passthrough extension in Hugo. - Enhanced MathJax section to emphasize its use as an alternative rendering engine. * fix(tabs): add null check for panels container and update example items * fix(tabs): improve tab group key handling and add validation for items parameter * refactor(tabs): comment out sync option in configuration and adjust tab formatting in documentation --------- Co-authored-by: hobobandy <30026704+hobobandy@users.noreply.github.com> Co-authored-by: Matt Dodson <47385188+MattDodsonEnglish@users.noreply.github.com> Co-authored-by: Andreas Deininger <adeininger@urbanonline.de> Co-authored-by: yuri <1969yuri1969@gmail.com>
2025-07-21 21:16:44 +01:00
(function () {
function updateGroup(container, index) {
const tabs = Array.from(container.querySelectorAll('.hextra-tabs-toggle'));
tabs.forEach((tab, i) => {
tab.dataset.state = i === index ? 'selected' : '';
if (i === index) {
tab.setAttribute('aria-selected', 'true');
tab.tabIndex = 0;
} else {
tab.removeAttribute('aria-selected');
tab.removeAttribute('tabindex');
}
});
const panelsContainer = container.parentElement.nextElementSibling;
if (!panelsContainer) return;
Array.from(panelsContainer.children).forEach((panel, i) => {
panel.dataset.state = i === index ? 'selected' : '';
if (i === index) {
panel.tabIndex = 0;
} else {
panel.removeAttribute('tabindex');
}
});
}
const syncGroups = document.querySelectorAll('[data-tab-group]');
syncGroups.forEach((group) => {
feat(tabs): implement synchronized tabs switching (#700) * Sync tabs across groups * feat(tabs): add optional synchronization * Move tabs sync setting under page params * fix: spacing between title and site title (#704) * docs: document configure opengraph image (#706) * [Docs] document using og:image * Make example title page match others * clarify wording * chore: update tailwind css to latest version 4.1.8 (#703) * fix: wrong SRI hash for katex.css (#702) * Correct URL given in 'dev.toml' * stylesheet 'katex.css': fix SRI hash * fix(build): run npm update to fix postcss complaint * feat(tags): improve usability of tags (#698) * feat(tags): improve usability of tags * Tags can be shown also at docs * Documented tag-related config flags * Added example tags to the site * Made rendered tags active * Move tags listing to ToC * Hide tags section on no tags * feat(math): add optional MathJax support (#707) * feat: add MathJax option * docs: move math engine note * refactor: update LaTeX documentation and improve MathJax integration - Adjusted LaTeX documentation for clarity and formatting. - Enhanced MathJax configuration in the templates to support both KaTeX and MathJax rendering. - Removed deprecated comments and streamlined the script loading process for MathJax. - Updated the passthrough extension settings in the Hugo configuration for better compatibility with LaTeX math expressions. * docs: simplify LaTeX documentation and clarify configuration steps - Updated LaTeX documentation to reflect that KaTeX is enabled by default, removing the need for manual activation. - Added examples for using LaTeX math expressions and clarified the configuration for the passthrough extension in Hugo. - Enhanced MathJax section to emphasize its use as an alternative rendering engine. * fix(tabs): add null check for panels container and update example items * fix(tabs): improve tab group key handling and add validation for items parameter * refactor(tabs): comment out sync option in configuration and adjust tab formatting in documentation --------- Co-authored-by: hobobandy <30026704+hobobandy@users.noreply.github.com> Co-authored-by: Matt Dodson <47385188+MattDodsonEnglish@users.noreply.github.com> Co-authored-by: Andreas Deininger <adeininger@urbanonline.de> Co-authored-by: yuri <1969yuri1969@gmail.com>
2025-07-21 21:16:44 +01:00
const key = encodeURIComponent(group.dataset.tabGroup);
const saved = localStorage.getItem('hextra-tab-' + key);
if (saved !== null) {
updateGroup(group, parseInt(saved, 10));
}
});
feat(tabs): implement synchronized tabs switching (#700) * Sync tabs across groups * feat(tabs): add optional synchronization * Move tabs sync setting under page params * fix: spacing between title and site title (#704) * docs: document configure opengraph image (#706) * [Docs] document using og:image * Make example title page match others * clarify wording * chore: update tailwind css to latest version 4.1.8 (#703) * fix: wrong SRI hash for katex.css (#702) * Correct URL given in 'dev.toml' * stylesheet 'katex.css': fix SRI hash * fix(build): run npm update to fix postcss complaint * feat(tags): improve usability of tags (#698) * feat(tags): improve usability of tags * Tags can be shown also at docs * Documented tag-related config flags * Added example tags to the site * Made rendered tags active * Move tags listing to ToC * Hide tags section on no tags * feat(math): add optional MathJax support (#707) * feat: add MathJax option * docs: move math engine note * refactor: update LaTeX documentation and improve MathJax integration - Adjusted LaTeX documentation for clarity and formatting. - Enhanced MathJax configuration in the templates to support both KaTeX and MathJax rendering. - Removed deprecated comments and streamlined the script loading process for MathJax. - Updated the passthrough extension settings in the Hugo configuration for better compatibility with LaTeX math expressions. * docs: simplify LaTeX documentation and clarify configuration steps - Updated LaTeX documentation to reflect that KaTeX is enabled by default, removing the need for manual activation. - Added examples for using LaTeX math expressions and clarified the configuration for the passthrough extension in Hugo. - Enhanced MathJax section to emphasize its use as an alternative rendering engine. * fix(tabs): add null check for panels container and update example items * fix(tabs): improve tab group key handling and add validation for items parameter * refactor(tabs): comment out sync option in configuration and adjust tab formatting in documentation --------- Co-authored-by: hobobandy <30026704+hobobandy@users.noreply.github.com> Co-authored-by: Matt Dodson <47385188+MattDodsonEnglish@users.noreply.github.com> Co-authored-by: Andreas Deininger <adeininger@urbanonline.de> Co-authored-by: yuri <1969yuri1969@gmail.com>
2025-07-21 21:16:44 +01:00
document.querySelectorAll('.hextra-tabs-toggle').forEach((button) => {
button.addEventListener('click', function (e) {
const container = e.target.parentElement;
const index = Array.from(container.querySelectorAll('.hextra-tabs-toggle')).indexOf(
e.target
);
if (container.dataset.tabGroup) {
// Sync behavior: update all tab groups with the same name
const tabGroupValue = container.dataset.tabGroup;
const key = encodeURIComponent(tabGroupValue);
document
.querySelectorAll('[data-tab-group="' + tabGroupValue + '"]')
.forEach((grp) => updateGroup(grp, index));
feat(tabs): implement synchronized tabs switching (#700) * Sync tabs across groups * feat(tabs): add optional synchronization * Move tabs sync setting under page params * fix: spacing between title and site title (#704) * docs: document configure opengraph image (#706) * [Docs] document using og:image * Make example title page match others * clarify wording * chore: update tailwind css to latest version 4.1.8 (#703) * fix: wrong SRI hash for katex.css (#702) * Correct URL given in 'dev.toml' * stylesheet 'katex.css': fix SRI hash * fix(build): run npm update to fix postcss complaint * feat(tags): improve usability of tags (#698) * feat(tags): improve usability of tags * Tags can be shown also at docs * Documented tag-related config flags * Added example tags to the site * Made rendered tags active * Move tags listing to ToC * Hide tags section on no tags * feat(math): add optional MathJax support (#707) * feat: add MathJax option * docs: move math engine note * refactor: update LaTeX documentation and improve MathJax integration - Adjusted LaTeX documentation for clarity and formatting. - Enhanced MathJax configuration in the templates to support both KaTeX and MathJax rendering. - Removed deprecated comments and streamlined the script loading process for MathJax. - Updated the passthrough extension settings in the Hugo configuration for better compatibility with LaTeX math expressions. * docs: simplify LaTeX documentation and clarify configuration steps - Updated LaTeX documentation to reflect that KaTeX is enabled by default, removing the need for manual activation. - Added examples for using LaTeX math expressions and clarified the configuration for the passthrough extension in Hugo. - Enhanced MathJax section to emphasize its use as an alternative rendering engine. * fix(tabs): add null check for panels container and update example items * fix(tabs): improve tab group key handling and add validation for items parameter * refactor(tabs): comment out sync option in configuration and adjust tab formatting in documentation --------- Co-authored-by: hobobandy <30026704+hobobandy@users.noreply.github.com> Co-authored-by: Matt Dodson <47385188+MattDodsonEnglish@users.noreply.github.com> Co-authored-by: Andreas Deininger <adeininger@urbanonline.de> Co-authored-by: yuri <1969yuri1969@gmail.com>
2025-07-21 21:16:44 +01:00
localStorage.setItem('hextra-tab-' + key, index.toString());
} else {
// Non-sync behavior: update only this specific tab group
updateGroup(container, index);
feat(tabs): implement synchronized tabs switching (#700) * Sync tabs across groups * feat(tabs): add optional synchronization * Move tabs sync setting under page params * fix: spacing between title and site title (#704) * docs: document configure opengraph image (#706) * [Docs] document using og:image * Make example title page match others * clarify wording * chore: update tailwind css to latest version 4.1.8 (#703) * fix: wrong SRI hash for katex.css (#702) * Correct URL given in 'dev.toml' * stylesheet 'katex.css': fix SRI hash * fix(build): run npm update to fix postcss complaint * feat(tags): improve usability of tags (#698) * feat(tags): improve usability of tags * Tags can be shown also at docs * Documented tag-related config flags * Added example tags to the site * Made rendered tags active * Move tags listing to ToC * Hide tags section on no tags * feat(math): add optional MathJax support (#707) * feat: add MathJax option * docs: move math engine note * refactor: update LaTeX documentation and improve MathJax integration - Adjusted LaTeX documentation for clarity and formatting. - Enhanced MathJax configuration in the templates to support both KaTeX and MathJax rendering. - Removed deprecated comments and streamlined the script loading process for MathJax. - Updated the passthrough extension settings in the Hugo configuration for better compatibility with LaTeX math expressions. * docs: simplify LaTeX documentation and clarify configuration steps - Updated LaTeX documentation to reflect that KaTeX is enabled by default, removing the need for manual activation. - Added examples for using LaTeX math expressions and clarified the configuration for the passthrough extension in Hugo. - Enhanced MathJax section to emphasize its use as an alternative rendering engine. * fix(tabs): add null check for panels container and update example items * fix(tabs): improve tab group key handling and add validation for items parameter * refactor(tabs): comment out sync option in configuration and adjust tab formatting in documentation --------- Co-authored-by: hobobandy <30026704+hobobandy@users.noreply.github.com> Co-authored-by: Matt Dodson <47385188+MattDodsonEnglish@users.noreply.github.com> Co-authored-by: Andreas Deininger <adeininger@urbanonline.de> Co-authored-by: yuri <1969yuri1969@gmail.com>
2025-07-21 21:16:44 +01:00
}
});
});
feat(tabs): implement synchronized tabs switching (#700) * Sync tabs across groups * feat(tabs): add optional synchronization * Move tabs sync setting under page params * fix: spacing between title and site title (#704) * docs: document configure opengraph image (#706) * [Docs] document using og:image * Make example title page match others * clarify wording * chore: update tailwind css to latest version 4.1.8 (#703) * fix: wrong SRI hash for katex.css (#702) * Correct URL given in 'dev.toml' * stylesheet 'katex.css': fix SRI hash * fix(build): run npm update to fix postcss complaint * feat(tags): improve usability of tags (#698) * feat(tags): improve usability of tags * Tags can be shown also at docs * Documented tag-related config flags * Added example tags to the site * Made rendered tags active * Move tags listing to ToC * Hide tags section on no tags * feat(math): add optional MathJax support (#707) * feat: add MathJax option * docs: move math engine note * refactor: update LaTeX documentation and improve MathJax integration - Adjusted LaTeX documentation for clarity and formatting. - Enhanced MathJax configuration in the templates to support both KaTeX and MathJax rendering. - Removed deprecated comments and streamlined the script loading process for MathJax. - Updated the passthrough extension settings in the Hugo configuration for better compatibility with LaTeX math expressions. * docs: simplify LaTeX documentation and clarify configuration steps - Updated LaTeX documentation to reflect that KaTeX is enabled by default, removing the need for manual activation. - Added examples for using LaTeX math expressions and clarified the configuration for the passthrough extension in Hugo. - Enhanced MathJax section to emphasize its use as an alternative rendering engine. * fix(tabs): add null check for panels container and update example items * fix(tabs): improve tab group key handling and add validation for items parameter * refactor(tabs): comment out sync option in configuration and adjust tab formatting in documentation --------- Co-authored-by: hobobandy <30026704+hobobandy@users.noreply.github.com> Co-authored-by: Matt Dodson <47385188+MattDodsonEnglish@users.noreply.github.com> Co-authored-by: Andreas Deininger <adeininger@urbanonline.de> Co-authored-by: yuri <1969yuri1969@gmail.com>
2025-07-21 21:16:44 +01:00
})();