Bin
2025-12-17 1442f92732d7c5311a627a7ba3aaa0bb8ffc539f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
(function () {
  const pageHeader = document.querySelector(".page-header");
  const pageSidebar = document.querySelector(".page-sidebar");
  const navToggleButtons = pageHeader.querySelectorAll("button");
  const sideBarToggleButtons =
    pageSidebar && pageSidebar.querySelectorAll("button");
  const hamburgerButton = pageHeader.querySelector(".hamburger-button");
 
  const toggleMenu = (e) => {
    const button = e.currentTarget;
    const menu = button.nextElementSibling;
    const menuStyles = getComputedStyle(menu);
    const arrow = button.querySelector("svg");
    const arrowStyles = getComputedStyle(arrow);
 
    arrow.style.setProperty(
      "transform",
      arrowStyles.transform === "none" ? "matrix(-1, 0, 0, -1, 0, 0)" : "none"
    );
    menu.style.setProperty(
      "display",
      menuStyles.display === "flex" ? "none" : "flex"
    );
  };
 
  navToggleButtons &&
    navToggleButtons.forEach((button) =>
      button.addEventListener("click", toggleMenu)
    );
  sideBarToggleButtons &&
    sideBarToggleButtons.forEach((button) =>
      button.addEventListener("click", toggleMenu)
    );
 
  const githubstarsContainer = document.querySelector(".github-stars-count");
 
  if (githubstarsContainer) {
    fetch("https://api.github.com/repos/humansignal/label-studio")
      .then((response) =>
        response.json().then((data) => {
          let stars = "";
          if (data.stargazers_count)
            stars = data.stargazers_count.toLocaleString("en-US");
          if (stars) githubstarsContainer.textContent = stars;
        })
      )
      .catch((err) => {
        console.log(err);
      });
  }
 
  window.addEventListener("load", (event) => {
    const searchInput = document.querySelector("#docsearch-input");
 
    const siteVersion = searchInput.dataset.siteVersion;
 
    const appId = "M7RXTHKYPM";
    const apiKey = "8ed23cbc92e0806140603fb62236efee";
    const indexName =
      siteVersion == "enterprise" ? "ghaction" : "labelstudiodocs";
 
    if (searchInput) {
      window.docsearch({
        container: "#docsearch-input",
        inputSelector: "#docsearch-input",
        appId,
        apiKey,
        indexName,
        algoliaOptions: { hitsPerPage: 10 },
      });
 
      const handleFocusSearch = (e) => {
        if (
          document.activeElement.localName === "body" &&
          e.code !== "Space" &&
          e.code !== "MetaLeft" &&
          !e.altKey &&
          !e.shiftKey &&
          !e.ctrlKey &&
          !e.metaKey
        ) {
          searchInput.focus();
        }
 
        if (
          document.activeElement.localName === "body" &&
          e.code === "KeyK" &&
          (e.metaKey || e.ctrlKey)
        ) {
          searchInput.focus();
        }
      };
 
      window.addEventListener("keydown", handleFocusSearch);
    }
  });
 
  hamburgerButton.addEventListener("click", () => {
    const nav = hamburgerButton.nextElementSibling;
    const navStyle = getComputedStyle(nav);
 
    hamburgerButton.classList.toggle("active");
 
    nav.style.setProperty(
      "display",
      navStyle.display === "flex" ? "none" : "flex"
    );
  });
 
  if (window.matchMedia("(hover: none)").matches) {
    const toggleQuickNav = (e) => {
      if (e.target.tagName.toLowerCase() !== "a") {
        const component = e.currentTarget;
        const menu = component.querySelector("ul");
        const menuStyles = getComputedStyle(menu);
 
        menu.style.setProperty(
          "display",
          menuStyles.display === "flex" ? "none" : "flex"
        );
      }
    };
 
    const toggleQuicNavButton = document.querySelector(
      ".page-header-content-switcher"
    );
    toggleQuicNavButton.addEventListener("click", toggleQuickNav);
  }
 
  pageSidebar.addEventListener("scroll", function () {
    localStorage.setItem("labelstudio_scrollPosition", this.scrollTop);
  });
})();