1(function ($) { 2 $.fn.mobileMenu = function (options) { 3 4 var defaults = { 5 defaultText: 'Navigate to...', 6 className: 'select-menu', 7 subMenuClass: 'sub-menu', 8 subMenuDash: '–' 9 }, 10 settings = $.extend(defaults, options), 11 el = $(this); 12 i = 0; 13 this.each(function () { 14 // ad class to submenu list 15 if ($(this).parents('aside').length > 0) return; 16 i++; 17 el.find('ul.children').addClass(settings.subMenuClass); 18 $(this).attr('id', 'main-menu-' + i); 19 // Create base menu 20 $('<select />', { 21 'id': 'mobile-menu-' + i, 22 'class': settings.className 23 }).insertAfter($('#main-menu-' + i)); 24 25 // Create default option 26 $('<option />', { 27 "value": '#', 28 "text": settings.defaultText 29 }).appendTo('#' + 'mobile-menu-' + i); 30 31 // Create select option from menu 32 $('#main-menu-' + i).find('a').each(function () { 33 var $this = '', 34 optText = '', 35 optSub = '', 36 len = '', 37 dash = ''; 38 39 $this = $(this), optText = ' ' + $this.text(), optSub = $this.parents('.' + settings.subMenuClass), len = optSub.length; 40 41 42 // if menu has sub menu 43 if ($this.parents('ul').hasClass(settings.subMenuClass)) { 44 dash = Array(len + 1).join(settings.subMenuDash); 45 optText = dash + optText; 46 } 47 48 // Now build menu and append it 49 $('<option />', { 50 "value": this.href, 51 "html": optText, 52 "selected": (this.href == window.location.href) 53 }).appendTo('#' + 'mobile-menu-' + i); 54 55 }); // End el.find('a').each 56 // Change event on select element 57 $('.' + settings.className).change(function () { 58 var locations = $(this).val(); 59 if (locations !== '#') { 60 window.location.href = $(this).val(); 61 }; 62 }); 63 64 }); 65 return this; 66 }; 67})(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.