1/** 2 * jQuery meanMenu v2.0.2 3 * Copyright (C) 2012-2013 Chris Wharton ([email protected]) 4 * 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT 11 * HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, 12 * INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR 13 * FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE 14 * OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, 15 * COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.COPYRIGHT HOLDERS WILL NOT 16 * BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL 17 * DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program. If not, see <http://gnu.org/licenses/>. 21 * 22 * Find more information at http://www.meanthemes.com/plugins/meanmenu/ 23 * 24 */ 25(function ($) { 26 $.fn.meanmenu = function (options) { 27 var defaults = { 28 meanMenuTarget: jQuery(this), // Target the current HTML markup you wish to replace 29 meanMenuContainer: '#masthead', // Choose where meanmenu will be placed within the HTML 30 meanMenuClose: "X", // single character you want to represent the close menu button 31 meanMenuCloseSize: "18px", // set font size of close button 32 meanMenuOpen: "<span /><span /><span />", // text/markup you want when menu is closed 33 meanRevealPosition: "right", // left right or center positions 34 meanRevealPositionDistance: "0", // Tweak the position of the menu 35 meanRevealColour: "", // override CSS colours for the reveal background 36 meanRevealHoverColour: "", // override CSS colours for the reveal hover 37 meanScreenWidth: "767", // set the screen width you want meanmenu to kick in at 38 meanNavPush: "", // set a height here in px, em or % if you want to budge your layout now the navigation is missing. 39 meanShowChildren: true, // true to show children in the menu, false to hide them 40 meanExpandableChildren: true, // true to allow expand/collapse children 41 meanExpand: "+", // single character you want to represent the expand for ULs 42 meanContract: "-", // single character you want to represent the contract for ULs 43 meanRemoveAttrs: false // true to remove classes and IDs, false to keep them 44 }; 45 var options = $.extend(defaults, options); 46 47 // get browser width 48 currentWidth = window.innerWidth || document.documentElement.clientWidth; 49 50 return this.each(function () { 51 var meanMenu = options.meanMenuTarget; 52 var meanContainer = options.meanMenuContainer; 53 var meanReveal = options.meanReveal; 54 var meanMenuClose = options.meanMenuClose; 55 var meanMenuCloseSize = options.meanMenuCloseSize; 56 var meanMenuOpen = options.meanMenuOpen; 57 var meanRevealPosition = options.meanRevealPosition; 58 var meanRevealPositionDistance = options.meanRevealPositionDistance; 59 var meanRevealColour = options.meanRevealColour; 60 var meanRevealHoverColour = options.meanRevealHoverColour; 61 var meanScreenWidth = options.meanScreenWidth; 62 var meanNavPush = options.meanNavPush; 63 var meanRevealClass = ".meanmenu-reveal"; 64 meanShowChildren = options.meanShowChildren; 65 meanExpandableChildren = options.meanExpandableChildren; 66 var meanExpand = options.meanExpand; 67 var meanContract = options.meanContract; 68 var meanRemoveAttrs = options.meanRemoveAttrs; 69 70 //detect known mobile/tablet usage 71 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)) ) { 72 var isMobile = true; 73 } 74 75 if ( (navigator.userAgent.match(/MSIE 8/i)) || (navigator.userAgent.match(/MSIE 7/i)) ) { 76 // add scrollbar for IE7 & 8 to stop breaking resize function on small content sites 77 jQuery('html').css("overflow-y" , "scroll"); 78 } 79 80 function meanCentered() { 81 if (meanRevealPosition == "center") { 82 var newWidth = window.innerWidth || document.documentElement.clientWidth; 83 var meanCenter = ( (newWidth/2)-22 )+"px"; 84 meanRevealPos = "left:" + meanCenter + ";right:auto;"; 85 86 if (!isMobile) { 87 jQuery('.meanmenu-reveal').css("left",meanCenter); 88 } else { 89 jQuery('.meanmenu-reveal').animate({ 90 left: meanCenter 91 }); 92 } 93 } 94 } 95 96 menuOn = false;
97 meanMenuExist = false; 98 99 if (meanRevealPosition == "right") { 100 meanRevealPos = "right:" + meanRevealPositionDistance + ";left:auto;"; 101 } 102 if (meanRevealPosition == "left") { 103 meanRevealPos = "left:" + meanRevealPositionDistance + ";right:auto;"; 104 } 105 // run center function 106 meanCentered(); 107 108 // set all styles for mean-reveal 109 meanStyles = "background:"+meanRevealColour+";color:"+meanRevealColour+";"+meanRevealPos; 110 111 function meanInner() { 112 // get last class name 113 if (jQuery($navreveal).is(".meanmenu-reveal.meanclose")) { 114 $navreveal.html(meanMenuClose); 115 } else { 116 $navreveal.html(meanMenuOpen); 117 } 118 } 119 120 //re-instate original nav (and call this on window.width functions) 121 function meanOriginal() { 122 jQuery('.mean-bar,.mean-push').remove(); 123 jQuery(meanContainer).removeClass("mean-container"); 124 jQuery(meanMenu).show(); 125 menuOn = false; 126 meanMenuExist = false; 127 } 128 129 //navigation reveal 130 function showMeanMenu() { 131 if (currentWidth <= meanScreenWidth) { 132 meanMenuExist = true; 133 // add class to body so we don't need to worry about media queries here, all CSS is wrapped in '.mean-container' 134 jQuery(meanContainer).addClass("mean-container"); 135 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>'); 136 137 //push meanMenu navigation into .mean-nav 138 var meanMenuContents = jQuery(meanMenu).html(); 139 jQuery('.mean-nav').html(meanMenuContents); 140 141 // remove all classes from EVERYTHING inside meanmenu nav 142 if(meanRemoveAttrs) { 143 jQuery('nav.mean-nav *').each(function() { 144 jQuery(this).removeAttr("class"); 145 jQuery(this).removeAttr("id"); 146 }); 147 } 148 149 // push in a holder div (this can be used if removal of nav is causing layout issues) 150 jQuery(meanMenu).before('<div class="mean-push" />'); 151 jQuery('.mean-push').css("margin-top",meanNavPush); 152 153 // hide current navigation and reveal mean nav link 154 jQuery(meanMenu).hide(); 155 jQuery(".meanmenu-reveal").show(); 156 157 // turn 'X' on or off 158 jQuery(meanRevealClass).html(meanMenuOpen); 159 $navreveal = jQuery(meanRevealClass); 160 161 //hide mean-nav ul 162 jQuery('.mean-nav ul').hide(); 163 164 // hide sub nav 165 if(meanShowChildren) { 166 // allow expandable sub nav(s) 167 if(meanExpandableChildren){ 168 jQuery('.mean-nav ul ul').each(function() { 169 if(jQuery(this).children().length){ 170 jQuery(this,'li:first').parent().append('<a class="mean-expand" href="#" style="font-size: '+ meanMenuCloseSize +'">'+ meanExpand +'</a>'); 171 } 172 }); 173 jQuery('.mean-expand').on("click",function(e){ 174 e.preventDefault(); 175 if (jQuery(this).hasClass("mean-clicked")) { 176 jQuery(this).text(meanExpand); 177 jQuery(this).prev('ul').slideUp(300, function(){}); 178 } else { 179 jQuery(this).text(meanContract); 180 jQuery(this).prev('ul').slideDown(300, function(){}); 181 } 182 jQuery(this).toggleClass("mean-clicked"); 183 }); 184 } else { 185 jQuery('.mean-nav ul ul').show(); 186 } 187 } else { 188 jQuery('.mean-nav ul ul').hide(); 189 } 190 191 // add last class to tidy up borders 192 jQuery('.mean-nav ul li').last().addClass('mean-last'); 193 194 $navreveal.removeClass("meanclose"); 195 jQuery($navreveal).click(function(e){ 196 e.preventDefault(); 197 if(menuOn == false) { 198 $navreveal.css("text-align", "center"); 199 $navreveal.css("text-indent", "0"); 200 $navreveal.css("font-size", meanMenuCloseSize); 201 jQuery('.mean-nav ul:first').slideDown(); 202 menuOn = true; 203 } else { 204 jQuery('.mean-nav ul:first').slideUp(); 205 menuOn = false;
206 } 207 $navreveal.toggleClass("meanclose"); 208 meanInner(); 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 // adjust menu positioning on centered navigation 235 window.onorientationchange = function() { 236 meanCentered(); 237 // get browser width 238 currentWidth = window.innerWidth || document.documentElement.clientWidth; 239 if (currentWidth >= meanScreenWidth) { 240 meanOriginal(); 241 } 242 if (currentWidth <= meanScreenWidth) { 243 if (meanMenuExist == false) { 244 showMeanMenu(); 245 } 246 } 247 } 248 // run main menuMenu function on load 249 showMeanMenu(); 250 }); 251 }; 252})(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.