Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,38 @@ jQuery(document).ready(function() {
jQuery('body').css({ 'margin-top': divheight });
}

var hideSearchForm = function() {
jQuery( '#masthead .search-form' ).hide( 'slow' );
};
jQuery('.header-search-icon').click(function(){
jQuery('#masthead .search-form').toggle('slow');

// focus after some time to fix conflict with toggleClass
setTimeout( function () {
jQuery( '#masthead .search-form input' ).focus();
}, 200 );

// For esc key press.
jQuery( document ).on( 'keyup', function ( e ) {

// on esc key press.
if ( 27 === e.keyCode ) {
// if search box is opened
if ( jQuery( '#masthead' ).has( '.search-form' ) ) {
hideSearchForm();
}

}
} );

jQuery( document ).on( 'click', function( e ) {
var container = jQuery( '.search-form, .header-search-icon, .search-form input' );
if ( ! container.is( e.target ) ) {
hideSearchForm();
}

} );

});

jQuery(window).bind('scroll', function() {
Expand Down