1/** 2 * jQuery Mobile Menu 3 * Turn unordered list menu into dropdown select menu 4 * version 1.0(31-OCT-2011) 5 * 6 * Built on top of the jQuery library 7 * http://jquery.com 8 * 9 * Documentation 10 * http://github.com/mambows/mobilemenu 11 */ 12(function($){ 13$.fn.mobileMenu = function(options) { 14 15 var defaults = { 16 defaultText: 'Navigate to...', 17 className: 'select-menu', 18 subMenuClass: 'sub-menu', 19 subMenuDash: '–' 20 }, 21 settings = $.extend( defaults, options ), 22 el = $(this); 23 24 this.each(function(){ 25 // ad class to submenu list 26 el.find('ul').addClass(settings.subMenuClass); 27 28 // Create base menu 29 $('<select />',{ 30 'class' : settings.className, 31 'onChange': 'scrollTo(this.value)', 32 'name' : "dropdpown" 33 }).insertAfter( el ); 34 35 // Create default option 36 $('<option />', { 37 "value" : '#', 38 "text" : settings.defaultText 39 }).appendTo( '.' + settings.className ); 40 41 // Create select option from menu 42 el.find('a').each(function(){ 43 var $this = $(this), 44 optText = ' ' + $this.text(), 45 optSub = $this.parents( '.' + settings.subMenuClass ), 46 len = optSub.length, 47 dash; 48 49 // if menu has sub menu 50 if( $this.parents('ul').hasClass( settings.subMenuClass ) ) { 51 dash = Array( len+1 ).join( settings.subMenuDash ); 52 optText = dash + optText; 53 } 54 55 // Now build menu and append it 56 $('<option />', { 57 "value" : this.href, 58 "html" : optText, 59 "selected" : (this.href == window.location.href) 60 }).appendTo( '.' + settings.className ); 61 62 }); // End el.find('a').each 63 64 // Change event on select element 65 $('.' + settings.className).change(function(){ 66 var locations = $(this).val(); 67 if( locations !== '#' ) { 68 window.location.href = $(this).val(); 69 }; 70 }); 71 72 }); // End this.each 73 74 return this; 75 76}; 77})(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.