1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 var dropdownClassName = "sd-dropdown";
10 function getDropdownElement() {
11 var dropdownId = window.location.hash;
16 var dropdownElement = document.getElementById(dropdownId.substring(1));
19 !dropdownElement.classList.contains(dropdownClassName)
24 return dropdownElement;
27 function setupDropdownLink() {
28 var dropdowns = document.getElementsByClassName(dropdownClassName);
29 for (var i = 0; i < dropdowns.length; i++) {
30 for (var j = 0; j < dropdowns[i].classList.length; j++) {
31 if (dropdowns[i].classList[j].startsWith("anchor-id-")) {
32 dropdowns[i].id = dropdowns[i].classList[j].replace("anchor-id-", "");
36 var aTag = document.createElement("a");
37 aTag.setAttribute("href", "#" + dropdowns[i].id);
38 aTag.classList.add("dropdown-link");
39 aTag.innerHTML = "ΒΆ";
42 dropdowns[i].getElementsByClassName("sd-summary-title")[0];
43 summaryElement.insertBefore(
45 summaryElement.getElementsByClassName("docutils")[0]
50 function scrollToDropdown() {
51 var dropdownElement = getDropdownElement();
52 if (dropdownElement) {
53 dropdownElement.open = true;
54 dropdownElement.scrollIntoView(true);
58 // Initialize dropdown link
59 window.addEventListener("DOMContentLoaded", () => {
60 if (document.getElementsByClassName(dropdownClassName).length) {
62 window.onhashchange = scrollToDropdown;
66 // Scroll to and open the dropdown direct links
67 window.onload = () => {
68 if (document.getElementsByClassName(dropdownClassName).length) {