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, button, .twp-carousel-prev, .twp-carousel-next, input[type=\"submit\"], .cursor-pointer", function () { e.classList.add('cursor-hover'), t.classList.add('cursor-hover') }), $('body').on("mouseleave", "a, button, .twp-carousel-prev, .twp-carousel-next, input[type=\"submit\"], .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); }); $('a').mouseenter(function () { $('.circle1').addClass('hover-link-active-1'); $('.circle2').addClass('hover-link-active-2'); }); $('a').mouseleave(function () { $('.circle1').removeClass('hover-link-active-1'); $('.circle2').removeClass('hover-link-active-2'); }); // Hide Comments $('.ashlar-no-comment .booster-block.booster-ratings-block, .ashlar-no-comment .comment-form-ratings, .ashlar-no-comment .twp-star-rating').hide(); // Rating disable if (ashlar_custom.single_post == 1 && ashlar_custom.ashlar_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; } // Carousel Block Home $(".mg-carousel-action").each(function () { $(this).slick({ slidesToShow: 5, slidesToScroll: 5, autoplaySpeed: 8000, infinite: true, nextArrow: '', prevArrow: '', responsive: [ { breakpoint: 1400, settings: { slidesToShow: 4, slidesToScroll: 4 } }, { breakpoint: 1200, settings: { slidesToShow: 3, slidesToScroll: 3 } }, { breakpoint: 991, settings: { slidesToShow: 2, slidesToScroll: 2 } }, { breakpoint: 640, settings: { slidesToShow: 1, slidesToScroll: 1, dots:false } } ] }); }); // Content Gallery Slide Start $("figure.wp-block-gallery.has-nested-images.columns-1, .wp-block-gallery.columns-1 ul.blocks-gallery-grid, .gallery-columns-1").each(function () { $(this).slick({ slidesToShow: 1, slidesToScroll: 1, fade: true, autoplay: false, autoplaySpeed: 8000, infinite: true, nextArrow: '', prevArrow: '', dots: false, rtl: rtled, }); }); // Content Gallery End // flatten object by concatting values function concatValues(obj) { var value = ''; for (var prop in obj) { value += obj[prop]; } return value; } // init Isotope var filterContainer = $('.twp-active-isotope').isotope({ itemSelector: '.twp-archive-items-main', masonry: { itemSelector: '.theme-panel-blocks', columnWidth: '.mg-grid-sizer', gutter: '.mg-grid-gutter', percentPosition: true }, sortAscending: false, category: '[data-category]', getSortData: { number: function (item) { return parseFloat($(item).find(".twp-post-views").text()); }, points: function (item) { return parseFloat($(item).find(".twp-post-like").text()); } }, }); // layout Isotope after each image loads filterContainer.imagesLoaded().progress(function () { filterContainer.isotope('layout'); }); var emasonry = $('.theme-panelarea-blocks').isotope({ itemSelector: '.theme-panel-blocks', percentPosition: true, masonry: { columnWidth: '.mg-grid-sizer', gutter: '.mg-grid-gutter', } }); // filter items on button click $('.filter-group').on('click', 'li span', function () { var filterValue = $(this).attr('data-filter'); emasonry.isotope({filter: filterValue}); }); // 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; }); // Widgets Tab $('.twp-nav-tabs .tab').on('click', function (event) { var tabid = $(this).attr('tab-data'); $(this).closest('.tabbed-container').find('.tab').removeClass('active'); $(this).addClass('active'); $(this).closest('.tabbed-container').find('.tab-content .tab-pane').removeClass('active'); $(this).closest('.tabbed-container').find('.content-' + tabid).addClass('active'); }); }); /* ----------------------------------------------------------------------------------------------- Intrinsic Ratio Embeds --------------------------------------------------------------------------------------------------- */ var Ashlar = Ashlar || {}, $ = jQuery; var $ashlar_doc = $(document), $ashlar_win = $(window), viewport = {}; viewport.top = $ashlar_win.scrollTop(); viewport.bottom = viewport.top + $ashlar_win.height(); Ashlar.instrinsicRatioVideos = { init: function () { Ashlar.instrinsicRatioVideos.makeFit(); $ashlar_win.on('resize fit-videos', function () { Ashlar.instrinsicRatioVideos.makeFit(); }); }, makeFit: function () { var vidSelector = "iframe, .format-video object, .format-video video"; $(vidSelector).each(function () { var $ashlar_video = $(this), $ashlar_container = $ashlar_video.parent(), ashlar_iTargetWidth = $ashlar_container.width(); // Skip videos we want to ignore if ($ashlar_video.hasClass('intrinsic-ignore') || $ashlar_video.parent().hasClass('intrinsic-ignore')) { return true; } if (!$ashlar_video.attr('data-origwidth')) { // Get the video element proportions $ashlar_video.attr('data-origwidth', $ashlar_video.attr('width')); $ashlar_video.attr('data-origheight', $ashlar_video.attr('height')); } // Get ratio from proportions var ashlar_ratio = ashlar_iTargetWidth / $ashlar_video.attr('data-origwidth'); // Scale based on ratio, thus retaining proportions $ashlar_video.css('width', ashlar_iTargetWidth + 'px'); $ashlar_video.css('height', ($ashlar_video.attr('data-origheight') * ashlar_ratio) + 'px'); }); } }; $ashlar_doc.ready(function () { Ashlar.instrinsicRatioVideos.init(); // Retain aspect ratio of videos on window resize });