From c930e92b5baca2ad781068d01a8fa2e4f2059fc4 Mon Sep 17 00:00:00 2001 From: Tim Date: Sat, 12 May 2018 10:59:50 +1000 Subject: [PATCH 01/23] Changed indenting to 1 tab for readability --- jquery.meanmenu.js | 512 ++++++++++++++++++++++----------------------- 1 file changed, 256 insertions(+), 256 deletions(-) diff --git a/jquery.meanmenu.js b/jquery.meanmenu.js index 70a49f1..c29a206 100644 --- a/jquery.meanmenu.js +++ b/jquery.meanmenu.js @@ -1,285 +1,285 @@ /*! -* jQuery meanMenu v2.0.8 -* @Copyright (C) 2012-2014 Chris Wharton @ MeanThemes (https://github.com/meanthemes/meanMenu) -* -*/ + * jQuery meanMenu v2.0.8 + * @Copyright (C) 2012-2014 Chris Wharton @ MeanThemes (https://github.com/meanthemes/meanMenu) + * + */ /* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT -* HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, -* INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR -* FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE -* OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, -* COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.COPYRIGHT HOLDERS WILL NOT -* BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL -* DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* -* Find more information at http://www.meanthemes.com/plugins/meanmenu/ -* -*/ -(function ($) { - "use strict"; - $.fn.meanmenu = function (options) { - var defaults = { - meanMenuTarget: jQuery(this), // Target the current HTML markup you wish to replace - meanMenuContainer: 'body', // Choose where meanmenu will be placed within the HTML - meanMenuClose: "X", // single character you want to represent the close menu button - meanMenuCloseSize: "18px", // set font size of close button - meanMenuOpen: "", // text/markup you want when menu is closed - meanRevealPosition: "right", // left right or center positions - meanRevealPositionDistance: "0", // Tweak the position of the menu - meanRevealColour: "", // override CSS colours for the reveal background - meanScreenWidth: "480", // set the screen width you want meanmenu to kick in at - meanNavPush: "", // set a height here in px, em or % if you want to budge your layout now the navigation is missing. - meanShowChildren: true, // true to show children in the menu, false to hide them - meanExpandableChildren: true, // true to allow expand/collapse children - meanExpand: "+", // single character you want to represent the expand for ULs - meanContract: "-", // single character you want to represent the contract for ULs - meanRemoveAttrs: false, // true to remove classes and IDs, false to keep them - onePage: false, // set to true for one page sites - meanDisplay: "block", // override display method for table cell based layouts e.g. table-cell - removeElements: "" // set to hide page elements - }; - options = $.extend(defaults, options); + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT + * HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR + * FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE + * OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, + * COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.COPYRIGHT HOLDERS WILL NOT + * BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL + * DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Find more information at http://www.meanthemes.com/plugins/meanmenu/ + * + */ +(function($) { + "use strict"; + $.fn.meanmenu = function(options) { + var defaults = { + meanMenuTarget: jQuery(this), // Target the current HTML markup you wish to replace + meanMenuContainer: 'body', // Choose where meanmenu will be placed within the HTML + meanMenuClose: "X", // single character you want to represent the close menu button + meanMenuCloseSize: "18px", // set font size of close button + meanMenuOpen: "", // text/markup you want when menu is closed + meanRevealPosition: "right", // left right or center positions + meanRevealPositionDistance: "0", // Tweak the position of the menu + meanRevealColour: "", // override CSS colours for the reveal background + meanScreenWidth: "480", // set the screen width you want meanmenu to kick in at + meanNavPush: "", // set a height here in px, em or % if you want to budge your layout now the navigation is missing. + meanShowChildren: true, // true to show children in the menu, false to hide them + meanExpandableChildren: true, // true to allow expand/collapse children + meanExpand: "+", // single character you want to represent the expand for ULs + meanContract: "-", // single character you want to represent the contract for ULs + meanRemoveAttrs: false, // true to remove classes and IDs, false to keep them + onePage: false, // set to true for one page sites + meanDisplay: "block", // override display method for table cell based layouts e.g. table-cell + removeElements: "" // set to hide page elements + }; + options = $.extend(defaults, options); - // get browser width - var currentWidth = window.innerWidth || document.documentElement.clientWidth; + // get browser width + var currentWidth = window.innerWidth || document.documentElement.clientWidth; - return this.each(function () { - var meanMenu = options.meanMenuTarget; - var meanContainer = options.meanMenuContainer; - var meanMenuClose = options.meanMenuClose; - var meanMenuCloseSize = options.meanMenuCloseSize; - var meanMenuOpen = options.meanMenuOpen; - var meanRevealPosition = options.meanRevealPosition; - var meanRevealPositionDistance = options.meanRevealPositionDistance; - var meanRevealColour = options.meanRevealColour; - var meanScreenWidth = options.meanScreenWidth; - var meanNavPush = options.meanNavPush; - var meanRevealClass = ".meanmenu-reveal"; - var meanShowChildren = options.meanShowChildren; - var meanExpandableChildren = options.meanExpandableChildren; - var meanExpand = options.meanExpand; - var meanContract = options.meanContract; - var meanRemoveAttrs = options.meanRemoveAttrs; - var onePage = options.onePage; - var meanDisplay = options.meanDisplay; - var removeElements = options.removeElements; + return this.each(function() { + var meanMenu = options.meanMenuTarget; + var meanContainer = options.meanMenuContainer; + var meanMenuClose = options.meanMenuClose; + var meanMenuCloseSize = options.meanMenuCloseSize; + var meanMenuOpen = options.meanMenuOpen; + var meanRevealPosition = options.meanRevealPosition; + var meanRevealPositionDistance = options.meanRevealPositionDistance; + var meanRevealColour = options.meanRevealColour; + var meanScreenWidth = options.meanScreenWidth; + var meanNavPush = options.meanNavPush; + var meanRevealClass = ".meanmenu-reveal"; + var meanShowChildren = options.meanShowChildren; + var meanExpandableChildren = options.meanExpandableChildren; + var meanExpand = options.meanExpand; + var meanContract = options.meanContract; + var meanRemoveAttrs = options.meanRemoveAttrs; + var onePage = options.onePage; + var meanDisplay = options.meanDisplay; + var removeElements = options.removeElements; - //detect known mobile/tablet usage - var isMobile = false; - 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)) ) { - isMobile = true; - } + //detect known mobile/tablet usage + var isMobile = false; + 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))) { + isMobile = true; + } - if ( (navigator.userAgent.match(/MSIE 8/i)) || (navigator.userAgent.match(/MSIE 7/i)) ) { - // add scrollbar for IE7 & 8 to stop breaking resize function on small content sites - jQuery('html').css("overflow-y" , "scroll"); - } + if ((navigator.userAgent.match(/MSIE 8/i)) || (navigator.userAgent.match(/MSIE 7/i))) { + // add scrollbar for IE7 & 8 to stop breaking resize function on small content sites + jQuery('html').css("overflow-y", "scroll"); + } - var meanRevealPos = ""; - var meanCentered = function() { - if (meanRevealPosition === "center") { - var newWidth = window.innerWidth || document.documentElement.clientWidth; - var meanCenter = ( (newWidth/2)-22 )+"px"; - meanRevealPos = "left:" + meanCenter + ";right:auto;"; + var meanRevealPos = ""; + var meanCentered = function() { + if (meanRevealPosition === "center") { + var newWidth = window.innerWidth || document.documentElement.clientWidth; + var meanCenter = ((newWidth / 2) - 22) + "px"; + meanRevealPos = "left:" + meanCenter + ";right:auto;"; - if (!isMobile) { - jQuery('.meanmenu-reveal').css("left",meanCenter); - } else { - jQuery('.meanmenu-reveal').animate({ - left: meanCenter - }); - } - } - }; + if (!isMobile) { + jQuery('.meanmenu-reveal').css("left", meanCenter); + } else { + jQuery('.meanmenu-reveal').animate({ + left: meanCenter + }); + } + } + }; - var menuOn = false; - var meanMenuExist = false; + var menuOn = false; + var meanMenuExist = false; - if (meanRevealPosition === "right") { - meanRevealPos = "right:" + meanRevealPositionDistance + ";left:auto;"; - } - if (meanRevealPosition === "left") { - meanRevealPos = "left:" + meanRevealPositionDistance + ";right:auto;"; - } - // run center function - meanCentered(); + if (meanRevealPosition === "right") { + meanRevealPos = "right:" + meanRevealPositionDistance + ";left:auto;"; + } + if (meanRevealPosition === "left") { + meanRevealPos = "left:" + meanRevealPositionDistance + ";right:auto;"; + } + // run center function + meanCentered(); - // set all styles for mean-reveal - var $navreveal = ""; + // set all styles for mean-reveal + var $navreveal = ""; - var meanInner = function() { - // get last class name - if (jQuery($navreveal).is(".meanmenu-reveal.meanclose")) { - $navreveal.html(meanMenuClose); - } else { - $navreveal.html(meanMenuOpen); - } - }; + var meanInner = function() { + // get last class name + if (jQuery($navreveal).is(".meanmenu-reveal.meanclose")) { + $navreveal.html(meanMenuClose); + } else { + $navreveal.html(meanMenuOpen); + } + }; - // re-instate original nav (and call this on window.width functions) - var meanOriginal = function() { - jQuery('.mean-bar,.mean-push').remove(); - jQuery(meanContainer).removeClass("mean-container"); - jQuery(meanMenu).css('display', meanDisplay); - menuOn = false; - meanMenuExist = false; - jQuery(removeElements).removeClass('mean-remove'); - }; + // re-instate original nav (and call this on window.width functions) + var meanOriginal = function() { + jQuery('.mean-bar,.mean-push').remove(); + jQuery(meanContainer).removeClass("mean-container"); + jQuery(meanMenu).css('display', meanDisplay); + menuOn = false; + meanMenuExist = false; + jQuery(removeElements).removeClass('mean-remove'); + }; - // navigation reveal - var showMeanMenu = function() { - var meanStyles = "background:"+meanRevealColour+";color:"+meanRevealColour+";"+meanRevealPos; - if (currentWidth <= meanScreenWidth) { - jQuery(removeElements).addClass('mean-remove'); - meanMenuExist = true; - // add class to body so we don't need to worry about media queries here, all CSS is wrapped in '.mean-container' - jQuery(meanContainer).addClass("mean-container"); - jQuery('.mean-container').prepend(''); + // navigation reveal + var showMeanMenu = function() { + var meanStyles = "background:" + meanRevealColour + ";color:" + meanRevealColour + ";" + meanRevealPos; + if (currentWidth <= meanScreenWidth) { + jQuery(removeElements).addClass('mean-remove'); + meanMenuExist = true; + // add class to body so we don't need to worry about media queries here, all CSS is wrapped in '.mean-container' + jQuery(meanContainer).addClass("mean-container"); + jQuery('.mean-container').prepend(''); - //push meanMenu navigation into .mean-nav - var meanMenuContents = jQuery(meanMenu).html(); - jQuery('.mean-nav').html(meanMenuContents); + //push meanMenu navigation into .mean-nav + var meanMenuContents = jQuery(meanMenu).html(); + jQuery('.mean-nav').html(meanMenuContents); - // remove all classes from EVERYTHING inside meanmenu nav - if(meanRemoveAttrs) { - jQuery('nav.mean-nav ul, nav.mean-nav ul *').each(function() { - // First check if this has mean-remove class - if (jQuery(this).is('.mean-remove')) { - jQuery(this).attr('class', 'mean-remove'); - } else { - jQuery(this).removeAttr("class"); - } - jQuery(this).removeAttr("id"); - }); - } + // remove all classes from EVERYTHING inside meanmenu nav + if (meanRemoveAttrs) { + jQuery('nav.mean-nav ul, nav.mean-nav ul *').each(function() { + // First check if this has mean-remove class + if (jQuery(this).is('.mean-remove')) { + jQuery(this).attr('class', 'mean-remove'); + } else { + jQuery(this).removeAttr("class"); + } + jQuery(this).removeAttr("id"); + }); + } - // push in a holder div (this can be used if removal of nav is causing layout issues) - jQuery(meanMenu).before('
'); - jQuery('.mean-push').css("margin-top",meanNavPush); + // push in a holder div (this can be used if removal of nav is causing layout issues) + jQuery(meanMenu).before('
'); + jQuery('.mean-push').css("margin-top", meanNavPush); - // hide current navigation and reveal mean nav link - jQuery(meanMenu).hide(); - jQuery(".meanmenu-reveal").show(); + // hide current navigation and reveal mean nav link + jQuery(meanMenu).hide(); + jQuery(".meanmenu-reveal").show(); - // turn 'X' on or off - jQuery(meanRevealClass).html(meanMenuOpen); - $navreveal = jQuery(meanRevealClass); + // turn 'X' on or off + jQuery(meanRevealClass).html(meanMenuOpen); + $navreveal = jQuery(meanRevealClass); - //hide mean-nav ul - jQuery('.mean-nav ul').hide(); + //hide mean-nav ul + jQuery('.mean-nav ul').hide(); - // hide sub nav - if(meanShowChildren) { - // allow expandable sub nav(s) - if(meanExpandableChildren){ - jQuery('.mean-nav ul ul').each(function() { - if(jQuery(this).children().length){ - jQuery(this,'li:first').parent().append(''+ meanExpand +''); - } - }); - jQuery('.mean-expand').on("click",function(e){ - e.preventDefault(); - if (jQuery(this).hasClass("mean-clicked")) { - jQuery(this).text(meanExpand); - jQuery(this).prev('ul').slideUp(300, function(){}); - } else { - jQuery(this).text(meanContract); - jQuery(this).prev('ul').slideDown(300, function(){}); - } - jQuery(this).toggleClass("mean-clicked"); - }); - } else { - jQuery('.mean-nav ul ul').show(); - } - } else { - jQuery('.mean-nav ul ul').hide(); - } + // hide sub nav + if (meanShowChildren) { + // allow expandable sub nav(s) + if (meanExpandableChildren) { + jQuery('.mean-nav ul ul').each(function() { + if (jQuery(this).children().length) { + jQuery(this, 'li:first').parent().append('' + meanExpand + ''); + } + }); + jQuery('.mean-expand').on("click", function(e) { + e.preventDefault(); + if (jQuery(this).hasClass("mean-clicked")) { + jQuery(this).text(meanExpand); + jQuery(this).prev('ul').slideUp(300, function() {}); + } else { + jQuery(this).text(meanContract); + jQuery(this).prev('ul').slideDown(300, function() {}); + } + jQuery(this).toggleClass("mean-clicked"); + }); + } else { + jQuery('.mean-nav ul ul').show(); + } + } else { + jQuery('.mean-nav ul ul').hide(); + } - // add last class to tidy up borders - jQuery('.mean-nav ul li').last().addClass('mean-last'); - $navreveal.removeClass("meanclose"); - jQuery($navreveal).click(function(e){ - e.preventDefault(); - if( menuOn === false ) { - $navreveal.css("text-align", "center"); - $navreveal.css("text-indent", "0"); - $navreveal.css("font-size", meanMenuCloseSize); - jQuery('.mean-nav ul:first').slideDown(); - menuOn = true; - } else { - jQuery('.mean-nav ul:first').slideUp(); - menuOn = false; - } - $navreveal.toggleClass("meanclose"); - meanInner(); - jQuery(removeElements).addClass('mean-remove'); - }); + // add last class to tidy up borders + jQuery('.mean-nav ul li').last().addClass('mean-last'); + $navreveal.removeClass("meanclose"); + jQuery($navreveal).click(function(e) { + e.preventDefault(); + if (menuOn === false) { + $navreveal.css("text-align", "center"); + $navreveal.css("text-indent", "0"); + $navreveal.css("font-size", meanMenuCloseSize); + jQuery('.mean-nav ul:first').slideDown(); + menuOn = true; + } else { + jQuery('.mean-nav ul:first').slideUp(); + menuOn = false; + } + $navreveal.toggleClass("meanclose"); + meanInner(); + jQuery(removeElements).addClass('mean-remove'); + }); - // for one page websites, reset all variables... - if ( onePage ) { - jQuery('.mean-nav ul > li > a:first-child').on( "click" , function () { - jQuery('.mean-nav ul:first').slideUp(); - menuOn = false; - jQuery($navreveal).toggleClass("meanclose").html(meanMenuOpen); - }); - } - } else { - meanOriginal(); - } - }; + // for one page websites, reset all variables... + if (onePage) { + jQuery('.mean-nav ul > li > a:first-child').on("click", function() { + jQuery('.mean-nav ul:first').slideUp(); + menuOn = false; + jQuery($navreveal).toggleClass("meanclose").html(meanMenuOpen); + }); + } + } else { + meanOriginal(); + } + }; - if (!isMobile) { - // reset menu on resize above meanScreenWidth - jQuery(window).resize(function () { - currentWidth = window.innerWidth || document.documentElement.clientWidth; - if (currentWidth > meanScreenWidth) { - meanOriginal(); - } else { - meanOriginal(); - } - if (currentWidth <= meanScreenWidth) { - showMeanMenu(); - meanCentered(); - } else { - meanOriginal(); - } - }); - } + if (!isMobile) { + // reset menu on resize above meanScreenWidth + jQuery(window).resize(function() { + currentWidth = window.innerWidth || document.documentElement.clientWidth; + if (currentWidth > meanScreenWidth) { + meanOriginal(); + } else { + meanOriginal(); + } + if (currentWidth <= meanScreenWidth) { + showMeanMenu(); + meanCentered(); + } else { + meanOriginal(); + } + }); + } - jQuery(window).resize(function () { - // get browser width - currentWidth = window.innerWidth || document.documentElement.clientWidth; + jQuery(window).resize(function() { + // get browser width + currentWidth = window.innerWidth || document.documentElement.clientWidth; - if (!isMobile) { - meanOriginal(); - if (currentWidth <= meanScreenWidth) { - showMeanMenu(); - meanCentered(); - } - } else { - meanCentered(); - if (currentWidth <= meanScreenWidth) { - if (meanMenuExist === false) { - showMeanMenu(); - } - } else { - meanOriginal(); - } - } - }); + if (!isMobile) { + meanOriginal(); + if (currentWidth <= meanScreenWidth) { + showMeanMenu(); + meanCentered(); + } + } else { + meanCentered(); + if (currentWidth <= meanScreenWidth) { + if (meanMenuExist === false) { + showMeanMenu(); + } + } else { + meanOriginal(); + } + } + }); - // run main menuMenu function on load - showMeanMenu(); - }); - }; + // run main menuMenu function on load + showMeanMenu(); + }); + }; })(jQuery); From 7cdef3b7c869070eeed0576b1d75278200ed95db Mon Sep 17 00:00:00 2001 From: Tim Date: Sat, 12 May 2018 11:14:57 +1000 Subject: [PATCH 02/23] Added option to specify expand/collapse link location User should be able to switch between adding the expand/collapse link before or after the child menu. --- jquery.meanmenu.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/jquery.meanmenu.js b/jquery.meanmenu.js index c29a206..865d4fe 100644 --- a/jquery.meanmenu.js +++ b/jquery.meanmenu.js @@ -40,6 +40,7 @@ meanNavPush: "", // set a height here in px, em or % if you want to budge your layout now the navigation is missing. meanShowChildren: true, // true to show children in the menu, false to hide them meanExpandableChildren: true, // true to allow expand/collapse children + meanExpandPosition: "after", // after to insert the expand/collapse link after the child menu meanExpand: "+", // single character you want to represent the expand for ULs meanContract: "-", // single character you want to represent the contract for ULs meanRemoveAttrs: false, // true to remove classes and IDs, false to keep them @@ -66,6 +67,7 @@ var meanRevealClass = ".meanmenu-reveal"; var meanShowChildren = options.meanShowChildren; var meanExpandableChildren = options.meanExpandableChildren; + var meanExpandPosition = options.meanExpandPosition; var meanExpand = options.meanExpand; var meanContract = options.meanContract; var meanRemoveAttrs = options.meanRemoveAttrs; @@ -113,7 +115,7 @@ } // run center function meanCentered(); - + // set all styles for mean-reveal var $navreveal = ""; @@ -184,8 +186,12 @@ if (meanExpandableChildren) { jQuery('.mean-nav ul ul').each(function() { if (jQuery(this).children().length) { - jQuery(this, 'li:first').parent().append('' + meanExpand + ''); - } + if (meanExpandPosition == "before") { + jQuery(this, 'li:first').parent().prepend('' + meanExpand + ''); + } else { + jQuery(this, 'li:first').parent().append('' + meanExpand + ''); + } + } }); jQuery('.mean-expand').on("click", function(e) { e.preventDefault(); From 535881c77af9413a4909633d5f77e6ad357ee52e Mon Sep 17 00:00:00 2001 From: Tim Date: Sat, 12 May 2018 11:14:58 +1000 Subject: [PATCH 03/23] Added option to specify expand/collapse link location User should be able to switch between adding the expand/collapse link before or after the child menu. --- jquery.meanmenu.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/jquery.meanmenu.js b/jquery.meanmenu.js index c29a206..865d4fe 100644 --- a/jquery.meanmenu.js +++ b/jquery.meanmenu.js @@ -40,6 +40,7 @@ meanNavPush: "", // set a height here in px, em or % if you want to budge your layout now the navigation is missing. meanShowChildren: true, // true to show children in the menu, false to hide them meanExpandableChildren: true, // true to allow expand/collapse children + meanExpandPosition: "after", // after to insert the expand/collapse link after the child menu meanExpand: "+", // single character you want to represent the expand for ULs meanContract: "-", // single character you want to represent the contract for ULs meanRemoveAttrs: false, // true to remove classes and IDs, false to keep them @@ -66,6 +67,7 @@ var meanRevealClass = ".meanmenu-reveal"; var meanShowChildren = options.meanShowChildren; var meanExpandableChildren = options.meanExpandableChildren; + var meanExpandPosition = options.meanExpandPosition; var meanExpand = options.meanExpand; var meanContract = options.meanContract; var meanRemoveAttrs = options.meanRemoveAttrs; @@ -113,7 +115,7 @@ } // run center function meanCentered(); - + // set all styles for mean-reveal var $navreveal = ""; @@ -184,8 +186,12 @@ if (meanExpandableChildren) { jQuery('.mean-nav ul ul').each(function() { if (jQuery(this).children().length) { - jQuery(this, 'li:first').parent().append('' + meanExpand + ''); - } + if (meanExpandPosition == "before") { + jQuery(this, 'li:first').parent().prepend('' + meanExpand + ''); + } else { + jQuery(this, 'li:first').parent().append('' + meanExpand + ''); + } + } }); jQuery('.mean-expand').on("click", function(e) { e.preventDefault(); From d9af26d679daadb431a28451176459b9538434c2 Mon Sep 17 00:00:00 2001 From: Tim Date: Sat, 12 May 2018 17:45:14 +1000 Subject: [PATCH 04/23] Added 2 new options: meanSpeed and meanExpandPosition Also updated the selection method of child menu expand/collapse links to use CSS direct decendent selectors rather than the original '.parent()' system --- jquery.meanmenu.js | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/jquery.meanmenu.js b/jquery.meanmenu.js index 865d4fe..9a854db 100644 --- a/jquery.meanmenu.js +++ b/jquery.meanmenu.js @@ -43,6 +43,7 @@ meanExpandPosition: "after", // after to insert the expand/collapse link after the child menu meanExpand: "+", // single character you want to represent the expand for ULs meanContract: "-", // single character you want to represent the contract for ULs + meanSpeed: 300, // an integer for the speed in milliseconds of the expand/collapse animations meanRemoveAttrs: false, // true to remove classes and IDs, false to keep them onePage: false, // set to true for one page sites meanDisplay: "block", // override display method for table cell based layouts e.g. table-cell @@ -70,6 +71,7 @@ var meanExpandPosition = options.meanExpandPosition; var meanExpand = options.meanExpand; var meanContract = options.meanContract; + var meanSpeed = options.meanSpeed; var meanRemoveAttrs = options.meanRemoveAttrs; var onePage = options.onePage; var meanDisplay = options.meanDisplay; @@ -115,7 +117,7 @@ } // run center function meanCentered(); - + // set all styles for mean-reveal var $navreveal = ""; @@ -186,21 +188,30 @@ if (meanExpandableChildren) { jQuery('.mean-nav ul ul').each(function() { if (jQuery(this).children().length) { + var expandLink = '' + meanExpand + ''; if (meanExpandPosition == "before") { - jQuery(this, 'li:first').parent().prepend('' + meanExpand + ''); - } else { - jQuery(this, 'li:first').parent().append('' + meanExpand + ''); - } - } + jQuery(this, 'li:first > ul').before(expandLink); + } else { + jQuery(this, 'li:first > ul').after(expandLink); + } + } }); jQuery('.mean-expand').on("click", function(e) { e.preventDefault(); if (jQuery(this).hasClass("mean-clicked")) { jQuery(this).text(meanExpand); - jQuery(this).prev('ul').slideUp(300, function() {}); + if (meanExpandPosition == "before") { + jQuery(this).next('ul').slideUp(meanSpeed, function() {}); + } else { + jQuery(this).prev('ul').slideUp(meanSpeed, function() {}); + } } else { jQuery(this).text(meanContract); - jQuery(this).prev('ul').slideDown(300, function() {}); + if (meanExpandPosition == "before") { + jQuery(this).next('ul').slideDown(meanSpeed, function() {}); + } else { + jQuery(this).prev('ul').slideDown(meanSpeed, function() {}); + } } jQuery(this).toggleClass("mean-clicked"); }); @@ -220,10 +231,10 @@ $navreveal.css("text-align", "center"); $navreveal.css("text-indent", "0"); $navreveal.css("font-size", meanMenuCloseSize); - jQuery('.mean-nav ul:first').slideDown(); + jQuery('.mean-nav ul:first').slideDown(meanSpeed); menuOn = true; } else { - jQuery('.mean-nav ul:first').slideUp(); + jQuery('.mean-nav ul:first').slideUp(meanSpeed); menuOn = false; } $navreveal.toggleClass("meanclose"); From 101f69b0940bcd52815e7b1df913a1336127cb71 Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 14 May 2018 22:05:00 +1000 Subject: [PATCH 05/23] Added new options to readme file --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 98f2b7c..95ca66c 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ meanScreenWidth: "480" meanNavPush: "" -- Set a height here in px, em or % if you want to budge your layout now the navigation is missing. +- Set a height here in px, em or % if you want to budge your layout now the navigation is missing meanShowChildren: true @@ -88,6 +88,14 @@ meanExpand: "+" - single character you want to represent the expand for ULs +meanExpandPostion: "after" + +- Set to either before or after to change where the expand/contract icon is inserted in the list markup. Useful for accessibility tweaks + +meanSpeed: 300 + +- an integer that sets the speed of all animations in milliseconds. 1000 = 1 second + meanContract: "-" - single character you want to represent the contract for ULs From ee9757864bf5bdc859dbe554581c2115bfd479af Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 14 May 2018 22:07:37 +1000 Subject: [PATCH 06/23] Updated compressed version --- jquery.meanmenu.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.meanmenu.min.js b/jquery.meanmenu.min.js index f684a5c..cbfe12a 100644 --- a/jquery.meanmenu.min.js +++ b/jquery.meanmenu.min.js @@ -1 +1 @@ -!function($){"use strict";$.fn.meanmenu=function(e){var n={meanMenuTarget:jQuery(this),meanMenuContainer:"body",meanMenuClose:"X",meanMenuCloseSize:"18px",meanMenuOpen:"",meanRevealPosition:"right",meanRevealPositionDistance:"0",meanRevealColour:"",meanScreenWidth:"480",meanNavPush:"",meanShowChildren:!0,meanExpandableChildren:!0,meanExpand:"+",meanContract:"-",meanRemoveAttrs:!1,onePage:!1,meanDisplay:"block",removeElements:""};e=$.extend(n,e);var a=window.innerWidth||document.documentElement.clientWidth;return this.each(function(){var n=e.meanMenuTarget,t=e.meanMenuContainer,r=e.meanMenuClose,i=e.meanMenuCloseSize,s=e.meanMenuOpen,u=e.meanRevealPosition,m=e.meanRevealPositionDistance,l=e.meanRevealColour,o=e.meanScreenWidth,c=e.meanNavPush,v=".meanmenu-reveal",h=e.meanShowChildren,d=e.meanExpandableChildren,y=e.meanExpand,j=e.meanContract,Q=e.meanRemoveAttrs,f=e.onePage,g=e.meanDisplay,p=e.removeElements,C=!1;(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))&&(C=!0),(navigator.userAgent.match(/MSIE 8/i)||navigator.userAgent.match(/MSIE 7/i))&&jQuery("html").css("overflow-y","scroll");var w="",x=function(){if("center"===u){var e=window.innerWidth||document.documentElement.clientWidth,n=e/2-22+"px";w="left:"+n+";right:auto;",C?jQuery(".meanmenu-reveal").animate({left:n}):jQuery(".meanmenu-reveal").css("left",n)}},A=!1,E=!1;"right"===u&&(w="right:"+m+";left:auto;"),"left"===u&&(w="left:"+m+";right:auto;"),x();var M="",P=function(){M.html(jQuery(M).is(".meanmenu-reveal.meanclose")?r:s)},W=function(){jQuery(".mean-bar,.mean-push").remove(),jQuery(t).removeClass("mean-container"),jQuery(n).css("display",g),A=!1,E=!1,jQuery(p).removeClass("mean-remove")},b=function(){var e="background:"+l+";color:"+l+";"+w;if(o>=a){jQuery(p).addClass("mean-remove"),E=!0,jQuery(t).addClass("mean-container"),jQuery(".mean-container").prepend('');var r=jQuery(n).html();jQuery(".mean-nav").html(r),Q&&jQuery("nav.mean-nav ul, nav.mean-nav ul *").each(function(){jQuery(this).is(".mean-remove")?jQuery(this).attr("class","mean-remove"):jQuery(this).removeAttr("class"),jQuery(this).removeAttr("id")}),jQuery(n).before('
'),jQuery(".mean-push").css("margin-top",c),jQuery(n).hide(),jQuery(".meanmenu-reveal").show(),jQuery(v).html(s),M=jQuery(v),jQuery(".mean-nav ul").hide(),h?d?(jQuery(".mean-nav ul ul").each(function(){jQuery(this).children().length&&jQuery(this,"li:first").parent().append(''+y+"")}),jQuery(".mean-expand").on("click",function(e){e.preventDefault(),jQuery(this).hasClass("mean-clicked")?(jQuery(this).text(y),jQuery(this).prev("ul").slideUp(300,function(){})):(jQuery(this).text(j),jQuery(this).prev("ul").slideDown(300,function(){})),jQuery(this).toggleClass("mean-clicked")})):jQuery(".mean-nav ul ul").show():jQuery(".mean-nav ul ul").hide(),jQuery(".mean-nav ul li").last().addClass("mean-last"),M.removeClass("meanclose"),jQuery(M).click(function(e){e.preventDefault(),A===!1?(M.css("text-align","center"),M.css("text-indent","0"),M.css("font-size",i),jQuery(".mean-nav ul:first").slideDown(),A=!0):(jQuery(".mean-nav ul:first").slideUp(),A=!1),M.toggleClass("meanclose"),P(),jQuery(p).addClass("mean-remove")}),f&&jQuery(".mean-nav ul > li > a:first-child").on("click",function(){jQuery(".mean-nav ul:first").slideUp(),A=!1,jQuery(M).toggleClass("meanclose").html(s)})}else W()};C||jQuery(window).resize(function(){a=window.innerWidth||document.documentElement.clientWidth,a>o,W(),o>=a?(b(),x()):W()}),jQuery(window).resize(function(){a=window.innerWidth||document.documentElement.clientWidth,C?(x(),o>=a?E===!1&&b():W()):(W(),o>=a&&(b(),x()))}),b()})}}(jQuery); \ No newline at end of file +!function(e){"use strict";e.fn.meanmenu=function(n){var a={meanMenuTarget:jQuery(this),meanMenuContainer:"body",meanMenuClose:"X",meanMenuCloseSize:"18px",meanMenuOpen:"",meanRevealPosition:"right",meanRevealPositionDistance:"0",meanRevealColour:"",meanScreenWidth:"480",meanNavPush:"",meanShowChildren:!0,meanExpandableChildren:!0,meanExpandPosition:"after",meanExpand:"+",meanContract:"-",meanRemoveAttrs:!1,onePage:!1,meanDisplay:"block",removeElements:""};n=e.extend(a,n);var t=window.innerWidth||document.documentElement.clientWidth;return this.each(function(){var e=n.meanMenuTarget,a=n.meanMenuContainer,r=n.meanMenuClose,i=n.meanMenuCloseSize,s=n.meanMenuOpen,m=n.meanRevealPosition,u=n.meanRevealPositionDistance,l=n.meanRevealColour,o=n.meanScreenWidth,c=n.meanNavPush,d=".meanmenu-reveal",h=n.meanShowChildren,v=n.meanExpandableChildren,y=n.meanExpandPosition,j=n.meanExpand,Q=n.meanContract,f=n.meanRemoveAttrs,p=n.onePage,g=n.meanDisplay,C=n.removeElements,w=!1;(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))&&(w=!0),(navigator.userAgent.match(/MSIE 8/i)||navigator.userAgent.match(/MSIE 7/i))&&jQuery("html").css("overflow-y","scroll");var x="",E=function(){if("center"===m){var e=(window.innerWidth||document.documentElement.clientWidth)/2-22+"px";x="left:"+e+";right:auto;",w?jQuery(".meanmenu-reveal").animate({left:e}):jQuery(".meanmenu-reveal").css("left",e)}},P=!1,A=!1;"right"===m&&(x="right:"+u+";left:auto;"),"left"===m&&(x="left:"+u+";right:auto;"),E();var M="",W=function(){jQuery(".mean-bar,.mean-push").remove(),jQuery(a).removeClass("mean-container"),jQuery(e).css("display",g),P=!1,A=!1,jQuery(C).removeClass("mean-remove")},b=function(){var n="background:"+l+";color:"+l+";"+x;if(t<=o){jQuery(C).addClass("mean-remove"),A=!0,jQuery(a).addClass("mean-container"),jQuery(".mean-container").prepend('');var m=jQuery(e).html();jQuery(".mean-nav").html(m),f&&jQuery("nav.mean-nav ul, nav.mean-nav ul *").each(function(){jQuery(this).is(".mean-remove")?jQuery(this).attr("class","mean-remove"):jQuery(this).removeAttr("class"),jQuery(this).removeAttr("id")}),jQuery(e).before('
'),jQuery(".mean-push").css("margin-top",c),jQuery(e).hide(),jQuery(".meanmenu-reveal").show(),jQuery(d).html(s),M=jQuery(d),jQuery(".mean-nav ul").hide(),h?v?(jQuery(".mean-nav ul ul").each(function(){jQuery(this).children().length&&("before"==y?jQuery(this,"li:first").parent().prepend(''+j+""):jQuery(this,"li:first").parent().append(''+j+""))}),jQuery(".mean-expand").on("click",function(e){e.preventDefault(),jQuery(this).hasClass("mean-clicked")?(jQuery(this).text(j),jQuery(this).prev("ul").slideUp(300,function(){})):(jQuery(this).text(Q),jQuery(this).prev("ul").slideDown(300,function(){})),jQuery(this).toggleClass("mean-clicked")})):jQuery(".mean-nav ul ul").show():jQuery(".mean-nav ul ul").hide(),jQuery(".mean-nav ul li").last().addClass("mean-last"),M.removeClass("meanclose"),jQuery(M).click(function(e){e.preventDefault(),!1===P?(M.css("text-align","center"),M.css("text-indent","0"),M.css("font-size",i),jQuery(".mean-nav ul:first").slideDown(),P=!0):(jQuery(".mean-nav ul:first").slideUp(),P=!1),M.toggleClass("meanclose"),jQuery(M).is(".meanmenu-reveal.meanclose")?M.html(r):M.html(s),jQuery(C).addClass("mean-remove")}),p&&jQuery(".mean-nav ul > li > a:first-child").on("click",function(){jQuery(".mean-nav ul:first").slideUp(),P=!1,jQuery(M).toggleClass("meanclose").html(s)})}else W()};w||jQuery(window).resize(function(){t=window.innerWidth||document.documentElement.clientWidth,W(),t<=o?(b(),E()):W()}),jQuery(window).resize(function(){t=window.innerWidth||document.documentElement.clientWidth,w?(E(),t<=o?!1===A&&b():W()):(W(),t<=o&&(b(),E()))}),b()})}}(jQuery); From 2b690c371b457598ab3b809e6171853824f74993 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 17 May 2018 15:35:15 +1000 Subject: [PATCH 07/23] Minor formatting fixes, no code changes --- jquery.meanmenu.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/jquery.meanmenu.js b/jquery.meanmenu.js index 865d4fe..f13778b 100644 --- a/jquery.meanmenu.js +++ b/jquery.meanmenu.js @@ -1,5 +1,7 @@ /*! - * jQuery meanMenu v2.0.8 + * jQuery meanMenu v2.0.9 - Forked version (https://github.com/T-Fletcher/meanMenu) + * + * Originally produced by: * @Copyright (C) 2012-2014 Chris Wharton @ MeanThemes (https://github.com/meanthemes/meanMenu) * */ @@ -187,11 +189,11 @@ jQuery('.mean-nav ul ul').each(function() { if (jQuery(this).children().length) { if (meanExpandPosition == "before") { - jQuery(this, 'li:first').parent().prepend('' + meanExpand + ''); - } else { - jQuery(this, 'li:first').parent().append('' + meanExpand + ''); - } - } + jQuery(this, 'li:first').parent().prepend('' + meanExpand + ''); + } else { + jQuery(this, 'li:first').parent().append('' + meanExpand + ''); + } + } }); jQuery('.mean-expand').on("click", function(e) { e.preventDefault(); From 9ff1b5cd365849e02a24415098d7b3e84cb625f8 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 17 May 2018 15:42:20 +1000 Subject: [PATCH 08/23] Updated compressed version From 6e93adcaddc27c5e67e8a26fe60023e9988ce81c Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 17 May 2018 15:52:58 +1000 Subject: [PATCH 09/23] 2.0.9 - Updated with changes and explanation --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 95ca66c..a5f8fea 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,17 @@ -MeanMenu v2.0.8 +MeanMenu v2.0.9 =========== +**This repo (https://github.com/T-Fletcher/meanMenu/) is a tweaked version, originally forked from MeanTheme's MeanMenu JS library (https://github.com/meanthemes/meanMenu)** + +## Changes +- Added a `meanExpandPosition` option to specify if the expand/contract link appears before or after the target child menu +- Added a `meanSpeed` option to specify animation speed in milliseconds +- Updated the selector for targeting child menus + +Note that I haven't updated the demo page or checked the styles, as this is just to cater for my specific project at this stage. I'll try to get to that later, or you can give it a go ;) + +Ok, back to the original README now... + +----- Looking for a WordPress version? --- From 0392bc2f998edc182f1fa901d99b89f61a835b42 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 17 May 2018 16:11:42 +1000 Subject: [PATCH 10/23] 2.0.9 From ad39f17d73bba836238d4e30fa10a30141966e4a Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 17 May 2018 21:17:50 +1000 Subject: [PATCH 11/23] Corrected bad merge --- jquery.meanmenu.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/jquery.meanmenu.js b/jquery.meanmenu.js index 9ba6771..fef5b8e 100644 --- a/jquery.meanmenu.js +++ b/jquery.meanmenu.js @@ -190,12 +190,6 @@ if (meanExpandableChildren) { jQuery('.mean-nav ul ul').each(function() { if (jQuery(this).children().length) { - if (meanExpandPosition == "before") { - jQuery(this, 'li:first').parent().prepend('' + meanExpand + ''); - } else { - jQuery(this, 'li:first').parent().append('' + meanExpand + ''); - } - } var expandLink = '' + meanExpand + ''; From a6f9a5cee24e6943fb95639f0c4c3266c794bc0d Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 17 May 2018 21:19:18 +1000 Subject: [PATCH 12/23] 2.0.10 Tweaked option description --- jquery.meanmenu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.meanmenu.js b/jquery.meanmenu.js index fef5b8e..96b5b2d 100644 --- a/jquery.meanmenu.js +++ b/jquery.meanmenu.js @@ -30,7 +30,7 @@ "use strict"; $.fn.meanmenu = function(options) { var defaults = { - meanMenuTarget: jQuery(this), // Target the current HTML markup you wish to replace + meanMenuTarget: jQuery(this), // Target the current HTML list wrapper you wish to replace meanMenuContainer: 'body', // Choose where meanmenu will be placed within the HTML meanMenuClose: "X", // single character you want to represent the close menu button meanMenuCloseSize: "18px", // set font size of close button From 53dd313b60c0d78ab0761066d0d33aeed1e3ccb2 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 17 May 2018 21:19:46 +1000 Subject: [PATCH 13/23] 2.0.10 --- jquery.meanmenu.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.meanmenu.min.js b/jquery.meanmenu.min.js index cbfe12a..7e7435e 100644 --- a/jquery.meanmenu.min.js +++ b/jquery.meanmenu.min.js @@ -1 +1 @@ -!function(e){"use strict";e.fn.meanmenu=function(n){var a={meanMenuTarget:jQuery(this),meanMenuContainer:"body",meanMenuClose:"X",meanMenuCloseSize:"18px",meanMenuOpen:"",meanRevealPosition:"right",meanRevealPositionDistance:"0",meanRevealColour:"",meanScreenWidth:"480",meanNavPush:"",meanShowChildren:!0,meanExpandableChildren:!0,meanExpandPosition:"after",meanExpand:"+",meanContract:"-",meanRemoveAttrs:!1,onePage:!1,meanDisplay:"block",removeElements:""};n=e.extend(a,n);var t=window.innerWidth||document.documentElement.clientWidth;return this.each(function(){var e=n.meanMenuTarget,a=n.meanMenuContainer,r=n.meanMenuClose,i=n.meanMenuCloseSize,s=n.meanMenuOpen,m=n.meanRevealPosition,u=n.meanRevealPositionDistance,l=n.meanRevealColour,o=n.meanScreenWidth,c=n.meanNavPush,d=".meanmenu-reveal",h=n.meanShowChildren,v=n.meanExpandableChildren,y=n.meanExpandPosition,j=n.meanExpand,Q=n.meanContract,f=n.meanRemoveAttrs,p=n.onePage,g=n.meanDisplay,C=n.removeElements,w=!1;(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))&&(w=!0),(navigator.userAgent.match(/MSIE 8/i)||navigator.userAgent.match(/MSIE 7/i))&&jQuery("html").css("overflow-y","scroll");var x="",E=function(){if("center"===m){var e=(window.innerWidth||document.documentElement.clientWidth)/2-22+"px";x="left:"+e+";right:auto;",w?jQuery(".meanmenu-reveal").animate({left:e}):jQuery(".meanmenu-reveal").css("left",e)}},P=!1,A=!1;"right"===m&&(x="right:"+u+";left:auto;"),"left"===m&&(x="left:"+u+";right:auto;"),E();var M="",W=function(){jQuery(".mean-bar,.mean-push").remove(),jQuery(a).removeClass("mean-container"),jQuery(e).css("display",g),P=!1,A=!1,jQuery(C).removeClass("mean-remove")},b=function(){var n="background:"+l+";color:"+l+";"+x;if(t<=o){jQuery(C).addClass("mean-remove"),A=!0,jQuery(a).addClass("mean-container"),jQuery(".mean-container").prepend('');var m=jQuery(e).html();jQuery(".mean-nav").html(m),f&&jQuery("nav.mean-nav ul, nav.mean-nav ul *").each(function(){jQuery(this).is(".mean-remove")?jQuery(this).attr("class","mean-remove"):jQuery(this).removeAttr("class"),jQuery(this).removeAttr("id")}),jQuery(e).before('
'),jQuery(".mean-push").css("margin-top",c),jQuery(e).hide(),jQuery(".meanmenu-reveal").show(),jQuery(d).html(s),M=jQuery(d),jQuery(".mean-nav ul").hide(),h?v?(jQuery(".mean-nav ul ul").each(function(){jQuery(this).children().length&&("before"==y?jQuery(this,"li:first").parent().prepend(''+j+""):jQuery(this,"li:first").parent().append(''+j+""))}),jQuery(".mean-expand").on("click",function(e){e.preventDefault(),jQuery(this).hasClass("mean-clicked")?(jQuery(this).text(j),jQuery(this).prev("ul").slideUp(300,function(){})):(jQuery(this).text(Q),jQuery(this).prev("ul").slideDown(300,function(){})),jQuery(this).toggleClass("mean-clicked")})):jQuery(".mean-nav ul ul").show():jQuery(".mean-nav ul ul").hide(),jQuery(".mean-nav ul li").last().addClass("mean-last"),M.removeClass("meanclose"),jQuery(M).click(function(e){e.preventDefault(),!1===P?(M.css("text-align","center"),M.css("text-indent","0"),M.css("font-size",i),jQuery(".mean-nav ul:first").slideDown(),P=!0):(jQuery(".mean-nav ul:first").slideUp(),P=!1),M.toggleClass("meanclose"),jQuery(M).is(".meanmenu-reveal.meanclose")?M.html(r):M.html(s),jQuery(C).addClass("mean-remove")}),p&&jQuery(".mean-nav ul > li > a:first-child").on("click",function(){jQuery(".mean-nav ul:first").slideUp(),P=!1,jQuery(M).toggleClass("meanclose").html(s)})}else W()};w||jQuery(window).resize(function(){t=window.innerWidth||document.documentElement.clientWidth,W(),t<=o?(b(),E()):W()}),jQuery(window).resize(function(){t=window.innerWidth||document.documentElement.clientWidth,w?(E(),t<=o?!1===A&&b():W()):(W(),t<=o&&(b(),E()))}),b()})}}(jQuery); +!function(e){"use strict";e.fn.meanmenu=function(n){var a={meanMenuTarget:jQuery(this),meanMenuContainer:"body",meanMenuClose:"X",meanMenuCloseSize:"18px",meanMenuOpen:"",meanRevealPosition:"right",meanRevealPositionDistance:"0",meanRevealColour:"",meanScreenWidth:"480",meanNavPush:"",meanShowChildren:!0,meanExpandableChildren:!0,meanExpandPosition:"after",meanExpand:"+",meanContract:"-",meanSpeed:300,meanRemoveAttrs:!1,onePage:!1,meanDisplay:"block",removeElements:""};n=e.extend(a,n);var t=window.innerWidth||document.documentElement.clientWidth;return this.each(function(){var e=n.meanMenuTarget,a=n.meanMenuContainer,r=n.meanMenuClose,i=n.meanMenuCloseSize,s=n.meanMenuOpen,u=n.meanRevealPosition,m=n.meanRevealPositionDistance,l=n.meanRevealColour,o=n.meanScreenWidth,c=n.meanNavPush,d=".meanmenu-reveal",h=n.meanShowChildren,v=n.meanExpandableChildren,y=n.meanExpandPosition,j=n.meanExpand,Q=n.meanContract,f=n.meanSpeed,g=n.meanRemoveAttrs,p=n.onePage,C=n.meanDisplay,w=n.removeElements,x=!1;(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))&&(x=!0),(navigator.userAgent.match(/MSIE 8/i)||navigator.userAgent.match(/MSIE 7/i))&&jQuery("html").css("overflow-y","scroll");var E="",P=function(){if("center"===u){var e=(window.innerWidth||document.documentElement.clientWidth)/2-22+"px";E="left:"+e+";right:auto;",x?jQuery(".meanmenu-reveal").animate({left:e}):jQuery(".meanmenu-reveal").css("left",e)}},b=!1,A=!1;"right"===u&&(E="right:"+m+";left:auto;"),"left"===u&&(E="left:"+m+";right:auto;"),P();var M="",S=function(){jQuery(".mean-bar,.mean-push").remove(),jQuery(a).removeClass("mean-container"),jQuery(e).css("display",C),b=!1,A=!1,jQuery(w).removeClass("mean-remove")},W=function(){var n="background:"+l+";color:"+l+";"+E;if(t<=o){jQuery(w).addClass("mean-remove"),A=!0,jQuery(a).addClass("mean-container"),jQuery(".mean-container").prepend('');var u=jQuery(e).html();jQuery(".mean-nav").html(u),g&&jQuery("nav.mean-nav ul, nav.mean-nav ul *").each(function(){jQuery(this).is(".mean-remove")?jQuery(this).attr("class","mean-remove"):jQuery(this).removeAttr("class"),jQuery(this).removeAttr("id")}),jQuery(e).before('
'),jQuery(".mean-push").css("margin-top",c),jQuery(e).hide(),jQuery(".meanmenu-reveal").show(),jQuery(d).html(s),M=jQuery(d),jQuery(".mean-nav ul").hide(),h?v?(jQuery(".mean-nav ul ul").each(function(){if(jQuery(this).children().length){var e=''+j+"";"before"==y?jQuery(this,"li:first > ul").before(e):jQuery(this,"li:first > ul").after(e)}}),jQuery(".mean-expand").on("click",function(e){e.preventDefault(),jQuery(this).hasClass("mean-clicked")?(jQuery(this).text(j),"before"==y?jQuery(this).next("ul").slideUp(f,function(){}):jQuery(this).prev("ul").slideUp(f,function(){})):(jQuery(this).text(Q),"before"==y?jQuery(this).next("ul").slideDown(f,function(){}):jQuery(this).prev("ul").slideDown(f,function(){})),jQuery(this).toggleClass("mean-clicked")})):jQuery(".mean-nav ul ul").show():jQuery(".mean-nav ul ul").hide(),jQuery(".mean-nav ul li").last().addClass("mean-last"),M.removeClass("meanclose"),jQuery(M).click(function(e){e.preventDefault(),!1===b?(M.css("text-align","center"),M.css("text-indent","0"),M.css("font-size",i),jQuery(".mean-nav ul:first").slideDown(f),b=!0):(jQuery(".mean-nav ul:first").slideUp(f),b=!1),M.toggleClass("meanclose"),jQuery(M).is(".meanmenu-reveal.meanclose")?M.html(r):M.html(s),jQuery(w).addClass("mean-remove")}),p&&jQuery(".mean-nav ul > li > a:first-child").on("click",function(){jQuery(".mean-nav ul:first").slideUp(),b=!1,jQuery(M).toggleClass("meanclose").html(s)})}else S()};x||jQuery(window).resize(function(){t=window.innerWidth||document.documentElement.clientWidth,S(),t<=o?(W(),P()):S()}),jQuery(window).resize(function(){t=window.innerWidth||document.documentElement.clientWidth,x?(P(),t<=o?!1===A&&W():S()):(S(),t<=o&&(W(),P()))}),W()})}}(jQuery); From bf491a6be61330a22ea038841b98ec4440a8fb1a Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 17 May 2018 21:20:20 +1000 Subject: [PATCH 14/23] 2.0.10 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a5f8fea..6d46ead 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -MeanMenu v2.0.9 +MeanMenu v2.0.10 =========== **This repo (https://github.com/T-Fletcher/meanMenu/) is a tweaked version, originally forked from MeanTheme's MeanMenu JS library (https://github.com/meanthemes/meanMenu)** From 4a4a6955096077026396b9027193c8f081dfc0fd Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 17 May 2018 21:24:00 +1000 Subject: [PATCH 15/23] 2.0.10 - includes demo of new features --- demo.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/demo.html b/demo.html index 369ddd0..b7a24f6 100644 --- a/demo.html +++ b/demo.html @@ -124,7 +124,10 @@

Check out our WordPress & From 8354b76d80b1c9eff42795b02b2f69d86d73926e Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 17 May 2018 21:27:40 +1000 Subject: [PATCH 16/23] 2.0.10 Removed reference to incomplete work that was actually completed in this version --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 6d46ead..97548e4 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,6 @@ MeanMenu v2.0.10 - Added a `meanSpeed` option to specify animation speed in milliseconds - Updated the selector for targeting child menus -Note that I haven't updated the demo page or checked the styles, as this is just to cater for my specific project at this stage. I'll try to get to that later, or you can give it a go ;) - Ok, back to the original README now... ----- From c6a15b3fc7ad45f0d0d15c4a77230968ba2dba99 Mon Sep 17 00:00:00 2001 From: Tim Date: Wed, 30 May 2018 22:04:44 +1000 Subject: [PATCH 17/23] 2.0.11 Added 'meanAria' option to include 'aria-expanded', 'aria-label' and 'role' on expand links for screenreaders --- jquery.meanmenu.js | 505 +++++++++++++++++++++++---------------------- 1 file changed, 259 insertions(+), 246 deletions(-) diff --git a/jquery.meanmenu.js b/jquery.meanmenu.js index 96b5b2d..04dc17a 100644 --- a/jquery.meanmenu.js +++ b/jquery.meanmenu.js @@ -1,5 +1,5 @@ /*! - * jQuery meanMenu v2.0.9 - Forked version (https://github.com/T-Fletcher/meanMenu) + * jQuery meanMenu v2.0.11 - Forked version (https://github.com/T-Fletcher/meanMenu) * * Originally produced by: * @Copyright (C) 2012-2014 Chris Wharton @ MeanThemes (https://github.com/meanthemes/meanMenu) @@ -27,280 +27,293 @@ * */ (function($) { - "use strict"; - $.fn.meanmenu = function(options) { - var defaults = { - meanMenuTarget: jQuery(this), // Target the current HTML list wrapper you wish to replace - meanMenuContainer: 'body', // Choose where meanmenu will be placed within the HTML - meanMenuClose: "X", // single character you want to represent the close menu button - meanMenuCloseSize: "18px", // set font size of close button - meanMenuOpen: "", // text/markup you want when menu is closed - meanRevealPosition: "right", // left right or center positions - meanRevealPositionDistance: "0", // Tweak the position of the menu - meanRevealColour: "", // override CSS colours for the reveal background - meanScreenWidth: "480", // set the screen width you want meanmenu to kick in at - meanNavPush: "", // set a height here in px, em or % if you want to budge your layout now the navigation is missing. - meanShowChildren: true, // true to show children in the menu, false to hide them - meanExpandableChildren: true, // true to allow expand/collapse children - meanExpandPosition: "after", // after to insert the expand/collapse link after the child menu - meanExpand: "+", // single character you want to represent the expand for ULs - meanContract: "-", // single character you want to represent the contract for ULs - meanSpeed: 300, // an integer for the speed in milliseconds of the expand/collapse animations - meanRemoveAttrs: false, // true to remove classes and IDs, false to keep them - onePage: false, // set to true for one page sites - meanDisplay: "block", // override display method for table cell based layouts e.g. table-cell - removeElements: "" // set to hide page elements - }; - options = $.extend(defaults, options); + "use strict"; + $.fn.meanmenu = function(options) { + var defaults = { + meanMenuTarget: jQuery(this), // Target the current HTML list wrapper you wish to replace + meanMenuContainer: 'body', // Choose where meanmenu will be placed within the HTML + meanMenuClose: "X", // single character you want to represent the close menu button + meanMenuCloseSize: "18px", // set font size of close button + meanMenuOpen: "", // text/markup you want when menu is closed + meanRevealPosition: "right", // left right or center positions + meanRevealPositionDistance: "0", // Tweak the position of the menu + meanRevealColour: "", // override CSS colours for the reveal background + meanScreenWidth: "480", // set the screen width you want meanmenu to kick in at + meanNavPush: "", // set a height here in px, em or % if you want to budge your layout now the navigation is missing. + meanShowChildren: true, // true to show children in the menu, false to hide them + meanExpandableChildren: true, // true to allow expand/collapse children + meanExpandPosition: "after", // after to insert the expand/collapse link after the child menu + meanExpand: "+", // single character you want to represent the expand for ULs + meanContract: "-", // single character you want to represent the contract for ULs + meanSpeed: 300, // an integer for the speed in milliseconds of the expand/collapse animations + meanAria: true, // true to enable 'aria-expanded', 'aria-label' and 'role' attributes on expand links, false to leave them out + meanRemoveAttrs: false, // true to remove classes and IDs, false to keep them + onePage: false, // set to true for one page sites + meanDisplay: "block", // override display method for table cell based layouts e.g. table-cell + removeElements: "" // set to hide page elements + }; + options = $.extend(defaults, options); - // get browser width - var currentWidth = window.innerWidth || document.documentElement.clientWidth; + // get browser width + var currentWidth = window.innerWidth || document.documentElement.clientWidth; - return this.each(function() { - var meanMenu = options.meanMenuTarget; - var meanContainer = options.meanMenuContainer; - var meanMenuClose = options.meanMenuClose; - var meanMenuCloseSize = options.meanMenuCloseSize; - var meanMenuOpen = options.meanMenuOpen; - var meanRevealPosition = options.meanRevealPosition; - var meanRevealPositionDistance = options.meanRevealPositionDistance; - var meanRevealColour = options.meanRevealColour; - var meanScreenWidth = options.meanScreenWidth; - var meanNavPush = options.meanNavPush; - var meanRevealClass = ".meanmenu-reveal"; - var meanShowChildren = options.meanShowChildren; - var meanExpandableChildren = options.meanExpandableChildren; - var meanExpandPosition = options.meanExpandPosition; - var meanExpand = options.meanExpand; - var meanContract = options.meanContract; - var meanSpeed = options.meanSpeed; - var meanRemoveAttrs = options.meanRemoveAttrs; - var onePage = options.onePage; - var meanDisplay = options.meanDisplay; - var removeElements = options.removeElements; + return this.each(function() { + var meanMenu = options.meanMenuTarget; + var meanContainer = options.meanMenuContainer; + var meanMenuClose = options.meanMenuClose; + var meanMenuCloseSize = options.meanMenuCloseSize; + var meanMenuOpen = options.meanMenuOpen; + var meanRevealPosition = options.meanRevealPosition; + var meanRevealPositionDistance = options.meanRevealPositionDistance; + var meanRevealColour = options.meanRevealColour; + var meanScreenWidth = options.meanScreenWidth; + var meanNavPush = options.meanNavPush; + var meanRevealClass = ".meanmenu-reveal"; + var meanShowChildren = options.meanShowChildren; + var meanExpandableChildren = options.meanExpandableChildren; + var meanExpandPosition = options.meanExpandPosition; + var meanExpand = options.meanExpand; + var meanContract = options.meanContract; + var meanSpeed = options.meanSpeed; + var meanAria = options.meanAria; + var meanRemoveAttrs = options.meanRemoveAttrs; + var onePage = options.onePage; + var meanDisplay = options.meanDisplay; + var removeElements = options.removeElements; - //detect known mobile/tablet usage - var isMobile = false; - 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))) { - isMobile = true; - } + //detect known mobile/tablet usage + var isMobile = false; + 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))) { + isMobile = true; + } - if ((navigator.userAgent.match(/MSIE 8/i)) || (navigator.userAgent.match(/MSIE 7/i))) { - // add scrollbar for IE7 & 8 to stop breaking resize function on small content sites - jQuery('html').css("overflow-y", "scroll"); - } + if ((navigator.userAgent.match(/MSIE 8/i)) || (navigator.userAgent.match(/MSIE 7/i))) { + // add scrollbar for IE7 & 8 to stop breaking resize function on small content sites + jQuery('html').css("overflow-y", "scroll"); + } - var meanRevealPos = ""; - var meanCentered = function() { - if (meanRevealPosition === "center") { - var newWidth = window.innerWidth || document.documentElement.clientWidth; - var meanCenter = ((newWidth / 2) - 22) + "px"; - meanRevealPos = "left:" + meanCenter + ";right:auto;"; + var meanRevealPos = ""; + var meanCentered = function() { + if (meanRevealPosition === "center") { + var newWidth = window.innerWidth || document.documentElement.clientWidth; + var meanCenter = ((newWidth / 2) - 22) + "px"; + meanRevealPos = "left:" + meanCenter + ";right:auto;"; - if (!isMobile) { - jQuery('.meanmenu-reveal').css("left", meanCenter); - } else { - jQuery('.meanmenu-reveal').animate({ - left: meanCenter - }); - } - } - }; + if (!isMobile) { + jQuery('.meanmenu-reveal').css("left", meanCenter); + } else { + jQuery('.meanmenu-reveal').animate({ + left: meanCenter + }); + } + } + }; - var menuOn = false; - var meanMenuExist = false; + var menuOn = false; + var meanMenuExist = false; - if (meanRevealPosition === "right") { - meanRevealPos = "right:" + meanRevealPositionDistance + ";left:auto;"; - } - if (meanRevealPosition === "left") { - meanRevealPos = "left:" + meanRevealPositionDistance + ";right:auto;"; - } - // run center function - meanCentered(); - - // set all styles for mean-reveal - var $navreveal = ""; + if (meanRevealPosition === "right") { + meanRevealPos = "right:" + meanRevealPositionDistance + ";left:auto;"; + } + if (meanRevealPosition === "left") { + meanRevealPos = "left:" + meanRevealPositionDistance + ";right:auto;"; + } + // run center function + meanCentered(); - var meanInner = function() { - // get last class name - if (jQuery($navreveal).is(".meanmenu-reveal.meanclose")) { - $navreveal.html(meanMenuClose); - } else { - $navreveal.html(meanMenuOpen); - } - }; + // set all styles for mean-reveal + var $navreveal = ""; - // re-instate original nav (and call this on window.width functions) - var meanOriginal = function() { - jQuery('.mean-bar,.mean-push').remove(); - jQuery(meanContainer).removeClass("mean-container"); - jQuery(meanMenu).css('display', meanDisplay); - menuOn = false; - meanMenuExist = false; - jQuery(removeElements).removeClass('mean-remove'); - }; + var meanInner = function() { + // get last class name + if (jQuery($navreveal).is(".meanmenu-reveal.meanclose")) { + $navreveal.html(meanMenuClose); + } else { + $navreveal.html(meanMenuOpen); + } + }; - // navigation reveal - var showMeanMenu = function() { - var meanStyles = "background:" + meanRevealColour + ";color:" + meanRevealColour + ";" + meanRevealPos; - if (currentWidth <= meanScreenWidth) { - jQuery(removeElements).addClass('mean-remove'); - meanMenuExist = true; - // add class to body so we don't need to worry about media queries here, all CSS is wrapped in '.mean-container' - jQuery(meanContainer).addClass("mean-container"); - jQuery('.mean-container').prepend(''); + // re-instate original nav (and call this on window.width functions) + var meanOriginal = function() { + jQuery('.mean-bar,.mean-push').remove(); + jQuery(meanContainer).removeClass("mean-container"); + jQuery(meanMenu).css('display', meanDisplay); + menuOn = false; + meanMenuExist = false; + jQuery(removeElements).removeClass('mean-remove'); + }; - //push meanMenu navigation into .mean-nav - var meanMenuContents = jQuery(meanMenu).html(); - jQuery('.mean-nav').html(meanMenuContents); + // navigation reveal + var showMeanMenu = function() { + var meanStyles = "background:" + meanRevealColour + ";color:" + meanRevealColour + ";" + meanRevealPos; + if (currentWidth <= meanScreenWidth) { + jQuery(removeElements).addClass('mean-remove'); + meanMenuExist = true; + // add class to body so we don't need to worry about media queries here, all CSS is wrapped in '.mean-container' + jQuery(meanContainer).addClass("mean-container"); + jQuery('.mean-container').prepend(''); - // remove all classes from EVERYTHING inside meanmenu nav - if (meanRemoveAttrs) { - jQuery('nav.mean-nav ul, nav.mean-nav ul *').each(function() { - // First check if this has mean-remove class - if (jQuery(this).is('.mean-remove')) { - jQuery(this).attr('class', 'mean-remove'); - } else { - jQuery(this).removeAttr("class"); - } - jQuery(this).removeAttr("id"); - }); - } + //push meanMenu navigation into .mean-nav + var meanMenuContents = jQuery(meanMenu).html(); + jQuery('.mean-nav').html(meanMenuContents); - // push in a holder div (this can be used if removal of nav is causing layout issues) - jQuery(meanMenu).before('
'); - jQuery('.mean-push').css("margin-top", meanNavPush); + // remove all classes from EVERYTHING inside meanmenu nav + if (meanRemoveAttrs) { + jQuery('nav.mean-nav ul, nav.mean-nav ul *').each(function() { + // First check if this has mean-remove class + if (jQuery(this).is('.mean-remove')) { + jQuery(this).attr('class', 'mean-remove'); + } else { + jQuery(this).removeAttr("class"); + } + jQuery(this).removeAttr("id"); + }); + } - // hide current navigation and reveal mean nav link - jQuery(meanMenu).hide(); - jQuery(".meanmenu-reveal").show(); + // push in a holder div (this can be used if removal of nav is causing layout issues) + jQuery(meanMenu).before('
'); + jQuery('.mean-push').css("margin-top", meanNavPush); - // turn 'X' on or off - jQuery(meanRevealClass).html(meanMenuOpen); - $navreveal = jQuery(meanRevealClass); + // hide current navigation and reveal mean nav link + jQuery(meanMenu).hide(); + jQuery(".meanmenu-reveal").show(); - //hide mean-nav ul - jQuery('.mean-nav ul').hide(); + // turn 'X' on or off + jQuery(meanRevealClass).html(meanMenuOpen); + $navreveal = jQuery(meanRevealClass); - // hide sub nav - if (meanShowChildren) { - // allow expandable sub nav(s) - if (meanExpandableChildren) { - jQuery('.mean-nav ul ul').each(function() { - if (jQuery(this).children().length) { + //hide mean-nav ul + jQuery('.mean-nav ul').hide(); - var expandLink = '' + meanExpand + ''; - - if (meanExpandPosition == "before") { - jQuery(this, 'li:first > ul').before(expandLink); - } else { - jQuery(this, 'li:first > ul').after(expandLink); - } - } - }); - jQuery('.mean-expand').on("click", function(e) { - e.preventDefault(); - if (jQuery(this).hasClass("mean-clicked")) { - jQuery(this).text(meanExpand); - if (meanExpandPosition == "before") { - jQuery(this).next('ul').slideUp(meanSpeed, function() {}); - } else { - jQuery(this).prev('ul').slideUp(meanSpeed, function() {}); - } - } else { - jQuery(this).text(meanContract); - if (meanExpandPosition == "before") { - jQuery(this).next('ul').slideDown(meanSpeed, function() {}); - } else { - jQuery(this).prev('ul').slideDown(meanSpeed, function() {}); - } - } - jQuery(this).toggleClass("mean-clicked"); - }); - } else { - jQuery('.mean-nav ul ul').show(); - } - } else { - jQuery('.mean-nav ul ul').hide(); - } + // hide sub nav + if (meanShowChildren) { + // allow expandable sub nav(s) + if (meanExpandableChildren) { + jQuery('.mean-nav ul ul').each(function() { + if (jQuery(this).children().length) { - // add last class to tidy up borders - jQuery('.mean-nav ul li').last().addClass('mean-last'); - $navreveal.removeClass("meanclose"); - jQuery($navreveal).click(function(e) { - e.preventDefault(); - if (menuOn === false) { - $navreveal.css("text-align", "center"); - $navreveal.css("text-indent", "0"); - $navreveal.css("font-size", meanMenuCloseSize); - jQuery('.mean-nav ul:first').slideDown(meanSpeed); - menuOn = true; - } else { - jQuery('.mean-nav ul:first').slideUp(meanSpeed); - menuOn = false; - } - $navreveal.toggleClass("meanclose"); - meanInner(); - jQuery(removeElements).addClass('mean-remove'); - }); + if (meanAria == true) { + var expandLinkLabel = jQuery(this, 'li:first > ul').prev('a').text(), + expandLink = ''; + } else { + var expandLink = '' + meanExpand + ''; + } - // for one page websites, reset all variables... - if (onePage) { - jQuery('.mean-nav ul > li > a:first-child').on("click", function() { - jQuery('.mean-nav ul:first').slideUp(); - menuOn = false; - jQuery($navreveal).toggleClass("meanclose").html(meanMenuOpen); - }); - } + if (meanExpandPosition == "before") { + jQuery(this, 'li:first > ul').before(expandLink); + } else { + jQuery(this, 'li:first > ul').after(expandLink); + } + } + }); + jQuery('.mean-expand').on("click", function(e) { + e.preventDefault(); + if (jQuery(this).hasClass("mean-clicked")) { + jQuery(this).text(meanExpand); + if (meanAria == true) { + jQuery(this).attr('aria-expanded', 'false'); + } + if (meanExpandPosition == "before") { + jQuery(this).next('ul').slideUp(meanSpeed, function() {}); + } else { + jQuery(this).prev('ul').slideUp(meanSpeed, function() {}); + } } else { - meanOriginal(); + jQuery(this).text(meanContract); + if (meanAria == true) { + jQuery(this).attr('aria-expanded', 'true') + } + if (meanExpandPosition == "before") { + jQuery(this).next('ul').slideDown(meanSpeed, function() {}); + } else { + jQuery(this).prev('ul').slideDown(meanSpeed, function() {}); + } } - }; - - if (!isMobile) { - // reset menu on resize above meanScreenWidth - jQuery(window).resize(function() { - currentWidth = window.innerWidth || document.documentElement.clientWidth; - if (currentWidth > meanScreenWidth) { - meanOriginal(); - } else { - meanOriginal(); - } - if (currentWidth <= meanScreenWidth) { - showMeanMenu(); - meanCentered(); - } else { - meanOriginal(); - } - }); + jQuery(this).toggleClass("mean-clicked"); + }); + } else { + jQuery('.mean-nav ul ul').show(); } + } else { + jQuery('.mean-nav ul ul').hide(); + } - jQuery(window).resize(function() { - // get browser width - currentWidth = window.innerWidth || document.documentElement.clientWidth; + // add last class to tidy up borders + jQuery('.mean-nav ul li').last().addClass('mean-last'); + $navreveal.removeClass("meanclose"); + jQuery($navreveal).click(function(e) { + e.preventDefault(); + if (menuOn === false) { + $navreveal.css("text-align", "center"); + $navreveal.css("text-indent", "0"); + $navreveal.css("font-size", meanMenuCloseSize); + jQuery('.mean-nav ul:first').slideDown(meanSpeed); + menuOn = true; + } else { + jQuery('.mean-nav ul:first').slideUp(meanSpeed); + menuOn = false; + } + $navreveal.toggleClass("meanclose"); + meanInner(); + jQuery(removeElements).addClass('mean-remove'); + }); - if (!isMobile) { - meanOriginal(); - if (currentWidth <= meanScreenWidth) { - showMeanMenu(); - meanCentered(); - } - } else { - meanCentered(); - if (currentWidth <= meanScreenWidth) { - if (meanMenuExist === false) { - showMeanMenu(); - } - } else { - meanOriginal(); - } - } + // for one page websites, reset all variables... + if (onePage) { + jQuery('.mean-nav ul > li > a:first-child').on("click", function() { + jQuery('.mean-nav ul:first').slideUp(); + menuOn = false; + jQuery($navreveal).toggleClass("meanclose").html(meanMenuOpen); }); + } + } else { + meanOriginal(); + } + }; - // run main menuMenu function on load + if (!isMobile) { + // reset menu on resize above meanScreenWidth + jQuery(window).resize(function() { + currentWidth = window.innerWidth || document.documentElement.clientWidth; + if (currentWidth > meanScreenWidth) { + meanOriginal(); + } else { + meanOriginal(); + } + if (currentWidth <= meanScreenWidth) { showMeanMenu(); + meanCentered(); + } else { + meanOriginal(); + } }); - }; + } + + jQuery(window).resize(function() { + // get browser width + currentWidth = window.innerWidth || document.documentElement.clientWidth; + + if (!isMobile) { + meanOriginal(); + if (currentWidth <= meanScreenWidth) { + showMeanMenu(); + meanCentered(); + } + } else { + meanCentered(); + if (currentWidth <= meanScreenWidth) { + if (meanMenuExist === false) { + showMeanMenu(); + } + } else { + meanOriginal(); + } + } + }); + + // run main menuMenu function on load + showMeanMenu(); + }); + }; })(jQuery); From 10345e5a8bdbc1070c7a33ad8e787ed54dc2969b Mon Sep 17 00:00:00 2001 From: Tim Date: Wed, 30 May 2018 22:06:23 +1000 Subject: [PATCH 18/23] 2.0.11 --- jquery.meanmenu.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.meanmenu.min.js b/jquery.meanmenu.min.js index 7e7435e..b1b1acd 100644 --- a/jquery.meanmenu.min.js +++ b/jquery.meanmenu.min.js @@ -1 +1 @@ -!function(e){"use strict";e.fn.meanmenu=function(n){var a={meanMenuTarget:jQuery(this),meanMenuContainer:"body",meanMenuClose:"X",meanMenuCloseSize:"18px",meanMenuOpen:"",meanRevealPosition:"right",meanRevealPositionDistance:"0",meanRevealColour:"",meanScreenWidth:"480",meanNavPush:"",meanShowChildren:!0,meanExpandableChildren:!0,meanExpandPosition:"after",meanExpand:"+",meanContract:"-",meanSpeed:300,meanRemoveAttrs:!1,onePage:!1,meanDisplay:"block",removeElements:""};n=e.extend(a,n);var t=window.innerWidth||document.documentElement.clientWidth;return this.each(function(){var e=n.meanMenuTarget,a=n.meanMenuContainer,r=n.meanMenuClose,i=n.meanMenuCloseSize,s=n.meanMenuOpen,u=n.meanRevealPosition,m=n.meanRevealPositionDistance,l=n.meanRevealColour,o=n.meanScreenWidth,c=n.meanNavPush,d=".meanmenu-reveal",h=n.meanShowChildren,v=n.meanExpandableChildren,y=n.meanExpandPosition,j=n.meanExpand,Q=n.meanContract,f=n.meanSpeed,g=n.meanRemoveAttrs,p=n.onePage,C=n.meanDisplay,w=n.removeElements,x=!1;(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))&&(x=!0),(navigator.userAgent.match(/MSIE 8/i)||navigator.userAgent.match(/MSIE 7/i))&&jQuery("html").css("overflow-y","scroll");var E="",P=function(){if("center"===u){var e=(window.innerWidth||document.documentElement.clientWidth)/2-22+"px";E="left:"+e+";right:auto;",x?jQuery(".meanmenu-reveal").animate({left:e}):jQuery(".meanmenu-reveal").css("left",e)}},b=!1,A=!1;"right"===u&&(E="right:"+m+";left:auto;"),"left"===u&&(E="left:"+m+";right:auto;"),P();var M="",S=function(){jQuery(".mean-bar,.mean-push").remove(),jQuery(a).removeClass("mean-container"),jQuery(e).css("display",C),b=!1,A=!1,jQuery(w).removeClass("mean-remove")},W=function(){var n="background:"+l+";color:"+l+";"+E;if(t<=o){jQuery(w).addClass("mean-remove"),A=!0,jQuery(a).addClass("mean-container"),jQuery(".mean-container").prepend('');var u=jQuery(e).html();jQuery(".mean-nav").html(u),g&&jQuery("nav.mean-nav ul, nav.mean-nav ul *").each(function(){jQuery(this).is(".mean-remove")?jQuery(this).attr("class","mean-remove"):jQuery(this).removeAttr("class"),jQuery(this).removeAttr("id")}),jQuery(e).before('
'),jQuery(".mean-push").css("margin-top",c),jQuery(e).hide(),jQuery(".meanmenu-reveal").show(),jQuery(d).html(s),M=jQuery(d),jQuery(".mean-nav ul").hide(),h?v?(jQuery(".mean-nav ul ul").each(function(){if(jQuery(this).children().length){var e=''+j+"";"before"==y?jQuery(this,"li:first > ul").before(e):jQuery(this,"li:first > ul").after(e)}}),jQuery(".mean-expand").on("click",function(e){e.preventDefault(),jQuery(this).hasClass("mean-clicked")?(jQuery(this).text(j),"before"==y?jQuery(this).next("ul").slideUp(f,function(){}):jQuery(this).prev("ul").slideUp(f,function(){})):(jQuery(this).text(Q),"before"==y?jQuery(this).next("ul").slideDown(f,function(){}):jQuery(this).prev("ul").slideDown(f,function(){})),jQuery(this).toggleClass("mean-clicked")})):jQuery(".mean-nav ul ul").show():jQuery(".mean-nav ul ul").hide(),jQuery(".mean-nav ul li").last().addClass("mean-last"),M.removeClass("meanclose"),jQuery(M).click(function(e){e.preventDefault(),!1===b?(M.css("text-align","center"),M.css("text-indent","0"),M.css("font-size",i),jQuery(".mean-nav ul:first").slideDown(f),b=!0):(jQuery(".mean-nav ul:first").slideUp(f),b=!1),M.toggleClass("meanclose"),jQuery(M).is(".meanmenu-reveal.meanclose")?M.html(r):M.html(s),jQuery(w).addClass("mean-remove")}),p&&jQuery(".mean-nav ul > li > a:first-child").on("click",function(){jQuery(".mean-nav ul:first").slideUp(),b=!1,jQuery(M).toggleClass("meanclose").html(s)})}else S()};x||jQuery(window).resize(function(){t=window.innerWidth||document.documentElement.clientWidth,S(),t<=o?(W(),P()):S()}),jQuery(window).resize(function(){t=window.innerWidth||document.documentElement.clientWidth,x?(P(),t<=o?!1===A&&W():S()):(S(),t<=o&&(W(),P()))}),W()})}}(jQuery); +!function(n){"use strict";n.fn.meanmenu=function(W){var e={meanMenuTarget:jQuery(this),meanMenuContainer:"body",meanMenuClose:"X",meanMenuCloseSize:"18px",meanMenuOpen:"",meanRevealPosition:"right",meanRevealPositionDistance:"0",meanRevealColour:"",meanScreenWidth:"480",meanNavPush:"",meanShowChildren:!0,meanExpandableChildren:!0,meanExpandPosition:"after",meanExpand:"+",meanContract:"-",meanSpeed:300,meanAria:!0,meanRemoveAttrs:!1,onePage:!1,meanDisplay:"block",removeElements:""};W=n.extend(e,W);var D=window.innerWidth||document.documentElement.clientWidth;return this.each(function(){var a=W.meanMenuTarget,t=W.meanMenuContainer,r=W.meanMenuClose,i=W.meanMenuCloseSize,s=W.meanMenuOpen,n=W.meanRevealPosition,e=W.meanRevealPositionDistance,u=W.meanRevealColour,l=W.meanScreenWidth,m=W.meanNavPush,o=".meanmenu-reveal",c=W.meanShowChildren,d=W.meanExpandableChildren,h=W.meanExpandPosition,v=W.meanExpand,y=W.meanContract,j=W.meanSpeed,Q=W.meanAria,f=W.meanRemoveAttrs,p=W.onePage,g=W.meanDisplay,C=W.removeElements,w=!1;(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))&&(w=!0),(navigator.userAgent.match(/MSIE 8/i)||navigator.userAgent.match(/MSIE 7/i))&&jQuery("html").css("overflow-y","scroll");var x="",b=function(){if("center"===n){var e=(window.innerWidth||document.documentElement.clientWidth)/2-22+"px";x="left:"+e+";right:auto;",w?jQuery(".meanmenu-reveal").animate({left:e}):jQuery(".meanmenu-reveal").css("left",e)}},A=!1,E=!1;"right"===n&&(x="right:"+e+";left:auto;"),"left"===n&&(x="left:"+e+";right:auto;"),b();var P="",M=function(){jQuery(".mean-bar,.mean-push").remove(),jQuery(t).removeClass("mean-container"),jQuery(a).css("display",g),E=A=!1,jQuery(C).removeClass("mean-remove")},S=function(){var e="background:"+u+";color:"+u+";"+x;if(D<=l){jQuery(C).addClass("mean-remove"),E=!0,jQuery(t).addClass("mean-container"),jQuery(".mean-container").prepend('');var n=jQuery(a).html();jQuery(".mean-nav").html(n),f&&jQuery("nav.mean-nav ul, nav.mean-nav ul *").each(function(){jQuery(this).is(".mean-remove")?jQuery(this).attr("class","mean-remove"):jQuery(this).removeAttr("class"),jQuery(this).removeAttr("id")}),jQuery(a).before('
'),jQuery(".mean-push").css("margin-top",m),jQuery(a).hide(),jQuery(".meanmenu-reveal").show(),jQuery(o).html(s),P=jQuery(o),jQuery(".mean-nav ul").hide(),c?d?(jQuery(".mean-nav ul ul").each(function(){if(jQuery(this).children().length){if(1==Q)var e='";else e=''+v+"";"before"==h?jQuery(this,"li:first > ul").before(e):jQuery(this,"li:first > ul").after(e)}}),jQuery(".mean-expand").on("click",function(e){e.preventDefault(),jQuery(this).hasClass("mean-clicked")?(jQuery(this).text(v),1==Q&&jQuery(this).attr("aria-expanded","false"),"before"==h?jQuery(this).next("ul").slideUp(j,function(){}):jQuery(this).prev("ul").slideUp(j,function(){})):(jQuery(this).text(y),1==Q&&jQuery(this).attr("aria-expanded","true"),"before"==h?jQuery(this).next("ul").slideDown(j,function(){}):jQuery(this).prev("ul").slideDown(j,function(){})),jQuery(this).toggleClass("mean-clicked")})):jQuery(".mean-nav ul ul").show():jQuery(".mean-nav ul ul").hide(),jQuery(".mean-nav ul li").last().addClass("mean-last"),P.removeClass("meanclose"),jQuery(P).click(function(e){e.preventDefault(),!1===A?(P.css("text-align","center"),P.css("text-indent","0"),P.css("font-size",i),jQuery(".mean-nav ul:first").slideDown(j),A=!0):(jQuery(".mean-nav ul:first").slideUp(j),A=!1),P.toggleClass("meanclose"),jQuery(P).is(".meanmenu-reveal.meanclose")?P.html(r):P.html(s),jQuery(C).addClass("mean-remove")}),p&&jQuery(".mean-nav ul > li > a:first-child").on("click",function(){jQuery(".mean-nav ul:first").slideUp(),A=!1,jQuery(P).toggleClass("meanclose").html(s)})}else M()};w||jQuery(window).resize(function(){D=window.innerWidth||document.documentElement.clientWidth,M(),D<=l?(S(),b()):M()}),jQuery(window).resize(function(){D=window.innerWidth||document.documentElement.clientWidth,w?(b(),D<=l?!1===E&&S():M()):(M(),D<=l&&(S(),b()))}),S()})}}(jQuery); From cf243c7e5cfd5ecb791b43367e74b17e46c5bead Mon Sep 17 00:00:00 2001 From: Tim Date: Wed, 30 May 2018 22:08:21 +1000 Subject: [PATCH 19/23] 2.011 --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 97548e4..c8c8498 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,12 @@ -MeanMenu v2.0.10 +MeanMenu v2.0.11 =========== **This repo (https://github.com/T-Fletcher/meanMenu/) is a tweaked version, originally forked from MeanTheme's MeanMenu JS library (https://github.com/meanthemes/meanMenu)** -## Changes +## Changes in 2.0.11 + +- Added a `meanAria` option to add screenreader-friendly attributes to expand links + +## Changes in 2.0.10 - Added a `meanExpandPosition` option to specify if the expand/contract link appears before or after the target child menu - Added a `meanSpeed` option to specify animation speed in milliseconds - Updated the selector for targeting child menus From 0c0b2c8a03367e53d879c470ccc1e6d17d21332c Mon Sep 17 00:00:00 2001 From: Tim Date: Wed, 30 May 2018 22:10:54 +1000 Subject: [PATCH 20/23] 2.0.11 Includes new `meanAria` option in action --- demo.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/demo.html b/demo.html index b7a24f6..91161c5 100644 --- a/demo.html +++ b/demo.html @@ -126,7 +126,8 @@

Check out our WordPress & jQuery(document).ready(function () { jQuery('header nav').meanmenu({ meanExpandPosition: 'before', - meanSpeed: 200 + meanSpeed: 200, + meanAria: true }); }); From cee09a356402ad035d9032a432432a67696bce2f Mon Sep 17 00:00:00 2001 From: Tim Date: Wed, 30 May 2018 22:14:06 +1000 Subject: [PATCH 21/23] 2.0.11 updated incorrect version number in commit message --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c8c8498..1e89f5f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ MeanMenu v2.0.11 ## Changes in 2.0.11 -- Added a `meanAria` option to add screenreader-friendly attributes to expand links +- Added a `meanAria` option to add screenreader-friendly attributes to expand links ## Changes in 2.0.10 - Added a `meanExpandPosition` option to specify if the expand/contract link appears before or after the target child menu From c2a20bc173532b86ebf26b4d78740da292ec7214 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 7 May 2021 10:43:59 +1000 Subject: [PATCH 22/23] Included meanAria details --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 1e89f5f..03c040f 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,10 @@ Then in your usual document.ready, this is working under the assumption your nav There are the following options (Options are shown with their defaults)... +meanAria: true + +- Adds `aria-expanded`, `aria-label` and `role` attributes for better accessibility and WCAG compliance + meanMenuContainer: 'body' - Choose where meanmenu will be placed within the HTML From 95423f7029e9e62ef51c7dab88759a5c2c08b6d4 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 7 May 2021 11:06:07 +1000 Subject: [PATCH 23/23] Removed version notes --- README.md | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/README.md b/README.md index 03c040f..250f522 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,5 @@ MeanMenu v2.0.11 =========== -**This repo (https://github.com/T-Fletcher/meanMenu/) is a tweaked version, originally forked from MeanTheme's MeanMenu JS library (https://github.com/meanthemes/meanMenu)** - -## Changes in 2.0.11 - -- Added a `meanAria` option to add screenreader-friendly attributes to expand links - -## Changes in 2.0.10 -- Added a `meanExpandPosition` option to specify if the expand/contract link appears before or after the target child menu -- Added a `meanSpeed` option to specify animation speed in milliseconds -- Updated the selector for targeting child menus - -Ok, back to the original README now... - ------ - Looking for a WordPress version? --- Our friends over at PluginHero have just released the WordPress version of MeanMenu.