jQuery(document).ready(function ($) {
"use strict";
$(window).load(function () {
$("body").addClass("page-loaded");
});
// Hide Comments
$('.dolpa-no-comment .booster-block.booster-ratings-block, .dolpa-no-comment .comment-form-ratings, .dolpa-no-comment .twp-star-rating').hide();
// Hide pagination
if( $('html').hasClass('js') ){
$('.pagination-no-js').remove();
}
// AOS
AOS.init({
duration: 800,
});
$('.tooltips').append("");
$(".tooltips").mouseenter(function(){
$(this).find('span').empty().append($(this).attr('data-tooltip'));
});
// Background
var pageSection = $(".data-bg");
pageSection.each(function (indx) {
if ($(this).attr("data-background")) {
$(this).css("background-image", "url(" + $(this).data("background") + ")");
}
});
$('.bg-image').each(function () {
var src = $(this).children('img').attr('src');
$(this).css('background-image', 'url(' + src + ')').children('img').hide();
});
// Content Gallery Start
var i = 1;
$('.entry-content .wp-block-gallery ').each(function () {
$(this).attr('gallery-data', 'gallery-num-' + i);
$(this).addClass('gallery-data-slick');
$(this).addClass('gallery-data-gallery-num-' + i);
i++;
var k = 0;
$(this).find('.blocks-gallery-item').each(function () {
$(this).attr('gallery-index', k);
k++;
});
});
var j = 1;
$('.footer-galleries .wp-block-gallery ').each(function () {
$(this).append('
');
$(this).addClass('gallery-num-' + j);
j++;
$(this).addClass('dolpa-slick-dactivated');
});
$('.gallery-data-slick .blocks-gallery-item a').click(function (event) {
event.preventDefault();
});
$('.gallery-data-slick .blocks-gallery-item').click(function () {
if (!$(this).closest('.gallery-data-slick').hasClass('columns-1')) {
$('html').attr('style', 'margin: 0; height: 100%; overflow: hidden');
var galid = $(this).closest('.gallery-data-slick').attr('gallery-data');
$('.' + galid).addClass('gallery-show fullscreen');
if ($('.' + galid).hasClass('dolpa-slick-dactivated')) {
$('.' + galid + ' .blocks-gallery-grid').slick({
slidesToShow: 1,
slidesToScroll: 1,
fade: true,
autoplay: false,
autoplaySpeed: 8000,
infinite: true,
nextArrow: '',
prevArrow: '',
dots: false,
});
}
var galindex = $(this).attr('gallery-index');
$('.' + galid + ' .blocks-gallery-grid').slick('slickGoTo', galindex);
$('.' + galid).removeClass('dolpa-slick-dactivated');
}
});
$('.wp-block-gallery.columns-1').append('');
$('.wp-block-gallery.columns-1').append('');
$('.gallery-popup').click(function () {
$(this).closest('.wp-block-gallery').addClass('fullscreen');
$('html').attr('style', 'margin: 0; height: 100%; overflow: hidden');
$('.wp-block-gallery.columns-1 .blocks-gallery-grid').slick("slickSetOption", "speed", 500, !0);
});
$('.gallery-popup-close').click(function () {
$(this).closest('.wp-block-gallery').removeClass('fullscreen gallery-show');
$('html').attr('style', '');
$('.wp-block-gallery.columns-1 .blocks-gallery-grid').slick("slickSetOption", "speed", 500, !0);
});
// Content Gallery End
// Widget Gallery Start
$('.widget_media_gallery a').click(function (event) {
event.preventDefault();
});
var k = 1;
$('.widget_media_gallery').each(function () {
if (!$(this).find('.gallery').hasClass('gallery-columns-1')) {
$(this).attr('gallery-id', 'gallery-' + k);
var gallhtml = $(this).find('.gallery').html();
$('.widget-footer-galleries').append('');
var l = 0;
$(this).find('.gallery-item').each(function () {
$(this).attr('index-item', l);
l++;
});
k++;
}
if ($(this).find('.gallery').hasClass('gallery-columns-1')) {
$(this).append('');
$(this).append('');
}
});
$('.footer-gallery-main a').click(function (event) {
event.preventDefault();
});
$('figure.gallery-item').click(function () {
if (!$(this).closest('.gallery').hasClass('gallery-columns-1')) {
$('html').attr('style', 'margin: 0; height: 100%; overflow: hidden');
}
var clickedgal = $(this).closest('.widget_media_gallery').attr('gallery-id');
$('.footer-' + clickedgal).closest('.footer-gallery-main').addClass('fullscreen');
if (!$('.footer-' + clickedgal).hasClass('widget-slider-active')) {
$('.footer-' + clickedgal).addClass('widget-slider-active');
$('.footer-' + clickedgal).slick({
slidesToShow: 1,
slidesToScroll: 1,
fade: true,
autoplay: false,
autoplaySpeed: 8000,
infinite: true,
nextArrow: '',
prevArrow: '',
dots: false,
});
}
var galindex = $(this).attr('index-item');
$('.footer-' + clickedgal).slick('slickGoTo', galindex);
});
$('.gallery-popup-close').click(function () {
$(this).closest('.footer-gallery-main').removeClass('fullscreen gallery-show');
$('html').attr('style', '');
});
$('.widget.widget_media_gallery .gallery-popup').click(function () {
$(this).closest('.widget_media_gallery').addClass('fullscreen');
$('html').attr('style', 'margin: 0; height: 100%; overflow: hidden');
$('.gallery-columns-1').slick("slickSetOption", "speed", 500, !0);
});
$('.widget.widget_media_gallery .gallery-popup-close').click(function () {
$(this).closest('.widget_media_gallery').removeClass('fullscreen');
$('html').attr('style', '');
$('.gallery-columns-1').slick("slickSetOption", "speed", 500, !0);
});
// Widget Gallery End
// Scroll To
$(".scroll-content").click(function () {
$('html, body').animate({
scrollTop: $("#content").offset().top
}, 500);
});
// Rating disable
if (dolpa_custom.single_post == 1 && dolpa_custom.dolpa_ed_post_reaction) {
$('.tpk-single-rating').remove();
$('.tpk-comment-rating-label').remove();
$('.comments-rating').remove();
$('.tpk-star-rating').remove();
}
// Add Class on article
$('.theme-article.post').each(function () {
$(this).addClass('theme-article-loaded');
});
// Aub Menu Toggle
$('.submenu-toggle').click(function () {
$(this).toggleClass('button-toggle-active');
var currentClass = $(this).attr('data-toggle-target');
$(currentClass).toggleClass('submenu-toggle-active');
});
// Toggle Search
$('.navbar-control-search').click(function () {
$('.header-searchbar').toggleClass('header-searchbar-active');
$('#search-closer').focus();
});
$('.aside-search-js').click(function () {
$('.header-searchbar-area .search-field-default').focus();
});
// Header Search show
$('.header-searchbar').click(function () {
$('.header-searchbar').removeClass('header-searchbar-active');
});
$(".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');
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).hasClass('skip-link-search-top') ){
$('#search-closer').focus();
}
if ( ! $( this ).parents( '.header-searchbar' ).length ) {
$('.header-searchbar .search-field').focus();
$('.header-searchbar-area .search-field-default').focus();
}
}
} );
$(document).keyup(function(j) {
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);
}
}
});
// Action On Esc Button
$(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');
$('html').removeAttr('style');
setTimeout(function () {
$('.navbar-control-offcanvas').focus();
}, 300);
}
}
});
// Toggle Menu
$('.navbar-control-offcanvas').click(function () {
$(this).addClass('active');
$('html').attr('style', 'overflow-y: scroll; position: fixed; width: 100%; left: 0px; top: 0px;');
$('#offcanvas-menu').toggleClass('offcanvas-menu-active');
$('.button-offcanvas-close').focus();
});
// Offcanvas Close
$('.offcanvas-close .button-offcanvas-close').click(function () {
$('#offcanvas-menu').removeClass('offcanvas-menu-active');
$('.navbar-control-offcanvas').removeClass('active');
$('html').removeAttr('style');
setTimeout(function () {
$('.navbar-control-offcanvas').focus();
}, 300);
});
// Offcanvas Close
$('#offcanvas-menu').click(function () {
$('#offcanvas-menu').removeClass('offcanvas-menu-active');
$('.navbar-control-offcanvas').removeClass('active');
$('html').removeAttr('style');
});
$(".offcanvas-wraper").click(function (e) {
e.stopPropagation(); //stops click event from reaching document
});
// Offcanvas re focus on close button
$('input, a, button').on('focus', function () {
if ($('#offcanvas-menu').hasClass('offcanvas-menu-active')) {
if( $(this).hasClass('skip-link-off-canvas') ){
if( !$("#offcanvas-menu #social-nav-offcanvas").length == 0 ){
$("#offcanvas-menu #social-nav-offcanvas ul li:last-child a").focus();
}else if( !$("#offcanvas-menu #primary-nav-offcanvas").length == 0 ){
$("#offcanvas-menu #primary-nav-offcanvas ul li:last-child a").focus();
}
}
if ($(this).hasClass('skip-link-offcanvas') ) {
$('.button-offcanvas-close').focus();
}
}
});
$("ul.wp-block-gallery.columns-1, .wp-block-gallery.columns-1 .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,
});
});
// Template Carousel Slider
$(".template-carousel-slide").each(function () {
$(this).slick({
autoplay: true,
slidesToShow: 4,
slidesToScroll: 4,
autoplaySpeed: 8000,
infinite: true,
nextArrow: '',
prevArrow: '',
responsive: [
{
breakpoint: 991,
settings: {
slidesToShow: 3,
slidesToScroll: 3
}
},
{
breakpoint: 768,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
},
{
breakpoint: 480,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
]
});
});
//Template Slide Slider
$(".template-slide").each(function () {
$(this).slick({
slidesToShow: 1,
slidesToScroll: 1,
fade: true,
autoplay: false,
autoplaySpeed: 8000,
infinite: true,
nextArrow: '',
prevArrow: '',
dots: false
});
});
// Sticky Components
$('.widget-area, .post-content-share').theiaStickySidebar({
additionalMarginTop: 30
});
var pageSection = $(".data-bg");
pageSection.each(function (indx) {
if ($(this).attr("data-background")) {
$(this).css("background-image", "url(" + $(this).data("background") + ")");
}
});
// Masonry Grid
if ($('.archive-layout-masonry').length > 0) {
/*Default masonry animation*/
var grid;
var hidden = 'scale(0.5)';
var visible = 'scale(1)';
grid = $('.archive-layout-masonry').imagesLoaded(function () {
grid.masonry({
itemSelector: '.theme-article',
hiddenStyle: {
transform: hidden,
opacity: 0
},
visibleStyle: {
transform: visible,
opacity: 1
}
});
});
}
// Widget Tab
$('.twp-nav-tabs .tab').on('click', function (event) {
var tabid = $(this).attr('id');
$(this).closest('.tabbed-container').find('.tab').removeClass('active');
$(this).addClass('active');
$(this).closest('.tabbed-container').find('.tab-pane').removeClass('active');
$('#content-' + tabid).addClass('active');
});
// Scroll TO Top Hide & show
$(window).scroll(function () {
if ($(window).scrollTop() > $(window).height() / 2) {
$(".scroll-up").fadeIn(300);
} else {
$(".scroll-up").fadeOut(300);
}
});
// Scroll to Top on Click
$('.scroll-up').click(function () {
$("html, body").animate({
scrollTop: 0
}, 700);
return false;
});
$(window).scroll(function () {
if ($(window).scrollTop() > $(window).height() / 2) {
$(".scroll-up").fadeIn(300);
} else {
$(".scroll-up").fadeOut(300);
}
});
// Scroll to Top on Click
$('.scroll-up').click(function () {
$("html, body").animate({
scrollTop: 0
}, 700);
return false;
});
});
/* -----------------------------------------------------------------------------------------------
Intrinsic Ratio Embeds
--------------------------------------------------------------------------------------------------- */
var dolpa = dolpa || {},
$ = jQuery;
var $dolpa_doc = $(document),
$dolpa_win = $(window),
viewport = {};
viewport.top = $dolpa_win.scrollTop();
viewport.bottom = viewport.top + $dolpa_win.height();
dolpa.instrinsicRatioVideos = {
init: function () {
dolpa.instrinsicRatioVideos.makeFit();
$dolpa_win.on('resize fit-videos', function () {
dolpa.instrinsicRatioVideos.makeFit();
});
},
makeFit: function () {
var vidSelector = "iframe, object, video";
$(vidSelector).each(function () {
var $dolpa_video = $(this),
$dolpa_container = $dolpa_video.parent(),
dolpa_iTargetWidth = $dolpa_container.width();
// Skip videos we want to ignore
if ($dolpa_video.hasClass('intrinsic-ignore') || $dolpa_video.parent().hasClass('intrinsic-ignore')) {
return true;
}
if (!$dolpa_video.attr('data-origwidth')) {
// Get the video element proportions
$dolpa_video.attr('data-origwidth', $dolpa_video.attr('width'));
$dolpa_video.attr('data-origheight', $dolpa_video.attr('height'));
}
// Get ratio from proportions
var dolpa_ratio = dolpa_iTargetWidth / $dolpa_video.attr('data-origwidth');
// Scale based on ratio, thus retaining proportions
$dolpa_video.css('width', dolpa_iTargetWidth + 'px');
$dolpa_video.css('height', ($dolpa_video.attr('data-origheight') * dolpa_ratio) + 'px');
});
}
};
$dolpa_doc.ready(function () {
dolpa.instrinsicRatioVideos.init(); // Retain aspect ratio of videos on window resize
});