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 optText = $this.text(), 40 optSub = $this.parents( '.' + settings.subMenuClass ), 41 len = optSub.length, 42 dash; 43 // if menu has sub menu 44 if( $this.parents('ul').hasClass( settings.subMenuClass ) ) { 45 dash = Array( len+1 ).join( settings.subMenuDash ); 46 optText = dash + optText; 47 } 48 if($this.is('span')){ 49 // Now build menu and append it 50 $('<optgroup />', {"label":optText,}).appendTo('.' + settings.className); 51 }else{ 52 // Now build menu and append it 53 $('<option />', {"value":this.href, "html":optText, "selected":(this.href == window.location.href)}).appendTo( '.' + settings.className ); 54 } 55 }); // End el.find('a').each 56 57 // Change event on select element 58 $('.' + settings.className).change(function(){ 59 var locations = $(this).val(); 60 if( locations !== '#' ) { 61 window.location.href = $(this).val(); 62 } 63 }); 64 }); // End this.each 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.