Instantly share code, notes, and snippets.
Last active
August 29, 2015 14:03
-
Save AlphaBlossom/709c640234b95e467070 to your computer and use it in GitHub Desktop.
Add Mmenu Off Canvas Mobile Menu to Genesis Child Theme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/********************************** | |
* | |
* Add id="menu" attribute to Primary Navigation | |
* | |
* @author AlphaBlossom / Tony Eppright | |
* @link http://www.alphablossom.com | |
* | |
**********************************/ | |
add_filter( 'genesis_attr_nav-primary', 'youruniqueprefix_primary_nav_id' ); | |
function youruniqueprefix_primary_nav_id( $attributes ) { | |
$attributes['id'] = 'menu'; | |
return $attributes; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/********************************** | |
* | |
* Add menu control for Mmenu | |
* | |
* @author AlphaBlossom / Tony Eppright | |
* @link http://www.alphablossom.com | |
* | |
**********************************/ | |
/* Navigation functions */ | |
add_action( 'genesis_before', 'youruniqueprefix_nav_control', 1 ); | |
function youruniqueprefix_nav_control() { | |
?> | |
<div id="header"> | |
<a href="#menu"> | |
<i class="fa fa-bars"></i> | |
</a> | |
</div> | |
<?php | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Mobile Navigation control */ | |
#header { | |
display: none; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function($) { | |
$(function() { | |
// initiate mmenu | |
$("#menu").mmenu({ | |
// options go here | |
}, { | |
// configuration: | |
clone : true, | |
}); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/********************************** | |
* | |
* Enqueue Style and Scripts for Mmenu. | |
* | |
* @author AlphaBlossom / Tony Eppright | |
* @link http://www.alphablossom.com | |
* | |
**********************************/ | |
add_action( 'wp_enqueue_scripts', 'youruniqueprefix_load_scripts'); | |
function youruniqueprefix_load_scripts() { | |
// CSS | |
wp_enqueue_style( 'youruniqueprefix_mmenu_css' , CHILD_URL . '/css/jquery.mmenu.css' , null ); | |
// JS | |
wp_enqueue_script( 'youruniqueprefix_mmenu_js' , CHILD_URL . '/js/jquery.mmenu.min.js' , array( 'jquery' ), '4.2.6', FALSE ); // mmenu js | |
wp_enqueue_script( 'youruniqueprefix_headerscript_js' , CHILD_URL . '/js/headerscript.js' , array( 'jquery' ), '1.0', FALSE ); // custom header j | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@media only screen and (max-width: 767px) { | |
/* Mobile Navigation */ | |
.site-container .nav-primary { | |
display: none; | |
} | |
.mm-page #header { | |
display: block; | |
position: absolute; | |
} | |
.mm-page #header a { | |
border-right: 1px solid #666; | |
display: block; | |
height: 64px; | |
text-align: center; | |
width: 64px; | |
} | |
.mm-page #header a i { | |
border-right: 1px solid #FFFFFF; | |
font-size: 20px; | |
line-height: 64px; | |
width: 63px; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.site-container .genesis-nav-menu { | |
clear: both; | |
color: #fff; | |
font-family: 'Lato', sans-serif; | |
letter-spacing: 1px; | |
letter-spacing: 0.1rem; | |
line-height: 1.5; | |
margin: 0; | |
padding: 0; | |
width: 100%; | |
} | |
.site-container .genesis-nav-menu .menu-item { | |
display: inline-block; | |
margin: 0; | |
padding: 0; | |
text-align: left; | |
float: left; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment