|
1 | | -$(document).ready(setNav); |
2 | | -$(window).resize(setNav); |
| 1 | +(function () { |
| 2 | + $(document).ready(setNav); |
| 3 | + $(window).resize(setNav); |
3 | 4 |
|
4 | | -function setNav() { |
5 | | - if ($("button.hamburger").is(":visible")) { |
6 | | - $("nav.mainNav").hide(); // Mobile View |
7 | | - } else { |
8 | | - $("nav.mainNav").show(); // Desktop View |
| 5 | + function setNav() { |
| 6 | + if ($("button.hamburger").is(":visible")) { |
| 7 | + $("nav.mainNav").hide(); // Mobile View |
| 8 | + } else { |
| 9 | + $("nav.mainNav").show(); // Desktop View |
| 10 | + } |
9 | 11 | } |
10 | | -} |
11 | 12 |
|
12 | | -$("button.hamburger").on("click", function () { |
13 | | - var mainNav = $("nav.mainNav"); |
14 | | - if (mainNav.is(":visible")) { |
15 | | - mainNav.fadeOut(100); |
16 | | - } else { |
17 | | - mainNav.fadeIn(100); |
18 | | - } |
19 | | -}); |
| 13 | + $("button.hamburger").on("click", function () { |
| 14 | + var mainNav = $("nav.mainNav"); |
| 15 | + if (mainNav.is(":visible")) { |
| 16 | + mainNav.fadeOut(100); |
| 17 | + } else { |
| 18 | + mainNav.fadeIn(100); |
| 19 | + } |
| 20 | + }); |
20 | 21 |
|
21 | | -$(window).click(function (e) { |
22 | | - if ( |
23 | | - !$(e.target).parent().hasClass("hamburger") && |
24 | | - $("button.hamburger").is(":visible") |
25 | | - ) { |
26 | | - $("nav.mainNav").fadeOut(100); |
27 | | - } |
28 | | -}); |
| 22 | + $(window).click(function (e) { |
| 23 | + if ( |
| 24 | + !$(e.target).parent().hasClass("hamburger") && |
| 25 | + $("button.hamburger").is(":visible") |
| 26 | + ) { |
| 27 | + $("nav.mainNav").fadeOut(100); |
| 28 | + } |
| 29 | + }); |
29 | 30 |
|
30 | | -// Functions to set nav links as active. Sub links can activate parents by naming files with same prefix, for example: documentation.php and documentation_view.php activate the same link |
31 | | -var url = location.pathname; |
32 | | -if (url.lastIndexOf(".") >= 0) { |
33 | | - url = url.substring(0, url.lastIndexOf(".")); |
34 | | -} |
| 31 | + // Functions to set nav links as active. Sub links can activate parents by naming files with same prefix, for example: documentation.php and documentation_view.php activate the same link |
| 32 | + var url = location.pathname; |
| 33 | + if (url.lastIndexOf(".") >= 0) { |
| 34 | + url = url.substring(0, url.lastIndexOf(".")); |
| 35 | + } |
35 | 36 |
|
36 | | -if (url.lastIndexOf("/") >= 0) { |
37 | | - url = url.substring(url.lastIndexOf("/") + 1); |
38 | | -} |
| 37 | + if (url.lastIndexOf("/") >= 0) { |
| 38 | + url = url.substring(url.lastIndexOf("/") + 1); |
| 39 | + } |
39 | 40 |
|
40 | | -$("nav.mainNav a").each(function () { |
41 | | - var href = $(this).attr("href"); |
| 41 | + $("nav.mainNav a").each(function () { |
| 42 | + var href = $(this).attr("href"); |
42 | 43 |
|
43 | | - if (href.lastIndexOf(".") >= 0) { |
44 | | - href = href.substring(0, href.lastIndexOf(".")); |
45 | | - } |
| 44 | + if (href.lastIndexOf(".") >= 0) { |
| 45 | + href = href.substring(0, href.lastIndexOf(".")); |
| 46 | + } |
46 | 47 |
|
47 | | - if (href.lastIndexOf("/") >= 0) { |
48 | | - href = href.substring(href.lastIndexOf("/") + 1); |
49 | | - } |
| 48 | + if (href.lastIndexOf("/") >= 0) { |
| 49 | + href = href.substring(href.lastIndexOf("/") + 1); |
| 50 | + } |
50 | 51 |
|
51 | | - if (url.indexOf(href) == 0) { |
52 | | - $(this).addClass("active"); |
53 | | - } |
54 | | -}); |
| 52 | + if (url.indexOf(href) == 0) { |
| 53 | + $(this).addClass("active"); |
| 54 | + } |
| 55 | + }); |
55 | 56 |
|
56 | | -/** |
57 | | - * btnDropdown Click Events |
58 | | - */ |
59 | | -$("div.btnDropdown > button").click(function () { |
60 | | - $("div.btnDropdown > div").toggle(); |
61 | | -}); |
| 57 | + /** |
| 58 | + * btnDropdown Click Events |
| 59 | + */ |
| 60 | + $("div.btnDropdown > button").click(function () { |
| 61 | + $("div.btnDropdown > div").toggle(); |
| 62 | + }); |
62 | 63 |
|
63 | | -$(window).click(function (e) { |
64 | | - if (!e.target.matches("div.btnDropdown > button")) { |
65 | | - $("div.btnDropdown > div").hide(); |
66 | | - } |
67 | | -}); |
| 64 | + $(window).click(function (e) { |
| 65 | + if (!e.target.matches("div.btnDropdown > button")) { |
| 66 | + $("div.btnDropdown > div").hide(); |
| 67 | + } |
| 68 | + }); |
| 69 | +})(); |
68 | 70 |
|
69 | 71 | function downloadFile(text, filename) { |
70 | 72 | var element = document.createElement("a"); |
|
0 commit comments