1(function ($, Drupal) { 2 "use strict"; 3 4 /** 5 * Initializes the open on hover functionality of the menu 6 * 7 * @param dropdownElements 8 */ 9 function dropdownElementsOpenOnHoverInitialization(dropdownElements) { 10 dropdownElements.each(function () { 11 $(this).hover( 12 function () { 13 $(this).addClass("open hovered"); 14 }, 15 function () { 16 let menu = $(this); 17 $(menu).removeClass("hovered"); 18 setTimeout(function () { 19 // if the menu was not hovered again 20 if ($(menu).hasClass("hovered") === false) { 21 $(menu).removeClass("open"); 22 } 23 }, 150); 24 } 25 ); 26 }); 27 } 28 29 /** 30 * Removes the open class from dropdowns if exists 31 * 32 * @param dropdownElements the array of dropdown elements 33 */ 34 function removeOpenDropdowns(dropdownElements) { 35 dropdownElements.each(function () { 36 if ($(this).hasClass("open")) { 37 $(this).removeClass("open"); 38 } 39 }); 40 } 41 42 /** 43 * Adds the open class from dropdowns if does not exist 44 * 45 * @param dropdownElements the array of dropdown elements 46 */ 47 function addOpenDropdowns(dropdownElements) { 48 dropdownElements.each(function () { 49 if (!$(this).hasClass("open")) { 50 $(this).addClass("open"); 51 } 52 }); 53 } 54 55 /** 56 * Handles burger button on load 57 */ 58 function initializeburgerButtonFunctionalities() { 59 $("button.navbar-toggle").click(function () { 60 let header = $("header"); 61 if ($(header).hasClass("menu-expanded")) { 62 header.removeClass("menu-expanded"); 63 } else { 64 header.addClass("menu-expanded"); 65 } 66 }); 67 } 68 69 /** 70 * Hides the burger menu and its functionalitites 71 * 72 */ 73 function hideBurgerMenu() {
74 let collapseNavbar = $(".navbar-collapse.collapse"); 75 let header = $("header"); 76 77 if (collapseNavbar.hasClass("in")) { 78 collapseNavbar.removeClass("in"); 79 } 80 if (header.hasClass("menu-expanded")) { 81 header.removeClass("menu-expanded"); 82 } 83 } 84 85 /** 86 * Initializes important functionalities of the language switcher 87 * 88 */ 89 function initializelanguageSwitcherFunctionalities() { 90 if ($("header .block-language").length > 0) { 91 $("header .block-language ul.links li").each(function () { 92 if ($(this).hasClass("is-active")) { 93 $(this).css("display", "none"); 94 var activeLanguage = $(this).find("a").text(); 95 $("header .block-language").append( 96 '<div class="active-language"><a href="javascript:;"><span class="separator">|</span>' + 97 activeLanguage + 98 '<span class="caret"></span></a></div>' 99 ); 100 } 101 }); 102 } 103 104 if ($("header .active-language").length > 0) { 105 $("header .active-language a").click(function () { 106 $("header .block-language > ul.links").toggleClass("language-expanded"); 107 }); 108 } 109 110 $(window).click(function () { 111 $("header .block-language > ul.links").removeClass("language-expanded"); 112 }); 113 114 $("header .active-language a").click(function (event) { 115 event.stopPropagation(); 116 }); 117 } 118 119 //page loading 120 $(document).ready(function () { 121 initializeburgerButtonFunctionalities(); 122 initializelanguageSwitcherFunctionalities(); 123 124 //menu hover feature 125 let dropdownElements = $(".region-header .main-menu .dropdown"); 126 if (dropdownElements.length > 0) { 127 if ($(window).width() >= 1080) { 128 //check for mobile mode 129 dropdownElementsOpenOnHoverInitialization(dropdownElements); 130 } else { 131 //if mobile mode, don't enable the hover functionality and instead open the complete menu 132 dropdownElements.addClass("open"); 133 } 134 } 135 136 $(window).on("resize", function () { 137 let win = $(this); 138 139 initializeburgerButtonFunctionalities(); 140 // if outside burger menu limit 141 if (win.width() >= 1080) { 142 hideBurgerMenu(); //hides the burger menu 143 dropdownElementsOpenOnHoverInitialization(dropdownElements); //initializes hover func of dropdown 144 removeOpenDropdowns(dropdownElements); //closes expanded dropdown elements 145 } else { 146 addOpenDropdowns(dropdownElements); 147 dropdownElements.each(function () { 148 $(this).unbind("mouseenter mouseleave"); 149 }); 150 } 151 }); 152 }); 153})(jQuery, Drupal);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.