1(function($) { 2 "use strict"; 3 $.fn.menumaker = function(options) { 4 var cssmenu = $(this), 5 settings = $.extend({ 6 title: "Menu", 7 format: "dropdown", 8 breakpoint: 768, 9 sticky: false 10 }, options); 11 return this.each(function() { 12 cssmenu.find('li ul').parent().addClass('has-sub'); 13 if (settings.format != 'select') { 14 cssmenu.prepend('<a href="#" id="menu-button">' + settings.title + '</a>'); 15 $(this).find("#menu-button").on('keydown', function(e) { 16 var tabKey = e.keyCode === 9; 17 var shiftKey = e.shiftKey; 18 if ($(this).hasClass('menu-opened')) { 19 if (shiftKey && tabKey) { 20 e.preventDefault(); 21 $('div#cssmenu > ul.menu').css('display', 'none').removeClass('open'); 22 $(this).removeClass('menu-opened'); 23 }; 24 } 25 }); 26 $(this).find("#menu-button").on('click', function() { 27 $(this).toggleClass('menu-opened'); 28 var mainmenu = $(this).next('ul'); 29 if (mainmenu.hasClass('open')) { 30 mainmenu.hide().removeClass('open'); 31 } else { 32 mainmenu.show().addClass('open'); 33 if (settings.format === "dropdown") { 34 mainmenu.find('ul').show(); 35 } 36 } 37 }); 38 var multiTg = function() { 39 function submenuButton() { 40 var buttonTag = 'span'; 41 if ($(window).width() > settings.breakpoint) { 42 buttonTag = 'span'; 43 } else { 44 buttonTag = 'span'; 45 } 46 cssmenu.find(".has-sub ul.sub-menu").before('<' + buttonTag + ' class="submenu-button"></' + buttonTag + '>'); 47 // let buttonLength = cssmenu.find(".has-sub").children('button').length; 48 // if (buttonLength < 1) { 49 // $('.submenu-button').siblings('.submenu-button').remove('.submenu-button'); 50 // } 51 var hasClicked = false; 52 cssmenu.find('.submenu-button').on('click', function(e) { 53 $(this).toggleClass('submenu-opened'); 54 if ($(this).siblings('ul').hasClass('open')) { 55 $(this).siblings('ul').removeClass('open').hide(); 56 } else { 57 $(this).siblings('ul').addClass('open').show(); 58 } 59 }); 60 } 61 submenuButton(); 62 // $(window).on('resize', function() { 63 // submenuButton(); 64 // }); 65 }; 66 if (settings.format === 'multitoggle') multiTg(); 67 else cssmenu.addClass('dropdown'); 68 } else if (settings.format === 'select') { 69 cssmenu.append('<select style="width: 100%"/>').addClass('select-list'); 70 var selectList = cssmenu.find('select'); 71 selectList.append('<option>' + settings.title + '</option>', { 72 "selected": "selected", 73 "value": "" 74 }); 75 cssmenu.find('a').each(function() { 76 var element = $(this), 77 indentation = ""; 78 for (i = 1; i < element.parents('ul').length; i++) { 79 indentation += '-'; 80 } 81 selectList.append('<option value="' + $(this).attr('href') + '">' + indentation + element.text() + '</option'); 82 }); 83 selectList.on('change', function() { 84 window.location = $(this).find("option:selected").val(); 85 }); 86 } 87 if (settings.sticky === true) cssmenu.css('position', 'fixed'); 88 var resizeFix = function() { 89 if ($(window).width() > settings.breakpoint) { 90 cssmenu.find('ul').show(); 91 cssmenu.removeClass('small-screen'); 92 if (settings.format === 'select') { 93 cssmenu.find('select').hide(); 94 } else { 95 cssmenu.find("#menu-button").removeClass("menu-opened"); 96 } 97 } 98 if ($(window).width() <= settings.breakpoint && !cssmenu.hasClass("small-screen")) { 99 cssmenu.find('ul').hide().removeClass('open'); 100 cssmenu.addClass('small-screen'); 101 if (settings.format === 'select') { 102 cssmenu.find('select').show(); 103 } 104 } 105 }; 106 resizeFix(); 107 return $(window).on('resize', resizeFix); 108 }); 109 }; 110})(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.