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