1(function ($) { 2 $.fn.mobileMenu = function (options) { 3 function isMobile() { 4 return ($('body').width() < 600); 5 } 6 var defaults = { 7 defaultText: 'Navigate to...', 8 className: 'select-menu', 9 subMenuClass: 'sub-menu', 10 subMenuDash: '--', 11 mainMenuSelector: '#mainmenu' 12 }, 13 settings = $.extend(defaults, options), 14 el = $(this), 15 output = '', 16 first = settings.defaultText; 17 this.each(function () { 18 output = ''; 19 el.find('ul').addClass(settings.subMenuClass); 20 el.find('a,.separator').each(function () { 21 if($(this).text() == "") { 22 return; 23 } 24 var $this = $(this), 25 optText = $this.text(), 26 optSub = $this.parents('.' + settings.subMenuClass), 27 len = optSub.length, 28 dash; 29 if ($this.parents('ul').hasClass(settings.subMenuClass)) { 30 dash = Array(len + 1).join(settings.subMenuDash); 31 optText = dash + optText; 32 } 33 if ($this.is('span')) 34 output += '<optgroup label="' + optText + '">'; 35 else 36 output += '<option value="' + this.href + '"' + (this.href == window.location.href ? ' selected="selected"' : '') + '> ' + optText + '</option>' 37 if (this.href == window.location.href) 38 first = optText; 39 }); 40 $('<div class="' + settings.className + '">' 41 + '<span class="icon"></span>'
42 + '<span class="holder">' + first + '</span>' 43 + '<select size="1" class="' + settings.className + '-list">' + output + '</select></div>').insertAfter(el); 44 $('.' + settings.className + '-list').change(function () { 45 var locations = $(this).val(); 46 if (locations !== '#') { 47 window.location.href = $(this).val(); 48 } 49 }); 50 }); 51 52 function runPlugin() { 53 if (isMobile()) { 54 $('.'+settings.className).show(); 55 $(settings.mainMenuSelector).hide(); 56 } else { 57 $('.'+settings.className).hide(); 58 $(settings.mainMenuSelector).show(); 59 } 60 } 61 runPlugin(); 62 $(window).resize(function () { 63 runPlugin(); 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.