|
1 |
| -// Right nav highlighting |
2 |
| -var sidebarObj = (document.getElementsByClassName("sidebar")[0]) ? document.getElementsByClassName("sidebar")[0] : document.getElementsByClassName("sidebar-home")[0]; |
3 |
| - |
4 |
| -// ensure that the left nav visibly displays the current topic |
5 |
| -var current = document.getElementsByClassName("active currentPage"); |
6 |
| -var body = document.getElementsByClassName("col-content content"); |
7 |
| -if (current[0]) { |
8 |
| - if (sidebarObj) { |
9 |
| - current[0].scrollIntoView(true); |
10 |
| - body[0].scrollIntoView(true); |
11 |
| - } |
12 |
| - // library hack |
13 |
| - if (document.location.pathname.indexOf("/samples/") > -1) { |
14 |
| - $(".currentPage").closest("ul").addClass("in"); |
15 |
| - } |
16 |
| -} |
17 | 1 |
|
18 | 2 | function navClicked(sourceLink) {
|
19 |
| - var classString = document.getElementById("#item" + sourceLink).className; |
20 |
| - if (classString.indexOf(" in") > -1) { |
21 |
| - //collapse |
22 |
| - document.getElementById("#item" + sourceLink).className = classString.replace(" in", ""); |
23 |
| - } else { |
24 |
| - //expand |
25 |
| - document.getElementById("#item" + sourceLink).className = classString.concat(" in"); |
| 3 | + let el = document.getElementById("#item"+sourceLink) |
| 4 | + if (el) { |
| 5 | + el.classList.toggle("in") |
26 | 6 | }
|
27 | 7 | }
|
28 | 8 |
|
29 |
| -var outputLetNav = []; |
30 |
| -var totalTopics = 0; |
| 9 | +let outputLetNav = [], totalTopics = 0; |
31 | 10 |
|
32 | 11 | function pageIsInSection(tree) {
|
33 | 12 | function processBranch(branch) {
|
@@ -154,28 +133,6 @@ $(window).scroll(function () {
|
154 | 133 | }
|
155 | 134 | });
|
156 | 135 |
|
157 |
| -/* |
158 |
| - * toggle menu ***************************************************************** |
159 |
| - */ |
160 |
| - |
161 |
| -$("#menu-toggle").click(function (e) { |
162 |
| - e.preventDefault(); |
163 |
| - $(".wrapper").toggleClass("right-open"); |
164 |
| - $(".col-toc").toggleClass("col-toc-hidden"); |
165 |
| -}); |
166 |
| - |
167 |
| -$("#menu-toggle-left").click(function (e) { |
168 |
| - e.preventDefault(); |
169 |
| - $(".col-nav").toggleClass("col-toc-hidden"); |
170 |
| -}); |
171 |
| - |
172 |
| -$(".navbar-toggle").click(function () { |
173 |
| - $("#sidebar-nav").each(function () { |
174 |
| - $(this).toggleClass("hidden-sm"); |
175 |
| - $(this).toggleClass("hidden-xs"); |
176 |
| - }); |
177 |
| -}); |
178 |
| - |
179 | 136 | var navHeight = $(".navbar").outerHeight(true) + 80;
|
180 | 137 |
|
181 | 138 | $(document.body).scrollspy({
|
@@ -233,30 +190,29 @@ $(document).ready(function () {
|
233 | 190 | });
|
234 | 191 | });
|
235 | 192 |
|
236 |
| -/* |
237 |
| - * make dropdown show on hover ************************************************* |
238 |
| - */ |
239 |
| - |
240 |
| -$("ul.nav li.dropdown").hover(function () { |
241 |
| - $(this).find(".dropdown-menu").stop(true, true).delay(200).fadeIn(500); |
242 |
| -}, function () { |
243 |
| - $(this).find(".dropdown-menu").stop(true, true).delay(200).fadeOut(500); |
244 |
| -}); |
| 193 | +function initNavToggle() { |
| 194 | + $("#menu-toggle").click(function (e) { |
| 195 | + e.preventDefault(); |
| 196 | + $(".wrapper").toggleClass("right-open"); |
| 197 | + $(".col-toc").toggleClass("col-toc-hidden"); |
| 198 | + }); |
245 | 199 |
|
246 |
| -/* |
247 |
| - * Components ****************************************************************** |
248 |
| - */ |
| 200 | + $(".navbar-toggle").click(function () { |
| 201 | + $("#sidebar-nav").each(function () { |
| 202 | + $(this).toggleClass("hidden-sm"); |
| 203 | + $(this).toggleClass("hidden-xs"); |
| 204 | + }); |
| 205 | + }); |
| 206 | +} |
249 | 207 |
|
250 |
| -$(function () { |
| 208 | +ready(() => { |
| 209 | + renderNav() |
| 210 | + initNavToggle() |
251 | 211 | $('[data-toggle="tooltip"]').tooltip()
|
252 |
| -}); |
253 | 212 |
|
254 |
| -// sync tabs with the same data-group |
255 |
| -window.onload = function () { |
256 |
| - $(".nav-tabs > li > a").click(function (e) { |
257 |
| - var group = $(this).attr("data-group"); |
258 |
| - $('.nav-tabs > li > a[data-group="' + group + '"]').tab("show"); |
| 213 | + // sync tabs with the same data-group |
| 214 | + $(".nav-tabs > li > a").click(function () { |
| 215 | + const group = $(this).attr("data-group"); |
| 216 | + $(`.nav-tabs > li > a[data-group='${ group }']`).tab("show"); |
259 | 217 | });
|
260 |
| -}; |
261 |
| - |
262 |
| -ready(renderNav); |
| 218 | +}); |
0 commit comments