garchive-wp-theme/scripts/main.js
2018-12-17 20:42:52 +00:00

47 lines
No EOL
1.1 KiB
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);
initTinyMCE('.rte');
});
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
});
}
function initTinyMCE(editorSelector) {
if (typeof tinymce === 'undefined')
return;
tinymce.init({
selector: editorSelector
});
}
})(jQuery);