93 lines
3.7 KiB
JavaScript
93 lines
3.7 KiB
JavaScript
jQuery(document).ready(function ($) {
|
|
|
|
// Top Search Bar Opening/Closing
|
|
$('.open-top-bar-search').on('click', function() {
|
|
$(this).hide();
|
|
$('.close-top-bar-search').show();
|
|
$('.top-search-bar-container').addClass('opened');
|
|
});
|
|
|
|
$('.close-top-bar-search').on('click', function () {
|
|
$(this).hide();
|
|
$('.open-top-bar-search').show();
|
|
$('.top-search-bar-container').removeClass('opened');
|
|
});
|
|
|
|
|
|
// Blog cards size equalizer
|
|
function equalizeArticleCardsHeights() {
|
|
if(php_vars.enable_posts_height_equalizer) {
|
|
$('.articles-list .row').each(function (index) {
|
|
if ($(this).css('display') == "inline") {
|
|
$('.article-card-container .article-meta').css('height', 'auto');
|
|
} else {
|
|
var max_height = 0;
|
|
$(this).find('.article-card-container').each(function () {
|
|
var height = $(this).find('.article-meta').outerHeight();
|
|
if (height > max_height) {
|
|
max_height = height;
|
|
}
|
|
});
|
|
$(this).find('.article-card-container').find('.article-meta').css('height', max_height + 'px')
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
equalizeArticleCardsHeights();
|
|
|
|
// Rewrite Search Widget
|
|
$('.widget_search .search-field').attr('type', 'text');
|
|
$('.widget_search .search-submit').remove();
|
|
$('.widget_search .search-form').append('<label><input type="submit" class="hidden-submit"/><svg role="img" xmlns="http://www.w3.org/2000/svg" width="24px" height="24px" viewBox="0 0 24 24" stroke="#2329D6" stroke-width="1" stroke-linecap="square" stroke-linejoin="miter" fill="none" color="#2329D6"> <title>Search</title> <desc>Icon of a magnifying glass</desc> <path d="M14.4121122,14.4121122 L20,20"/> <circle cx="10" cy="10" r="6"/> </svg></label>');
|
|
|
|
// Rewrite Meow Search Block
|
|
$('.mwt-search .mwt-search').attr('type', 'text');
|
|
$('.mwt-search .search-submit').remove();
|
|
$('.mwt-search form.search-form').append('<label><input type="submit" class="hidden-submit" style="display:none;"/><svg role="img" xmlns="http://www.w3.org/2000/svg" width="24px" height="24px" viewBox="0 0 24 24" stroke="#2329D6" stroke-width="1" stroke-linecap="square" stroke-linejoin="miter" fill="none" color="#2329D6"> <title>Search</title> <desc >Icon of a magnifying glass</desc> <path d="M14.4121122,14.4121122 L20,20"/> <circle cx="10" cy="10" r="6"/> </svg></label>');
|
|
|
|
// Mobile Navigation Init
|
|
$('.mobile-navigation').css('margin-top', - $('.mobile-navigation').outerHeight() + 'px')
|
|
// Mobile Navigation Toggle
|
|
$('.mobile-navigation-toggle').on('click', function() {
|
|
if($(this).hasClass('active')) {
|
|
$('.mobile-navigation').animate({ marginTop: - $('.mobile-navigation').outerHeight() + 'px'}, 200);
|
|
$(this).removeClass('active')
|
|
} else {
|
|
$('.mobile-navigation').animate({ marginTop: 0 }, 200);
|
|
$(this).addClass('active')
|
|
}
|
|
})
|
|
|
|
// On window resize
|
|
var resizeTimer
|
|
$(window).on('resize', function() {
|
|
clearTimeout(resizeTimer);
|
|
resizeTimer = setTimeout(function () {
|
|
$('.article-card-container .article-meta').css('height', 'auto');
|
|
equalizeArticleCardsHeights();
|
|
}, 250);
|
|
})
|
|
|
|
// On infinite scroll loading more posts
|
|
$(document.body).on('post-load', function () {
|
|
equalizeArticleCardsHeights();
|
|
});
|
|
|
|
// Scroll back to top button
|
|
if ($('.scroll-back-to-top-btn').length > -1) {
|
|
$(window).on('scroll', function() {
|
|
var scrollTop = $(this).scrollTop();
|
|
if(scrollTop > 100) {
|
|
$('.scroll-back-to-top-btn').addClass('visible');
|
|
}
|
|
if(scrollTop <= 100) {
|
|
$('.scroll-back-to-top-btn').removeClass('visible');
|
|
}
|
|
});
|
|
|
|
$('.scroll-back-to-top-btn').on('click', function() {
|
|
$("html, body").animate({ scrollTop: 0 }, 300);
|
|
})
|
|
}
|
|
}); |