1/*global $ */ 2$(document).ready(function () { 3 4 "use strict"; 5 6 $('.menu > ul > li:has( > ul)').addClass('menu-dropdown-icon'); 7 //Checks if li has sub (ul) and adds class for toggle icon - just an UI 8 9 10 $('.menu > ul > li > ul:not(:has(ul))').addClass('normal-sub'); 11 //Checks if drodown menu's li elements have anothere level (ul), if not the dropdown is shown as regular dropdown, not a mega menu (thanks Luka Kladaric) 12 13 $(".menu > ul").before("<a href=\"#\" class=\"menu-mobile\"> <img class=\"menu-mobile-logo\" src=\"/wp-content/uploads/2019/04/KONSTRUKTA_defense-logo-b.svg\"></a>"); 14 15 //Adds menu-mobile class (for mobile toggle menu) before the normal menu 16 //Mobile menu is hidden if width is more then 959px, but normal menu is displayed 17 //Normal menu is hidden if width is below 959px, and jquery adds mobile menu 18 //Done this way so it can be used with wordpress without any trouble 19 20 $(".menu > ul > li").hover( 21 function (e) { 22 if ($(window).width() > 943) { 23 $(this).children("ul").fadeIn(150); 24 e.preventDefault(); 25 } 26 }, function (e) { 27 if ($(window).width() > 943) { 28 $(this).children("ul").fadeOut(150); 29 e.preventDefault(); 30 } 31 } 32 ); 33 //If width is more than 943px dropdowns are displayed on hover 34 35 36 //the following hides the menu when a click is registered outside 37 $(document).on('click', function(e){ 38 if($(e.target).parents('.menu').length === 0) 39 $(".menu > ul").removeClass('show-on-mobile'); 40 }); 41 42 $(".menu > ul > li").click(function() { 43 //no more overlapping menus 44 //hides other children menus when a list item with children menus is clicked 45 var thisMenu = $(this).children("ul"); 46 var prevState = thisMenu.css('display'); 47 $(".menu > ul > li > ul").fadeOut(); 48 if ($(window).width() < 943) { 49 if(prevState !== 'block') 50 thisMenu.fadeIn(150); 51 } 52 }); 53 //If width is less or equal to 943px dropdowns are displayed on click (thanks Aman Jain from stackoverflow) 54 55 $(".menu-mobile").click(function (e) { 56 $(".menu > ul").toggleClass('show-on-mobile'); 57 e.preventDefault(); 58 }); 59 //when clicked on mobile-menu, normal menu is shown as a list, classic rwd menu story (thanks mwl from stackoverflow) 60 61});
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.