PageSourceSearch

https://www.braxtedpark.co.uk/scripts/menu.js

js braxtedpark.co.uk collected 2026-10-09 22:50:07 UTC 3,026 bytes, 91 lines download raw bytes

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