1/* 2 3Responsive Mobile Menu v1.1 4Plugin URI: responsivemultimenu.com 5 6Author: Adam Wysocki 7Author URI: http://oncebuilder.com 8 9License: http://opensource.org/licenses/MIT 10 11*/ 12 13function adaptMenu() { 14 /* toggle menu on resize */ 15 $('.rmm').each(function() { 16 // initialize vars 17 var maxWidth = 0; 18 var width = 0; 19 20 // width of menu list (non-toggled) 21 $('.rmm-menu').children("li").each(function() { 22 if($(this).parent().hasClass('rmm-menu')){ 23 width = $(this).outerWidth();//outerWidth(); 24 if(width>0){ 25 maxWidth += width; 26 } 27 } 28 }); 29 30 // compare width 31 var width = $('.rmm').css('max-width'); 32 width = width.replace('px', ''); 33 34 if ( $(this).parent().width() > width ) { 35 $('.rmm-menu').removeClass("rmm-mobile"); 36 37 //remove all classes from mobile verion 38 $(".rmm-menu ul").removeClass("rmm-subview"); 39 $(".rmm-menu li").removeClass("rmm-subover-hidden"); 40 $(".rmm-menu li").removeClass("rmm-subover-visible"); 41 $(".rmm-menu a").removeClass("rmm-subover-header"); 42 43 $(".rmm-toggled").removeClass("rmm-closed"); 44 $('.rmm-toggled').hide(); 45 46 //$('.rmm-toggled').removeClass("rmm-view"); 47 //$('.rmm-toggled').addClass("rmm-closed"); 48 }else { 49 $('.rmm-menu').addClass("rmm-mobile"); 50 $('.rmm-toggled').show(); 51 $('.rmm-toggled').addClass("rmm-closed"); 52 53 //$('.rmm-toggled').removeClass("rmm-closed"); 54 } 55 }); 56} 57 58function responsiveMultiMenu() { 59 $('.rmm').each(function() { 60 // create mobile menu classes here to light up HTML 61 $(this).find("ul").addClass("rmm-submenu"); 62 $(this).find("ul:first").addClass("rmm-menu"); 63 $(this).find("ul:first").removeClass("rmm-submenu"); 64 $(this).find('.rmm-submenu').prepend( '<li class="rmm-back"><a href="#">back</a></li>' ); 65 $(this).find("ul").prev().addClass("rmm-dropdown"); 66 67 // initialize vars 68 var maxWidth = 0; 69 var width = 0; 70 71 // width of menu list (non-toggled) 72 $('.rmm-menu').children("li").each(function() { 73 if($(this).parent().hasClass('rmm-menu')){ 74 width = $(this).outerWidth();//outerWidth(); 75 if(width>0){ 76 maxWidth += width; 77 } 78 console.log(width) 79 } 80 }); 81 82 if ($.support.leadingWhitespace) { 83 $(this).css('max-width' , (maxWidth+5)+'px'); 84 }else{ 85 $(this).css('width' , (maxWidth+5)+'px'); 86 } 87 88 // create dropdown button 89 var str='' 90 str+='<div class="rmm-toggled rmm-view rmm-closed">' 91 str+='<div class="rmm-toggled-controls">' 92 str+='<div class="rmm-toggled-title">Menu</div>'; 93 str+='<div class="rmm-toggled-button"><span> </span><span> </span><span> </span></div>'; 94 str+='</div>'; 95 str+='</div>'; 96 97 $(this).prepend(str); 98 }); 99 100 // click interacts in mobile wersion 101 $('.rmm-dropdown').click(function (e) { 102 if($(this).parents(".rmm-menu").hasClass('rmm-mobile')){ 103 e.preventDefault(); 104 e.stopPropagation(); 105 106 $(this).next().addClass("rmm-subview"); 107 108 var index=$(this).parent().index(); 109 110 var i=0; 111 $(this).parent().parent().children("li").each(function() { 112 if(index==$(this).index()){ 113 $(this).removeClass("rmm-subover-hidden"); 114 $(this).addClass("rmm-subover-visible"); 115 }else{ 116 $(this).removeClass("rmm-subover-visible"); 117 $(this).addClass("rmm-subover-hidden"); 118 } 119 }); 120 $(this).addClass("rmm-subover-header"); 121 } 122 }); 123 124 // click back interacts in mobile version 125 $('.rmm-back a').click(function () { 126 $(this).parent().parent().prev().removeClass("rmm-subover-header"); 127 $(this).parent().parent().removeClass("rmm-subview"); 128 $(this).parent().parent().parent().parent().find("li").removeClass("rmm-subover-hidden"); 129 }); 130 131 // click toggler interacts in mobile version 132 $('.rmm-toggled, .rmm-toggled .rmm-button').click(function(){ 133 if ($(this).is(".rmm-closed")) { 134 $(this).removeClass("rmm-closed"); 135 }else { 136 $(this).addClass("rmm-closed"); 137 } 138 }); 139} 140 141jQuery(window).load(function() { 142 responsiveMultiMenu(); 143 adaptMenu(); 144}); 145 146 147$(window).resize(function() { 148 adaptMenu(); 149});
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.