if(typeof RB_VIEWPORT_OBSERVER==='undefined'){
var RB_VIEWPORT_OBSERVER={
observe: function (){
return null;
},
unobserve: function (){},
destroy: function (){},
refreshAll: function (){},
has: function (){
return false;
},
getActiveIds: function (){
return [];
},
destroyAll: function (){},
};}
var FOXIZ_MAIN_SCRIPT=(function (Module, $){
'use strict';
Module.initParams=function (){
this.yesStorage=this.isStorageAvailable();
this.themeSettings=typeof foxizParams!=='undefined' ? foxizParams:{};
this.galleriesData=typeof foxizGalleriesData!=='undefined' ? foxizGalleriesData:{};
this.ajaxURL=typeof foxizCoreParams!=='undefined' ? foxizCoreParams.ajaxurl||'':'';
this.ajaxData={};
this.siteAccessFlag=false;
this._document=$(document);
this._body=$('body');
this._window=$(window);
this.html=$('html, body');
this.outerHTML=$('html');
this.iOS=/(iPad|iPhone|iPod)/g.test(navigator.userAgent);
this.sticky={};
this.eSticky={};
this.YTPlayers={};
this.articleData=[];
this.readIndicatorPercent=0;
this.isProgress=false;
this.readIndicator=$('#reading-progress');
this.popupNewsletterEl=$('#rb-popup-newsletter');
this.personalizeUID =
typeof FOXIZ_CORE_SCRIPT!=='undefined'&&FOXIZ_CORE_SCRIPT.personalizeUID!==undefined
? FOXIZ_CORE_SCRIPT.personalizeUID
: 'u0';
this._scrollHandlers={};
this._scrollTicking=false;
this._scrollListenerActive=false;
};
Module._onScroll=function (){
const self=this;
if(!self._scrollTicking){
self._scrollTicking=true;
requestAnimationFrame(function (){
const handlers=self._scrollHandlers;
for (const id in handlers){
if(handlers[id]) handlers[id]();
}
self._scrollTicking=false;
});
}};
Module.addScrollHandler=function (id, handler){
this._scrollHandlers[id]=handler;
if(!this._scrollListenerActive){
this._scrollListenerActive=true;
window.addEventListener('scroll', this._onScroll.bind(this), { passive: true });
}};
Module.removeScrollHandler=function (id){
delete this._scrollHandlers[id];
};
Module.init=function (){
this.initParams();
this.syncLayoutLike();
this.topSpacing();
this.siteAccessDetector();
this.headerDropdown();
this.mobileCollapse();
this.initSubMenuPos();
this.privacyTrigger();
this.popupNewsletter();
this.documentClick();
this.backTop();
this.readIndicatorInit();
this.fontResizer();
this.breakingNews();
this.sequentialGalleryDisplay();
this.sliders();
this.carousels();
this.liveSearch();
this.personalizeBlocks();
this.personalizeCategories();
this.likeToggle();
this.singleInfiniteLoadNext();
this.loginPopup();
this.popupTemplate();
this.loadYoutubeIframe();
this.browserResize();
this.footerSlideUp();
this.cartNotification();
this.newsNotification();
this.tocToggle();
this.delayLoad();
this.showPostComment();
this.replyReview();
this.paginationNextPrev();
this.paginationLoadMore();
this.paginationInfinite();
this.productQuantity();
this.readingCollect();
this.liveBlog();
this.neededReloadFuncs();
};
Module.neededReloadFuncs=function (){
this.hoverTipsy();
this.scrollToComment();
this.usersRating();
this.singleGallery();
this.floatingVideo();
this.videoPreview();
this.floatingVideoRemove();
this.scrollTableContent();
this.singleScrollRefresh();
this.playerAutoPlay();
this.hoverEffects();
this.highlightShares();
this.galleryLightbox();
this.singleFeaturedLightbox();
this.accordion();
this.resIframeClassic();
this.taxBasedAccordion();
this.scrollBarSlider();
};
Module.reInitAll=function (){
this._window.trigger('load');
this.syncLayoutLike();
if(typeof FOXIZ_PERSONALIZE!=='undefined'){
FOXIZ_PERSONALIZE.syncPersonalizeLayout();
}
if(typeof RB_REACTION!=='undefined'){
RB_REACTION.syncReactLayout();
}
this.neededReloadFuncs();
RB_VIEWPORT_OBSERVER.refreshAll();
};
Module.reloadBlockFunc=function (){
this._window.trigger('load');
if(typeof FOXIZ_PERSONALIZE!=='undefined'){
FOXIZ_PERSONALIZE.syncLayoutBookmarks();
}
this.syncLayoutLike();
this.videoPreview();
this.hoverTipsy();
RB_VIEWPORT_OBSERVER.refreshAll();
};
Module.initElementor=function (){
if('undefined'!==typeof initDarkMode&&!FOXIZ_MAIN_SCRIPT.editorDarkModeInit){
FOXIZ_MAIN_SCRIPT.editorDarkModeInit=true;
initDarkMode();
}
FOXIZ_MAIN_SCRIPT.breakingNews();
FOXIZ_MAIN_SCRIPT.carousels();
FOXIZ_MAIN_SCRIPT.sliders();
};
Module.isRTL=function (){
return this._body.hasClass('rtl');
};
Module.animationFrame=function (callback){
const func =
window.requestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame ||
this.animationFrameFallback;
func.call(window, callback);
};
Module.animationFrameFallback=function (callback){
window.setTimeout(callback, 1000 / 60);
};
Module.isStorageAvailable=function (){
let storage;
try {
storage=window['localStorage'];
storage.setItem('__rbStorageSet', 'x');
storage.removeItem('__rbStorageSet');
return true;
} catch (e){
return false;
}};
Module.setStorage=function (key, data){
this.yesStorage&&localStorage.setItem(key, typeof data==='string' ? data:JSON.stringify(data));
};
Module.getStorage=function (key, defaultValue){
if(!this.yesStorage) return null;
const data=localStorage.getItem(key);
if(data===null) return defaultValue;
try {
return JSON.parse(data);
} catch (e){
return data;
}};
Module.deleteStorage=function (key){
this.yesStorage&&localStorage.removeItem(key);
};
Module.SetTTLStorage=function (id, value, ttl){
const data={
value: value,
ttl: Date.now() + ttl * 3600000,
};
this.setStorage(id, data);
};
Module.getTTLStorage=function (id){
const data=this.getStorage(id);
if(data&&Date.now() <=data.ttl){
return data.value;
}
this.deleteStorage(id);
return null;
};
Module.delayLoad=function (){
const self=this;
setTimeout(function (){
self.stickyNavBar();
self.stickyHeaderBuilder();
}, 100);
};
Module.browserResize=function (){
const self=this;
self._window.on('resize', function (){
self.topSpacing();
self.calcSubMenuPos();
});
};
Module.hoverTipsy=function (){
if(!$.fn.rbTipsy){
return false;
}
this._body.find('[data-copy]').rbTipsy({
title: 'data-copy',
fade: true,
opacity: 1,
trigger: 'hover',
gravity: 's',
});
if(window.innerWidth > 1024){
this._body.find('#site-header [data-title]').rbTipsy({
title: 'data-title',
fade: true,
opacity: 1,
trigger: 'hover',
gravity: 'n',
});
this._body.find('.site-wrap [data-title]').rbTipsy({
title: 'data-title',
fade: true,
opacity: 1,
trigger: 'hover',
gravity: 's',
});
}};
Module.fontResizer=function (){
const self=this;
let size=self.yesStorage ? sessionStorage.getItem('rubyResizerStep'):1;
self._body.on('click', '.font-resizer-trigger', function (e){
e.preventDefault();
e.stopPropagation();
size++;
if(3 < size){
size=1;
self._body.removeClass('medium-entry-size big-entry-size');
}else{
if(2==size){
self._body.addClass('medium-entry-size').removeClass('big-entry-size');
}else{
self._body.addClass('big-entry-size').removeClass('medium-entry-size');
}}
self.yesStorage&&sessionStorage.setItem('rubyResizerStep', size);
});
};
Module.hoverEffects=function (){
const selectors=$('.effect-fadeout');
if(selectors.length===0){
return;
}
selectors
.off('mouseenter mouseleave')
.on('mouseenter', function (e){
e.stopPropagation();
const target=$(this);
if(!target.hasClass('activated')){
target.addClass('activated');
}})
.on('mouseleave', function (){
$(this).removeClass('activated');
});
};
Module.videoPreview=function (){
let playPromise;
$('.preview-trigger')
.on('mouseenter', function (){
const target=$(this);
const wrap=target.find('.preview-video');
if(!wrap.hasClass('video-added')){
const video =
'<video preload="auto" muted loop><source src="' +
wrap.data('source') +
'" type="' +
wrap.data('type') +
'"></video>';
wrap.append(video).addClass('video-added');
}
target.addClass('show-preview');
wrap.css('z-index', 3);
const el=target.find('video')[0];
if(el){
playPromise=el.play();
}})
.on('mouseleave', function (){
const target=$(this);
target.find('.preview-video').css('z-index', 1);
const el=target.find('video')[0];
if(el&&playPromise!==undefined){
playPromise
.then((_)=> {
el.pause();
})
.catch();
}});
};
Module.playerAutoPlay=function (){
const self=this;
const items=$('.is-autoplay');
const nonResIframe=$('.entry-content > iframe');
if(items!=null&&items.length > 0){
items.each(function (index){
const el=$(this);
if(!el.hasClass('is-loaded')){
RB_VIEWPORT_OBSERVER.observe('iframe_' + index, {
element: el,
offset: '70%',
once: true,
handler: function (){
const iframe=el.find('iframe');
self.initAutoPlay(iframe);
el.addClass('is-loaded');
},
});
}});
}
if(nonResIframe!=null&&nonResIframe.length > 0){
nonResIframe.each(function (){
const el=$(this);
if(!el.hasClass('is-loaded')){
const iURL=el.attr('src');
if(iURL.indexOf('youtube.com') > 0 ||
iURL.indexOf('youtu.be') > 0 ||
iURL.indexOf('vimeo.com') > 0
){
el.wrap('<div class="rb-ires is-loaded"></div>');
}}
});
}};
Module.initAutoPlay=function (item){
if(item.length > 0&&undefined!==item[0]){
const src=item[0].src;
if(src.indexOf('?') > -1){
item[0].src +='&autoplay=1';
}else{
item[0].src +='?autoplay=1';
}}
};
Module.tocToggle=function (){
this._document.on('click', '.toc-toggle', function (e){
e.preventDefault();
e.stopPropagation();
const target=$(this);
const content=target.parents('.ruby-table-contents').find('.toc-content');
content.toggle(200);
target.toggleClass('activate');
});
};
Module.headerDropdown=function (){
const self=this;
$('.more-trigger').on('click', function (e){
e.preventDefault();
e.stopPropagation();
self.calcSubMenuPos();
const target=$(this);
const holder=target.parents('.header-wrap').find('.more-section-outer');
if(!holder.hasClass('dropdown-activated')){
self._body.find('.dropdown-activated').removeClass('dropdown-activated');
holder.addClass('dropdown-activated');
}else{
holder.removeClass('dropdown-activated');
}
if(target.hasClass('search-btn')){
setTimeout(function (){
holder.find('input[type="text"]').focus();
}, 150);
}
return false;
});
$('.search-trigger').on('click', function (e){
e.preventDefault();
e.stopPropagation();
const holder=$(this).parent('.header-dropdown-outer');
if(!holder.hasClass('dropdown-activated')){
self._body.find('.dropdown-activated').removeClass('dropdown-activated');
holder.addClass('dropdown-activated');
setTimeout(function (){
holder.find('input[type="text"]').focus();
}, 150);
}else{
holder.removeClass('dropdown-activated');
}
return false;
});
$('.dropdown-trigger').on('click', function (e){
e.preventDefault();
e.stopPropagation();
const holder=$(this).parent('.header-dropdown-outer');
if(!holder.hasClass('dropdown-activated')){
self._body.find('.dropdown-activated').removeClass('dropdown-activated');
holder.addClass('dropdown-activated');
}else{
holder.removeClass('dropdown-activated');
}});
};
Module.topSpacing=function (){
const self=this;
if(self._body.hasClass('top-spacing')){
const height=$('.top-site-ad').outerHeight();
$('.site-outer').css('margin-top', height);
}};
Module.documentClick=function (){
const self=this;
const wrapper=$('.more-section-outer, .header-dropdown-outer, .mobile-collapse, .mfp-wrap');
const inlineSearchForm=$('.is-form-layout');
document.addEventListener('click', function (e){
if(!wrapper.is(e.target)&&wrapper.has(e.target).length===0){
wrapper.removeClass('dropdown-activated');
self.outerHTML.removeClass('collapse-activated');
}
if(!inlineSearchForm.is(e.target)&&inlineSearchForm.has(e.target).length===0){
inlineSearchForm.find('.live-search-response').fadeOut(500);
}});
};
Module.initSubMenuPos=function (){
const self=this;
let trigger=false;
setTimeout(function (){
self.calcSubMenuPos();
}, 1000);
$('.menu-has-child-mega').on('mouseenter', function (){
if(!trigger){
self.calcSubMenuPos();
}
trigger=true;
});
};
Module.calcSubMenuPos=function (){
if(window.outerWidth < 1025){
return false;
}
const self=this;
const megaParents=$('.menu-has-child-mega');
const headerWrapper=$('#site-header');
if(megaParents.length > 0){
megaParents.each(function (){
const item=$(this);
item.find('.mega-dropdown').css({
width: self._body.width(),
left: -item.offset().left,
});
item.addClass('mega-menu-loaded');
});
}
if(headerWrapper.length > 0){
let headerLeftOffset=headerWrapper.offset().left;
let headerWidth=headerWrapper.width();
let headerRightOffset=headerLeftOffset + headerWidth;
const flexDropdown=$('.flex-dropdown');
const subElements=$('ul.sub-menu');
if(subElements.length > 0){
subElements.each(function (){
const item=$(this);
let itemLeftOffset=item.offset().left;
let itemRightOffset=itemLeftOffset + item.width() + 100;
if(itemRightOffset > headerRightOffset){
item.addClass('left-direction');
}});
}
if(flexDropdown.length > 0){
flexDropdown.each(function (){
const item=$(this);
const parentItem=item.parent();
if(parentItem.hasClass('is-child-wide')||item.hasClass('mega-has-left')){
return;
}
const itemWidth=item.width();
const itemHalfWidth=itemWidth / 2;
const parentItemOffset=parentItem.offset().left;
const parentHalfWidth=parentItem.width() / 2;
const parentItemCenterOffset=parentItemOffset + parentHalfWidth;
const rightSpacing=headerRightOffset - parentItemCenterOffset;
const leftSpacing=parentItemCenterOffset - headerLeftOffset;
if(itemWidth >=headerWidth){
item.css({
width: headerWidth - 2,
left: -parentItemOffset,
});
}else if(itemHalfWidth > rightSpacing){
item.css({
right: -rightSpacing + parentHalfWidth + 1,
left: 'auto',
});
}else if(itemHalfWidth > leftSpacing){
item.css({
left: -leftSpacing + parentHalfWidth + 1,
right: 'auto',
});
}else{
item.css({
right: 'auto',
left: -itemHalfWidth + parentHalfWidth,
});
}});
}}
};
Module.stickyNavBar=function (){
const self=this;
if(self._body.hasClass('elementor-editor-active')){
return false;
}
self.sticky.section=$('#sticky-holder');
self.sticky.outer=$('#navbar-outer');
if((!self._body.hasClass('is-mstick')&&!self._body.hasClass('yes-tstick')) ||
self.sticky.outer.length < 1 ||
self.sticky.section.length < 1
){
return false;
}
self.sticky.smartSticky = !!self._body.hasClass('is-smart-sticky');
self.sticky.isSticky=false;
self.sticky.lastScroll=0;
if(self._body.hasClass('yes-tstick')){
self.sticky.isTitleSticky=true;
}else{
self.sticky.isTitleSticky=0;
}
self.sticky.additionalOffset=200;
if(window.innerWidth > 1024){
if(self.sticky.isTitleSticky){
self.sticky.additionalOffset=450;
}else{
self.sticky.additionalOffset=0;
}}
if(self._body.hasClass('admin-bar')){
self.sticky.adminBarSpacing=32;
}else{
self.sticky.adminBarSpacing=0;
}
self.sticky.topOffset=self.sticky.section.offset().top;
self.sticky.stickySectionHeight=self.sticky.section.outerHeight();
self.sticky.outer.css('min-height', self.sticky.outer.outerHeight());
self.sticky.activatePos =
self.sticky.topOffset + 1 + self.sticky.stickySectionHeight + self.sticky.additionalOffset;
self.sticky.deactivePos=self.sticky.topOffset - self.sticky.adminBarSpacing + self.sticky.additionalOffset;
if(self.sticky.smartSticky){
self.addScrollHandler('stickyNav', self.initSmartStickyNavBar.bind(self));
}else{
self.addScrollHandler('stickyNav', self.initStickyNavBar.bind(self));
}
self._window.on('unstickMenu', function (){
self.sticky.outer.css('min-height', self.sticky.outer.outerHeight());
self.sticky.stickySectionHeight=self.sticky.section.outerHeight();
self.sticky.topOffset=self.sticky.section.offset().top;
self.sticky.activatePos =
self.sticky.topOffset + 1 + self.sticky.stickySectionHeight + self.sticky.additionalOffset;
self.sticky.deactivePos =
self.sticky.topOffset - self.sticky.adminBarSpacing + self.sticky.additionalOffset;
});
};
Module.initStickyNavBar=function (){
const self=this;
const scroll=self._window.scrollTop();
if(!self.sticky.isSticky&&scroll > self.sticky.activatePos){
self.sticky.isSticky=true;
self._body.addClass('stick-animated sticky-on');
self.sticky.stickAnimatedTimeout=setTimeout(function (){
self._body.removeClass('stick-animated');
}, 200);
}else if(self.sticky.isSticky&&scroll <=self.sticky.deactivePos){
self.sticky.isSticky=false;
self._body.removeClass('sticky-on stick-animated');
self._window.trigger('unstickMenu');
}};
Module.initSmartStickyNavBar=function (){
const self=this;
const scroll=self._window.scrollTop();
if(!self.sticky.isSticky&&scroll > self.sticky.activatePos&&scroll < self.sticky.lastScroll){
self.sticky.isSticky=true;
self._body.addClass('stick-animated sticky-on');
self.sticky.stickAnimatedTimeout=setTimeout(function (){
self._body.removeClass('stick-animated');
}, 200);
}else if(self.sticky.isSticky&&(scroll <=self.sticky.deactivePos||scroll > self.sticky.lastScroll)){
self.sticky.isSticky=false;
self._body.removeClass('sticky-on stick-animated');
if(scroll <=self.sticky.deactivePos){
self._window.trigger('unstickESection');
}}
self.sticky.lastScroll=scroll;
};
Module.stickyHeaderBuilder=function (){
const self=this;
if(self._body.hasClass('elementor-editor-active')){
return false;
}
let stickySection=$('.header-template .e-section-sticky').first();
const hasTitleSticky=$('body.single-post #s-title-sticky').first();
if(stickySection.length < 1){
return false;
}
if(hasTitleSticky.length > 0){
self._body.addClass('yes-tstick');
self.eSticky.isTitleSticky=true;
}else{
self.eSticky.isTitleSticky=0;
}
self.eSticky.additionalOffset=200;
if(window.innerWidth > 1024){
if(self.eSticky.isTitleSticky){
self.eSticky.additionalOffset=450;
}else{
self.eSticky.additionalOffset=0;
}}
self.eSticky.smartSticky = !!stickySection.hasClass('is-smart-sticky');
if(window.innerWidth <=1024){
stickySection.removeClass('e-section-sticky');
stickySection=$('#header-template-holder').addClass('e-section-sticky');
}
self.eSticky.section=stickySection;
self.eSticky.outer=stickySection.parent();
self.eSticky.adminBarSpacing=0;
self.eSticky.isSticky=false;
self.eSticky.lastScroll=0;
self.eSticky.stickySectionHeight=stickySection.outerHeight();
self.eSticky.topOffset=stickySection.offset().top;
if(self._body.hasClass('admin-bar')){
self.eSticky.adminBarSpacing=32;
}
self.eSticky.outer.css('min-height', self.eSticky.outer.outerHeight());
self.eSticky.activatePos =
self.eSticky.topOffset + 1 + self.eSticky.stickySectionHeight + self.eSticky.additionalOffset;
self.eSticky.deactivePos =
self.eSticky.topOffset - self.eSticky.adminBarSpacing + self.eSticky.additionalOffset;
if(self.eSticky.smartSticky){
self.addScrollHandler('stickyESection', self.initSmartStickyESection.bind(self));
}else{
self.addScrollHandler('stickyESection', self.initStickyESection.bind(self));
}
self._window.on('unstickESection', function (){
self.eSticky.outer.css('min-height', self.eSticky.outer.outerHeight());
self.eSticky.stickySectionHeight=self.eSticky.section.outerHeight();
self.eSticky.topOffset=self.eSticky.section.offset().top;
self.eSticky.activatePos =
self.eSticky.topOffset + 1 + self.eSticky.stickySectionHeight + self.eSticky.additionalOffset;
self.eSticky.deactivePos =
self.eSticky.topOffset - self.eSticky.adminBarSpacing + self.eSticky.additionalOffset;
});
};
Module.initStickyESection=function (){
const self=this;
const scroll=self._window.scrollTop();
if(!self.eSticky.isSticky&&scroll > self.eSticky.activatePos){
self.eSticky.isSticky=true;
self._body.addClass('stick-animated sticky-on');
self.eSticky.stickAnimatedTimeout=setTimeout(function (){
self._body.removeClass('stick-animated');
}, 200);
}else if(self.eSticky.isSticky&&scroll <=self.eSticky.deactivePos){
self.eSticky.isSticky=false;
self._body.removeClass('sticky-on stick-animated');
self._window.trigger('unstickESection');
}};
Module.initSmartStickyESection=function (){
const self=this;
const scroll=self._window.scrollTop();
if(!self.eSticky.isSticky&&scroll > self.eSticky.activatePos&&scroll < self.eSticky.lastScroll){
self.eSticky.isSticky=true;
self._body.addClass('stick-animated sticky-on');
self.eSticky.stickAnimatedTimeout=setTimeout(function (){
self._body.removeClass('stick-animated');
}, 200);
}else if(self.eSticky.isSticky&&(scroll <=self.eSticky.deactivePos||scroll > self.eSticky.lastScroll)){
self.eSticky.isSticky=false;
self._body.removeClass('sticky-on stick-animated');
if(scroll <=self.eSticky.deactivePos){
self._window.trigger('unstickESection');
}}
self.eSticky.lastScroll=scroll;
};
Module.mobileCollapse=function (){
const self=this;
const $mobileMenuTrigger=$('.mobile-menu-trigger');
const $outerHTML=self.outerHTML;
const $mobileSearchForm=$outerHTML.find('.mobile-search-form input[type="text"]');
$mobileMenuTrigger.on('click', function (e){
e.preventDefault();
e.stopPropagation();
const target=$(this);
if(target.hasClass('mobile-search-icon')){
setTimeout(function (){
$mobileSearchForm.focus();
}, 100);
}
const isCollapseActivated=$outerHTML.hasClass('collapse-activated');
$outerHTML.toggleClass('collapse-activated', !isCollapseActivated);
});
};
Module.privacyTrigger=function (){
const self=this;
$('#privacy-trigger').on('click', function (e){
e.preventDefault();
e.stopPropagation();
self.setStorage('RubyPrivacyAllowed', '1');
$('#rb-privacy').slideUp(200, function (){
$(this).remove();
});
return false;
});
};
Module.backTop=function (){
if(this._body.hasClass('is-backtop')){
$().UItoTop({
text: '<i class="rbi rbi-darrow-top"></i>',
});
}};
Module.loginPopup=function (){
const self=this;
const form=$('#rb-user-popup-form');
if(form.length < 1){
return false;
}
this._document.on('click', '.login-toggle', (e)=> {
e.preventDefault();
e.stopPropagation();
$.magnificPopup.open({
type: 'inline',
preloader: false,
removalDelay: 400,
showCloseBtn: true,
closeBtnInside: true,
closeOnBgClick: false,
items: {
src: form,
type: 'inline',
},
mainClass: 'rb-popup-center',
closeMarkup: '<span class="close-popup-btn mfp-close"><span class="close-icon"></span></span>',
fixedBgPos: true,
fixedContentPos: true,
callbacks: { open: ()=> self.reloadCaptchaPopups() },
});
});
};
Module.popupTemplate=function (){
const templateCache={};
this._document.on('click', '.popup-trigger-btn', (e)=> {
e.preventDefault();
e.stopPropagation();
const target=$(e.target);
const templateID=target.data('trigger')||'';
const position=target.data('position')||'';
if(!templateCache[templateID]){
const template=$(`#tmpl-${templateID}`);
if(template.length===0){
return;
}
templateCache[templateID]=template.html();
}
$.magnificPopup.open({
type: 'inline',
preloader: false,
removalDelay: 400,
showCloseBtn: true,
closeBtnInside: true,
closeOnBgClick: true,
allowHTMLInTemplate: true,
items: {
src: templateCache[templateID],
type: 'inline',
},
mainClass: `is-template-popup popup-${templateID} ${position}`,
closeMarkup: '<span class="close-popup-btn mfp-close"><span class="close-icon"></span></span>',
fixedBgPos: true,
fixedContentPos: true,
callbacks: { open: ()=> self.reloadCaptchaPopups() },
});
});
};
Module.popupNewsletter=function (){
const self=this;
if(self.popupNewsletterEl.length > 0){
const display=self.popupNewsletterEl.data('display');
self.newsletterExpired=self.popupNewsletterEl.data('expired');
self.newsletterDisplayOffset=self.popupNewsletterEl.data('offset');
const delay=self.popupNewsletterEl.data('delay');
const oldExpired=self.getStorage('RubyNewsletterExpired');
if(self.newsletterExpired===0){
self.deleteStorage('RubyNewsletter');
}
if(!oldExpired||self.newsletterExpired!==oldExpired){
self.setStorage('RubyNewsletterExpired', self.newsletterExpired);
self.deleteStorage('RubyNewsletter');
}
if(!self.getTTLStorage('RubyNewsletter')){
if(!display||'scroll'===display){
self.addScrollHandler('newsletter', self.scrollPopupNewsletter.bind(self));
}else{
setTimeout(function (){
self.popupNewsletterInit();
}, delay);
}}
}};
Module.scrollPopupNewsletter=function (){
const self=this;
if(!self.newsletterPopupFlag&&self._window.scrollTop() > self.newsletterDisplayOffset){
self.newsletterPopupFlag=true;
self.removeScrollHandler('newsletter');
self.popupNewsletterInit();
}};
Module.popupNewsletterInit=function (){
const self=this;
if(self.siteAccessFlag){
return;
}
if(!self.popupNewsletterEl.hasClass('is-pos-fixed')){
$.magnificPopup.open({
type: 'inline',
preloader: false,
closeBtnInside: true,
removalDelay: 400,
showCloseBtn: true,
closeOnBgClick: false,
disableOn: 1024,
items: {
src: '#rb-popup-newsletter',
type: 'inline',
},
mainClass: 'rb-popup-center',
fixedBgPos: true,
fixedContentPos: true,
closeMarkup: '<span class="close-popup-btn mfp-close"><span class="close-icon"></span></span>',
callbacks: {
open: ()=> self.reloadCaptchaPopups(),
close: function (){
if(self.siteAccessFlag){
return;
}
self.SetTTLStorage('RubyNewsletter', 1, self.newsletterExpired * 24);
},
},
});
}else{
self.popupNewsletterEl.removeClass('is-hidden');
setTimeout(()=> {
self.popupNewsletterEl.addClass('yes-show');
}, 10);
const closeBtn=self.popupNewsletterEl.find('.close-popup-btn');
closeBtn.on('click', function (){
self.SetTTLStorage('RubyNewsletter', 1, self.newsletterExpired * 24);
self.popupNewsletterEl.removeClass('yes-show');
setTimeout(()=> {
self.popupNewsletterEl.addClass('is-hidden');
}, 400);
});
}};
Module.footerSlideUp=function (){
const target=$('#footer-slideup');
if(target.length > 0){
const self=this;
self.footerSlideUpExpired=target.data('expired');
const delay=target.data('delay');
const oldExpired=self.getStorage('footerSlideUpExpired');
if(!oldExpired||self.footerSlideUpExpired!=oldExpired){
self.setStorage('footerSlideUpExpired', self.footerSlideUpExpired);
self.deleteStorage('footerSlideUp');
}
if(!self.getTTLStorage('footerSlideUp')){
setTimeout(function (){
self.footerSlideUpInit();
}, delay);
}
setTimeout(function (){
self.footerSlideUpToggle();
}, delay);
}};
Module.footerSlideUpToggle=function (){
const self=this;
$('.slideup-toggle')
.off('click')
.on('click', function (e){
e.preventDefault();
e.stopPropagation();
self.footerSlideUpInit();
return false;
});
};
Module.footerSlideUpInit=function (){
if(this._body.hasClass('yes-f-slideup')){
this._body.removeClass('yes-f-slideup');
this.SetTTLStorage('footerSlideUp', 1, this.footerSlideUpExpired * 24);
}else{
this._body.addClass('yes-f-slideup');
this.deleteStorage('footerSlideUp');
}};
Module.loadYoutubeIframe=function (){
const self=this;
const blockPlaylist=$('.yt-playlist');
if(blockPlaylist.length > 0){
const tag=document.createElement('script');
tag.src='//www.youtube.com/iframe_api';
const firstScriptTag=document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
}
window.onYouTubeIframeAPIReady=function (){
$('.yt-playlist').each(function (){
const target=$(this);
const iframe=target.find('.yt-player');
const videoID=target.data('id');
const blockID=target.data('block');
self.YTPlayers[blockID]=new YT.Player(iframe.get(0), {
height: '540',
width: '960',
videoId: videoID,
events: {
onReady: self.videoPlayToggle,
onStateChange: self.videoPlayToggle,
},
});
});
$('.plist-item').on('click', function (e){
e.preventDefault();
e.stopPropagation();
const target=$(this);
const wrapper=target.closest('.yt-playlist');
const currentBlockID=wrapper.data('block');
const videoID=target.data('id');
const title=target.find('.plist-item-title').text();
const meta=target.data('index');
Object.keys(self.YTPlayers).forEach(function (id){
self.YTPlayers[id].pauseVideo();
});
self.YTPlayers[currentBlockID].loadVideoById({
videoId: videoID,
});
wrapper.find('.yt-trigger').addClass('is-playing');
wrapper.find('.play-title').hide().text(title).fadeIn(200);
wrapper.find('.video-index').text(meta);
});
};};
Module.videoPlayToggle=function (){
const players=FOXIZ_MAIN_SCRIPT.YTPlayers;
$('.yt-trigger').on('click', function (e){
e.preventDefault();
e.stopPropagation();
const target=$(this);
const currentBlockID=target.closest('.yt-playlist').data('block');
const currentState=players[currentBlockID].getPlayerState();
const isPlaying=[1, 3].includes(currentState);
if(!isPlaying){
players[currentBlockID].playVideo();
target.addClass('is-playing');
}else{
players[currentBlockID].pauseVideo();
target.removeClass('is-playing');
}});
};
Module.showPostComment=function (){
const self=this;
this._document.on('click', '.smeta-sec .meta-comment', function (e){
e.stopPropagation();
const commentBtn=$('.show-post-comment');
if(commentBtn.length > 0){
self.html.animate({ scrollTop: commentBtn.offset().top }, 300);
commentBtn.trigger('click');
}});
this._document.on('click', '.show-post-comment', function (e){
e.preventDefault();
e.stopPropagation();
const target=$(this);
const wrap=target.parent();
target.fadeOut(200, function (){
target.remove();
wrap.find('.is-invisible').removeClass('is-invisible');
wrap.next('.comment-holder').removeClass('is-hidden');
});
});
};
Module.scrollTableContent=function (){
const self=this;
const behavior=self._body.hasClass('toc-smooth') ? 'smooth':'instant';
self._document.on('click', '.anchor-link', function (e){
e.stopPropagation();
const targetClass=$(this).data('index');
if(!targetClass) return;
let $scrollElement=$(`.${targetClass}`);
if(!$scrollElement.length){
const $parentContainer=$(this).closest('.s-ct');
if($parentContainer.length){
$scrollElement=$parentContainer.find('.restrict-box, .continue-reading-btn').first();
}}
if(!$scrollElement.length) return;
setTimeout(()=> {
window.scrollTo({
top: $scrollElement.offset().top,
behavior: behavior,
});
}, 10);
});
};
Module.scrollToComment=function (){
const self=this;
const hash=window.location.hash;
if(hash==='#respond'||hash.startsWith('#comment')){
const commentBtn=$('.show-post-comment').first();
if(commentBtn.length===0){
return;
}
self.html.animate({ scrollTop: commentBtn.offset().top - 200 }, 400);
commentBtn.trigger('click');
}};
Module.replyReview=function (){
this._document.on('click', '.comment-reply-link', function (){
const target=$(this);
const wrapper=target.parents('.rb-reviews-area');
const cancelLink=$('#cancel-comment-reply-link');
if(wrapper.length > 0){
wrapper.find('.rb-form-rating').addClass('is-hidden');
cancelLink.on('click', function (){
wrapper.find('.rb-form-rating').removeClass('is-hidden');
});
}});
};
Module.usersRating=function (){
const self=this;
const reviewsForm=self._body.find('.rb-reviews-form');
if(reviewsForm.length > 0){
reviewsForm.each(function (){
const reviewForm=$(this);
if(!reviewForm.hasClass('is-loaded')){
reviewForm.addClass('is-loaded');
const ratingForm=reviewForm.find('.rb-form-rating');
const selection=reviewForm.find('.rb-rating-selection');
const text=reviewForm.find('.rating-alert').html();
let ratingValue=null;
selection.val('');
selection.hide();
selection.before('<div class="rb-review-stars">\
<span>\
<a class="star" data-rating="1" href="#"><i class="rbi rbi-star-o"></i></a>\
<a class="star" data-rating="2" href="#"><i class="rbi rbi-star-o"></i></a>\
<a class="star" data-rating="3" href="#"><i class="rbi rbi-star-o"></i></a>\
<a class="star" data-rating="4" href="#"><i class="rbi rbi-star-o"></i></a>\
<a class="star" data-rating="5" href="#"><i class="rbi rbi-star-o"></i></a>\
</span>\
</div>'
);
ratingForm.on('click', 'a.star', function (e){
e.preventDefault();
e.stopPropagation();
const star=$(this);
ratingValue=star.data('rating');
star.siblings('a').removeClass('active');
star.addClass('active');
ratingForm.addClass('selected');
});
reviewForm.on('click', '#respond #submit', function (){
selection.val(ratingValue);
if(!selection.val()){
window.alert(text);
return false;
}});
}});
}};
Module.readIndicatorInit=function (){
const self=this;
if(!self._body.hasClass('single')||self.readIndicator.length < 1){
return false;
}
let content=$('.entry-content').first();
if(!content.length) return false;
self.indicatorTop=content.offset().top;
self.indicatorHeight=content.outerHeight(true) - self._window.height();
setTimeout(function (){
self.indicatorTop=content.offset().top;
self.indicatorHeight=content.outerHeight(true) - self._window.height();
}, 1000);
self.addScrollHandler('readIndicator', self.readIndicatorCalc.bind(self));
};
Module.readIndicatorCalc=function (){
const self=this;
const scroll=self._window.scrollTop();
self.readIndicatorPercent=Math.min(((scroll - self.indicatorTop) / self.indicatorHeight) * 100, 100);
if(self.readIndicatorPercent <=100){
self.readIndicator.css('width', self.readIndicatorPercent + '%');
}};
Module.breakingNews=function (){
const self=this;
const breakingNews=$('.breaking-news-slider');
if(breakingNews.length < 1){
return false;
}
breakingNews.each(function (){
const el=$(this);
let params={
slidesPerView: 1,
loop: true,
};
if(el.data('play')){
params.autoplay={
delay: el.data('speed')||self.themeSettings.sliderSpeed,
stopOnLastSlide: false,
disableOnInteraction: self.isElementorEditor ? true:window.outerWidth < 1025,
pauseOnMouseEnter: true,
};}
params.navigation={
nextEl: el.find('.breaking-news-next')[0],
prevEl: el.find('.breaking-news-prev')[0],
};
new RBSwiper(this, params);
});
};
Module.sliders=function (){
const self=this;
const sliders=$('.post-slider');
if(sliders.length < 1){
return false;
}
sliders.each(function (){
const slider=$(this);
let params={
grabCursor: true,
allowTouchMove: true,
effect: self.themeSettings.sliderEffect,
loop: true,
};
if(slider.data('play')){
params.autoplay={
delay: slider.data('speed')||self.themeSettings.sliderSpeed,
stopOnLastSlide: true,
disableOnInteraction: self.isElementorEditor ? true:window.outerWidth < 1025,
pauseOnMouseEnter: true,
};}
params.pagination={
el: slider.find('.slider-pagination')[0],
clickable: true,
};
params.navigation={
nextEl: slider.find('.slider-next')[0],
prevEl: slider.find('.slider-prev')[0],
};
new RBSwiper(this, params);
});
};
Module.carousels=function (){
const self=this;
const carousels=$('.post-carousel');
if(carousels.length < 1){
return false;
}
carousels.each(function (){
const carousel=$(this);
let params={
grabCursor: true,
allowTouchMove: true,
freeMode: false,
loop: true,
};
params.slidesPerView=carousel.data('mcol');
params.spaceBetween=carousel.data('mgap');
params.centeredSlides=carousel.data('centered');
params.navigation={
nextEl: carousel.find('.slider-next')[0],
prevEl: carousel.find('.slider-prev')[0],
};
if(carousel.find('.slider-pagination')[0]){
params.pagination={
el: carousel.find('.slider-pagination')[0],
type: 'bullets',
clickable: true,
};}
if(carousel.data('play')){
params.autoplay={
delay: carousel.data('speed')||self.themeSettings.sliderSpeed,
stopOnLastSlide: false,
disableOnInteraction: self.isElementorEditor ? true:window.outerWidth < 1025,
pauseOnMouseEnter: true,
};}
if(carousel.data('fmode')){
params.freeMode=true;
}
params.breakpoints={
768: {
slidesPerView: carousel.data('tcol'),
spaceBetween: carousel.data('tgap'),
},
1025: {
slidesPerView: carousel.data('col'),
spaceBetween: carousel.data('gap'),
},
1500: {
slidesPerView: carousel.data('wcol'),
spaceBetween: carousel.data('gap'),
},
};
params.on={
afterInit: function (swiper){
const wrap=$(swiper.$wrapperEl);
$(swiper.$wrapperEl).find('.p-box').css('height', wrap.height());
},
resize: function (swiper){
const wrap=$(swiper.$wrapperEl);
$(swiper.$wrapperEl).find('.p-box').css('height', wrap.height());
},
};
new RBSwiper(this, params);
});
};
Module.singleGallery=function (){
const self=this;
const gallerySections=self._body.find('.featured-gallery-wrap');
if(gallerySections.length===0){
return;
}
gallerySections.each(function (){
const section=$(this);
if(!section.hasClass('is-loaded')){
const index=section.data('gallery');
const sliderEl=section.find('.gallery-slider').attr('id');
const sliderNavEl=section.find('.gallery-slider-nav').attr('id');
const carouselEl=section.find('.gallery-carousel').attr('id');
const coverflowEL=section.find('.gallery-coverflow').attr('id');
if(sliderEl&&sliderNavEl){
const navEl=$('#' + sliderNavEl);
const navSlidesCount=navEl.find('.swiper-slide').length;
const shouldLoopNav=navSlidesCount >=6;
const viewSlides=Math.min(navSlidesCount, 6);
if(!shouldLoopNav){
navEl.css('max-width', `${navSlidesCount * 125}px`);
}
const galleryNav=new RBSwiper('#' + sliderNavEl, {
spaceBetween: 15,
slidesPerView: viewSlides,
freeMode: self.themeSettings.sliderFMode,
grabCursor: true,
loop: shouldLoopNav,
watchSlidesVisibility: shouldLoopNav,
watchSlidesProgress: true,
on: {
init: function (){
$(this.$wrapperEl).removeClass('pre-load');
},
},
});
const gallerySlider=new RBSwiper('#' + sliderEl, {
spaceBetween: 0,
grabCursor: true,
loop: true,
pagination: {
el: '.swiper-pagination-' + index,
type: 'progressbar',
clickable: true,
},
on: {
init: function (){
section.addClass('is-loaded');
},
},
thumbs: {
swiper: galleryNav,
},
});
gallerySlider.on('slideChange', function (){
const index=this.activeIndex;
if(index){
const label=$(this.$el).next().find('.current-slider-count');
label.fadeOut(0, function (){
$(this)
.html(index <=label.data('total') ? index:1)
.fadeIn(50);
});
}});
}
if('undefined'!==typeof carouselEl){
new RBSwiper('#' + carouselEl, {
spaceBetween: 20,
slidesPerView: 'auto',
freeMode: self.themeSettings.sliderFMode,
loop: false,
grabCursor: true,
scrollbar: {
el: '.swiper-scrollbar-' + index,
hide: true,
},
on: {
init: function (){
$(this.$wrapperEl).removeClass('pre-load');
section.addClass('is-loaded');
},
},
});
}
if('undefined'!==typeof coverflowEL){
new RBSwiper('#' + coverflowEL, {
effect: 'coverflow',
grabCursor: true,
centeredSlides: true,
slidesPerView: 1.2,
coverflowEffect: {
rotate: 50,
stretch: 0,
depth: 250,
modifier: 1,
slideShadows: true,
},
breakpoints: {
768: {
slidesPerView: 3,
},
},
on: {
init: function (){
$(this.$wrapperEl).removeClass('pre-load');
section.addClass('is-loaded');
},
},
pagination: {
el: '.swiper-pagination-' + index,
clickable: true,
},
});
}}
});
};
Module.scrollBarSlider=function (){
const self=this;
const items=$('.gb-slider-scrollbar');
if(!items.length) return;
items.each(function (index, itemEl){
if($(itemEl).hasClass('is-loaded')) return;
const autoplay=$(itemEl).data('autoplay')===1;
const caption=$(itemEl).closest('.gb-image-slider').find('.gb-image-caption');
const scrollbarEl=$(itemEl).find('.swiper-scrollbar')[0];
$(itemEl).find('.swiper-wrapper').children().addClass('swiper-slide');
const updateCaption=(swiper)=> {
const captionText=$(swiper.slides[swiper.activeIndex]).find('.wp-element-caption').html()||'';
caption.fadeOut(150, ()=> caption.html(captionText).fadeIn(200));
};
new RBSwiper(itemEl, {
slidesPerView: 1,
loop: false,
grabCursor: true,
autoplay: autoplay
? {
delay: self.themeSettings.sliderSpeed||5000,
disableOnInteraction: self.isElementorEditor ? true:window.outerWidth < 1025,
}
: false,
scrollbar: {
el: scrollbarEl,
hide: false,
},
on: {
init(){
$(itemEl).removeClass('pre-load').addClass('is-loaded');
updateCaption(this);
},
slideChange(){
updateCaption(this);
},
},
});
});
};
Module.highlightShares=function (){
const self=this;
if(!self.themeSettings.highlightShares ||
(window.matchMedia&&window.matchMedia('(pointer: coarse)').matches)
){
return;
}
const config={
selectableElements: ['.is-highlight-shares'],
twitterUsername: self.themeSettings.twitterName,
facebook: !!self.themeSettings.highlightShareFacebook,
twitter: !!self.themeSettings.highlightShareTwitter,
};
const extra=self.themeSettings.highlightShareReddit
? [
{
icon: '<i class="rbi rbi-reddit"></i>',
url: 'https://reddit.com/submit?url=PAGE_URL&title=TEXT_SELECTION',
},
]
: [];
Sharect.config(config).appendCustomShareButtons(extra).init();
};
Module._floatingVideo={
active: false,
el: null,
$el: null,
isFloating: false,
scrollHandler: null
};
Module.floatingVideo=function (){
const self=this;
const fv=self._floatingVideo;
if(fv.active) return;
const floating=$('.floating-video').not('.is-loaded');
if(floating.length===0||window.outerWidth < 1025){
return false;
}
floating.addClass('is-loaded');
fv.active=true;
fv.el=floating[0];
fv.$el=floating;
fv.isFloating=false;
fv.scrollHandler=function (){
if(!fv.el||!fv.active) return;
const rect=fv.el.getBoundingClientRect();
const shouldFloat=rect.bottom < 0;
if(shouldFloat&&!fv.isFloating){
fv.isFloating=true;
fv.$el.addClass('floating-activated');
if(!fv.$el.find('.floating-close').length){
fv.$el.find('.float-holder')
.prepend('<a class="floating-close close-popup-btn" href="#"><span class="close-icon"></span></a>');
}}else if(!shouldFloat&&fv.isFloating){
fv.isFloating=false;
fv.$el.removeClass('floating-activated');
}};
self.addScrollHandler('floatingVideo', fv.scrollHandler);
};
Module.floatingVideoRemove=function (){
const self=this;
self._body.on('click', '.floating-close', function (e){
e.preventDefault();
e.stopPropagation();
const fv=self._floatingVideo;
if(fv.$el){
fv.$el.removeClass('floating-activated');
}
self.removeScrollHandler('floatingVideo');
fv.active=false;
fv.el=null;
fv.$el=null;
fv.isFloating=false;
fv.scrollHandler=null;
});
};
Module.siteAccessDetector=function (){
const self=this;
const method=self.themeSettings?.adDetectorMethod;
if(!method||self.siteAccessFlag||self.crwDetect()){
return;
}
setTimeout(()=> {
if(self.siteAccessFlag) return;
switch (parseInt(method)){
case 1:
self.baitElementDetector();
break;
case 2:
self.externalScriptDetector();
break;
case 3:
self.combinedDetector();
break;
}}, 1500);
};
Module.baitElementDetector=function (){
const self=this;
const bait=self.createBaitElement();
document.body.appendChild(bait);
setTimeout(()=> {
const isBlocked=self.checkBaitElement(bait);
bait.remove();
if(isBlocked){
self.siteAccessFlag=true;
$.magnificPopup.close();
setTimeout(()=> {
self.siteAccessNotification();
}, 200);
}}, 100);
};
Module.externalScriptDetector=function (){
const self=this;
const testUrl='https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js';
const script=document.createElement('script');
script.src=testUrl;
script.async=true;
let completed=false;
const complete=(blocked)=> {
if(completed) return;
completed=true;
script.remove();
if(blocked){
self.siteAccessFlag=true;
$.magnificPopup.close();
setTimeout(()=> {
self.siteAccessNotification();
}, 200);
}};
script.onerror=()=> complete(true);
script.onload=()=> complete(false);
setTimeout(()=> complete(true), 5000);
document.head.appendChild(script);
};
Module.combinedDetector=function (){
const self=this;
const bait=self.createBaitElement();
document.body.appendChild(bait);
setTimeout(()=> {
const baitBlocked=self.checkBaitElement(bait);
bait.remove();
if(baitBlocked){
self.siteAccessFlag=true;
$.magnificPopup.close();
setTimeout(()=> {
self.siteAccessNotification();
}, 200);
return;
}
self.externalScriptDetector();
}, 100);
};
Module.createBaitElement=function (){
const container=document.createElement('div');
container.id='rb-adcheck';
container.setAttribute('aria-hidden', 'true');
container.style.cssText='position:absolute;bottom:0;left:0;z-index:-1;pointer-events:none;overflow:hidden;';
const inner=document.createElement('div');
inner.id='google_ads_iframe_test';
inner.className='adsbygoogle ad-slot adbanner ads-banner banner_ad ad-placeholder pub_300x250 textads adsbox';
inner.setAttribute('data-ad-slot', 'test');
inner.style.cssText='width:300px;height:250px;background:transparent;';
container.appendChild(inner);
return container;
};
Module.checkBaitElement=function (container){
const inner=container.querySelector('.adsbygoogle');
if(!inner||!document.body.contains(inner)){
return true;
}
const style=window.getComputedStyle(inner);
const rect=inner.getBoundingClientRect();
return (
rect.height < 1 ||
rect.width < 1 ||
style.display==='none' ||
style.visibility==='hidden' ||
parseFloat(style.opacity)===0 ||
inner.offsetParent===null
);
};
Module.siteAccessNotification=function (){
$.magnificPopup.open({
type: 'inline',
preloader: false,
showCloseBtn: false,
closeBtnInside: false,
enableEscapeKey: false,
closeOnBgClick: false,
removalDelay: 9999999,
items: {
src: $('#tmpl-rb-site-access').html(),
type: 'inline',
},
mainClass: 'rb-popup-center site-access-popup',
fixedBgPos: true,
fixedContentPos: true,
});
window.addEventListener('contextmenu', (event)=> event.preventDefault());
};
Module.galleryLightbox=function (){
const self=this;
if(!self.galleriesData){
return;
}
$('.gallery-popup-trigger').on('click', function (e){
e.preventDefault();
e.stopPropagation();
const target=$(this);
const slideIndex=target.data('index');
$.magnificPopup.open({
type: 'inline',
mainClass: 'rb-gallery-popup rb-popup-center',
closeMarkup:
'<button title="%title%" class="mfp-close mfp-button"><i class="rbi rbi-close"></i></button>',
closeOnBgClick: false,
removalDelay: 400,
showCloseBtn: true,
fixedBgPos: true,
fixedContentPos: true,
preloader: false,
gallery: {
enabled: true,
preload: [0, 2],
arrowMarkup:
'<button title="%title%" type="button" class="mfp-arrow mfp-button mfp-arrow-%dir%"><i class="rbi rbi-%dir%"></i></button>',
tCounter: '<span>%curr% / %total%</span>',
},
callbacks: {
open: function (){
let itemsArray=Object.values(self.galleriesData);
let targetIndex=itemsArray.findIndex((item)=> item.key===slideIndex);
if(targetIndex!==-1){
$.magnificPopup.instance.goTo(targetIndex);
}},
change: function (){
let imgContainer=$('.gallery-popup-content');
let loader=imgContainer.find('.rb-loader');
let img=imgContainer.find('img');
loader.show();
if(!img.length){
loader.hide();
return;
}
let loaderTimeout=setTimeout(()=> {
loader.fadeIn(200);
}, 300);
img.on('load', function (){
clearTimeout(loaderTimeout);
loader.hide();
}).on('error', function (){
clearTimeout(loaderTimeout);
loader.hide();
});
},
afterClose: function (){
$.magnificPopup.instance.popupsCache={};},
buildControls: function (){
if(this.arrowLeft&&this.arrowRight){
this.contentContainer
.find('.gallery-popup-nav')
.append(this.arrowLeft.add(this.arrowRight));
}},
},
inline: {
markup:
'<div class="gallery-popup-header light-scheme">' +
'<div class="mfp-counter"></div><div class="mfp-title h5"></div>' +
'<div class="popup-header-right"><div class="mfp-close"></div></div>' +
'</div><div class="gallery-popup-nav"></div>' +
'<div class="gallery-popup-content"><i class="rb-loader"></i>' +
'<div class="gallery-popup-image mfp-image"></div>' +
'<div class="gallery-popup-entry light-scheme">' +
'<div class="h4 mfp-excerpt"></div>' +
'<div class="description-text mfp-description"></div>' +
'</div>' +
'</div>',
},
items: Object.values(self.galleriesData),
});
return false;
});
};
Module.singleFeaturedLightbox=function (){
$('.featured-lightbox-trigger').on('click', function (e){
e.preventDefault();
e.stopPropagation();
const trigger=$(this);
const source='<img src="' + trigger.data('source') + '" alt="' + $(this).find('img').attr('alt') + '">';
const caption=trigger.data('caption');
const attribution=trigger.data('attribution');
$.magnificPopup.open({
mainClass: 'rb-popup-center popup-no-overflow',
closeOnBgClick: true,
removalDelay: 400,
showCloseBtn: true,
fixedBgPos: true,
fixedContentPos: true,
preloader: false,
closeMarkup:
'<button title="%title%" class="mfp-close rb-popup-close"><i class="rbi rbi-close"></i></button>',
callbacks: {
afterClose: function (){
$.magnificPopup.instance.popupsCache={};},
},
inline: {
markup:
'<div class="featured-popup-image"><div class="mfp-source"></div>' +
'<div class="mfp-close rb-popup-close"></div></div>' +
'<div class="gallery-popup-entry light-scheme">' +
'<div class="h4 mfp-excerpt"></div>' +
'<div class="description-text mfp-description"></div>' +
'</div>',
},
items: {
source: source,
excerpt: caption,
description: attribution,
},
});
});
};
Module.paginationNextPrev=function (){
const self=this;
self._body.on('click', '.pagination-trigger', function (e){
e.preventDefault();
e.stopPropagation();
const paginationTrigger=$(this);
if(paginationTrigger.hasClass('is-disable')){
return;
}
const block=paginationTrigger.parents('.block-wrap');
const uuid=block.attr('id');
if(!self.ajaxData[uuid]){
self.ajaxData[uuid]=self.getBlockSettings(uuid);
}
if(self.ajaxData[uuid]&&self.ajaxData[uuid].processing){
return;
}
self.ajaxData[uuid].processing=true;
const type=paginationTrigger.data('type');
self.ajaxStartAnimation(block, 'replace');
self.ajaxReplaceLoad(block, uuid, type);
});
};
Module.ajaxReplaceLoad=function (block, uuid, type){
const self=this;
if(!self.ajaxData[uuid].paged){
self.ajaxData[uuid].paged=1;
}
if('prev'===type){
self.ajaxData[uuid].page_next=parseInt(self.ajaxData[uuid].paged) - 1;
}else{
self.ajaxData[uuid].page_next=parseInt(self.ajaxData[uuid].paged) + 1;
}
const cacheID=self.cacheData.getCacheID(uuid, self.ajaxData[uuid].page_next);
if(self.cacheData.exist(cacheID)){
const cache=self.cacheData.get(cacheID);
if('undefined'!==typeof cache.paged){
self.ajaxData[uuid].paged=cache.paged;
}
setTimeout(function (){
self.ajaxRenderHTML(block, uuid, cache, 'replace');
}, 200);
}else{
$.ajax({
type: 'GET',
url: self.ajaxURL,
data: {
action: 'rblivep',
data: self.ajaxData[uuid],
},
success: function (response){
response=JSON.parse(JSON.stringify(response));
if('undefined'!==typeof response.paged){
self.ajaxData[uuid].paged=response.paged;
}
self.cacheData.set(cacheID, response);
self.ajaxRenderHTML(block, uuid, response, 'replace');
},
});
}};
Module.paginationLoadMore=function (){
const self=this;
self._body.on('click', '.loadmore-trigger', function (e){
e.preventDefault();
e.stopPropagation();
const paginationTrigger=$(this);
if(paginationTrigger.hasClass('is-disable')){
return;
}
const block=paginationTrigger.parents('.block-wrap');
const uuid=block.attr('id');
if(!self.ajaxData[uuid]){
self.ajaxData[uuid]=self.getBlockSettings(uuid);
}
if(self.ajaxData[uuid]&&self.ajaxData[uuid].processing){
return;
}
self.ajaxData[uuid].processing=true;
self.ajaxStartAnimation(block, 'append');
self.ajaxAppendLoad(block, uuid);
});
};
Module.paginationInfinite=function (){
const self=this;
const infiniteElements=$('.pagination-infinite');
if(infiniteElements.length > 0){
infiniteElements.each(function (){
const paginationTrigger=$(this);
if(!paginationTrigger.hasClass('is-disable')){
const block=paginationTrigger.parents('.block-wrap');
if((block.hasClass('is-hoz-scroll') ||
block.hasClass('is-mhoz-scroll') ||
block.hasClass('is-thoz-scroll')) &&
window.outerWidth < 1025
){
paginationTrigger.addClass('is-disable');
return;
}
const uuid=block.attr('id');
const observerID='infinite_' + uuid;
if(!self.ajaxData[uuid]){
self.ajaxData[uuid]=self.getBlockSettings(uuid);
}
RB_VIEWPORT_OBSERVER.observe(observerID, {
element: paginationTrigger,
offset: '132%',
continuous: true,
handler: function (direction){
if(self.ajaxData[uuid]&&self.ajaxData[uuid].processing){
return;
}
if('down'===direction){
self.ajaxData[uuid].processing=true;
self.ajaxStartAnimation(block, 'append');
self.ajaxAppendLoad(block, uuid);
}},
});
}});
}};
Module.ajaxAppendLoad=function (block, uuid){
const self=this;
if(!self.ajaxData[uuid].paged){
self.ajaxData[uuid].paged=1;
}
if(self.ajaxData[uuid].paged >=self.ajaxData[uuid].page_max){
return;
}
self.ajaxData[uuid].page_next=parseInt(self.ajaxData[uuid].paged) + 1;
$.ajax({
type: 'GET',
url: self.ajaxURL,
data: {
action: 'rblivep',
data: self.ajaxData[uuid],
},
success: function (response){
response=JSON.parse(JSON.stringify(response));
if('undefined'!==typeof response.paged){
self.ajaxData[uuid].paged=response.paged;
}
if('undefined'!==typeof response.notice){
response.content=response.content + response.notice;
}
self.ajaxRenderHTML(block, uuid, response, 'append');
},
});
};
Module.liveSearch=function (){
const liveSearch=$('.live-search-form');
if(liveSearch.length===0){
return;
}
const self=this;
liveSearch.each(function (){
const liveSearchEl=$(this);
const input=liveSearchEl.find('input[type="text"]');
const responseWrap=liveSearchEl.find('.live-search-response');
const animation=liveSearchEl.find('.live-search-animation');
const limit=liveSearchEl.data('limit');
const search=liveSearchEl.data('search');
const follow=liveSearchEl.data('follow');
const tax=liveSearchEl.data('tax');
const dsource=liveSearchEl.data('dsource');
const ptype=liveSearchEl.data('ptype');
input.attr('autocomplete', 'off');
input.on('focus', function (){
const param=$(this).val();
if(param&&!responseWrap.is(':empty')){
responseWrap.css('height', 'auto').fadeIn(200);
}});
const delay=(function (){
let timer=0;
return function (callback, ms){
clearTimeout(timer);
timer=setTimeout(callback, ms);
};})();
input.keyup(function (){
const param=$(this).val();
delay(function (){
if(param){
liveSearchEl.addClass('search-loading');
setTimeout(function (){
animation.fadeIn(100);
}, 120);
$.ajax({
type: 'GET',
url: self.ajaxURL,
data: {
action: 'rbsearch',
s: param,
limit: limit,
search: search,
follow: follow,
tax: tax,
dsource: dsource,
ptype: ptype,
},
success: function (data){
data=$.parseJSON(JSON.stringify(data));
animation.fadeOut(200);
setTimeout(function (){
liveSearchEl.removeClass('search-loading');
}, 200);
responseWrap.hide().empty().css('height', responseWrap.height());
responseWrap.html(data);
if('category'===search&&follow&&typeof FOXIZ_PERSONALIZE!=='undefined'){
FOXIZ_PERSONALIZE.syncLayoutCategories();
}
responseWrap.css('height', 'auto').fadeIn(200);
},
});
}else{
responseWrap.fadeOut(200, function (){
responseWrap.empty().css('height', 'auto');
});
}}, 300);
});
});
};
Module.personalizeBlocks=function (){
const self=this;
const elements=$('.is-ajax-block');
if(elements.length > 0){
const blockRequests=elements.map(function (){
const block=$(this);
const uuid=block.attr('id');
if(!self.ajaxData[uuid]){
self.ajaxData[uuid]=self.getBlockSettings(uuid);
}
if(self.ajaxData[uuid].content_source &&
self.ajaxData[uuid].content_source==='recommended' &&
typeof foxizQueriedIDs!=='undefined' &&
foxizQueriedIDs.data
){
self.ajaxData[uuid].post_not_in=foxizQueriedIDs.data;
}
self.ajaxData[uuid].uID=self.getStorage('RBUUID', '0');
return $.ajax({
type: 'GET',
url: self.ajaxURL,
data: {
action: 'rbpersonalizeb',
data: self.ajaxData[uuid],
},
});
});
Promise.all(blockRequests).then((responses)=> {
responses.forEach((response, index)=> {
const block=$(elements[index]);
block.html(response).fadeIn(200);
block.dequeue();
});
self.reloadBlockFunc();
});
}};
Module.personalizeCategories=function (){
const self=this;
const elements=$('.is-ajax-categories');
if(elements.length > 0){
const categoryRequests=elements.map(function (){
const block=$(this);
const uuid=block.attr('id');
if(!self.ajaxData[uuid]){
self.ajaxData[uuid]=self.getBlockSettings(uuid);
}
return $.ajax({
type: 'GET',
url: self.ajaxURL,
data: {
action: 'rbpersonalizecat',
data: self.ajaxData[uuid],
},
});
});
Promise.all(categoryRequests).then((responses)=> {
responses.forEach((response, index)=> {
const block=$(elements[index]);
block.html(response).fadeIn(200);
block.dequeue();
});
if(typeof FOXIZ_PERSONALIZE!=='undefined'){
FOXIZ_PERSONALIZE.syncLayoutCategories();
}
self.reloadBlockFunc();
});
}};
Module.readingCollect=function (){
const self=this;
if(self.themeSettings.yesReadingHis===undefined){
return;
}
$.ajax({
type: 'GET',
url: self.ajaxURL,
data: {
action: 'rbcollect',
id: self.themeSettings.yesReadingHis,
},
});
};
Module.newsNotification=function (){
const notificationWrapper=$('.rb-notification');
if(notificationWrapper.length < 1){
return false;
}
const self=this;
const storageKey=this.personalizeUID + '-notification';
const dot=$('.notification-info');
let reload=notificationWrapper.data('interval');
if(!reload||isNaN(reload)||reload <=0){
reload=15;
}
function countNewPosts(currentIds, viewedIds){
if(!currentIds) return 0;
if(!viewedIds) return currentIds.split(',').length;
const current=currentIds.split(',');
const viewed=viewedIds.split(',');
let count=0;
for (let i=0; i < current.length; i++){
if(viewed.indexOf(current[i])===-1){
count++;
}}
return count;
}
const cached=self.getStorage(storageKey);
if(cached&&cached.content){
notificationWrapper.append(cached.content);
const newCount=countNewPosts(cached.ids, cached.viewedIds);
if(newCount > 0){
dot.append(newCount);
dot.css('opacity', 1);
}}
$('.notification-trigger').on('click', function (){
dot.css('opacity', 0).empty();
const current=self.getStorage(storageKey);
if(current&&current.ids){
current.viewedIds=current.ids;
self.setStorage(storageKey, current);
}});
const isExpired = !cached||!cached.ttl||Date.now() > cached.ttl;
if(isExpired){
$.ajax({
type: 'GET',
url: self.ajaxURL,
data: { action: 'rbnotification' },
success: function (response){
response=$.parseJSON(JSON.stringify(response));
const newIds=response.ids||'';
const oldIds=cached ? cached.ids||'':'';
const viewedIds=cached ? cached.viewedIds||'':'';
self.setStorage(storageKey, {
content: response.content,
count: response.count,
ids: newIds,
viewedIds: viewedIds,
ttl: Date.now() + reload * 60000,
});
if(!cached||newIds!==oldIds){
notificationWrapper.empty().append(response.content);
dot.empty();
const newCount=countNewPosts(newIds, viewedIds);
if(newCount > 0){
dot.append(newCount);
dot.css('opacity', 1);
}}
},
});
}};
Module.cacheData={
data: {},
get: function (id){
return this.data[id];
},
set: function (id, data){
this.remove(id);
this.data[id]=data;
},
remove: function (id){
delete this.data[id];
},
getCacheID: function (blockID, currentPage){
return JSON.stringify('RB_' + blockID + '_' + currentPage);
},
exist: function (id){
return this.data.hasOwnProperty(id)&&this.data[id]!==null;
},
};
Module.ajaxStartAnimation=function (block, action){
const inner=block.find('.block-inner');
block.find('.pagination-trigger').addClass('is-disable');
inner.stop();
if('replace'===action){
inner.css('min-height', inner.outerHeight());
inner.fadeTo('200', 0.05);
inner.after('<i class="rb-loader loader-absolute"></i>');
}else{
block.find('.loadmore-trigger').addClass('loading');
block.find('.rb-loader').css({ display: 'block' }).delay(200).animate({ opacity: 1 }, 200);
}};
Module.ajaxRenderHTML=function (block, uuid, response, action){
const self=this;
block.delay(50).queue(function (){
const uuid=block.attr('id');
const inner=block.find('.block-inner');
block.find('.pagination-trigger').removeClass('is-disable');
inner.stop();
if('replace'===action){
inner.html(response.content);
block.find('.rb-loader').animate({ opacity: 0 }, 200, function (){
$(this).remove();
});
inner.css('min-height', '');
inner.fadeTo(200, 1);
}else{
const content=$(response.content);
inner.append(content);
content.addClass('is-invisible');
content.addClass('opacity-animate');
block.find('.rb-loader').animate({ opacity: 0 }, 200, function (){
$(this).css({ display: 'none' });
});
setTimeout(function (){
content.removeClass('is-invisible');
}, 200);
block.find('.loadmore-trigger').removeClass('loading');
}
self.ajaxTriggerState(block, uuid);
self.ajaxData[uuid].processing=false;
var observerID='infinite_' + uuid;
if(RB_VIEWPORT_OBSERVER.has(observerID)){
RB_VIEWPORT_OBSERVER.refresh(observerID);
}
block.dequeue();
self.reloadBlockFunc();
});
};
Module.ajaxTriggerState=function (block, uuid){
const self=this;
block.find('.pagination-trigger').removeClass('is-disable');
if(self.ajaxData[uuid].paged < 2){
block.find('[data-type="prev"]').addClass('is-disable');
}else if(self.ajaxData[uuid].paged >=self.ajaxData[uuid].page_max){
block.find('[data-type="next"]').addClass('is-disable');
block.find('.loadmore-trigger').addClass('is-disable').hide();
block.find('.pagination-infinite').addClass('is-disable').hide();
}};
Module.getBlockSettings=function (uuid){
const settings=typeof window[uuid]!=='undefined' ? window[uuid]:undefined;
return this.cleanNull(settings);
};
Module.cleanNull=function (data){
if(typeof data==='string'){
return data;
}
if(data&&typeof data==='object'){
Object.keys(data).forEach((key)=> {
if(data[key]===''||data[key]===null){
delete data[key];
}});
}
return data;
};
Module.singleInfiniteLoadNext=function (){
const infiniteWrapper=$('#single-post-infinite');
const self=this;
if(!infiniteWrapper.length||self.disabledLoadNext()){
return;
}
self.singleLoadNextCounter=1;
self.singleLoadNextLimit=self.themeSettings?.singleLoadNextLimit
? parseInt(self.themeSettings.singleLoadNextLimit, 10)
: 20;
const infiniteLoadPoint=$('#single-infinite-point');
const animationIcon=infiniteLoadPoint.find('.rb-loader');
const rootURL=new URL(window.location.href);
const rootGetParams=rootURL.searchParams;
RB_VIEWPORT_OBSERVER.observe('ajaxSingleNextPosts', {
element: infiniteLoadPoint,
offset: '138%',
continuous: true,
handler: function (direction){
if(self.ajaxData.singleProcessing ||
direction==='up' ||
self.singleLoadNextCounter > self.singleLoadNextLimit
){
return;
}
const nextPostURL=new URL(infiniteWrapper.data('nextposturl'));
nextPostURL.searchParams.set('rbsnp', '1');
if(rootGetParams){
rootGetParams.forEach((value, key)=> {
if(key!=='rbsnp'&&'p'!==key){
nextPostURL.searchParams.set(key, value);
}});
}
self.ajaxData.singleProcessing=true;
animationIcon.css('display', 'block').animate({ opacity: 1 }, 200);
$.ajax({
type: 'GET',
url: nextPostURL.toString(),
dataType: 'html',
success: function (response){
response=$('<div id="temp-dom"></div>')
.append($.parseHTML(response))
.find('.single-post-outer');
const nextPostURL=response.data('nextposturl');
if(nextPostURL){
infiniteWrapper.data('nextposturl', nextPostURL);
}else{
infiniteWrapper.removeAttr('id');
infiniteLoadPoint.remove();
RB_VIEWPORT_OBSERVER.unobserve('ajaxSingleNextPosts');
}
animationIcon.animate({ opacity: 0 }, 200, function (){
$(this).css('display', 'none');
});
infiniteWrapper.append(response);
self.ajaxData.singleProcessing=false;
self.singleLoadNextCounter++;
if(RB_VIEWPORT_OBSERVER.has('ajaxSingleNextPosts')){
RB_VIEWPORT_OBSERVER.refresh('ajaxSingleNextPosts');
}
setTimeout(function (){
self.reInitAll();
if(typeof FOXIZ_CORE_SCRIPT!=='undefined'){
FOXIZ_CORE_SCRIPT.loadGoogleAds(response);
FOXIZ_CORE_SCRIPT.loadInstagram(response);
FOXIZ_CORE_SCRIPT.loadTwttr();
FOXIZ_CORE_SCRIPT.loadTikTok&&FOXIZ_CORE_SCRIPT.loadTikTok(response);
FOXIZ_CORE_SCRIPT.loadThreads&&FOXIZ_CORE_SCRIPT.loadThreads(response);
FOXIZ_CORE_SCRIPT.loadBluesky&&FOXIZ_CORE_SCRIPT.loadBluesky(response);
}}, 1);
},
error: function (){
animationIcon.animate({ opacity: 0 }, 200, function (){
$(this).css('display', 'none');
});
self.ajaxData.singleProcessing=false;
},
});
},
});
};
Module.singleScrollRefresh=function (){
const infiniteWrapper=$('#single-post-infinite');
if(!infiniteWrapper.length){
return;
}
const self=this;
self.articleData=[];
const articleOuter=infiniteWrapper.find('.single-post-outer');
if(articleOuter.length > 0){
self.inviewPostID=articleOuter.eq(0).data('postid');
articleOuter.each(function (){
const article=$(this);
const itemData={
postID: article.data('postid'),
postURL: article.data('postlink'),
postTitle: article.find('h1.s-title').text(),
shareList: article.find('.sticky-share-list-buffer').html(),
top: article.offset().top,
bottom: article.offset().top + article.outerHeight(true),
};
if(self.readIndicator.length > 0){
const content=article.find('.rbct').eq(0);
itemData.indicatorTop=content.offset().top;
itemData.indicatorHeight=content.outerHeight(true) - self._window.height();
}
self.articleData.push(itemData);
});
if(!self._singleScrollListenerAdded){
self._singleScrollListenerAdded=true;
self.addScrollHandler('singleScroll', self.scrollToUpdateArticle.bind(self));
}}
};
Module.scrollToUpdateArticle=function (){
const self=this;
const scroll=self._window.scrollTop();
self.articleData.every((article)=> {
if(scroll > article.top + 5&&scroll < article.bottom - 5){
if(article.indicatorTop){
self.readIndicatorPercent=Math.min(((scroll - article.indicatorTop) / article.indicatorHeight) * 100,
100
);
if(self.readIndicatorPercent <=100){
self.readIndicator.css('width', `${self.readIndicatorPercent}%`);
}}
if(article.postID!==self.inviewPostID){
self.inviewPostID=article.postID;
const articleEl=$('[data-postid="' + article.postID + '"]');
if(article.postURL){
history.replaceState({ postId: article.postID }, article.postTitle, article.postURL);
self.updateCanonicalURL(article.postURL);
}
document.title=article.postTitle;
$('.single-post-outer').removeClass('activated');
articleEl.addClass('activated');
$('#s-title-sticky .sticky-title').hide().html(article.postTitle).fadeIn(300);
$('#s-title-sticky .sticky-share-list').html(article.shareList);
self._body.find('.floating-video').removeClass('floating-activated');
const hasContinueReading=articleEl.hasClass('has-continue-reading');
const continueBtn=articleEl.find('.continue-reading');
const isTeaserMode=hasContinueReading&&continueBtn.length > 0&&continueBtn.is(':visible');
if(!isTeaserMode&&typeof FOXIZ_CORE_SCRIPT!=='undefined'){
FOXIZ_CORE_SCRIPT.updateGA(article);
}}
return false;
}
return true;
});
};
Module.updateCanonicalURL=function (url){
if(!url) return;
let canonical=document.querySelector('link[rel="canonical"]');
if(canonical){
canonical.href=url;
}
let ogUrl=document.querySelector('meta[property="og:url"]');
if(ogUrl){
ogUrl.content=url;
}};
Module.crwDetect=function (){
const botPatterns=[
/alexa|altavista|ask jeeves|attentio|baiduspider|bingbot|chtml generic|crawler|fastmobilecrawl|feedfetcher-google|firefly|froogle|gigabot|googlebot|googlebot-mobile|heritrix|httrack|ia_archiver|irlbot|iescholar|infoseek|jumpbot|linkcheck|lycos|mediapartners|mediobot|motionbot|msnbot|mshots|openbot|pss-webkit-request|pythumbnail|scooter|slurp|snapbot|spider|taptubot|technoratisnoop|teoma|twiceler|yahooseeker|yahooysmcm|yammybot|ahrefsbot|pingdom.com_bot|kraken|yandexbot|twitterbot|tweetmemebot|openhosebot|queryseekerspider|linkdexbot|grokkit-crawler|livelapbot|germcrawler|domaintunocrawler|grapeshotcrawler|cloudflare-alwaysonline/i,
];
const userAgent=navigator.userAgent;
return botPatterns.some((pattern)=> pattern.test(userAgent));
};
Module.disabledLoadNext=function (){
if(this.themeSettings.crwLoadNext){
return false;
}
return this.crwDetect();
};
Module.productQuantity=function (){
this._document.on('click', '.quantity .quantity-btn', function (e){
e.preventDefault();
e.stopPropagation();
const button=$(this);
const input=button.parent().find('input');
let step=1;
let min=1;
let max=9999;
let value_old=parseInt(input.val());
let value_new=parseInt(input.val());
if(input.attr('step')){
step=parseInt(input.attr('step'));
}
if(input.attr('min')){
min=parseInt(input.attr('min'));
}
if(input.attr('max')){
max=parseInt(input.attr('max'));
}
if(button.hasClass('up')){
if(value_old < max){
value_new=value_old + step;
}else{
value_new=1;
}}else if(button.hasClass('down')){
if(value_old > min){
value_new=value_old - step;
}else{
value_new=0;
}}
if(!input.attr('disabled')){
input.val(value_new).change();
}});
};
Module.cartNotification=function (){
const self=this;
const element=$('#add-cart-popup');
self._body.on('added_to_cart', function (){
element.fadeIn(200);
self.cartNotificationTimeOut=setTimeout(function (){
element.fadeOut(200);
}, 5000);
self.hoveringNotification(element);
});
};
Module.hoveringNotification=function (element){
const self=this;
element.on('mouseenter', function (){
clearTimeout(self.cartNotificationTimeOut);
});
element.on('mouseleave', function (){
setTimeout(function (){
element.fadeOut(200);
}, 1500);
});
};
Module.likeToggle=function (){
const self=this;
let reaction='';
self._body.on('click', '.like-trigger, .dislike-trigger', function (e){
e.preventDefault();
e.stopPropagation();
const target=$(this);
const wrap=target.parent('[data-like]');
const pid=wrap.data('like');
if(!pid||self.isProgress) return;
self.isProgress=true;
const storageKey=self.getLikeKey(pid);
const isLike=target.hasClass('like-trigger');
const isDislike=target.hasClass('dislike-trigger');
const sibEl=target.siblings();
const likeCountEl=wrap.find('.like-count');
const dislikeCountEl=wrap.find('.dislike-count');
let likeCountText=likeCountEl.text();
let dislikeCountText=dislikeCountEl.text();
if(isLike){
if(!target.hasClass('triggered')){
reaction='like';
if(!/[kKmM]/.test(likeCountText)){
likeCountText=parseInt(likeCountText);
if(isNaN(likeCountText)){
likeCountText=0;
}
likeCountEl.text(likeCountText + 1);
}
target.addClass('triggered');
if(sibEl.hasClass('triggered')){
sibEl.removeClass('triggered');
if(!/[kKmM]/.test(dislikeCountText)){
dislikeCountText=parseInt(dislikeCountText) - 1;
if(isNaN(dislikeCountText)||dislikeCountText < 1){
dislikeCountText='';
}
dislikeCountEl.text(dislikeCountText);
}}
self.setStorage(storageKey, 'like');
}else{
reaction='rmlike';
if(!/[kKmM]/.test(likeCountText)){
likeCountText=parseInt(likeCountText) - 1;
if(isNaN(likeCountText)||likeCountText < 1){
likeCountText='';
}
likeCountEl.text(likeCountText);
}
target.removeClass('triggered');
self.deleteStorage(storageKey);
}}else if(isDislike){
if(!target.hasClass('triggered')){
reaction='dislike';
if(!/[kKmM]/.test(dislikeCountText)){
dislikeCountText=parseInt(dislikeCountText);
if(isNaN(dislikeCountText)){
dislikeCountText=0;
}
dislikeCountEl.text(dislikeCountText + 1);
}
target.addClass('triggered');
if(sibEl.hasClass('triggered')){
sibEl.removeClass('triggered');
if(!/[kKmM]/.test(likeCountText)){
likeCountText=parseInt(likeCountText) - 1;
if(isNaN(likeCountText)||likeCountText < 1){
likeCountText='';
}
likeCountEl.text(likeCountText);
}}
self.setStorage(storageKey, 'dislike');
}else{
reaction='rmdislike';
if(!/[kKmM]/.test(dislikeCountText)){
likeCountText=parseInt(likeCountText) - 1;
if(isNaN(likeCountText)||likeCountText < 1){
likeCountText='';
}
dislikeCountEl.text(likeCountText);
}
target.removeClass('triggered');
self.deleteStorage(storageKey);
}}
$.ajax({
type: 'GET',
url: self.ajaxURL,
data: {
uuid: self.personalizeUID,
action: 'rbvoting',
value: reaction,
pid: pid,
},
complete: ()=> {
self.isProgress=false;
},
});
});
};
Module.syncLayoutLike=function (){
this.isProgress=true;
const likeElements=document.querySelectorAll('[data-like]:not(.loaded)');
const jsCount=this._body.hasClass('is-jscount');
let count, countEl;
for (const el of likeElements){
el.classList.add('loaded');
const key=this.getLikeKey(el.getAttribute('data-like'));
const triggered=this.getStorage(key);
if(!triggered) continue;
const likeEl=el.querySelector('.el-like');
const dislikeEl=el.querySelector('.el-dislike');
if(!likeEl||!dislikeEl) continue;
if(triggered==='like'){
likeEl.classList.add('triggered');
countEl=jsCount ? likeEl.querySelector('.like-count'):null;
if(countEl){
count=parseInt(countEl.textContent.trim())||0;
countEl.textContent=count + 1;
}}else if(triggered==='dislike'){
dislikeEl.classList.add('triggered');
countEl=jsCount ? dislikeEl.querySelector('.dislike-count'):null;
if(countEl){
count=parseInt(countEl.textContent.trim())||0;
countEl.textContent=count + 1;
}}
}
this.isProgress=false;
};
Module.getLikeKey=function (id){
return this.personalizeUID + '-like-' + id;
};
Module.liveBlog=function (){
const self=this;
const liveEntry=$('.rb-live-entry');
if(liveEntry.length===0){
return false;
}
let intervalId;
let delayTimeoutId;
const interval=Math.min(1800, Math.max(15, this.themeSettings.liveInterval||1800));
const liveSwitcher=$('#live-interval-switcher');
const storedSetting=this.getStorage('liveIntervalCheckbox');
const startInterval=()=> {
clearInterval(intervalId);
intervalId=setInterval(()=> this.updateLiveBlog(liveEntry), interval * 1000);
};
const stopAll=()=> {
clearInterval(intervalId);
clearTimeout(delayTimeoutId);
};
const handleToggle=()=> {
stopAll();
if(liveSwitcher.prop('checked')){
delayTimeoutId=setTimeout(()=> {
this.updateLiveBlog(liveEntry);
startInterval();
}, 3000);
self.setStorage('liveIntervalCheckbox', 'yes');
}else{
self.setStorage('liveIntervalCheckbox', 'no');
}};
if(storedSetting!==null){
liveSwitcher.prop('checked', storedSetting==='yes');
}else{
self.setStorage('liveIntervalCheckbox', 'yes');
}
if(liveSwitcher.prop('checked')){
startInterval();
}
liveSwitcher.on('change', handleToggle);
};
Module.updateLiveBlog=function (liveEntry){
const self=this;
const liveURL=new URL(window.location.href);
liveURL.searchParams.set('rblive', '1');
$.ajax({
type: 'GET',
url: liveURL.toString(),
dataType: 'html',
success: function (response){
response=$('<div id="temp-dom"></div>').append($.parseHTML(response)).find('#rb-live-content');
liveEntry.html(response.html());
const liveCountElement=liveEntry.prev().find('.live-count');
if(liveCountElement.length){
liveCountElement.text(response.data('total'));
}
setTimeout(function (){
self.reInitAll();
if(typeof FOXIZ_CORE_SCRIPT!=='undefined'){
FOXIZ_CORE_SCRIPT.loadGoogleAds(response);
FOXIZ_CORE_SCRIPT.loadInstagram(response);
FOXIZ_CORE_SCRIPT.loadTwttr();
}}, 1);
},
});
};
Module.accordion=function (){
$('.gb-accordion').each(function (){
const accordion=$(this);
if(accordion.hasClass('yesLoaded')) return;
accordion.addClass('yesLoaded');
const accordionItems=accordion.find('.gb-accordion-item');
if(accordion.hasClass('yes-open')){
accordionItems.first().addClass('active').find('.accordion-item-content').css('display', 'block');
}
accordion.on('click', '.accordion-item-header', function (e){
e.preventDefault();
const header=$(this);
const item=header.closest('.gb-accordion-item');
const content=item.find('.accordion-item-content');
if(item.hasClass('active')){
item.removeClass('active');
content.stop().slideUp(200);
}else{
const activeItem=accordionItems.filter('.active');
activeItem.removeClass('active').find('.accordion-item-content').stop().slideUp(200);
item.addClass('active');
content.stop().slideDown(200);
}});
});
};
Module.resIframeClassic=function (){
if(!document.body.classList.contains('res-iframe-classic')) return;
const iframes=document.querySelectorAll('.rbct iframe');
iframes.forEach((iframe)=> {
const parent=iframe.parentElement;
const grandParent=parent.parentElement;
const greatGrandParent=grandParent.parentElement;
if([parent, grandParent, greatGrandParent].some((element)=> {
const classNames=Array.from(element.classList);
return classNames.some((className)=> className.indexOf('wp-block')!==-1);
})
)
return;
if(!iframe.parentElement.classList.contains('rb-video-ires')){
if(iframe.src.includes('youtube.com') ||
iframe.src.includes('youtu.be') ||
iframe.src.includes('vimeo.com') ||
iframe.src.includes('dailymotion.com')
){
iframe.parentElement.classList.add('rb-video-ires');
}}
});
};
Module.taxBasedAccordion=function (){
const self=this;
$('.block-tax-accordion').each(function (){
const accordion=$(this);
if(accordion.hasClass('is-loaded')){
return;
}
accordion.addClass('is-loaded');
const accordionItems=accordion.find('.tax-accordion-item');
const lastOpenedTab=self.getStorage(accordion.attr('id') + '_lastOpenedTab', null);
if(lastOpenedTab){
const tabToOpen=accordion.find('[data-tab="' + lastOpenedTab + '"] .tax-accordion-sub');
if(tabToOpen.length!==0){
tabToOpen.show();
}}
accordionItems.each(function (){
const item=$(this);
const trigger=item.find('.tax-accordion-trigger');
const subMenu=item.find('.tax-accordion-sub');
trigger.click(function (){
if(!subMenu.is(':visible')){
accordion.find('.tax-accordion-sub').not(subMenu).slideUp();
}
subMenu.slideToggle(function (){
if(subMenu.is(':visible')){
self.setStorage(accordion.attr('id') + '_lastOpenedTab', item.attr('data-tab'));
}else{
self.deleteStorage(accordion.attr('id') + '_lastOpenedTab');
}});
});
});
});
};
Module.sequentialGalleryDisplay=function (){
const galleries=Array.from(document.querySelectorAll('.gallery-animated'));
galleries.forEach((gallery, galleryIndex)=> {
const images=Array.from(gallery.querySelectorAll('.e-gallery-item'));
RB_VIEWPORT_OBSERVER.observe('gallery_' + galleryIndex, {
element: gallery,
offset: '100%',
once: true,
handler: function (direction){
if(direction==='down'){
images.forEach((image, index)=> {
requestAnimationFrame(()=> {
setTimeout(()=> {
image.classList.add('gallery-visible');
}, index * 120);
});
});
}},
});
});
};
Module.reloadCaptchaPopups=function (delay=50){
setTimeout(()=> {
const $content=$($.magnificPopup?.instance?.content||[]);
if(!$content.length) return;
const removeDuplicateCaptchas=(form)=> {
const seen=new Set();
$(form)
.find('.g-recaptcha, .h-captcha, .cf-turnstile, .turnstile-widget, .frc-captcha, [data-arkose-public-key], .arkose-enforcement, .geetest_holder, .geetest_panel'
)
.each(function (){
const cls=this.className;
const type=[
'g-recaptcha',
'h-captcha',
'cf-turnstile',
'turnstile-widget',
'frc-captcha',
'arkose',
'geetest',
].find((t)=>
cls.includes(t) ||
$(this).data('arkose-public-key') ||
$(this).hasClass('arkose-enforcement')
);
if(!type) return;
const key=`${type}`;
if(seen.has(key)){
$(this).remove();
}else{
seen.add(key);
}});
};
try {
$content.find('form').each(function (){
removeDuplicateCaptchas(this);
});
if(typeof grecaptcha!=='undefined'&&grecaptcha?.reset){
$content.find('.g-recaptcha').each(function (){
const wid=this.dataset.widgetId;
if(wid){
try {
grecaptcha.reset(Number(wid));
} catch {}}
});
}
if(typeof turnstile!=='undefined'&&turnstile?.reset){
$content.find('.cf-turnstile, .turnstile-widget').each(function (){
const iframe=this.querySelector('iframe');
const wid=iframe?.dataset?.wid;
if(wid){
try {
turnstile.reset(wid);
} catch {}}
});
}
if(typeof hcaptcha!=='undefined'&&hcaptcha?.reset){
$content.find('.h-captcha').each(function (){
const wid=this.dataset.widgetId;
if(wid){
try {
hcaptcha.reset(Number(wid));
} catch {}}
});
}
if(typeof friendlycaptcha!=='undefined'&&friendlycaptcha?.widget){
$content.find('.frc-captcha').each(function (){
const stored=$(this).data('frc-widget');
if(stored?.reset){
try {
stored.reset();
} catch {}}
});
}
if(window?.arkose?.reset||typeof ECArkose!=='undefined'){
const $arkoseEls=$content.find('[data-arkose-public-key], .arkose-enforcement');
if($arkoseEls.length){
try {
window?.arkose?.reset?.();
ECArkose?.reset?.();
} catch {}}
}
if(typeof initGeetest!=='undefined'||typeof GeetInit!=='undefined'){
$content.find('.geetest_holder, .geetest_panel').each(function (){
const inst=this.geetestInstance;
if(inst?.reset){
try {
inst.reset();
} catch {}}
});
}} catch (err){}}, delay);
};
return Module;
})(FOXIZ_MAIN_SCRIPT||{}, jQuery);
jQuery(document).ready(function ($){
FOXIZ_MAIN_SCRIPT.init();
});
jQuery(window).on('elementor/frontend/init', function (){
if(typeof elementorFrontend!=='undefined' &&
typeof elementorFrontend.isEditMode==='function' &&
elementorFrontend.isEditMode()
){
FOXIZ_MAIN_SCRIPT.isElementorEditor=true;
FOXIZ_MAIN_SCRIPT.editorDarkModeInit=false;
elementorFrontend.hooks.addAction('frontend/element_ready/widget', FOXIZ_MAIN_SCRIPT.initElementor);
}});