// js function for site mode function Blook_Set_Cookie(cname, cvalue, exdays) { var d = new Date(); d.setTime(d.getTime() + (exdays*24*60*60*1000)); var expires = "expires="+ d.toUTCString(); document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; } function Blook_Get_Cookie(cname) { var name = cname + "="; var decodedCookie = decodeURIComponent(document.cookie); var ca = decodedCookie.split(';'); for(var i = 0; i sticky) { e(breakingNews).addClass("show"); e(footer).addClass("show"); } } e(closeBtn).on("click",function(){ e(breakingNews).removeClass("blook-active show"); e("#breaking-news-open-content").addClass("show"); e(footer).removeClass("breaking-news-active"); }); e(openBtn).on("click",function(){ e(breakingNews).addClass("blook-active show"); e("#breaking-news-open-content").removeClass("show"); e(footer).addClass("breaking-news-active"); }); }; // Image popup n.magnificPopUp = function () { e(".wp-block-gallery,.gallery").each(function () { e(this).magnificPopup({ delegate: "a", type: "image", closeOnContentClick: false, closeBtnInside: false, mainClass: "mfp-with-zoom mfp-img-mobile", image: { verticalFit: true, titleSrc: function (item) { return item.el.attr("title"); } }, gallery: { enabled: true }, zoom: { enabled: true, duration: 300, opener: function (element) { return element.find("img"); } } }); }); }; // Min Height Calculation n.minHeight = function() { var windowHeight = e(window).height(); var topbar = e('.blook-topbar').outerHeight(); var header = e('#masthead').outerHeight(); var contentMinHeight = (windowHeight - 65) - ( topbar + header); e(".blook-min-height").css("minHeight",contentMinHeight); }; // Mobile menu n.mobileMenu = function () { e("#nav-menu-icon").on("click",function(){ e("#mobile-menu").addClass("open"); e("#primary-menu").clone().appendTo(".mobile-menu-container"); e("#body-overlay").toggleClass("show"); e("body").css("overflow","hidden"); }); e("#mobile-menu-close,#body-overlay").on("click",function(){ e("#mobile-menu").removeClass("open"); e("#mobile-menu #primary-menu").remove(); e("#body-overlay").removeClass("show"); e("body").css("overflow","visible"); }); }; // Navigation bar n.navigation = function() { e("ul#primary-menu>li,div#primary-menu>ul>li").has("ul").addClass("down-arrow"); e("ul#primary-menu>li>ul li,div#primary-menu>ul>li>ul li").has("ul").addClass("right-arrow"); // Offcanvas e(".offcanvas-btn").on("click",function(){ e("#offcanvas-content").addClass("open"); e("#body-overlay").addClass("show"); e("body").css("overflow","hidden"); }); e("#offcanvas-close,#body-overlay").on("click",function(){ e("#offcanvas-content").removeClass("open"); e("#body-overlay").removeClass("show"); e("body").css("overflow","visible"); }); e('.trending-box-skip-start').focus(function(){ e('.blook-post-list .blook-col:last-child h3.blook-post-title a').focus(); }); // Trending e("#trending").on("click",function(){ e('body').toggleClass('twp-trending-active'); e("#trending-content").slideToggle(); e("#search-content").slideUp(); setTimeout(function(){ if( e('body').hasClass('twp-trending-active') ){ e('#trending-close').focus(); } },300); }); e(document).keyup(function(j) { if (j.key === "Escape") { // escape key maps to keycode `27` if ( e( 'body' ).hasClass( 'twp-trending-active' ) ) { e('body').toggleClass('twp-trending-active'); e("#trending-content").slideUp(); e("#trending").focus(); } if ( e( '.blook-popup-section' ).hasClass( 'open' ) ) { e("#newsletter-content").removeClass("open"); e("#newsletter-content").addClass("close"); e("#body-overlay").removeClass("show"); e("body").css("overflow","visible"); e('#newsletter').focus(); } } }); e("#trending-close").on("click",function(){ e('body').toggleClass('twp-trending-active'); e("#trending-content").slideUp(); e("#trending").focus(); }); // Search e("#navbar-search").on("click",function(){ e("#search-content").slideToggle(); e("#trending-content").slideUp(); }); e("#search-close").on("click",function(){ e("#search-content").slideUp(); }); // Dark and light mode e("#color-mode").on("click",function(){ if (e('body').hasClass('dark-mode')) { e('body').removeClass('dark-mode'); e('body').addClass('light-mode'); Blook_Set_Cookie('BlookSiteMode', 'true',365); }else { e('body').addClass('dark-mode'); e('body').removeClass('light-mode'); Blook_Set_Cookie('BlookSiteMode', 'false',365); } // e("body").toggleClass("dark-mode"); // Blook_Set_Cookie('BlookSiteMode', 'true',365); }); // Add class and remove on body element regarding mode if ( Blook_Get_Cookie('BlookSiteMode') == 'false') { e('body').addClass("dark-mode"); }else{ e("body").removeClass("dark-mode"); } // Newsletter popup e("#newsletter").on("click",function(){ e("#newsletter-content").addClass("open"); e("#newsletter-content").removeClass("close"); e("#body-overlay").addClass("show"); e("body").css("overflow","hidden"); e('#newsletter-close').focus(); }); e('.newsletter-skip-end').focus(function(){ e('#newsletter-close').focus(); }); e('.newsletter-skip-start').focus(function(){ e('.newsletter-skip-end-1').focus(); }); e("#newsletter-close").on("click",function(){ e("#newsletter-content").removeClass("open"); e("#newsletter-content").addClass("close"); e("#body-overlay").removeClass("show"); e("body").css("overflow","visible"); e('#newsletter').focus(); }); }; // Post Load more button n.PostLoad = function(){ var ajaxurl = blook_main.ajax_url; var loading = blook_main.loading; var loadmore = blook_main.loadmore; var nomore = blook_main.nomore; var ajax_nonce = blook_main.ajax_nonce; var page = 2; e('body').on('click', '.load-posts-btn', function() { if( !e(this).hasClass('loading') ){ e(this).addClass('loading'); e(this).html(''+loading+''); var data = { 'action': 'blook_component_post_load', 'page': page, '_wpnonce': ajax_nonce, }; e.post(ajaxurl, data, function(response) { e('.ajax-post-load').append(response); page++; if( !e.trim(response) ){ e('.load-posts-btn').addClass('no-more-post'); e('.load-posts-btn').html(nomore); }else{ e('.load-posts-btn').html(loadmore); } e('.load-posts-btn').removeClass('loading'); }); } }); }; // Circulare progressbar n.progressBar = function () { var winScroll = document.body.scrollTop || document.documentElement.scrollTop; var height = document.documentElement.scrollHeight - document.documentElement.clientHeight; var scrolled = (winScroll / height) * 100; var stroke = ( 1 - scrolled / 100 ) * (2 * (22 / 7) * 40); e('.blook-progress-percent').text(scrolled.toFixed()+'%'); e('#progress-indicator').css('stroke-dashoffset',stroke); }; // Slider and carousel n.slider = function (){ var rtlStatus = false; if( e('body').hasClass('rtl') ){ rtlStatus = true; } e('.blook-single-slider,.wp-block-gallery.columns-1 .blocks-gallery-grid,ul.wp-block-gallery.columns-1,.widget .gallery-columns-1').slick({ slidesToShow: 1, slidesToScroll: 1, arrows: true, cssEase: 'linear', dots: false, rtl: rtlStatus, }); e('.blook-full-width-carousel-slider').slick({ slidesToShow: 5, slidesToScroll: 1, arrows: true, cssEase: 'linear', dots: false, rtl: rtlStatus, responsive: [ { breakpoint: 1100, settings: { slidesToShow: 3, } }, { breakpoint: 991, settings: { slidesToShow: 2, } }, { breakpoint: 480, settings: { slidesToShow: 1, } } ] }); e('.blook-boxed-width-carousel-slider').slick({ slidesToShow: 3, slidesToScroll: 1, arrows: true, cssEase: 'linear', dots: false, rtl: rtlStatus, responsive: [ { breakpoint: 991, settings: { slidesToShow: 2, } }, { breakpoint: 480, settings: { slidesToShow: 1, } } ] }); e('.blook-carousel-slider-3').slick({ slidesToShow: 3, slidesToScroll: 1, arrows: true, cssEase: 'linear', dots: false, rtl: rtlStatus, }); e(".blook-breaking-news-slider").slick({ speed: 2000, autoplay: true, autoplaySpeed: 0, cssEase: 'linear', slidesToShow: 4, slidesToScroll: 1, arrows: false, infinite: true, swipeToSlide: true, centerMode: true, focusOnSelect: true, rtl: rtlStatus, responsive: [ { breakpoint: 1100, settings: { slidesToShow: 3, } }, { breakpoint: 991, settings: { slidesToShow: 2, } }, { breakpoint: 480, settings: { slidesToShow: 1, } } ] }); }; // Sticky navbar n.stickyNav = function () { var navbar = "#blook-site-navbar"; var stickyNav = "#sticky-nav"; if( e(stickyNav).length && e(navbar).length ){ var sticky = e(stickyNav).offset().top; if (window.pageYOffset > sticky) { e(navbar).addClass("sticky"); }else{ e(navbar).removeClass("sticky"); } } }; // STICKY SIDEBAR n.stickyPostContent = function () { if(e(window).width() > 1024){ e(".sticky-component-1,.sticky-component-2, .widget-area").theiaStickySidebar({ additionalMarginTop: 30 }); } e(".sticky-component-2, .widget-area").theiaStickySidebar({ additionalMarginTop: 30 }); }; // Sticky scroll to top n.stickyScrollToTop = function(){ var navbar = document.getElementById("blook-site-navbar"); var navbarOffset = navbar.offsetTop + 300; if( window.pageYOffset > navbarOffset){ e("#scroll-top").addClass("show"); }else{ e("#scroll-top").removeClass("show"); } }; n.scrollToTop = function() { e("#scroll-top").on("click",function(){ e("html,body").animate({ scrollTop: 0 },1000); return false; }); }; n.searchTrendingOnClick = function() { e("#navbar-search, #trending").on("click",function(){ e("html,body").animate({ scrollTop: e('#masthead').height() },1000); return false; }); e('.trending-box-skip-end').focus(function(){ e('#trending-close').focus(); }); }; e(window).on('load', function () { e('#status').fadeOut(); e('#preloader').delay(350).fadeOut('slow'); e('body').delay(350).css({ 'overflow': 'visible' }); }); e(document).ready(function () { n.breakingNews(); n.magnificPopUp(); n.minHeight(); n.mobileMenu(); n.navigation(); n.PostLoad(); n.scrollToTop(); n.slider(); n.stickyPostContent(); n.searchTrendingOnClick(); }); e(window).scroll(function () { n.breakingNews(); n.progressBar(); n.stickyNav(); n.stickyScrollToTop(); }); e(window).resize(function(){ n.minHeight(); n.stickyPostContent(); }); })(jQuery);