jQuery(document).ready(function ($) { $(document).ready(function () { $(".main__wrapper_item-btn").on("click", function () { $("html, body").animate( { scrollTop: $("section.ovid").offset().top, }, "slow" ); return false; }); // Mobile MENU const hamburger = document.querySelector(".hamburger"); const navMenu = document.querySelector(".header"); const body = document.querySelector("body"); const navLink = document.querySelectorAll( ".header__wrapper_menu-nav .menu li a" ); const html = document.querySelector("html"); hamburger.addEventListener("click", mobileMenu); function mobileMenu() { hamburger.classList.toggle("active"); navMenu.classList.toggle("active"); body.classList.toggle("mobMenuActive"); html.classList.toggle("mobMenuActive"); } navLink.forEach((n) => n.addEventListener("click", closeMenu)); function closeMenu() { hamburger.classList.remove("active"); navMenu.classList.remove("active"); body.classList.remove("mobMenuActive"); html.classList.remove("mobMenuActive"); } // END MOBILE // FILTER BUTTON $("#blogFilter").on("click", function (e) { e.preventDefault(); $(this).toggleClass("active"); $(".insights-blog__list").toggleClass("d-none"); }); // END FILTER BUTTON }); }); /** * START FILTER AJAX */ jQuery(document).ready(function ($) { jQuery(document).on( "click", "button.tet", function (e) { e.preventDefault(); $("#content").animate({ opacity: 0.5 }, 300); var cat = $(this).data("category"); var menuPanelEl = document.querySelector(`.insights-blog__list_item > button[data-category="${cat}"]`) $(".insights-blog__list_item > button").removeClass("active"); $(".insights-blog__list_item > button").removeClass("activeCategory"); menuPanelEl.classList.add('active'); menuPanelEl.classList.add('activeCategory'); $.ajax({ url: wpAjax.ajaxUrl, data: { action: "filter", category: cat }, type: "post", beforeSend: function (xhr) { console.log("Loading..."); }, success: function (result) { $("#content").html(result).animate({ opacity: 1 }, 300); // lazyloader.init(); }, error: function (result) { console.warn(result); }, }); } ); }); // END --- FILTER AJAX /** * AJAX Pagination function */ jQuery(document).ready(function ($) { jQuery(document).on("click", ".btn-loadmore", function (e) { e.preventDefault(); var category = $(".activeCategory").data("category"); var _this = $(this); var data = { action: "loadmore", query: _this.attr("data-param-posts"), page: this_page, // tpl: _this.attr("data-tpl"), }; $.ajax({ url: wpAjax.ajaxUrl, data: data, type: "POST", beforeSend: function (xhr) { _this.html('
Loading...
'); }, success: function (data) { if (data) { _this.html("See More"); $(".posts-list").append(data); this_page++; if (this_page == _this.attr("data-max-pages")) { _this.remove(); $(".noposts").html("There is no more news."); } } else { _this.remove(); } }, }); }); }); // END Pagination function