window.addEventListener("load", function () { jQuery(document).ready(function ($) { "use strict"; $("body").addClass("page-loaded"); var myCursor = jQuery(".theme-custom-cursor"); if (myCursor.length) { if ($("body")) { const e = document.querySelector(".theme-cursor-secondary"), t = document.querySelector(".theme-cursor-primary"); let n, i = 0, o = !1; (window.onmousemove = function (s) { o || (t.style.transform = "translate(" + s.clientX + "px, " + s.clientY + "px)"), (e.style.transform = "translate(" + s.clientX + "px, " + s.clientY + "px)"), (n = s.clientY), (i = s.clientX); }), $("body").on("mouseenter", "a, .cursor-pointer", function () { e.classList.add("cursor-hover"), t.classList.add("cursor-hover"); }), $("body").on("mouseleave", "a, .cursor-pointer", function () { ($(this).is("a") && $(this).closest(".cursor-pointer").length) || (e.classList.remove("cursor-hover"), t.classList.remove("cursor-hover")); }), (e.style.visibility = "visible"), (t.style.visibility = "visible"); } } }); }); jQuery(document).ready(function ($) { "use strict"; // Scroll To $(".scroll-content").click(function () { $("html, body").animate( { scrollTop: $("#content").offset().top, }, 500 ); }); // Hide Comments $( ".alok-no-comment .booster-block.booster-ratings-block, .alok-no-comment .comment-form-ratings, .alok-no-comment .twp-star-rating" ).hide(); // Rating disable if (alok_custom.single_post == 1 && alok_custom.alok_ed_post_reaction) { $(".tpk-single-rating").remove(); $(".tpk-comment-rating-label").remove(); $(".comments-rating").remove(); $(".tpk-star-rating").remove(); } // Add Class on article $(".twp-archive-items.post").each(function () { $(this).addClass("twp-article-loded"); }); // Aub Menu Toggle $(".submenu-toggle").click(function () { $(this).toggleClass("button-toggle-active"); var currentClass = $(this).attr("data-toggle-target"); $(currentClass).toggleClass("submenu-toggle-active"); }); // Header Search Popup End $(".navbar-control-search").click(function () { $(".header-searchbar").toggleClass("header-searchbar-active"); $("body").addClass("body-scroll-locked"); $("#search-closer").focus(); }); $(".header-searchbar").click(function () { $(".header-searchbar").removeClass("header-searchbar-active"); $("body").removeClass("body-scroll-locked"); }); $(".header-searchbar-inner").click(function (e) { e.stopPropagation(); //stops click event from reaching document }); // Header Search hide $("#search-closer").click(function () { $(".header-searchbar").removeClass("header-searchbar-active"); $("body").removeClass("body-scroll-locked"); setTimeout(function () { $(".navbar-control-search").focus(); }, 300); }); // Focus on search input on search icon expand $(".navbar-control-search").click(function () { setTimeout(function () { $(".header-searchbar .search-field").focus(); }, 300); }); $("input, a, button").on("focus", function () { if ($(".header-searchbar").hasClass("header-searchbar-active")) { if (!$(this).parents(".header-searchbar").length) { $(".header-searchbar .search-field").focus(); $(".header-searchbar-area .search-field-default").focus(); } } }); $(".skip-link-search-start").focus(function () { $("#search-closer").focus(); }); $(".skip-link-search-end").focus(function () { $(".header-searchbar-area .search-field").focus(); }); $(".skip-link-menu-start").focus(function () { if (!$("#offcanvas-menu #primary-nav-offcanvas").length == 0) { $("#offcanvas-menu #primary-nav-offcanvas ul li:last-child a").focus(); } if (!$("#offcanvas-menu #social-nav-offcanvas").length == 0) { $("#offcanvas-menu #social-nav-offcanvas ul li:last-child a").focus(); } }); // Action On Esc Button For Search $(document).keyup(function (j) { $("body").removeClass("body-scroll-locked"); if (j.key === "Escape") { // escape key maps to keycode `27` if ($(".header-searchbar").hasClass("header-searchbar-active")) { $(".header-searchbar").removeClass("header-searchbar-active"); setTimeout(function () { $(".navbar-control-search").focus(); }, 300); setTimeout(function () { $(".aside-search-js").focus(); }, 300); } } }); // Header Search Popup End // Action On Esc Button For Offcanvas $(document).keyup(function (j) { if (j.key === "Escape") { // escape key maps to keycode `27` if ($("#offcanvas-menu").hasClass("offcanvas-menu-active")) { $(".header-searchbar").removeClass("header-searchbar-active"); $("#offcanvas-menu").removeClass("offcanvas-menu-active"); $(".navbar-control-offcanvas").removeClass("active"); $("body").removeClass("body-scroll-locked"); setTimeout(function () { $(".navbar-control-offcanvas").focus(); }, 300); } } }); // Toggle Menu Start $(".navbar-control-offcanvas").click(function () { $(this).addClass("active"); $("body").addClass("body-scroll-locked"); $("#offcanvas-menu").toggleClass("offcanvas-menu-active"); $(".button-offcanvas-close").focus(); }); $(".offcanvas-close .button-offcanvas-close").click(function () { $("#offcanvas-menu").removeClass("offcanvas-menu-active"); $(".navbar-control-offcanvas").removeClass("active"); $("body").removeClass("body-scroll-locked"); $("html").removeAttr("style"); $(".navbar-control-offcanvas").focus(); }); $("#offcanvas-menu").click(function () { $("#offcanvas-menu").removeClass("offcanvas-menu-active"); $(".navbar-control-offcanvas").removeClass("active"); $("body").removeClass("body-scroll-locked"); }); $(".offcanvas-wraper").click(function (e) { e.stopPropagation(); //stops click event from reaching document }); $(".skip-link-menu-end").focus(function () { $(".button-offcanvas-close").focus(); }); // Toggle Menu End // Data Background var pageSection = $(".data-bg"); pageSection.each(function (indx) { var src = $(this).attr("data-background"); if (src) { $(this).css("background-image", "url(" + src + ")"); } }); var rtled = false; if ($("body").hasClass("rtl")) { rtled = true; } // flatten object by concatting values function concatValues(obj) { var value = ""; for (var prop in obj) { value += obj[prop]; } return value; } // Navigation toggle on scroll $(window).scroll(function () { if ($(window).scrollTop() > $(window).height() / 2) { $("body").addClass("theme-floatingbar-active"); } else { $("body").removeClass("theme-floatingbar-active"); } }); // Scroll to Top on Click $(".to-the-top").click(function () { $("html, body").animate( { scrollTop: 0, }, 700 ); return false; }); });