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 }).insertAfter( el ); 32 33 // Create default option 34 $('<option />', { 35 "value" : '#', 36 "text" : settings.defaultText 37 }).appendTo( '.' + settings.className ); 38 39 // Create select option from menu 40 el.find('a,.separator').each(function(){ 41 var $this = $(this), 42 optText = $this.text(), 43 optSub = $this.parents( '.' + settings.subMenuClass ), 44 len = optSub.length, 45 dash; 46 47 // if menu has sub menu 48 if( $this.parents('ul').hasClass( settings.subMenuClass ) ) { 49 dash = Array( len+1 ).join( settings.subMenuDash ); 50 optText = dash + optText; 51 } 52 if($this.is('span')){ 53 // Now build menu and append it 54 $('<optgroup />', { 55 "label" : optText, 56 }).appendTo( '.' + settings.className ); 57 } 58 else{ 59 // Now build menu and append it 60 $('<option />', { 61 "value" : this.href, 62 "html" : optText, 63 "selected" : (this.href == window.location.href) 64 }).appendTo( '.' + settings.className ); 65 } 66 67 }); // End el.find('a').each 68 69 // Change event on select element 70 $('.' + settings.className).change(function(){ 71 var locations = $(this).val(); 72 if( locations !== '#' ) { 73 window.location.href = $(this).val(); 74 } 75 }); 76 $('.select-menu').show(); 77 78 }); // End this.each 79 80 return this; 81}; 82})(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.