garchive-wp-theme/scripts/main.js
Aaron Yarborough eec5362717 Initial commit
2018-12-17 16:30:40 +00:00

37 lines
No EOL
944 B
JavaScript

(function($) {
var postGrid,
search,
searchbox;
$(document).ready(function() {
postGrid = $('#postGrid');
search = $('#search');
searchbox = $('#searchBox')
initPostGrid(postGrid, '.gar-post-box');
initSearch('a[data-toggle=search]', search, searchbox);
});
function initSearch(toggleSelector, search, searchbox) {
$(toggleSelector).click(function(e) {
e.preventDefault();
search.toggleClass('open');
if (search.hasClass('open')) {
searchbox.focus();
}
});
}
function initPostGrid(grid, itemSelector) {
// Don't init masonry if there are no items
if (!$(itemSelector).length)
return;
grid.masonry({
itemSelector: itemSelector,
percentPosition: true,
gutter: 20
});
}
})(jQuery);