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 var defaults = { 15 defaultText: 'Navigate to...', 16 className: 'select-menu', 17 subMenuClass: 'sub-menu', 18 subMenuDash: '–' 19 }, 20 settings = $.extend( defaults, options ), 21 el = $(this); 22 23 $("head").append('<style type="text/css">@media(max-width: 767px){.sf-menu{display:none;} .select-menu{display: block;}}</style>') 24 25 this.each(function(){ 26 // ad class to submenu list 27 el.find('ul').addClass(settings.subMenuClass); 28 29 // Create base menu 30 $('<select />',{'class':settings.className}).insertAfter(el); 31 32 // Create default option 33 $('<option />', {"value":'#', "text":settings.defaultText}).appendTo( '.' + settings.className ); 34 35 // Create select option from menu 36 el.find('a,.separator').each(function(){ 37 var $this = $(this), 38 optText = $this.context.firstChild.textContent, 39 optSub = $this.parents( '.' + settings.subMenuClass ), 40 len = optSub.length, 41 dash; 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 if($this.is('span')){ 48 // Now build menu and append it 49 $('<optgroup />', {"label":optText,}).appendTo('.' + settings.className); 50 }else{ 51 // Now build menu and append it 52 $('<option />', {"value":this.href, "html":optText, "selected":(this.href == window.location.href)}).appendTo( '.' + settings.className ); 53 } 54 }); // End el.find('a').each 55 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 }); // End this.each 64 return this; 65 }; 66})(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.