/*global $ */ $(document).ready(function () { "use strict"; $('.menu > ul > li:has( > ul)').addclass('menu-dropdown-icon'); //checks if li has sub (ul) and adds class for toggle icon - just an ui $('.menu > ul > li > ul:not(:has(ul))').addclass('normal-sub'); //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) // $(".menu > ul").before("navigation"); //adds menu-mobile class (for mobile toggle menu) before the normal menu //mobile menu is hidden if width is more then 959px, but normal menu is displayed //normal menu is hidden if width is below 959px, and jquery adds mobile menu //done this way so it can be used with wordpress without any trouble $(".menu > ul > li").hover(function (e) { if ($(window).width() > 943) { $(this).children("ul").stop(true, false).fadetoggle(150); e.preventdefault(); } }); //if width is more than 943px dropdowns are displayed on hover $(".menu > ul > li").click(function (e) { if ($(window).width() <= 943) { $(this).children("ul").fadetoggle(150); e.preventdefault(); } }); //if width is less or equal to 943px dropdowns are displayed on click (thanks aman jain from stackoverflow) $(".menu-mobile").click(function (e) { $(".menu > ul").toggleclass('show-on-mobile'); e.preventdefault(); }); //when clicked on mobile-menu, normal menu is shown as a list, classic rwd menu story (thanks mwl from stackoverflow) });