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