summaryrefslogtreecommitdiffstats
path: root/docs/_static/sphinx_design.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
commit0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch)
treea31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /docs/_static/sphinx_design.js
parentInitial commit. (diff)
downloadfirefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz
firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'docs/_static/sphinx_design.js')
-rw-r--r--docs/_static/sphinx_design.js72
1 files changed, 72 insertions, 0 deletions
diff --git a/docs/_static/sphinx_design.js b/docs/_static/sphinx_design.js
new file mode 100644
index 0000000000..d080f2d634
--- /dev/null
+++ b/docs/_static/sphinx_design.js
@@ -0,0 +1,72 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+(function () {
+ "use strict";
+
+ var dropdownClassName = "sd-dropdown";
+
+ function getDropdownElement() {
+ var dropdownId = window.location.hash;
+ if (!dropdownId) {
+ return false;
+ }
+
+ var dropdownElement = document.getElementById(dropdownId.substring(1));
+ if (
+ !dropdownElement ||
+ !dropdownElement.classList.contains(dropdownClassName)
+ ) {
+ return false;
+ }
+
+ return dropdownElement;
+ }
+
+ function setupDropdownLink() {
+ var dropdowns = document.getElementsByClassName(dropdownClassName);
+ for (var i = 0; i < dropdowns.length; i++) {
+ for (var j = 0; j < dropdowns[i].classList.length; j++) {
+ if (dropdowns[i].classList[j].startsWith("anchor-id-")) {
+ dropdowns[i].id = dropdowns[i].classList[j].replace("anchor-id-", "");
+ }
+ }
+
+ var aTag = document.createElement("a");
+ aTag.setAttribute("href", "#" + dropdowns[i].id);
+ aTag.classList.add("dropdown-link");
+ aTag.innerHTML = "ΒΆ";
+
+ var summaryElement =
+ dropdowns[i].getElementsByClassName("sd-summary-title")[0];
+ summaryElement.insertBefore(
+ aTag,
+ summaryElement.getElementsByClassName("docutils")[0]
+ );
+ }
+ }
+
+ function scrollToDropdown() {
+ var dropdownElement = getDropdownElement();
+ if (dropdownElement) {
+ dropdownElement.open = true;
+ dropdownElement.scrollIntoView(true);
+ }
+ }
+
+ // Initiallize dropdown link
+ window.addEventListener("DOMContentLoaded", () => {
+ if (document.getElementsByClassName(dropdownClassName).length) {
+ setupDropdownLink();
+ window.onhashchange = scrollToDropdown;
+ }
+ });
+
+ // Scroll to and open the dropdown direct links
+ window.onload = () => {
+ if (document.getElementsByClassName(dropdownClassName).length) {
+ scrollToDropdown();
+ }
+ };
+})();