1(function ($) { 2 'use strict'; 3 4 function handleWindow() { 5 var body = document.querySelector('body'); 6 7 if (window.innerWidth > body.clientWidth + 5) { 8 body.classList.add('has-scrollbar'); 9 body.setAttribute('style', '--scroll-bar: ' + (window.innerWidth - body.clientWidth) + 'px'); 10 } else { 11 body.classList.remove('has-scrollbar'); 12 } 13 } 14 15 function navigation() { 16 var $button = $('.site-navigation .menu-toggle'), 17 $menu = $('.site-navigation'); 18 $button.on('click', function () { 19 $menu.toggleClass('toggled'); 20 }); 21 22 if ($menu.length > 0) { 23 $menu.find('.menu-item-has-children > a, .page_item_has_children > a').each((index, element) => { 24 var $dropdown = $('<button class="dropdown-toggle"></button>'); 25 $dropdown.insertAfter(element); 26 27 }); 28 $(document).on('click', '.site-navigation .dropdown-toggle', function (e) { 29 e.preventDefault(); 30 $(e.target).toggleClass('toggled-on'); 31 $(e.target).siblings('ul').stop().toggleClass('show'); 32 }); 33 } 34 35 } 36 37 function minHeight() { 38 var bodyHeight = $(window).outerHeight(), 39 headerHeight = $('header.site-header').outerHeight(true), 40 footerHeight = $('footer.site-footer').outerHeight(true), 41 siteMain = $('.site-main').outerHeight(true); 42 43 if (bodyHeight > (headerHeight + footerHeight + siteMain)) { 44 45 $('.site-main').css({ 46 'min-height': bodyHeight - headerHeight - footerHeight 47 }); 48 } 49 } 50 51 function search_popup() { 52 53 var $button_search = $('.button-search-popup'); 54 var $drop_down = $('.site-search-popup-wrap'); 55 $button_search.on('click', function (e) { 56 e.preventDefault(); 57 $('html').toggleClass('search-popup-active'); 58 }); 59 60 $('.site-search-popup-close').on('click', function (e) { 61 e.preventDefault(); 62 $('html').removeClass('search-popup-active'); 63 }); 64 65 $(document).mouseup(function (e) { 66 if (!$drop_down.is(e.target) && $drop_down.has(e.target).length == 0) { 67 $('html').removeClass('search-popup-active'); 68 } 69 }); 70 } 71 72 function side_collapse() { 73 $('body').on('click', '[data-toggle="button-side"]', function (e) { 74 e.preventDefault(); 75 e.stopPropagation(); 76 var $target = $(this).data('target'); 77 $($target).toggleClass('active'); 78 79 }).on('click', '.side-overlay', function (e) { 80 e.preventDefault(); 81 var $target = $(this).siblings('.side-wrap'); 82 $target.removeClass('active'); 83 }).on('click', '.close-side', function (e) { 84 e.preventDefault(); 85 var $target = $(this).closest('.side-wrap'); 86 $target.removeClass('active'); 87 }); 88 89 } 90 91 function account_side() { 92 var $account_side = $('body .site-header-account .my-account-icon'); 93 var $account_active = $('body .site-header-account .account-dropdown'); 94 $(document).mouseup(function (e) { 95 if ($account_side.has(e.target).length == 0 && !$account_active.is(e.target) && $account_active.has(e.target).length == 0) { 96 $account_active.removeClass('active'); 97 } 98 }); 99 100 $account_side.on('click', function (e) { 101 e.preventDefault(); 102 e.stopPropagation(); 103 var $target = $(this).siblings('.account-dropdown'); 104 $target.toggleClass('active'); 105 }); 106 } 107 108 function setPositionLvN($item) { 109 var sub = $item.children('.sub-menu'), 110 offset = $item.offset(), 111 width = $item.outerWidth(), 112 screen_width = $(window).width(), 113 sub_width = sub.outerWidth(); 114 var align_delta = offset.left + width + sub_width - screen_width; 115 if (align_delta > 0) { 116 if ($item.parents('.menu-item-has-children').length) { 117 sub.css({ left: 'auto', right: '100%' }); 118 }else { 119 sub.css({ left: 'auto', right: '0' }); 120 } 121 } else { 122 sub.css({ left: '', right: '' }); 123 } 124 } 125 126 function initSubmenuHover() { 127 $('.site-header .primary-navigation .menu-item-has-children').hover(function (event) { 128 var $item = $(event.currentTarget); 129 setPositionLvN($item); 130 }); 131 } 132 initSubmenuHover(); 133 134 // minHeight(); 135 handleWindow(); 136 navigation(); 137 account_side(); 138 side_collapse(); 139 $(document).ready(function () { 140 search_popup(); 141 }); 142})(jQuery);
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.