Skip to content

Instantly share code, notes, and snippets.

@IgorGavrilenko
Last active February 18, 2018 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IgorGavrilenko/b483cfd98ced13a428484a3c63f06f95 to your computer and use it in GitHub Desktop.
Save IgorGavrilenko/b483cfd98ced13a428484a3c63f06f95 to your computer and use it in GitHub Desktop.
(function() {
var sbTrigger = $('.searchbox-btn-mobile'),
sbItem = $('#search_mini_form'),
sbActive = 'is-active',
sbParent = '.searchbox';
sbTrigger.each(function(e){
$(this).click(function() {
sbItem.eq(e).toggle();
sbTrigger.toggleClass(sbActive);
});
});
$(document).on('click', function(e) {
if (!$(e.target).closest(sbParent).length) {
sbItem.hide();
sbTrigger.removeClass(sbActive);
}
e.stopPropagation();
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment