1/** 2 * jQuery Mobile Menu 3 * Turn unordered list menu into dropdown select menu 4 * version 1.1(27-JULY-2013) 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 var $el = $(this), 26 $select_menu; 27 28 // ad class to submenu list 29 $el.find('ul').addClass(settings.subMenuClass); 30 31 // Create base menu 32 var $select_menu = $('<select />',{ 33 'class' : settings.className + ' ' + el.get(0).className 34 }).insertAfter( $el ); 35 36 // Create default option 37 $('<option />', { 38 "value" : '#', 39 "text" : settings.defaultText 40 }).appendTo( $select_menu ); 41 42 // Create select option from menu 43 $el.find('a').each(function(){ 44 var $this = $(this), 45 optText = ' ' + $this.text(), 46 optSub = $this.parents( '.' + settings.subMenuClass ), 47 len = optSub.length, 48 dash; 49 50 // if menu has sub menu 51 if( $this.parents('ul').hasClass( settings.subMenuClass ) ) { 52 dash = Array( len+1 ).join( settings.subMenuDash ); 53 optText = dash + optText; 54 } 55 56 // Now build menu and append it 57 $('<option />', { 58 "value" : this.href, 59 "html" : optText, 60 "selected" : (this.href == window.location.href) 61 }).appendTo( $select_menu ); 62 63 }); // End el.find('a').each 64 65 // Change event on select element 66 $select_menu.change(function(){ 67 var locations = $(this).val(); 68 if( locations !== '#' ) { 69 window.location.href = $(this).val(); 70 }; 71 }); 72 73 }); // End this.each 74 75 return this; 76 77}; 78})(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.