-
-
Save billerickson/b029efa2cc67d95f6463 to your computer and use it in GitHub Desktop.
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
<?php | |
/** | |
* Add Search to Menu | |
* | |
*/ | |
function be_add_search_to_menu( $menu, $args ) { | |
if( 'header' == $args->theme_location ) | |
$menu .= '<li class="menu-item search"><a href="#"><i class="icon-search"></i></a>' . get_search_form( false ) . '</li>'; | |
return $menu; | |
} | |
add_filter( 'wp_nav_menu_items', 'be_add_search_to_menu', 10, 2 ); |
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(function($){ | |
// Open Search | |
$('.genesis-nav-menu .menu-item.search a').click(function(e){ | |
$('.genesis-nav-menu .search-form').css('display', 'block'); | |
$('.genesis-nav-menu .search-form input[type="search"]').focus(); | |
e.preventDefault(); | |
}); | |
// Close Search | |
$(document).mouseup(function (e){ | |
var container = $('.search-form'); | |
if (!container.is(e.target) // if the target of the click isn't the container... | |
&& container.has(e.target).length === 0) // ... nor a descendant of the container | |
{ | |
container.hide(); | |
} | |
}); | |
}); |
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
.genesis-nav-menu .search-form { | |
background: #fff; | |
border-top: 4px solid #76bd22; | |
position: absolute; | |
top: 0; | |
right: 0; | |
width: 100%; | |
display: none; | |
} | |
.genesis-nav-menu .search-form input[type="search"] { | |
color: #5d5d5d; | |
font-size: 16px; | |
line-height: 30px; | |
outline: none; | |
border: none; | |
} | |
.genesis-nav-menu .search-form input[type="submit"] { | |
background: transparent url(images/search.jpg) no-repeat center center; | |
background-size: 20px 19px; | |
border: none; | |
width: 42px; | |
height: 50px; | |
position: absolute; | |
top: 0; | |
right: 0; | |
min-width: 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment