1 2(function ($) { 3 "use strict"; 4 $.fn.meanmenu = function (options) { 5 var defaults = { 6 meanMenuTarget: jQuery(this), // Target the current HTML markup you wish to replace 7 meanMenuContainer: '.mobile-menu-area .container', // Choose where meanmenu will be placed within the HTML 8 meanMenuClose: "X", // single character you want to represent the close menu button 9 meanMenuCloseSize: "18px", // set font size of close button 10 meanMenuOpen: "<span /><span /><span />", // text/markup you want when menu is closed 11 meanRevealPosition: "right", // left right or center positions 12 meanRevealPositionDistance: "0", // Tweak the position of the menu 13 meanRevealColour: "", // override CSS colours for the reveal background 14 meanScreenWidth: "991", // set the screen width you want meanmenu to kick in at 15 meanNavPush: "", // set a height here in px, em or % if you want to budge your layout now the navigation is missing. 16 meanShowChildren: true, // true to show children in the menu, false to hide them 17 meanExpandableChildren: true, // true to allow expand/collapse children 18 meanExpand: "+", // single character you want to represent the expand for ULs 19 meanContract: "-", // single character you want to represent the contract for ULs 20 meanRemoveAttrs: false, // true to remove classes and IDs, false to keep them 21 onePage: false, // set to true for one page sites 22 meanDisplay: "block", // override display method for table cell based layouts e.g. table-cell 23 removeElements: "" // set to hide page elements 24 }; 25 options = $.extend(defaults, options); 26 27 // get browser width 28 var currentWidth = window.innerWidth || document.documentElement.clientWidth; 29 30 return this.each(function () { 31 var meanMenu = options.meanMenuTarget; 32 var meanContainer = options.meanMenuContainer; 33 var meanMenuClose = options.meanMenuClose; 34 var meanMenuCloseSize = options.meanMenuCloseSize; 35 var meanMenuOpen = options.meanMenuOpen; 36 var meanRevealPosition = options.meanRevealPosition; 37 var meanRevealPositionDistance = options.meanRevealPositionDistance; 38 var meanRevealColour = options.meanRevealColour; 39 var meanScreenWidth = options.meanScreenWidth; 40 var meanNavPush = options.meanNavPush; 41 var meanRevealClass = ".meanmenu-reveal"; 42 var meanShowChildren = options.meanShowChildren; 43 var meanExpandableChildren = options.meanExpandableChildren; 44 var meanExpand = options.meanExpand; 45 var meanContract = options.meanContract; 46 var meanRemoveAttrs = options.meanRemoveAttrs; 47 var onePage = options.onePage; 48 var meanDisplay = options.meanDisplay; 49 var removeElements = options.removeElements; 50 51 //detect known mobile/tablet usage 52 var isMobile = false; 53 if ( (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i)) || (navigator.userAgent.match(/Android/i)) || (navigator.userAgent.match(/Blackberry/i)) || (navigator.userAgent.match(/Windows Phone/i)) ) { 54 isMobile = true; 55 } 56 57 if ( (navigator.userAgent.match(/MSIE 8/i)) || (navigator.userAgent.match(/MSIE 7/i)) ) { 58 // add scrollbar for IE7 & 8 to stop breaking resize function on small content sites 59 jQuery('html').css("overflow-y" , "scroll"); 60 } 61 62 var meanRevealPos = ""; 63 var meanCentered = function() { 64 if (meanRevealPosition === "center") { 65 var newWidth = window.innerWidth || document.documentElement.clientWidth; 66 var meanCenter = ( (newWidth/2)-22 )+"px"; 67 meanRevealPos = "left:" + meanCenter + ";right:auto;"; 68 69 if (!isMobile) { 70 jQuery('.meanmenu-reveal').css("left",meanCenter); 71 } else { 72 jQuery('.meanmenu-reveal').animate({ 73 left: meanCenter 74 }); 75 } 76 } 77 }; 78 79 var menuOn = false; 80 var meanMenuExist = false; 81 82 83 if (meanRevealPosition === "right") { 84 meanRevealPos = "right:" + meanRevealPositionDistance + ";left:auto;"; 85 } 86 if (meanRevealPosition === "left") { 87 meanRevealPos = "left:" + meanRevealPositionDistance + ";right:auto;"; 88 } 89 // run center function 90 meanCentered(); 91 92 // set all styles for mean-reveal
93 var $navreveal = ""; 94 95 var meanInner = function() { 96 // get last class name 97 if (jQuery($navreveal).is(".meanmenu-reveal.meanclose")) { 98 $navreveal.html(meanMenuClose); 99 } else { 100 $navreveal.html(meanMenuOpen); 101 } 102 }; 103 104 // re-instate original nav (and call this on window.width functions) 105 var meanOriginal = function() { 106 jQuery('.mean-bar,.mean-push').remove(); 107 jQuery(meanContainer).removeClass("mean-container"); 108 jQuery(meanMenu).css('display', meanDisplay); 109 menuOn = false; 110 meanMenuExist = false; 111 jQuery(removeElements).removeClass('mean-remove'); 112 }; 113 114 // navigation reveal 115 var showMeanMenu = function() { 116 var meanStyles = "background:"+meanRevealColour+";color:"+meanRevealColour+";"+meanRevealPos; 117 if (currentWidth <= meanScreenWidth) { 118 jQuery(removeElements).addClass('mean-remove'); 119 meanMenuExist = true; 120 // add class to body so we don't need to worry about media queries here, all CSS is wrapped in '.mean-container' 121 jQuery(meanContainer).addClass("mean-container"); 122 jQuery('.mean-container').prepend('<div class="mean-bar"><a href="#nav" class="meanmenu-reveal" style="'+meanStyles+'">Show Navigation</a><nav class="mean-nav"></nav></div>'); 123 124 //push meanMenu navigation into .mean-nav 125 var meanMenuContents = jQuery(meanMenu).html(); 126 jQuery('.mean-nav').html(meanMenuContents); 127 128 // remove all classes from EVERYTHING inside meanmenu nav 129 if(meanRemoveAttrs) { 130 jQuery('nav.mean-nav ul, nav.mean-nav ul *').each(function() { 131 // First check if this has mean-remove class 132 if (jQuery(this).is('.mean-remove')) { 133 jQuery(this).attr('class', 'mean-remove'); 134 } else { 135 jQuery(this).removeAttr("class"); 136 } 137 jQuery(this).removeAttr("id"); 138 }); 139 } 140 141 // push in a holder div (this can be used if removal of nav is causing layout issues) 142 jQuery(meanMenu).before('<div class="mean-push" />'); 143 jQuery('.mean-push').css("margin-top",meanNavPush); 144 145 // hide current navigation and reveal mean nav link 146 jQuery(meanMenu).hide(); 147 jQuery(".meanmenu-reveal").show(); 148 149 // turn 'X' on or off 150 jQuery(meanRevealClass).html(meanMenuOpen); 151 $navreveal = jQuery(meanRevealClass); 152 153 //hide mean-nav ul 154 jQuery('.mean-nav ul').hide(); 155 156 // hide sub nav 157 if(meanShowChildren) { 158 // allow expandable sub nav(s) 159 if(meanExpandableChildren){ 160 jQuery('.mean-nav ul ul').each(function() { 161 if(jQuery(this).children().length){ 162 jQuery(this,'li:first').parent().append('<a class="mean-expand" href="#" style="font-size: '+ meanMenuCloseSize +'">'+ meanExpand +'</a>'); 163 } 164 }); 165 jQuery('.mean-expand').on("click",function(e){ 166 e.preventDefault(); 167 if (jQuery(this).hasClass("mean-clicked")) { 168 jQuery(this).text(meanExpand); 169 jQuery(this).prev('ul').slideUp(300, function(){}); 170 } else { 171 jQuery(this).text(meanContract); 172 jQuery(this).prev('ul').slideDown(300, function(){}); 173 } 174 jQuery(this).toggleClass("mean-clicked"); 175 }); 176 } else { 177 jQuery('.mean-nav ul ul').show(); 178 } 179 } else { 180 jQuery('.mean-nav ul ul').hide(); 181 } 182 183 // add last class to tidy up borders 184 jQuery('.mean-nav ul li').last().addClass('mean-last'); 185 $navreveal.removeClass("meanclose"); 186 jQuery($navreveal).click(function(e){ 187 e.preventDefault(); 188 if( menuOn === false ) { 189 $navreveal.css("text-align", "center"); 190 $navreveal.css("text-indent", "0"); 191 $navreveal.css("font-size", meanMenuCloseSize); 192 jQuery('.mean-nav ul:first').slideDown(); 193 menuOn = true; 194 } else { 195 jQuery('.mean-nav ul:first').slideUp(); 196 menuOn = false;
197 } 198 $navreveal.toggleClass("meanclose"); 199 meanInner(); 200 jQuery(removeElements).addClass('mean-remove'); 201 }); 202 203 // for one page websites, reset all variables... 204 if ( onePage ) { 205 jQuery('.mean-nav ul > li > a:first-child').on( "click" , function () { 206 jQuery('.mean-nav ul:first').slideUp(); 207 menuOn = false; 208 jQuery($navreveal).toggleClass("meanclose").html(meanMenuOpen); 209 }); 210 } 211 } else { 212 meanOriginal(); 213 } 214 }; 215 216 if (!isMobile) { 217 // reset menu on resize above meanScreenWidth 218 jQuery(window).resize(function () { 219 currentWidth = window.innerWidth || document.documentElement.clientWidth; 220 if (currentWidth > meanScreenWidth) { 221 meanOriginal(); 222 } else { 223 meanOriginal(); 224 } 225 if (currentWidth <= meanScreenWidth) { 226 showMeanMenu(); 227 meanCentered(); 228 } else { 229 meanOriginal(); 230 } 231 }); 232 } 233 234 jQuery(window).resize(function () { 235 // get browser width 236 currentWidth = window.innerWidth || document.documentElement.clientWidth; 237 238 if (!isMobile) { 239 meanOriginal(); 240 if (currentWidth <= meanScreenWidth) { 241 showMeanMenu(); 242 meanCentered(); 243 } 244 } else { 245 meanCentered(); 246 if (currentWidth <= meanScreenWidth) { 247 if (meanMenuExist === false) { 248 showMeanMenu(); 249 } 250 } else { 251 meanOriginal(); 252 } 253 } 254 }); 255 256 // run main menuMenu function on load 257 showMeanMenu(); 258 }); 259 }; 260})(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.