PageSourceSearch

https://ednoticias.com/wp-content/themes/foxiz/assets/js/global.js?ver=2.6.9

js ednoticias.com collected 2026-10-02 22:08:48 UTC 124,590 bytes, 3,050 lines download raw bytes

1/**  FOXIZ MAN SCRIPT */
2var FOXIZ_MAIN_SCRIPT = (function (Module, $) {
3        'use strict';
4
5        Module.initParams = function () {
6            this.yesStorage = this.isStorageAvailable();
7            this.themeSettings = typeof foxizParams !== 'undefined' ? foxizParams : {};
8            this.galleriesData = typeof foxizGalleriesData !== 'undefined' ? foxizGalleriesData : {};
9            this.ajaxURL = typeof foxizCoreParams !== 'undefined' ? foxizCoreParams.ajaxurl || '' : '';
10            this.ajaxData = {};
11            this.siteAccessFlag = false;
12            this._document = $(document);
13            this._body = $('body');
14            this._window = $(window);
15            this.html = $('html, body');
16            this.outerHTML = $('html');
17            this.iOS = /(iPad|iPhone|iPod)/g.test(navigator.userAgent);
18            this.wPoint = {};
19            this.sticky = {};
20            this.eSticky = {};
21            this.YTPlayers = {};
22            this.articleData = [];
23            this.readIndicatorPercent = 0;
24            this.isProgress = false;
25            this.readIndicator = $('#reading-progress');
26            this.popupNewsletterEl = $('#rb-popup-newsletter');
27
28            this.personalizeUID = (typeof FOXIZ_CORE_SCRIPT !== "undefined" && FOXIZ_CORE_SCRIPT.personalizeUID !== undefined)
29                ? FOXIZ_CORE_SCRIPT.personalizeUID
30                : 'u0';
31        }
32
33        Module.init = function () {
34            this.initParams();
35            this.syncLayoutLike();
36            this.topSpacing();
37            this.siteAccessDetector();
38            this.headerDropdown();
39            this.mobileCollapse();
40            this.initSubMenuPos();
41            this.privacyTrigger();
42            this.popupNewsletter();
43            this.documentClick();
44            this.backTop();
45            this.readIndicatorInit();
46            this.fontResizer();
47            this.breakingNews();
48            this.sliders();
49            this.carousels();
50            this.liveSearch();
51            this.personalizeBlocks();
52            this.personalizeCategories();
53            this.likeToggle();
54            this.singleInfiniteLoadNext();
55            this.loginPopup();
56            this.popupTemplate();
57            this.loadYoutubeIframe();
58            this.browserResize();
59            this.footerSlideUp();
60            this.cartNotification();
61            this.newsNotification();
62            this.tocToggle();
63            this.delayLoad();
64            this.showPostComment();
65            this.replyReview();
66            this.paginationNextPrev();
67            this.paginationLoadMore();
68            this.paginationInfinite();
69            this.productQuantity();
70            this.readingCollect();
71            this.liveBlog();
72            this.neededReloadFuncs();
73        }
74
75        Module.neededReloadFuncs = function () {
76            this.hoverTipsy();
77            this.scrollToComment();
78            this.usersRating();
79            this.singleGallery();
80            this.floatingVideo();
81            this.videoPreview();
82            this.floatingVideoRemove();
83            this.scrollTableContent();
84            this.singleScrollRefresh();
85            this.playerAutoPlay();
86            this.hoverEffects();
87            this.highlightShares();
88            this.galleryLightbox();
89            this.singleFeaturedLightbox();
90            this.accordion();
91            this.resIframeClassic();
92            this.taxBasedAccordion();
93            this.scrollBarSlider();
94        }
95
96        Module.reInitAll = function () {
97
98            this._window.trigger('load');
99            this.syncLayoutLike();
100            if (typeof FOXIZ_PERSONALIZE !== 'undefined') {
101                FOXIZ_PERSONALIZE.syncPersonalizeLayout();
102            }
103            if (typeof RB_REACTION !== 'undefined') {
104                RB_REACTION.syncReactLayout();
105            }
106            this.neededReloadFuncs();
107            Waypoint.refreshAll();
108        }
109
110        /** sync layout & reload features */
111        Module.reloadBlockFunc = function () {
112            this._window.trigger('load');
113
114            if (typeof FOXIZ_PERSONALIZE !== 'undefined') {
115                FOXIZ_PERSONALIZE.syncLayoutBookmarks();
116            }
117            this.syncLayoutLike();
118            this.videoPreview();
119            this.hoverTipsy();
120            Waypoint.refreshAll();
121        }
122
123        Module.initElementor = function () {
124            if ('undefined' !== typeof initDarkMode && !FOXIZ_MAIN_SCRIPT.editorDarkModeInit) {
125                FOXIZ_MAIN_SCRIPT.editorDarkModeInit = true;
126                initDarkMode();
127            }
128            FOXIZ_MAIN_SCRIPT.breakingNews();
129            FOXIZ_MAIN_SCRIPT.carousels();
130            FOXIZ_MAIN_SCRIPT.sliders();
131        }
132
133        Module.isRTL = function () {
134            return this._body.hasClass('rtl');
135        }
136
137        Module.animationFrame = function (callback) {
138            const func = window.requestAnimationFrame || window.mozRequestAnimationFrame ||
139                window.webkitRequestAnimationFrame || this.animationFrameFallback
140            func.call(window, callback)
141        }
142
143        Module.animationFrameFallback = function (callback) {
144            window.setTimeout(callback, 1000 / 60)
145        }
146
147        /**
148         *
149         * @returns {boolean}
150         */
151        Module.isStorageAvailable = function () {
152            let storage;
153            try {
154                storage = window['localStorage'];
155                storage.setItem('__rbStorageSet', 'x');
156                storage.removeItem('__rbStorageSet');
157                return true;
158            } catch (e) {
159                return false;
160            }
161        }
162
163        /**
164         * set localStorage
165         * @param key
166         * @param data
167         */
168        Module.setStorage = function (key, data) {
169            this.yesStorage && localStorage.setItem(key, typeof data === 'string' ? data : JSON.stringify(data));
170        }
171
172        /**
173         * get localStorage
174         * @param key
175         * @param defaultValue
176         * @returns {any}
177         */
178        Module.getStorage = function (key, defaultValue) {
179            if (!this.yesStorage) return null;
180            const data = localStorage.getItem(key);
181            if (data === null) return defaultValue;
182            try {
183                return JSON.parse(data);
184            } catch (e) {
185                return data;
186            }
187        }
188
189        /**
190         * delelte localStorage
191         * @param key
192         */
193        Module.deleteStorage = function (key) {
194            this.yesStorage && localStorage.removeItem(key);
195        }
196
197        /**
198         *
199         * @param id
200         * @param value
201         * @param ttl
202         * @constructor
203         */
204        Module.SetTTLStorage = function (id, value, ttl) {
205            const data = {
206                value: value,
207                ttl: Date.now() + ttl * 3600000
208            };
209
210            this.setStorage(id, data);
211        }
212
213        /**
214         *
215         * @param id
216         * @returns {null|*}
217         */
218        Module.getTTLStorage = function (id) {
219
220            const data = this.getStorage(id);
221            if (data && Date.now() <= data.ttl) {
222                return data.value;
223            }
224            this.deleteStorage(id);
225            return null;
226        };
227
228        /** on load */
229        Module.delayLoad = function () {
230            const self = this;
231            setTimeout(function () {
232                self.stickyNavBar();
233                self.stickyHeaderBuilder();
234            }, 100)
235        }
236
237        /** resize */
238        Module.browserResize = function () {
239            const self = this;
240
241            self._window.on('resize', function () {
242                self.topSpacing();
243                self.calcSubMenuPos();
244            })
245        }
246
247        /* ================================ HEADERS ================================ */
248        Module.hoverTipsy = function () {
249
250            if (!$.fn.rbTipsy) {
251                return false;
252            }
253
254            this._body.find('[data-copy]').rbTipsy({
255                title: 'data-copy',
256                fade: true,
257                opacity: 1,
258                trigger: 'hover',
259                gravity: 's'
260            });
261
262            if (window.innerWidth > 1024) {
263                this._body.find('#site-header [data-title]').rbTipsy({
264                    title: 'data-title',
265                    fade: true,
266                    opacity: 1,
267                    trigger: 'hover',
268                    gravity: 'n'
269                });
270
271                this._body.find('.site-wrap [data-title]').rbTipsy({
272                    title: 'data-title',
273                    fade: true,
274                    opacity: 1,
275                    trigger: 'hover',
276                    gravity: 's'
277                });
278            }
279        }
280
281        /** font resizer */
282        Module.fontResizer = function () {
283            const self = this;
284            let size = self.yesStorage ? sessionStorage.getItem('rubyResizerStep') : 1;
285
286            self._body.on('click', '.font-resizer-trigger', function (e) {
287                e.preventDefault();
288                e.stopPropagation();
289                size++;
290                if (3 < size) {
291                    size = 1;
292                    self._body.removeClass('medium-entry-size big-entry-size')
293                } else {
294                    if (2 == size) {
295                        self._body.addClass('medium-entry-size').removeClass('big-entry-size');
296                    } else {
297                        self._body.addClass('big-entry-size').removeClass('medium-entry-size')
298                    }
299                }
300
301                self.yesStorage && sessionStorage.setItem('rubyResizerStep', size);
302            });
303        }
304
305        /** hover */
306        Module.hoverEffects = function () {
307            const selectors = $('.effect-fadeout');
308
309            if (selectors.length === 0) {
310                return;
311            }
312            selectors.off('mouseenter mouseleave').on('mouseenter', function (e) {
313                e.stopPropagation();
314                const target = $(this);
315                if (!target.hasClass('activated')) {
316                    target.addClass('activated');
317                }
318            }).on('mouseleave', function () {
319                $(this).removeClass('activated');
320            });
321        }
322
323        Module.videoPreview = function () {
324            let playPromise;
325
326            $('.preview-trigger').on('mouseenter', function () {
327                const target = $(this);
328                const wrap = target.find('.preview-video');
329                if (!wrap.hasClass('video-added')) {
330                    const video = '<video preload="auto" muted loop><source src="' + wrap.data('source') + '" type="' + wrap.data('type') + '"></video>';
331                    wrap.append(video).addClass('video-added');
332                }
333                target.addClass('show-preview');
334                wrap.css('z-index', 3);
335                const el = target.find('video')[0];
336                if (el) {
337                    playPromise = el.play();
338                }
339            }).on('mouseleave', function () {
340                const target = $(this);
341                target.find('.preview-video').css('z-index', 1);
342                const el = target.find('video')[0];
343                if (el && playPromise !== undefined) {
344                    playPromise.then(_ => {
345                        el.pause();
346                    }).catch();
347                }
348            });
349        }
350
351        Module.playerAutoPlay = function () {
352            const self = this;
353            const items = $('.is-autoplay');
354            const nonResIframe = $('.entry-content > iframe');
355
356            if (items != null && items.length > 0) {
357                items.each(function () {
358                    const el = $(this);
359                    if (!el.hasClass('is-loaded')) {
360                        self.wPoint['iframe'] = new Waypoint({
361                            element: el,
362                            handler: function () {
363                                const iframe = el.find('iframe');
364                                self.initAutoPlay(iframe);
365                                el.addClass('is-loaded');
366                                this.destroy();
367                            },
368                            offset: '60%'
369                        });
370                    }
371                })
372            }
373
374            if (nonResIframe != null && nonResIframe.length > 0) {
375                nonResIframe.each(function () {
376                    const el = $(this);
377                    if (!el.hasClass('is-loaded')) {
378                        const iURL = el.attr('src');
379                        if (iURL.indexOf('youtube.com') > 0 || iURL.indexOf('youtu.be') > 0 || iURL.indexOf('vimeo.com') > 0) {
380                            el.wrap('<div class="rb-ires is-loaded"></div>');
381                        }
382                    }
383                })
384            }
385        }
386
387        Module.initAutoPlay = function (item) {
388            if (item.length > 0 && undefined !== item[0]) {
389                const src = item[0].src;
390                if (src.indexOf('?') > -1) {
391                    item[0].src += "&autoplay=1";
392                } else {
393                    item[0].src += "?autoplay=1";
394                }
395            }
396        }
397
398        Module.tocToggle = function () {
399            this._document.on('click', '.toc-toggle', function (e) {
400                e.preventDefault();
401                e.stopPropagation();
402
403                const target = $(this);
404                const content = target.parents('.ruby-table-contents').find('.toc-content');
405                content.toggle(200);
406                target.toggleClass('activate');
407            });
408        };
409
410        /** Header JS functions */
411        Module.headerDropdown = function () {
412
413            const self = this;
414            $('.more-trigger').on('click', function (e) {
415
416                e.preventDefault();
417                e.stopPropagation();
418
419                /** re calc menu  */
420                self.calcSubMenuPos();
421
422                const target = $(this);
423                const holder = target.parents('.header-wrap').find('.more-section-outer');
424
425                if (!holder.hasClass('dropdown-activated')) {
426                    self._body.find('.dropdown-activated').removeClass('dropdown-activated');
427                    holder.addClass('dropdown-activated');
428                } else {
429                    holder.removeClass('dropdown-activated');
430                }
431                if (target.hasClass('search-btn')) {
432                    setTimeout(function () {
433                        holder.find('input[type="text"]').focus()
434                    }, 150);
435                }
436
437                return false;
438            });
439
440            /** search trigger */
441            $('.search-trigger').on('click', function (e) {
442                e.preventDefault();
443                e.stopPropagation();
444                const holder = $(this).parent('.header-dropdown-outer');
445                if (!holder.hasClass('dropdown-activated')) {
446                    self._body.find('.dropdown-activated').removeClass('dropdown-activated');
447                    holder.addClass('dropdown-activated');
448                    setTimeout(function () {
449                        holder.find('input[type="text"]').focus()
450                    }, 150);
451                } else {
452                    holder.removeClass('dropdown-activated');
453                }
454                return false;
455            });
456
457            /** header dropdown */
458            $('.dropdown-trigger').on('click', function (e) {
459                e.preventDefault();
460                e.stopPropagation();
461                const holder = $(this).parent('.header-dropdown-outer');
462                if (!holder.hasClass('dropdown-activated')) {
463                    self._body.find('.dropdown-activated').removeClass('dropdown-activated');
464                    holder.addClass('dropdown-activated');
465                } else {
466                    holder.removeClass('dropdown-activated');
467                }
468            });
469        }
470
471        Module.topSpacing = function () {
472            const self = this;
473            if (self._body.hasClass('top-spacing')) {
474                const height = $('.top-site-ad').outerHeight();
475                $('.site-outer').css('margin-top', height);
476            }
477        }
478
479        /** outside click */
480        Module.documentClick = function () {
481
482            const self = this;
483            const wrapper = $('.more-section-outer, .header-dropdown-outer, .mobile-collapse, .mfp-wrap');
484            const inlineSearchForm = $('.is-form-layout');
485
486            document.addEventListener('click', function (e) {
487
488                if (!wrapper.is(e.target) && wrapper.has(e.target).length === 0) {
489                    wrapper.removeClass('dropdown-activated');
490                    self.outerHTML.removeClass('collapse-activated');
491                }
492
493                if (!inlineSearchForm.is(e.target) && inlineSearchForm.has(e.target).length === 0) {
494                    inlineSearchForm.find('.live-search-response').fadeOut(500);
495                }
496            });
497        }
498
499        /** calc mega menu position */
500        Module.initSubMenuPos = function () {
501            const self = this;
502            let trigger = false;
503
504            /** add delay to ensure image loaded */
505            setTimeout(function () {
506                self.calcSubMenuPos();
507            }, 1000);
508
509            /** re calc when hovering */
510            $('.menu-has-child-mega').on('mouseenter', function () {
511                if (!trigger) {
512                    self.calcSubMenuPos();
513                }
514                trigger = true;
515            })
516        }
517
518        Module.calcSubMenuPos = function () {
519
520            if (window.outerWidth < 1025) {
521                return false;
522            }
523
524            const self = this;
525            const megaParents = $('.menu-has-child-mega');
526            const headerWrapper = $('#site-header');
527
528            /** for mega wide */
529            if (megaParents.length > 0) {
530                megaParents.each(function () {
531                    const item = $(this);
532                    item.find('.mega-dropdown').css({
533                        'width': self._body.width(),
534                        'left': -item.offset().left,
535                    });
536                    item.addClass('mega-menu-loaded')
537                })
538            }
539
540            /** sub-menu left right direction */
541            if (headerWrapper.length > 0) {
542
543                let headerLeftOffset = headerWrapper.offset().left;
544                let headerWidth = headerWrapper.width();
545                let headerRightOffset = headerLeftOffset + headerWidth;
546
547                const flexDropdown = $('.flex-dropdown');
548
549                /** sub menu direction */
550                const subElements = $('ul.sub-menu');
551                if (subElements.length > 0) {
552                    subElements.each(function () {
553                        const item = $(this);
554                        let itemLeftOffset = item.offset().left;
555                        let itemRightOffset = itemLeftOffset + item.width() + 100;
556                        if (itemRightOffset > headerRightOffset) {
557                            item.addClass('left-direction');
558                        }
559                    })
560                }
561
562                /** calc dropdown flex width */
563                if (flexDropdown.length > 0) {
564                    flexDropdown.each(function () {
565                        const item = $(this);
566                        const parentItem = item.parent();
567                        if (parentItem.hasClass('is-child-wide') || item.hasClass('mega-has-left')) {
568                            return;
569                        }
570                        const itemWidth = item.width();
571                        const itemHalfWidth = itemWidth / 2;
572                        const parentItemOffset = parentItem.offset().left;
573                        const parentHalfWidth = parentItem.width() / 2;
574                        const parentItemCenterOffset = parentItemOffset + parentHalfWidth;
575                        const rightSpacing = headerRightOffset - parentItemCenterOffset;
576                        const leftSpacing = parentItemCenterOffset - headerLeftOffset;
577
578                        if (itemWidth >= headerWidth) {
579                            item.css({
580                                'width': headerWidth - 2,
581                                'left': -parentItemOffset
582                            });
583                        } else if (itemHalfWidth > rightSpacing) {
584                            item.css({
585                                'right': -rightSpacing + parentHalfWidth + 1,
586                                'left': 'auto',
587                            });
588                        } else if (itemHalfWidth > leftSpacing) {
589                            item.css({
590                                'left': -leftSpacing + parentHalfWidth + 1,
591                                'right': 'auto',
592                            });
593                        } else {
594                            item.css({
595                                'right': 'auto',
596                                'left': -itemHalfWidth + parentHalfWidth,
597                            });
598                        }
599                    });
600                }
601            }
602        }
603
604        /**
605         *
606         * @returns {boolean}
607         */
608        Module.stickyNavBar = function () {
609
610            const self = this;
611
612            /** turn off sticky on editor mode */
613            if (self._body.hasClass('elementor-editor-active')) {
614                return false;
615            }
616
617            self.sticky.section = $('#sticky-holder');
618            self.sticky.outer = $('#navbar-outer');
619
620            if ((!self._body.hasClass('is-mstick') && !self._body.hasClass('yes-tstick')) || self.sticky.outer.length < 1 || self.sticky.section.length < 1) {
621                return false;
622            }
623
624            self.sticky.smartSticky = !!self._body.hasClass('is-smart-sticky');
625            self.sticky.isSticky = false;
626            self.sticky.lastScroll = 0;
627
628            if (self._body.hasClass('yes-tstick')) {
629                self.sticky.isTitleSticky = true;
630            } else {
631                self.sticky.isTitleSticky = 0;
632            }
633
634            self.sticky.additionalOffset = 200;
635            if (window.innerWidth > 1024) {
636                if (self.sticky.isTitleSticky) {
637                    self.sticky.additionalOffset = 450;
638                } else {
639                    self.sticky.additionalOffset = 0;
640                }
641            }
642
643            if (self._body.hasClass('admin-bar')) {
644                self.sticky.adminBarSpacing = 32;
645            } else {
646                self.sticky.adminBarSpacing = 0;
647            }
648
649            self.sticky.topOffset = self.sticky.section.offset().top;
650            self.sticky.stickySectionHeight = self.sticky.section.outerHeight();
651
652            self.sticky.outer.css('min-height', self.sticky.outer.outerHeight());
653            self.sticky.activatePos = self.sticky.topOffset + 1 + self.sticky.stickySectionHeight + self.sticky.additionalOffset;
654            self.sticky.deactivePos = self.sticky.topOffset - self.sticky.adminBarSpacing + self.sticky.additionalOffset;
655
656            if (window.addEventListener) {
657                if (self.sticky.smartSticky) {
658                    window.addEventListener('scroll', function () {
659                        self.animationFrame(self.initSmartStickyNavBar.bind(self));
660                    }, false);
661                } else {
662                    window.addEventListener('scroll', function () {
663                        self.animationFrame(self.initStickyNavBar.bind(self));
664                    }, false);
665                }
666            }
667
668            self._window.on('unstickMenu', function () {
669                self.sticky.outer.css('min-height', self.sticky.outer.outerHeight());
670                self.sticky.stickySectionHeight = self.sticky.section.outerHeight();
671                self.sticky.topOffset = self.sticky.section.offset().top;
672                self.sticky.activatePos = self.sticky.topOffset + 1 + self.sticky.stickySectionHeight + self.sticky.additionalOffset;
673                self.sticky.deactivePos = self.sticky.topOffset - self.sticky.adminBarSpacing + self.sticky.additionalOffset;
674            });
675        }
676
677        Module.initStickyNavBar = function () {
678            const self = this;
679            const scroll = self._window.scrollTop();
680
681            if (!self.sticky.isSticky && scroll > self.sticky.activatePos) {
682                self.sticky.isSticky = true;
683                self._body.addClass('stick-animated sticky-on');
684                self.sticky.stickAnimatedTimeout = setTimeout(function () {
685                    self._body.removeClass('stick-animated');
686                }, 200);
687            } else if (self.sticky.isSticky && scroll <= self.sticky.deactivePos) {
688                self.sticky.isSticky = false;
689                self._body.removeClass('sticky-on stick-animated');
690                self._window.trigger('unstickMenu');
691            }
692        }
693
694        Module.initSmartStickyNavBar = function () {
695            const self = this;
696            const scroll = self._window.scrollTop();
697
698            if (!self.sticky.isSticky && scroll > self.sticky.activatePos && scroll < self.sticky.lastScroll) {
699                self.sticky.isSticky = true;
700                self._body.addClass('stick-animated sticky-on');
701                self.sticky.stickAnimatedTimeout = setTimeout(function () {
702                    self._body.removeClass('stick-animated');
703                }, 200);
704            } else if (self.sticky.isSticky && (scroll <= self.sticky.deactivePos || scroll > self.sticky.lastScroll)) {
705                self.sticky.isSticky = false;
706                self._body.removeClass('sticky-on stick-animated');
707                if (scroll <= self.sticky.deactivePos) {
708                    self._window.trigger('unstickESection');
709                }
710            }
711            self.sticky.lastScroll = scroll;
712        }
713
714        /** header sticky template */
715        Module.stickyHeaderBuilder = function () {
716
717            const self = this;
718
719            /** turn off sticky on editor mode */
720            if (self._body.hasClass('elementor-editor-active')) {
721                return false;
722            }
723
724            let stickySection = $('.header-template .e-section-sticky').first();
725            const hasTitleSticky = $('body.single-post #s-title-sticky').first();
726
727            if (stickySection.length < 1) {
728                return false;
729            }
730
731            if (hasTitleSticky.length > 0) {
732                self._body.addClass('yes-tstick');
733                self.eSticky.isTitleSticky = true;
734            } else {
735                self.eSticky.isTitleSticky = 0;
736            }
737
738            self.eSticky.additionalOffset = 200;
739            if (window.innerWidth > 1024) {
740                if (self.eSticky.isTitleSticky) {
741                    self.eSticky.additionalOffset = 450;
742                } else {
743                    self.eSticky.additionalOffset = 0;
744                }
745            }
746
747            self.eSticky.smartSticky = !!stickySection.hasClass('is-smart-sticky');
748
749            /** mobile sticky for header template */
750            if (window.innerWidth <= 1024) {
751                stickySection.removeClass('e-section-sticky');
752                stickySection = $('#header-template-holder').addClass('e-section-sticky');
753            }
754
755            self.eSticky.section = stickySection;
756            self.eSticky.outer = stickySection.parent();
757
758            self.eSticky.adminBarSpacing = 0;
759            self.eSticky.isSticky = false;
760            self.eSticky.lastScroll = 0;
761            self.eSticky.stickySectionHeight = stickySection.outerHeight();
762            self.eSticky.topOffset = stickySection.offset().top;
763
764            /** set min height */
765            if (self._body.hasClass('admin-bar')) {
766                self.eSticky.adminBarSpacing = 32;
767            }
768            self.eSticky.outer.css('min-height', self.eSticky.outer.outerHeight());
769            self.eSticky.activatePos = self.eSticky.topOffset + 1 + self.eSticky.stickySectionHeight + self.eSticky.additionalOffset;
770            self.eSticky.deactivePos = self.eSticky.topOffset - self.eSticky.adminBarSpacing + self.eSticky.additionalOffset;
771
772            if (window.addEventListener) {
773                if (self.eSticky.smartSticky) {
774                    window.addEventListener('scroll', function () {
775                        self.animationFrame(self.initSmartStickyESection.bind(self));
776                    }, false);
777                } else {
778                    window.addEventListener('scroll', function () {
779                        self.animationFrame(self.initStickyESection.bind(self));
780                    }, false);
781                }
782            }
783
784            /** re-calc height values */
785            self._window.on('unstickESection', function () {
786                self.eSticky.outer.css('min-height', self.eSticky.outer.outerHeight());
787                self.eSticky.stickySectionHeight = self.eSticky.section.outerHeight();
788                self.eSticky.topOffset = self.eSticky.section.offset().top;
789                self.eSticky.activatePos = self.eSticky.topOffset + 1 + self.eSticky.stickySectionHeight + self.eSticky.additionalOffset;
790                self.eSticky.deactivePos = self.eSticky.topOffset - self.eSticky.adminBarSpacing + self.eSticky.additionalOffset;
791            });
792        }
793
794        Module.initStickyESection = function () {
795            const self = this;
796            const scroll = self._window.scrollTop();
797            if (!self.eSticky.isSticky && scroll > self.eSticky.activatePos) {
798                self.eSticky.isSticky = true;
799                self._body.addClass('stick-animated sticky-on');
800                self.eSticky.stickAnimatedTimeout = setTimeout(function () {
801                    self._body.removeClass('stick-animated');
802                }, 200);
803            } else if (self.eSticky.isSticky && scroll <= self.eSticky.deactivePos) {
804                self.eSticky.isSticky = false;
805                self._body.removeClass('sticky-on stick-animated');
806                self._window.trigger('unstickESection');
807            }
808        }
809
810        Module.initSmartStickyESection = function () {
811            const self = this;
812            const scroll = self._window.scrollTop();
813
814            if (!self.eSticky.isSticky && scroll > self.eSticky.activatePos && scroll < self.eSticky.lastScroll) {
815                self.eSticky.isSticky = true;
816                self._body.addClass('stick-animated sticky-on');
817                self.eSticky.stickAnimatedTimeout = setTimeout(function () {
818                    self._body.removeClass('stick-animated');
819                }, 200);
820            } else if (self.eSticky.isSticky && (scroll <= self.eSticky.deactivePos || scroll > self.eSticky.lastScroll)) {
821                self.eSticky.isSticky = false;
822                self._body.removeClass('sticky-on stick-animated');
823                if (scroll <= self.eSticky.deactivePos) {
824                    self._window.trigger('unstickESection');
825                }
826            }
827
828            self.eSticky.lastScroll = scroll;
829        }
830
831        /** mobileCollapse */
832        Module.mobileCollapse = function () {
833            const self = this;
834            const $mobileMenuTrigger = $('.mobile-menu-trigger');
835            const $outerHTML = self.outerHTML;
836            const $mobileSearchForm = $outerHTML.find('.mobile-search-form input[type="text"]');
837
838            $mobileMenuTrigger.on('click', function (e) {
839                e.preventDefault();
840                e.stopPropagation();
841                const target = $(this);
842
843                if (target.hasClass('mobile-search-icon')) {
844                    setTimeout(function () {
845                        $mobileSearchForm.focus();
846                    }, 100);
847                }
848
849                const isCollapseActivated = $outerHTML.hasClass('collapse-
849activated');
850                $outerHTML.toggleClass('collapse-activated', !isCollapseActivated);
851            });
852        }
853
854        /**
855         * privacy trigger
856         */
857        Module.privacyTrigger = function () {
858            const self = this;
859            $('#privacy-trigger').on('click', function (e) {
860                e.preventDefault();
861                e.stopPropagation();
862                self.setStorage('RubyPrivacyAllowed', '1');
863                $('#rb-privacy').slideUp(200, function () {
864                    $(this).remove();
865                });
866                return false;
867            });
868        }
869
870        /** back top */
871        Module.backTop = function () {
872            if (this._body.hasClass('is-backtop')) {
873                $().UItoTop({
874                    text: '<i class="rbi rbi-darrow-top"></i>',
875                });
876            }
877        }
878
879        /** login popup */
880        Module.loginPopup = function () {
881            const form = $('#rb-user-popup-form');
882            if (form.length < 1) {
883                return false;
884            }
885            this._document.on('click', '.login-toggle', (e) => {
886                e.preventDefault();
887                e.stopPropagation();
888                $.magnificPopup.open({
889                    type: 'inline',
890                    preloader: false,
891                    removalDelay: 400,
892                    showCloseBtn: true,
893                    closeBtnInside: true,
894                    closeOnBgClick: false,
895                    items: {
896                        src: form,
897                        type: 'inline'
898                    },
899                    mainClass: 'rb-popup-center',
900                    closeMarkup: '<span class="close-popup-btn mfp-close"><span class="close-icon"></span></span>',
901                    fixedBgPos: true,
902                    fixedContentPos: true,
903                    callbacks: {
904                        open: function () {
905                            // Reset Turnstile or reCAPTCHA if initialized
906                            if (typeof turnstile !== 'undefined') {
907                                try {
908                                    turnstile.reset();
909                                } catch (e) {
910                                }
911                            } else if (typeof grecaptcha !== 'undefined') {
912                                try {
913                                    grecaptcha.reset();
914                                } catch (e) {
915                                }
916                            }
917                        }
918
919                    }
920                });
921            });
922        };
923
924        /** popup template blocks */
925        Module.popupTemplate = function () {
926
927            const templateCache = {};
928            this._document.on('click', '.popup-trigger-btn', (e) => {
929
930                e.preventDefault();
931                e.stopPropagation();
932
933                const target = $(e.target);
934                const templateID = target.data('trigger') || '';
935                const position = target.data('position') || '';
936
937                if (!templateCache[templateID]) {
938                    const template = $(`#tmpl-${templateID}`);
939                    if (template.length === 0) {
940                        return;
941                    }
942                    templateCache[templateID] = template.html();
943                }
944                $.magnificPopup.open({
945                    type: 'inline',
946                    preloader: false,
947                    removalDelay: 400,
948                    showCloseBtn: true,
949                    closeBtnInside: true,
950                    closeOnBgClick: true,
951                    allowHTMLInTemplate: true,
952                    items: {
953                        src: templateCache[templateID],
954                        type: 'inline'
955                    },
956                    mainClass: `is-template-popup popup-${templateID} ${position}`,
957                    closeMarkup: '<span class="close-popup-btn mfp-close"><span class="close-icon"></span></span>',
958                    fixedBgPos: true,
959                    fixedContentPos: true
960                });
961            });
962        };
963
964        /** newsletter */
965        Module.popupNewsletter = function () {
966
967            const self = this;
968            if (self.popupNewsletterEl.length > 0) {
969                const display = self.popupNewsletterEl.data('display');
970                self.newsletterExpired = self.popupNewsletterEl.data('expired');
971                self.newsletterDisplayOffset = self.popupNewsletterEl.data('offset');
972                const delay = self.popupNewsletterEl.data('delay');
973                const oldExpired = self.getStorage('RubyNewsletterExpired');
974
975                if (self.newsletterExpired === 0) {
976                    self.deleteStorage('RubyNewsletter');
977                }
978
979                if (!oldExpired || self.newsletterExpired !== oldExpired) {
980                    self.setStorage('RubyNewsletterExpired', self.newsletterExpired);
981                    self.deleteStorage('RubyNewsletter');
982                }
983
984                if (!self.getTTLStorage('RubyNewsletter')) {
985                    if (!display || 'scroll' === display) {
986                        if (window.addEventListener) {
987                            window.addEventListener('scroll', function () {
988                                self.animationFrame(self.scrollPopupNewsletter.bind(self));
989                            }, false);
990                        }
991                    } else {
992                        setTimeout(function () {
993                            self.popupNewsletterInit();
994                        }, delay);
995                    }
996                }
997            }
998        }
999
1000        Module.scrollPopupNewsletter = function () {
1001            const self = this;
1002            if (!self.newsletterPopupFlag && self._window.scrollTop() > self.newsletterDisplayOffset) {
1003                self.newsletterPopupFlag = true;
1004                self.popupNewsletterInit();
1005            }
1006        }
1007
1008        Module.popupNewsletterInit = function () {
1009
1010            const self = this;
1011            if (self.siteAccessFlag) {
1012                return;
1013            }
1014
1015            if (!self.popupNewsletterEl.hasClass('is-pos-fixed')) {
1016                $.magnificPopup.open({
1017                    type: 'inline',
1018                    preloader: false,
1019                    closeBtnInside: true,
1020                    removalDelay: 400,
1021                    showCloseBtn: true,
1022                    closeOnBgClick: false,
1023                    disableOn: 1024,
1024                    items: {
1025                        src: '#rb-popup-newsletter',
1026                        type: 'inline'
1027                    },
1028                    mainClass: 'rb-popup-center',
1029                    fixedBgPos: true,
1030                    fixedContentPos: true,
1031                    closeMarkup: '<span class="close-popup-btn mfp-close"><span class="close-icon"></span></span>',
1032                    callbacks: {
1033                        close: function () {
1034                            if (self.siteAccessFlag) {
1035                                return;
1036                            }
1037                            self.SetTTLStorage('RubyNewsletter', 1, self.newsletterExpired * 24);
1038                        }
1039                    }
1040                });
1041            } else {
1042                self.popupNewsletterEl.removeClass('is-hidden');
1043                setTimeout(() => {
1044                    self.popupNewsletterEl.addClass('yes-show');
1045                }, 10);
1046                const closeBtn = self.popupNewsletterEl.find('.close-popup-btn');
1047                closeBtn.on('click', function () {
1048                    self.SetTTLStorage('RubyNewsletter', 1, self.newsletterExpired * 24);
1049                    self.popupNewsletterEl.removeClass('yes-show');
1050                    setTimeout(() => {
1051                        self.popupNewsletterEl.addClass('is-hidden');
1052                    }, 400);
1053                });
1054            }
1055        }
1056
1057        /** footer slide up */
1058        Module.footerSlideUp = function () {
1059            const target = $('#footer-slideup');
1060            if (target.length > 0) {
1061                const self = this;
1062                self.footerSlideUpExpired = target.data('expired');
1063                const delay = target.data('delay');
1064                const oldExpired = self.getStorage('footerSlideUpExpired');
1065                if (!oldExpired || self.footerSlideUpExpired != oldExpired) {
1066                    self.setStorage('footerSlideUpExpired', self.footerSlideUpExpired);
1067                    self.deleteStorage('footerSlideUp');
1068                }
1069                if (!self.getTTLStorage('footerSlideUp')) {
1070                    setTimeout(function () {
1071                        self.footerSlideUpInit();
1072                    }, delay);
1073                }
1074                /** show hide toggle */
1075                setTimeout(function () {
1076                    self.footerSlideUpToggle();
1077                }, delay);
1078            }
1079        }
1080
1081        Module.footerSlideUpToggle = function () {
1082            const self = this;
1083            $('.slideup-toggle').off('click').on('click', function (e) {
1084                e.preventDefault();
1085                e.stopPropagation();
1086                self.footerSlideUpInit();
1087                return false;
1088            });
1089        }
1090
1091        Module.footerSlideUpInit = function () {
1092            if (this._body.hasClass('yes-f-slideup')) {
1093                this._body.removeClass('yes-f-slideup');
1094                this.SetTTLStorage('footerSlideUp', 1, this.footerSlideUpExpired * 24);
1095            } else {
1096                this._body.addClass('yes-f-slideup');
1097                this.deleteStorage('footerSlideUp');
1098            }
1099        }
1100
1101        /** youtube iframe */
1102        Module.loadYoutubeIframe = function () {
1103
1104            const self = this;
1105            const blockPlaylist = $('.yt-playlist');
1106            if (blockPlaylist.length > 0) {
1107                const tag = document.createElement('script');
1108                tag.src = "//www.youtube.com/iframe_api";
1109                const firstScriptTag = document.getElementsByTagName('script')[0];
1110                firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
1111            }
1112
1113            window.onYouTubeIframeAPIReady = function () {
1114                $('.yt-playlist').each(function () {
1115                    const target = $(this);
1116                    const iframe = target.find('.yt-player');
1117                    const videoID = target.data('id');
1118                    const blockID = target.data('block');
1119                    self.YTPlayers[blockID] = new YT.Player(iframe.get(0), {
1120                        height: '540',
1121                        width: '960',
1122                        videoId: videoID,
1123                        events: {
1124                            'onReady': self.videoPlayToggle,
1125                            'onStateChange': self.videoPlayToggle
1126                        }
1127                    });
1128                });
1129
1130                $('.plist-item').on('click', function (e) {
1131                    e.preventDefault();
1132                    e.stopPropagation();
1133
1134                    const target = $(this);
1135                    const wrapper = target.closest('.yt-playlist');
1136                    const currentBlockID = wrapper.data('block');
1137                    const videoID = target.data('id');
1138                    const title = target.find('.plist-item-title').text();
1139                    const meta = target.data('index');
1140
1141                    Object.keys(self.YTPlayers).forEach(function (id) {
1142                        self.YTPlayers[id].pauseVideo();
1143                    });
1144                    self.YTPlayers[currentBlockID].loadVideoById({
1145                        'videoId': videoID
1146                    });
1147
1148                    wrapper.find('.yt-trigger').addClass('is-playing');
1149                    wrapper.find('.play-title').hide().text(title).fadeIn(200);
1150                    wrapper.find('.video-index').text(meta);
1151                });
1152            }
1153        }
1154
1155        Module.videoPlayToggle = function () {
1156
1157            const players = FOXIZ_MAIN_SCRIPT.YTPlayers;
1158
1159            $('.yt-trigger').on('click', function (e) {
1160                e.preventDefault();
1161                e.stopPropagation();
1162
1163                const target = $(this);
1164                const currentBlockID = target.closest('.yt-playlist').data('block');
1165                const currentState = players[currentBlockID].getPlayerState();
1166                const isPlaying = [1, 3].includes(currentState);
1167                if (!isPlaying) {
1168                    players[currentBlockID].playVideo();
1169                    target.addClass('is-playing');
1170                } else {
1171                    players[currentBlockID].pauseVideo();
1172                    target.removeClass('is-playing');
1173                }
1174            });
1175        }
1176
1177        /** Comment scripts */
1178        Module.showPostComment = function () {
1179            const self = this;
1180
1181            this._document.on('click', '.smeta-sec .meta-comment', function (e) {
1182                e.stopPropagation();
1183                const commentBtn = $('.show-post-comment');
1184                if (commentBtn.length > 0) {
1185                    self.html.animate({scrollTop: commentBtn.offset().top}, 300);
1186                    commentBtn.trigger('click');
1187                }
1188            });
1189
1190            this._document.on('click', '.show-post-comment', function (e) {
1191                e.preventDefault();
1192                e.stopPropagation();
1193                const target = $(this);
1194                const wrap = target.parent();
1195
1196                target.fadeOut(200, function () {
1197                    target.remove();
1198                    wrap.find('.is-invisible').removeClass('is-invisible');
1199                    wrap.next('.comment-holder').removeClass('is-hidden');
1200                })
1201            });
1202        }
1203
1204        /** table scroll */
1205        Module.scrollTableContent = function () {
1206
1207            const self = this;
1208            const behavior = self._body.hasClass('toc-smooth') ? 'smooth' : 'instant';
1209
1210            self._document.on('click', '.anchor-link', function (e) {
1211                e.stopPropagation();
1212
1213                const targetClass = $(this).data('index');
1214                if (!targetClass) return;
1215
1216                let $scrollElement = $(`.${targetClass}`);
1217
1218                // if target not found, search inside its parent .s-ct
1219                if (!$scrollElement.length) {
1220                    const $parentContainer = $(this).closest('.s-ct');
1221                    if ($parentContainer.length) {
1222                        $scrollElement = $parentContainer.find('.restrict-box, .continue-reading-btn').first();
1223                    }
1224                }
1225
1226                if (!$scrollElement.length) return;
1227
1228                setTimeout(() => {
1229                    window.scrollTo({
1230                        top: $scrollElement.offset().top,
1231                        behavior: behavior,
1232                    });
1233                }, 10);
1234            });
1235        };
1236
1237        /** scroll to comment  */
1238        Module.scrollToComment = function () {
1239            const self = this;
1240            const hash = window.location.hash;
1241            if (hash === '#respond' || hash.startsWith('#comment')) {
1242                const commentBtn = $('.show-post-comment').first();
1243                if (commentBtn.length === 0) {
1244                    return;
1245                }
1246                self.html.animate({scrollTop: commentBtn.offset().top - 200}, 400);
1247                commentBtn.trigger('click');
1248            }
1249        }
1250
1251        Module.replyReview = function () {
1252            this._document.on('click', '.comment-reply-link', function () {
1253                const target = $(this);
1254                const wrapper = target.parents('.rb-reviews-area');
1255                const cancelLink = $('#cancel-comment-reply-link');
1256                if (wrapper.length > 0) {
1257                    wrapper.find('.rb-form-rating').addClass('is-hidden');
1258                    cancelLink.on('click', function () {
1259                        wrapper.find('.rb-form-rating').removeClass('is-hidden');
1260                    });
1261                }
1262            });
1263        }
1264
1265        /** user rating */
1266        Module.usersRating = function () {
1267            const self = this;
1268            const reviewsForm = self._body.find('.rb-reviews-form');
1269            if (reviewsForm.length > 0) {
1270                reviewsForm.each(function () {
1271                    const reviewForm = $(this);
1272                    if (!reviewForm.hasClass('is-loaded')) {
1273                        reviewForm.addClass('is-loaded');
1274                        const ratingForm = reviewForm.find('.rb-form-rating');
1275                        const selection = reviewForm.find('.rb-rating-selection');
1276                        const text = reviewForm.find('.rating-alert').html();
1277                        let ratingValue = null;
1278
1279                        selection.val('');
1280                        selection.hide();
1281                        selection.before(
1282                            '<div class="rb-review-stars">\
1283                                <span>\
1284                                    <a class="star" data-rating="1" href="#"><i class="rbi rbi-star-o"></i></a>\
1285                                    <a class="star" data-rating="2" href="#"><i class="rbi rbi-star-o"></i></a>\
1286                                    <a class="star" data-rating="3" href="#"><i class="rbi rbi-star-o"></i></a>\
1287                                    <a class="star" data-rating="4" href="#"><i class="rbi rbi-star-o"></i></a>\
1288                                    <a class="star" data-rating="5" href="#"><i class="rbi rbi-star-o"></i></a>\
1289                                </span>\
1290                            </div>'
1291                        );
1292
1293                        ratingForm.on('click', 'a.star', function (e) {
1294                            e.preventDefault();
1295                            e.stopPropagation();
1296                            const star = $(this);
1297                            ratingValue = star.data('rating');
1298                            star.siblings('a').removeClass('active');
1299                            star.addClass('active');
1300                            ratingForm.addClass('selected');
1301                        });
1302
1303                        reviewForm.on('click', '#respond #submit', function () {
1304                            selection.val(ratingValue);
1305                            if (!selection.val()) {
1306                                window.alert(text);
1307                                return false;
1308                            }
1309                        });
1310                    }
1311                });
1312            }
1313        }
1314
1315        /**
1316         *
1317         * @returns {boolean}
1318         */
1319        Module.readIndicatorInit = function () {
1320
1321            const self = this;
1322            if (!self._body.hasClass('single') || self.readIndicator.length < 1) {
1323                return false;
1324            }
1325
1326            let content = $('.entry-content').first();
1327            if (!content.length) return false;
1328
1329            self.indicatorTop = content.offset().top;
1330            self.indicatorHeight = content.outerHeight(true) - self._window.height();
1331            /** delay for load images */
1332            setTimeout(function () {
1333                self.indicatorTop = content.offset().top;
1334                self.indicatorHeight = content.outerHeight(true) - self._window.height();
1335            }, 1000)
1336
1337            if (window.addEventListener) {
1338                window.addEventListener('scroll', function () {
1339                    self.animationFrame(self.readIndicatorCalc.bind(self));
1340                }, false);
1341            }
1342        }
1343
1344        Module.readIndicatorCalc = function () {
1345            const self = this;
1346            const scroll = self._window.scrollTop();
1347            self.readIndicatorPercent = Math.min(((scroll - self.indicatorTop) / self.indicatorHeight) * 100, 100);
1348            if (self.readIndicatorPercent <= 100) {
1349                self.readIndicator.css('width', self.readIndicatorPercent + '%');
1350            }
1351        }
1352
1353        /** breaking news */
1354        Module.breakingNews = function () {
1355            const self = this;
1356            const breakingNews = $('.breaking-news-slider')
1357
1358            if (breakingNews.length < 1) {
1359                return false;
1360            }
1361
1362            breakingNews.each(function () {
1363                const el = $(this);
1364                let params = {
1365                    slidesPerView: 1,
1366                    loop: true,
1367                }
1368                if (el.data('play')) {
1369                    params.autoplay = {
1370                        delay: el.data('speed') || self.themeSettings.sliderSpeed,
1371                        stopOnLastSlide: false,
1372                        disableOnInteraction: self.isElementorEditor ? true : (window.outerWidth < 1025),
1373                        pauseOnMouseEnter: true
1374                    };
1375                }
1376                params.navigation = {
1377                    nextEl: el.find('.breaking-news-next')[0],
1378                    prevEl: el.find('.breaking-news-prev')[0]
1379                }
1380                new RBSwiper(this, params);
1381            });
1382        }
1383
1384        /** overlay slider */
1385        Module.sliders = function () {
1386
1387            const self = this;
1388            const sliders = $('.post-slider');
1389            if (sliders.length < 1) {
1390                return false;
1391            }
1392
1393            sliders.each(function () {
1394                const slider = $(this);
1395                let params = {
1396                    grabCursor: true,
1397                    allowTouchMove: true,
1398                    effect: self.themeSettings.sliderEffect,
1399                    loop: true,
1400                }
1401                if (slider.data('play')) {
1402                    params.autoplay = {
1403                        delay: slider.data('speed') || self.themeSettings.sliderSpeed,
1404                        stopOnLastSlide: true,
1405                        disableOnInteraction: self.isElementorEditor ? true : (window.outerWidth < 1025),
1406                        pauseOnMouseEnter: true
1407                    };
1408                }
1409
1410                params.pagination = {
1411                    el: slider.find('.slider-pagination')[0],
1412                    clickable: true,
1413                };
1414
1415                params.navigation = {
1416                    nextEl: slider.find('.slider-next')[0],
1417                    prevEl: slider.find('.slider-prev')[0]
1418                }
1419                new RBSwiper(this, params);
1420            });
1421        }
1422
1423        /** carousel blocks */
1424        Module.carousels = function () {
1425            const self = this;
1426            const carousels = $('.post-carousel');
1427            if (carousels.length < 1) {
1428                return false;
1429            }
1430            carousels.each(function () {
1431                const carousel = $(this);
1432                let params = {
1433                    grabCursor: true,
1434                    allowTouchMove: true,
1435                    freeMode: false,
1436                    loop: true
1437                }
1438                params.slidesPerView = carousel.data('mcol');
1439                params.spaceBetween = carousel.data('mgap');
1440                params.centeredSlides = carousel.data('centered');
1441
1442                params.navigation = {
1443                    nextEl: carousel.find('.slider-next')[0],
1444                    prevEl: carousel.find('.slider-prev')[0]
1445                }
1446                if (carousel.find('.slider-pagination')[0]) {
1447                    params.pagination = {
1448                        el: carousel.find('.slider-pagination')[0],
1449                        type: 'bullets',
1450                        clickable: true,
1451                    };
1452                }
1453
1454                if (carousel.data('play')) {
1455                    params.autoplay = {
1456                        delay: carousel.data('speed') || self.themeSettings.sliderSpeed,
1457                        stopOnLastSlide: false,
1458                        disableOnInteraction: self.isElementorEditor ? true : (window.outerWidth < 1025),
1459                        pauseOnMouseEnter: true
1460                    };
1461                }
1462
1463                if (carousel.data('fmode')) {
1464                    params.freeMode = true;
1465                }
1466                params.breakpoints = {
1467                    768: {
1468                        slidesPerView: carousel.data('tcol'),
1469                        spaceBetween: carousel.data('tgap')
1470                    },
1471                    1025: {
1472                        slidesPerView: carousel.data('col'),
1473                        spaceBetween: carousel.data('gap')
1474                    },
1475                    1500: {
1476                        slidesPerView: carousel.data('wcol'),
1477                        spaceBetween: carousel.data('gap')
1478                    }
1479                };
1480                params.on = {
1481                    afterInit: function (swiper) {
1482                        const wrap = $(swiper.$wrapperEl);
1483                        $(swiper.$wrapperEl).find('.p-box').css('height', wrap.height());
1484                    },
1485                    resize: function (swiper) {
1486                        const wrap = $(swiper.$wrapperEl);
1487                        $(swiper.$wrapperEl).find('.p-box').css('height', wrap.height());
1488                    },
1489                };
1490
1491                new RBSwiper(this, params);
1492            });
1493        }
1494
1495        /* ================================ SINGLE GALLERY ================================ */
1496        Module.singleGallery = function () {
1497
1498            const self = this;
1499            const gallerySections = self._body.find('.featured-gallery-wrap');
1500            if (gallerySections.length === 0) {
1501                return;
1502            }
1503
1504            gallerySections.each(function () {
1505                const section = $(this);
1506                if (!section.hasClass('is-loaded')) {
1507                    const index = section.data('gallery');
1508                    const sliderEl = section.find('.gallery-slider').attr('id');
1509                    const sliderNavEl = section.find('.gallery-slider-nav').attr('id');
1510                    const carouselEl = section.find('.gallery-carousel').attr('id');
1511                    const coverflowEL = section.find('.gallery-coverflow').attr('id');
1512
1513                    if (sliderEl && sliderNavEl) {
1514
1515                        const navEl = $('#' + sliderNavEl);
1516                        const navSlidesCount = navEl.find('.swiper-slide').length;
1517                        const shouldLoopNav = navSlidesCount >= 6;
1518                        const viewSlides = Math.min(navSlidesCount, 6);
1519
1520                        if (!shouldLoopNav) {
1521                            navEl.css('max-width', `${navSlidesCount * 125}px`);
1522                        }
1523
1524                        const galleryNav = new RBSwiper('#' + sliderNavEl, {
1525                            spaceBetween: 15,
1526                            slidesPerView: viewSlides,
1527                            freeMode: self.themeSettings.sliderFMode,
1528                            grabCursor: true,
1529                            loop: shouldLoopNav,
1530                            watchSlidesVisibility: shouldLoopNav,
1531                            watchSlidesProgress: true,
1532                            on: {
1533                                init: function () {
1534                                    $(this.$wrapperEl).removeClass('pre-load');
1535                                },
1536                            },
1537                        });
1538
1539                        const gallerySlider = new RBSwiper('#' + sliderEl, {
1540                            spaceBetween: 0,
1541                            grabCursor: true,
1542                            loop: true,
1543                            pagination: {
1544                                el: '.swiper-pagination-' + index,
1545                                type: 'progressbar',
1546                                clickable: true,
1547                            },
1548                            on: {
1549                                init: function () {
1550                                    section.addClass('is-loaded');
1551                                },
1552                            },
1553                            thumbs: {
1554                                swiper: galleryNav
1555                            }
1556                        });
1557
1558                        gallerySlider.on('slideChange', function () {
1559                            const index = this.activeIndex;
1560                            if (index) {
1561                                const label = $(this.$el).next().find('.current-slider-count');
1562                                label.fadeOut(0, function () {
1563                                    $(this).html(index <= label.data('total') ? index : 1).fadeIn(50);
1564                                });
1565                            }
1566                        });
1567                    }
1568
1569                    if ('undefined' !== typeof carouselEl) {
1570                        new RBSwiper('#' + carouselEl, {
1571                            spaceBetween: 20,
1572                            slidesPerView: 'auto',
1573                            freeMode: self.themeSettings.sliderFMode,
1574                            loop: false,
1575                            grabCursor: true,
1576                            scrollbar: {
1577                                el: '.swiper-scrollbar-' + index,
1578                                hide: true,
1579                            },
1580                            on: {
1581                                init: function () {
1582                                    $(this.$wrapperEl).removeClass('pre-load');
1583                                    section.addClass('is-loaded');
1584                                },
1585                            },
1586                        });
1587                    }
1588
1589                    if ('undefined' !== typeof coverflowEL) {
1590                        new RBSwiper('#' + coverflowEL, {
1591                            effect: "coverflow",
1592                            grabCursor: true,
1593                            centeredSlides: true,
1594                            slidesPerView: 1.2,
1595                            coverflowEffect: {
1596                                rotate: 50,
1597                                stretch: 0,
1598                                depth: 250,
1599                                modifier: 1,
1600                                slideShadows: true,
1601                            },
1602                            breakpoints: {
1603                                768: {
1604                                    slidesPerView: 3
1605                                }
1606                            },
1607                            on: {
1608                                init: function () {
1609                                    $(this.$wrapperEl).removeClass('pre-load');
1610                                    section.addClass('is-loaded');
1611                                },
1612                            },
1613                            pagination: {
1614                                el: '.swiper-pagination-' + index,
1615                                clickable: true,
1616                            },
1617                        });
1618                    }
1619                }
1620            });
1621        }
1622
1623        Module.scrollBarSlider = function () {
1624
1625            const self = this;
1626            const items = $('.gb-slider-scrollbar');
1627            if (!items.length) return;
1628
1629            items.each(function (index, itemEl) {
1630                if ($(itemEl).hasClass('is-loaded')) return;
1631
1632                const autoplay = $(itemEl).data('autoplay') === 1;
1633                const caption = $(itemEl).closest('.gb-image-slider').find('.gb-image-caption');
1634                const scrollbarEl = $(itemEl).find('.swiper-scrollbar')[0];
1635
1636                $(itemEl).find('.swiper-wrapper').children().addClass('swiper-slide');
1637
1638                const updateCaption = (swiper) => {
1639                    const captionText = $(swiper.slides[swiper.activeIndex]).find('.wp-element-caption').html() || '';
1640                    caption.fadeOut(150, () => caption.html(captionText).fadeIn(200));
1641                };
1642
1643                new RBSwiper(itemEl, {
1644                    slidesPerView: 1,
1645                    loop: false,
1646                    grabCursor: true,
1647                    autoplay: autoplay ? {
1648                        delay: self.themeSettings.sliderSpeed || 5000,
1649                        disableOnInteraction: self.isElementorEditor ? true : window.outerWidth < 1025,
1650                    } : false,
1651                    scrollbar: {
1652                        el: scrollbarEl,
1653                        hide: false,
1654                    },
1655                    on: {
1656                        init() {
1657                            $(itemEl).removeClass('pre-load').addClass('is-loaded');
1658                            updateCaption(this);
1659                        },
1660                        sl
1660ideChange() {
1661                            updateCaption(this);
1662                        },
1663                    },
1664                });
1665            });
1666        };
1667
1668        Module.highlightShares = function () {
1669
1670            const self = this;
1671
1672            if (!self.themeSettings.highlightShares || (window.matchMedia && window.matchMedia('(pointer: coarse)').matches)) {
1673                return;
1674            }
1675
1676            const config = {
1677                selectableElements: ['.is-highlight-shares'],
1678                twitterUsername: self.themeSettings.twitterName,
1679                facebook: !!self.themeSettings.highlightShareFacebook,
1680                twitter: !!self.themeSettings.highlightShareTwitter
1681            };
1682
1683            const extra = self.themeSettings.highlightShareReddit ? [{
1684                icon: '<i class="rbi rbi-reddit"></i>',
1685                url: 'https://reddit.com/submit?url=PAGE_URL&title=TEXT_SELECTION'
1686            }] : [];
1687
1688            Sharect.config(config).appendCustomShareButtons(extra).init();
1689        }
1690
1691        /**
1692         *
1693         * @returns {boolean}
1694         */
1695        Module.floatingVideo = function () {
1696
1697            const self = this;
1698            const floating = $('.floating-video').not('.is-loaded');
1699
1700            if (floating.length === 0 || window.outerWidth < 1025) {
1701                return false;
1702            }
1703
1704            self.wPoint['Floating'] = new Waypoint({
1705                element: floating,
1706                offset: -floating.height(),
1707                handler: function (direction) {
1708                    self._body.find('.floating-video').addClass('is-loaded').removeClass('floating-activated');
1709                    self._body.find('.floating-close').remove();
1710                    if ('down' == direction) {
1711                        this.element.addClass(' floating-activated');
1712                        this.element.find('.float-holder').prepend('<a class="floating-close close-popup-btn" href="#"><span class="close-icon"></span></a>');
1713                    }
1714                }
1715            });
1716        }
1717
1718        Module.floatingVideoRemove = function () {
1719            const self = this;
1720            self._body.on('click', '.floating-close', function (e) {
1721                e.preventDefault();
1722                e.stopPropagation();
1723                self._body.find('.floating-video').removeClass('floating-activated');
1724                self.wPoint['Floating'].destroy();
1725            })
1726        }
1727
1728        Module.siteAccessDetector = function () {
1729            const self = this;
1730
1731            if (self.themeSettings && self.themeSettings.adDetectorMethod) {
1732                if (self.crwDetect()) {
1733                    return false;
1734                }
1735
1736                setTimeout(() => {
1737                    if (self.themeSettings.adDetectorMethod == 2) {
1738                        self.advanceAdBlockDetector();
1739                    } else {
1740                        self.basicAdBlockDetector();
1741                    }
1742                }, 1500);
1743            }
1744        };
1745
1746        Module.basicAdBlockDetector = function () {
1747
1748            const self = this;
1749            const checktag = $('#rb-checktag');
1750            const placebo = $('.rb-adbanner');
1751
1752            if (checktag.length === 0) {
1753                return false;
1754            }
1755            if (placebo.height() < 1) {
1756                self.siteAccessFlag = true;
1757                $.magnificPopup.close();
1758                setTimeout(() => {
1759                    self.siteAccessNotification();
1760                }, 200);
1761            }
1762        };
1763
1764        Module.advanceAdBlockDetector = async function () {
1765            const self = this;
1766            const googleAdUrl = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js';
1767            const isAdBlocked = await (async () => {
1768                try {
1769                    const controller = new AbortController();
1770                    const timeoutId = setTimeout(() => controller.abort(), 3000);
1771                    await fetch(googleAdUrl, {method: 'HEAD', signal: controller.signal});
1772                    clearTimeout(timeoutId);
1773                    return false;
1774                } catch (error) {
1775                    return true;
1776                }
1777            })();
1778            if (isAdBlocked) {
1779                self.siteAccessFlag = true;
1780                self.siteAccessNotification();
1781            }
1782        };
1783
1784        Module.siteAccessNotification = function () {
1785            $.magnificPopup.open({
1786                type: 'inline',
1787                preloader: false,
1788                showCloseBtn: false,
1789                closeBtnInside: false,
1790                enableEscapeKey: false,
1791                closeOnBgClick: false,
1792                removalDelay: 9999999,
1793                items: {
1794                    src: $('#tmpl-rb-site-access').html(),
1795                    type: 'inline'
1796                },
1797                mainClass: 'rb-popup-center site-access-popup',
1798                fixedBgPos: true,
1799                fixedContentPos: true,
1800            });
1801
1802            window.addEventListener('contextmenu', event => event.preventDefault());
1803        }
1804
1805        /** build gallery lightbox */
1806        Module.galleryLightbox = function () {
1807
1808            const self = this;
1809            if (!self.galleriesData) {
1810                return;
1811            }
1812
1813            $('.gallery-popup-trigger').on('click', function (e) {
1814                e.preventDefault();
1815                e.stopPropagation();
1816
1817                const target = $(this);
1818                const slideIndex = target.data('index');
1819
1820                $.magnificPopup.open({
1821                    type: 'inline',
1822                    mainClass: 'rb-gallery-popup rb-popup-center',
1823                    closeMarkup: '<button title="%title%" class="mfp-close mfp-button"><i class="rbi rbi-close"></i></button>',
1824                    closeOnBgClick: false,
1825                    removalDelay: 400,
1826                    showCloseBtn: true,
1827                    fixedBgPos: true,
1828                    fixedContentPos: true,
1829                    preloader: false,
1830                    gallery: {
1831                        enabled: true,
1832                        preload: [0, 2],
1833                        arrowMarkup: '<button title="%title%" type="button" class="mfp-arrow mfp-button mfp-arrow-%dir%"><i class="rbi rbi-%dir%"></i></button>',
1834                        tCounter: '<span>%curr% / %total%</span>'
1835                    },
1836                    callbacks: {
1837                        open: function () {
1838                            let itemsArray = Object.values(self.galleriesData);
1839                            let targetIndex = itemsArray.findIndex(item => item.key === slideIndex);
1840                            if (targetIndex !== -1) {
1841                                $.magnificPopup.instance.goTo(targetIndex);
1842                            }
1843                        },
1844                        change: function () {
1845
1846                            let imgContainer = $('.gallery-popup-content');
1847                            let loader = imgContainer.find('.rb-loader');
1848                            let img = imgContainer.find('img');
1849                            loader.show();
1850
1851                            if (!img.length) {
1852                                loader.hide();
1853                                return;
1854                            }
1855
1856                            let loaderTimeout = setTimeout(() => {
1857                                loader.fadeIn(200);
1858                            }, 300); // Show loader only if image takes longer  300ms
1859
1860                            img.on('load', function () {
1861                                clearTimeout(loaderTimeout); // Prevent loader from showing if image loads within 300ms
1862                                loader.hide();
1863                            }).on('error', function () {
1864                                clearTimeout(loaderTimeout);
1865                                loader.hide();
1866                            });
1867                        },
1868                        afterClose: function () {
1869                            $.magnificPopup.instance.popupsCache = {};
1870                        },
1871                        buildControls: function () {
1872                            if (this.arrowLeft && this.arrowRight) {
1873                                this.contentContainer.find('.gallery-popup-nav').append(this.arrowLeft.add(this.arrowRight));
1874                            }
1875                        }
1876                    },
1877                    inline: {
1878                        markup:
1879                            '<div class="gallery-popup-header light-scheme">' +
1880                            '<div class="mfp-counter"></div><div class="mfp-title h5"></div>' +
1881                            '<div class="popup-header-right"><div class="mfp-close"></div></div>' +
1882                            '</div><div class="gallery-popup-nav"></div>' +
1883                            '<div class="gallery-popup-content"><i class="rb-loader"></i>' +
1884                            '<div class="gallery-popup-image mfp-image"></div>' +
1885                            '<div class="gallery-popup-entry light-scheme">' +
1886                            '<div class="h4 mfp-excerpt"></div>' +
1887                            '<div class="description-text mfp-description"></div>' +
1888                            '</div>' +
1889                            '</div>'
1890                    },
1891                    items: Object.values(self.galleriesData)
1892                });
1893
1894                return false;
1895            });
1896        };
1897
1898        /** single featured lightbox */
1899        Module.singleFeaturedLightbox = function () {
1900            $('.featured-lightbox-trigger').on('click', function (e) {
1901
1902                e.preventDefault();
1903                e.stopPropagation();
1904
1905                const trigger = $(this);
1906                const source = '<img src="' + trigger.data('source') + '" alt="' + $(this).find('img').attr('alt') + '">';
1907                const caption = trigger.data('caption');
1908                const attribution = trigger.data('attribution');
1909
1910                $.magnificPopup.open({
1911                    mainClass: 'rb-popup-center popup-no-overflow',
1912                    closeOnBgClick: true,
1913                    removalDelay: 400,
1914                    showCloseBtn: true,
1915                    fixedBgPos: true,
1916                    fixedContentPos: true,
1917                    preloader: false,
1918                    closeMarkup: '<button title="%title%" class="mfp-close rb-popup-close"><i class="rbi rbi-close"></i></button>',
1919                    callbacks: {
1920                        afterClose: function () {
1921                            $.magnificPopup.instance.popupsCache = {};
1922                        },
1923                    },
1924                    inline: {
1925                        markup:
1926                            '<div class="featured-popup-image"><div class="mfp-source"></div>' +
1927                            '<div class="mfp-close rb-popup-close"></div></div>' +
1928                            '<div class="gallery-popup-entry light-scheme">' +
1929                            '<div class="h4 mfp-excerpt"></div>' +
1930                            '<div class="description-text mfp-description"></div>' +
1931                            '</div>'
1932                    },
1933                    items: {
1934                        source: source,
1935                        excerpt: caption,
1936                        description: attribution,
1937                    },
1938                });
1939            });
1940        }
1941
1942        /** Ajax pagination */
1943        Module.paginationNextPrev = function () {
1944            const self = this;
1945            self._body.on('click', '.pagination-trigger', function (e) {
1946
1947                e.preventDefault();
1948                e.stopPropagation();
1949                const paginationTrigger = $(this);
1950                if (paginationTrigger.hasClass('is-disable')) {
1951                    return;
1952                }
1953
1954                const block = paginationTrigger.parents('.block-wrap');
1955                const uuid = block.attr('id');
1956
1957                if (!self.ajaxData[uuid]) {
1958                    self.ajaxData[uuid] = self.getBlockSettings(uuid);
1959                }
1960                if (self.ajaxData[uuid] && self.ajaxData[uuid].processing) {
1961                    return;
1962                }
1963                self.ajaxData[uuid].processing = true;
1964                const type = paginationTrigger.data('type');
1965                self.ajaxStartAnimation(block, 'replace');
1966                self.ajaxReplaceLoad(block, uuid, type);
1967            });
1968        }
1969
1970        Module.ajaxReplaceLoad = function (block, uuid, type) {
1971
1972            const self = this;
1973
1974            if (!self.ajaxData[uuid].paged) {
1975                self.ajaxData[uuid].paged = 1;
1976            }
1977            if ('prev' === type) {
1978                self.ajaxData[uuid].page_next = parseInt(self.ajaxData[uuid].paged) - 1;
1979            } else {
1980                self.ajaxData[uuid].page_next = parseInt(self.ajaxData[uuid].paged) + 1;
1981            }
1982
1983            const cacheID = self.cacheData.getCacheID(uuid, self.ajaxData[uuid].page_next);
1984
1985            /** use cache */
1986            if (self.cacheData.exist(cacheID)) {
1987                const cache = self.cacheData.get(cacheID);
1988                if ('undefined' !== typeof cache.paged) {
1989                    self.ajaxData[uuid].paged = cache.paged;
1990                }
1991                setTimeout(function () {
1992                    self.ajaxRenderHTML(block, uuid, cache, 'replace');
1993                }, 200)
1994
1995            } else {
1996                /** POST AJAX */
1997                $.ajax({
1998                    type: 'GET',
1999                    url: self.ajaxURL,
2000                    data: {
2001                        action: 'rblivep',
2002                        data: self.ajaxData[uuid]
2003                    },
2004                    success: function (response) {
2005                        response = JSON.parse(JSON.stringify(response));
2006                        if ('undefined' !== typeof response.paged) {
2007                            self.ajaxData[uuid].paged = response.paged;
2008                        }
2009                        self.cacheData.set(cacheID, response);
2010                        self.ajaxRenderHTML(block, uuid, response, 'replace');
2011                    }
2012                });
2013            }
2014        }
2015
2016        Module.paginationLoadMore = function () {
2017            const self = this;
2018            self._body.on('click', '.loadmore-trigger', function (e) {
2019
2020                e.preventDefault();
2021                e.stopPropagation();
2022
2023                const paginationTrigger = $(this);
2024                if (paginationTrigger.hasClass('is-disable')) {
2025                    return;
2026                }
2027
2028                const block = paginationTrigger.parents('.block-wrap');
2029                const uuid = block.attr('id');
2030
2031                if (!self.ajaxData[uuid]) {
2032                    self.ajaxData[uuid] = self.getBlockSettings(uuid);
2033                }
2034                if (self.ajaxData[uuid] && self.ajaxData[uuid].processing) {
2035                    return;
2036                }
2037                self.ajaxData[uuid].processing = true;
2038                self.ajaxStartAnimation(block, 'append');
2039                self.ajaxAppendLoad(block, uuid);
2040            })
2041        }
2042
2043        Module.paginationInfinite = function () {
2044
2045            const self = this;
2046
2047            const infiniteElements = $('.pagination-infinite');
2048            if (infiniteElements.length > 0) {
2049                infiniteElements.each(function () {
2050                    const paginationTrigger = $(this);
2051                    if (!paginationTrigger.hasClass('is-disable')) {
2052                        const block = paginationTrigger.parents('.block-wrap');
2053                        if ((block.hasClass('is-hoz-scroll') || block.hasClass('is-mhoz-scroll') || block.hasClass('is-thoz-scroll')) && window.outerWidth < 1025) {
2054                            paginationTrigger.addClass('is-disable');
2055                            return;
2056                        }
2057                        const uuid = block.attr('id');
2058                        const wPointID = 'infinite' + uuid;
2059                        if (!self.ajaxData[uuid]) {
2060                            self.ajaxData[uuid] = self.getBlockSettings(uuid);
2061                        }
2062                        const params = {
2063                            element: paginationTrigger,
2064                            offset: 'bottom-in-view',
2065                            handler: function (direction) {
2066                                if (self.ajaxData[uuid] && self.ajaxData[uuid].processing) {
2067                                    return;
2068                                }
2069                                if ('down' == direction) {
2070                                    self.ajaxData[uuid].processing = true;
2071                                    self.ajaxStartAnimation(block, 'append');
2072                                    self.ajaxAppendLoad(block, uuid);
2073                                }
2074                            }
2075                        }
2076                        self.wPoint[wPointID] = new Waypoint(params);
2077                    }
2078                });
2079            }
2080        }
2081
2082        Module.ajaxAppendLoad = function (block, uuid) {
2083            const self = this;
2084            if (!self.ajaxData[uuid].paged) {
2085                self.ajaxData[uuid].paged = 1;
2086            }
2087            if (self.ajaxData[uuid].paged >= self.ajaxData[uuid].page_max) {
2088                return;
2089            }
2090            self.ajaxData[uuid].page_next = parseInt(self.ajaxData[uuid].paged) + 1;
2091            $.ajax({
2092                type: 'GET',
2093                url: self.ajaxURL,
2094                data: {
2095                    action: 'rblivep',
2096                    data: self.ajaxData[uuid]
2097                },
2098                success: function (response) {
2099                    response = JSON.parse(JSON.stringify(response));
2100                    if ('undefined' !== typeof response.paged) {
2101                        self.ajaxData[uuid].paged = response.paged;
2102                    }
2103                    if ('undefined' !== typeof response.notice) {
2104                        response.content = response.content + response.notice;
2105                    }
2106                    self.ajaxRenderHTML(block, uuid, response, 'append');
2107                }
2108            });
2109        }
2110
2111        Module.liveSearch = function () {
2112
2113            const liveSearch = $('.live-search-form');
2114            if (liveSearch.length === 0) {
2115                return;
2116            }
2117
2118            const self = this;
2119
2120            liveSearch.each(function () {
2121                const liveSearchEl = $(this);
2122                const input = liveSearchEl.find('input[type="text"]');
2123                const responseWrap = liveSearchEl.find('.live-search-response');
2124                const animation = liveSearchEl.find('.live-search-animation');
2125                const limit = liveSearchEl.data('limit');
2126                const search = liveSearchEl.data('search');
2127                const follow = liveSearchEl.data('follow');
2128                const tax = liveSearchEl.data('tax');
2129                const dsource = liveSearchEl.data('dsource');
2130                const ptype = liveSearchEl.data('ptype');
2131
2132                input.attr('autocomplete', 'off');
2133
2134                input.on('focus', function () {
2135                    const param = $(this).val();
2136                    if (param && !responseWrap.is(':empty')) {
2137                        responseWrap.css('height', 'auto').fadeIn(200);
2138                    }
2139                });
2140
2141                const delay = (function () {
2142                    let timer = 0;
2143                    return function (callback, ms) {
2144                        clearTimeout(timer);
2145                        timer = setTimeout(callback, ms);
2146                    };
2147                })();
2148
2149                input.keyup(function () {
2150                    const param = $(this).val();
2151                    delay(function () {
2152                        if (param) {
2153                            liveSearchEl.addClass('search-loading');
2154                            setTimeout(function () {
2155                                animation.fadeIn(100);
2156                            }, 120);
2157
2158                            $.ajax({
2159                                type: 'GET',
2160                                url: self.ajaxURL,
2161                                data: {
2162                                    action: 'rbsearch',
2163                                    s: param,
2164                                    limit: limit,
2165                                    search: search,
2166                                    follow: follow,
2167                                    tax: tax,
2168                                    dsource: dsource,
2169                                    ptype: ptype,
2170                                },
2171                                success: function (data) {
2172                                    data = $.parseJSON(JSON.stringify(data));
2173                                    animation.fadeOut(200);
2174                                    setTimeout(function () {
2175                                        liveSearchEl.removeClass('search-loading');
2176                                    }, 200);
2177                                    responseWrap.hide().empty().css('height', responseWrap.height());
2178                                    responseWrap.html(data);
2179                                    if ('category' === search && follow && typeof FOXIZ_PERSONALIZE !== 'undefined') {
2180                                        FOXIZ_PERSONALIZE.syncLayoutCategories();
2181                                    }
2182                                    responseWrap.css('height', 'auto').fadeIn(200);
2183                                }
2184                            });
2185                        } else {
2186                            responseWrap.fadeOut(200, function () {
2187                                responseWrap.empty().css('height', 'auto');
2188                            });
2189                        }
2190                    }, 300);
2191                })
2192            });
2193        }
2194
2195        /** personalized block */
2196        Module.personalizeBlocks = function () {
2197            const self = this;
2198            const elements = $('.is-ajax-block');
2199            if (elements.length > 0) {
2200                const blockRequests = elements.map(function () {
2201                    const block = $(this);
2202                    const uuid = block.attr('id');
2203                    if (!self.ajaxData[uuid]) {
2204                        self.ajaxData[uuid] = self.getBlockSettings(uuid);
2205                    }
2206
2207                    if (self.ajaxData[uuid].content_source &&
2208                        self.ajaxData[uuid].content_source === 'recommended' &&
2209                        typeof foxizQueriedIDs !== 'undefined' && foxizQueriedIDs.data
2210                    ) {
2211                        self.ajaxData[uuid].post_not_in = foxizQueriedIDs.data;
2212                    }
2213
2214                    self.ajaxData[uuid].uID = self.getStorage('RBUUID', '0');
2215
2216                    return $.ajax({
2217                        type: 'GET',
2218                        url: self.ajaxURL,
2219                        data: {
2220                            action: 'rbpersonalizeb',
2221                            data: self.ajaxData[uuid]
2222                        }
2223                    });
2224                });
2225
2226                Promise.all(blockRequests).then(responses => {
2227                    responses.forEach((response, index) => {
2228                        const block = $(elements[index]);
2229                        block.html(response).fadeIn(200);
2230                        block.dequeue();
2231                    });
2232                    self.reloadBlockFunc();
2233                });
2234            }
2235        };
2236
2237        /** personalized categories */
2238        Module.personalizeCategories = function () {
2239
2240            const self = this;
2241            const elements = $('.is-ajax-categories');
2242            if (elements.length > 0) {
2243                const categoryRequests = elements.map(function () {
2244                    const block = $(this);
2245                    const uuid = block.attr('id');
2246                    if (!self.ajaxData[uuid]) {
2247                        self.ajaxData[uuid] = self.getBlockSettings(uuid);
2248                    }
2249                    return $.ajax({
2250                        type: 'GET',
2251                        url: self.ajaxURL,
2252                        data: {
2253                            action: 'rbpersonalizecat',
2254                            data: self.ajaxData[uuid]
2255                        }
2256                    });
2257                });
2258
2259                Promise.all(categoryRequests).then(responses => {
2260                    responses.forEach((response, index) => {
2261                        const block = $(elements[index]);
2262                        block.html(response).fadeIn(200);
2263                        block.dequeue();
2264                    });
2265
2266                    if (typeof FOXIZ_PERSONALIZE !== 'undefined') {
2267                        FOXIZ_PERSONALIZE.syncLayoutCategories();
2268                    }
2269                    self.reloadBlockFunc();
2270                });
2271            }
2272        };
2273
2274        Module.readingCollect = function () {
2275            const self = this;
2276            if (self.themeSettings.yesReadingHis === undefined) {
2277                return;
2278            }
2279            $.ajax({
2280                type: 'GET',
2281                url: self.ajaxURL,
2282                data: {
2283                    action: 'rbcollect',
2284                    id: self.themeSettings.yesReadingHis
2285                }
2286            });
2287        };
2288
2289        /** header notification */
2290        Module.newsNotification = function () {
2291
2292            const notificationWrapper = $('.rb-notification');
2293            if (notificationWrapper.length < 1) {
2294                return false;
2295            }
2296            const notificationID = this.personalizeUID + '-notification';
2297            const notificationCount = this.personalizeUID + '-notification-count';
2298
2299            const self = this;
2300            const dot = $('.notification-info');
2301            const content = self.getTTLStorage(notificationID);
2302            const count = self.getTTLStorage(notificationCount);
2303            let reload = notificationWrapper.data('interval');
2304            if (!reload || isNaN(reload) || reload <= 0) {
2305                reload = 6;
2306            }
2307            if (!content) {
2308                $.ajax({
2309                    type: 'GET',
2310                    url: self.ajaxURL,
2311                    data: {
2312                        action: 'rbnotification',
2313                    },
2314                    success: function (response) {
2315                        response = $.parseJSON(JSON.stringify(response));
2316                        self.SetTTLStorage(notificationID, response.content, reload);
2317                        self.SetTTLStorage(notificationCount, response.count, reload);
2318                        notificationWrapper.append(response.content);
2319                        if (response.count) {
2320                            dot.append(response.count);
2321                            dot.css('opacity', 1);
2322                        }
2323                    }
2324                });
2325            } else {
2326                notificationWrapper.append(content);
2327                dot.append(count);
2328            }
2329        };
2330
2331        /** register cache object */
2332        Module.cacheData = {
2333
2334            data: {},
2335            get: function (id) {
2336                return this.data[id];
2337            },
2338
2339            set: function (id, data) {
2340                this.remove(id);
2341                this.data[id] = data;
2342            },
2343
2344            remove: function (id) {
2345                delete this.data[id];
2346            },
2347
2348            getCacheID: function (blockID, currentPage) {
2349                return JSON.stringify('RB_' + blockID + '_' + currentPage);
2350            },
2351
2352            exist: function (id) {
2353                return this.data.hasOwnProperty(id) && this.data[id] !== null;
2354            }
2355        }
2356
2357        /**
2358         * ajax start animation
2359         * @param block
2360         * @param action
2361         */
2362        Module.ajaxStartAnimation = function (block, action) {
2363
2364            const inner = block.find('.block-inner');
2365            block.find('.pagination-trigger').addClass('is-disable');
2366            inner.stop();
2367
2368            if ('replace' === action) {
2369                inner.css('min-height', inner.outerHeight());
2370                inner.fadeTo('200', 0.05);
2371                inner.after('<i class="rb-loader loader-absolute"></i>');
2372            } else {
2373                block.find('.loadmore-trigger').addClass('loading');
2374                block.find('.rb-loader').css({'display': 'block'}).delay(200).animate({opacity: 1}, 200);
2375            }
2376        }
2377
2378        /**
2379         * render ajax
2380         * @param block
2381         * @param uuid
2382         * @param response
2383         * @param action
2384         */
2385        Module.ajaxRenderHTML = function (block, uuid, response, action) {
2386
2387            const self = this;
2388
2389            block.delay(50).queue(function () {
2390                const uuid = block.attr('id');
2391                const inner = block.find('.block-inner');
2392                block.find('.pagination-trigger').removeClass('is-disable');
2393                inner.stop();
2394
2395                if ('replace' === action) {
2396                    inner.html(response.content);
2397                    block.find('.rb-loader').animate({opacity: 0}, 200, function () {
2398                        $(this).remove();
2399                    })
2400                    inner.css('min-height', '');
2401                    inner.fadeTo(200, 1);
2402
2403                } else {
2404                    const content = $(response.content);
2405                    inner.append(content);
2406                    content.addClass('is-invisible');
2407                    content.addClass('opacity-animate');
2408
2409                    block.find('.rb-loader').animate({opacity: 0}, 200, function () {
2410                        $(this).css({'display': 'none'});
2411                    });
2412                    setTimeout(function () {
2413                        content.removeClass('is-invisible');
2414                    }, 200);
2415                    block.find('.loadmore-trigger').removeClass('loading');
2416                }
2417
2418                /** reload */
2419                self.ajaxTriggerState(block, uuid);
2420                self.ajaxData[uuid].processing = false;
2421                block.dequeue();
2422                self.reloadBlockFunc();
2423            });
2424        }
2425
2426        /**
2427         * set
2428         * @param block
2429         * @param uuid
2430         */
2431        Module.ajaxTriggerState = function (block, uuid) {
2432            const self = this;
2433            block.find('.pagination-trigger').removeClass('is-disable');
2434            if (self.ajaxData[uuid].paged < 2) {
2435                block.find('[data-type="prev"]').addClass('is-disable');
2436            } else if (self.ajaxData[uuid].paged >= self.ajaxData[uuid].page_max) {
2437                block.find('[data-type="next"]').addClass('is-disable');
2438                block.find('.loadmore-trigger').addClass('is-disable').hide();
2439                block.find('.pagination-infinite').addClass('is-disable').hide();
2440            }
2441        }
2442
2443        Module.getBlockSettings = function (uuid) {
2444            const settings = typeof window[uuid] !== 'undefined' ? window[uuid] : undefined;
2445            return this.cleanNull(settings);
2446        }
2447
2448        Module.cleanNull = function (data) {
2449            if (typeof data === 'string') {
2450                return data;
2451            }
2452
2453            if (data && typeof data === 'object') {
2454                Object.keys(data).forEach(key => {
2455                    if (data[key] === '' || data[key] === null) {
2456                        delete data[key];
2457                    }
2458                });
2459            }
2460
2461            return data;
2462        };
2463
2464        /* SINGLE INFINITE */
2465        Module.singleInfiniteLoadNext = function () {
2466
2467            const infiniteWrapper = $('#single-post-infinite');
2468            const self = this;
2469
2470            if (!infiniteWrapper.length || self.disabledLoadNext()) {
2471                return;
2472            }
2473
2474            self.singleLoadNextCounter = 1;
2475            self.singleLoadNextLimit = self.themeSettings?.singleLoadNextLimit ? parseInt(self.themeSettings.singleLoadNextLimit, 10) : 20;
2476
2477            const infiniteLoadPoint = $('#single-infinite-point');
2478            const animationIcon = infiniteLoadPoint.find('.rb-loader');
2479            const rootURL = new URL(window.location.href);
2480            const rootGetParams = rootURL.searchParams;
2481
2482            const loadNextParams = {
2483                element: infiniteLoadPoint,
2484                offset: 'bottom-in-view',
2485                handler: function (direction) {
2486                    if (self.ajaxData.singleProcessing || direction === 'up' || self.singleLoadNextCounter > self.singleLoadNextLimit) {
2487                        return;
2488                    }
2489                    const nextPostURL = new URL(infiniteWrapper.data('nextposturl'));
2490                    nextPostURL.searchParams.set('rbsnp', '1');
2491                    if (rootGetParams) {
2492                        rootGetParams.forEach((value, key) => {
2493                            if (key !== 'rbsnp' && 'p' !== key) {
2494                                nextPostURL.searchParams.set(key, value);
2495                            }
2496                        });
2497                    }
2498                    self.ajaxData.singleProcessing = true;
2499                    animationIcon.css('display', 'block').animate({opacity: 1}, 200);
2500
2501                    $.ajax({
2502                        type: 'GET',
2503                        url: nextPostURL.toString(),
2504                        dataType: 'html',
2505                        success: function (response) {
2506                            response = $('<div id="temp-dom"></div>').append($.parseHTML(response)).find('.single-post-outer');
2507                            const nextPostURL = response.data('nextposturl');
2508
2509                            if (nextPostURL) {
2510                                infiniteWrapper.data('nextposturl', nextPostURL);
2511                            } else {
2512                                infiniteWrapper.removeAttr('id');
2513                                infiniteLoadPoint.remove();
2514                            }
2515
2516                            animationIcon.animate({opacity: 0}, 200).delay(200).css('display', 'none');
2517                            infiniteWrapper.append(response);
2518                            self.ajaxData.singleProcessing = false;
2519                            self.singleLoadNextCounter++;
2520
2521                            setTimeout(function () {
2522                                self.reInitAll();
2523                                if (typeof FOXIZ_CORE_SCRIPT !== 'undefined') {
2524                                    FOXIZ_CORE_SCRIPT.loadGoogleAds(response);
2525                                    FOXIZ_CORE_SCRIPT.loadInstagram(response);
2526                                    FOXIZ_CORE_SCRIPT.loadTwttr();
2527                                }
2528                            }, 1);
2529                        }
2530                    });
2531                }
2532            };
2533
2534            self.wPoint.ajaxSingleNextPosts = new Waypoint(loadNextParams);
2535        };
2536
2537        Module.singleScrollRefresh = function () {
2538
2539            const infiniteWrapper = $('#single-post-infinite');
2540            if (!infiniteWrapper.length) {
2541                return;
2542            }
2543            const self = this;
2544            self.articleData = [];
2545            const articleOuter = infiniteWrapper.find('.single-post-outer');
2546
2547            if (articleOuter.length > 0) {
2548                self.inviewPostID = articleOuter.eq(0).data('postid');
2549
2550                articleOuter.each(function () {
2551                    const article = $(this);
2552                    const itemData = {
2553                        postID: article.data('postid'),
2554                        postURL: article.data('postlink'),
2555                        postTitle: article.find('h1.s-title').text(),
2556                        shareList: article.find('.sticky-share-list-buffer').html(),
2557                        top: article.offset().top,
2558                        bottom: article.offset().top + article.outerHeight(true)
2559                    };
2560
2561                    if (self.readIndicator.length > 0) {
2562                        const content = article.find('.rbct').eq(0);
2563                        itemData.indicatorTop = content.offset().top;
2564                        itemData.indicatorHeight = content.outerHeight(true) - self._window.height();
2565                    }
2566                    self.articleData.push(itemData);
2567                });
2568
2569                const onScroll = () => {
2570                    self.animationFrame(self.scrollToUpdateArticle.bind(self));
2571                };
2572                if (window.addEventListener) {
2573                    window.addEventListener('scroll', onScroll, false);
2574                }
2575            }
2576        }
2577
2578        /** scrollToUpdateArticle */
2579        Module.scrollToUpdateArticle = function () {
2580            const self = this;
2581            const scroll = self._window.scrollTop();
2582
2583            self.articleData.every(article => {
2584                if (scroll > (article.top + 5) && scroll < (article.bottom - 5)) {
2585                    if (article.indicatorTop) {
2586                        self.readIndicatorPercent = Math.min(((scroll - article.indicatorTop) / article.indicatorHeight) * 100, 100);
2587                        if (self.readIndicatorPercent <= 100) {
2588                            self.readIndicator.css('width', `${self.readIndicatorPercent}%`);
2589                        }
2590                    }
2591
2592                    if (article.postID !== self.inviewPostID) {
2593                        self.inviewPostID = article.postID;
2594                        if (article.postURL) {
2595                            history.replaceState(null, null, article.postURL);
2596                        }
2597                        document.title = article.postTitle;
2598                        $('.single-post-outer').removeClass('activated');
2599                        $('[data-postid="' + article.postID + '"]').addClass('activated');
2600                        $('#s-title-sticky .sticky-title').hide().html(article.postTitle).fadeIn(300);
2601                        $('#s-title-sticky .sticky-share-list').html(article.shareList);
2602                        self._body.find('.floating-video').removeClass('floating-activated');
2603
2604                        if (typeof FOXIZ_CORE_SCRIPT !== 'undefined') {
2605                            FOXIZ_CORE_SCRIPT.updateGA(article);
2606                        }
2607                    }
2608                    return false;
2609                }
2610
2611                return true;
2612
2613            });
2614        }
2615
2616        /**
2617         * @returns {boolean}
2618         */
2619        Module.crwDetect = function () {
2620            const botPatterns = [
2621                /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|yaho
2621oysmcm|yammybot|ahrefsbot|pingdom.com_bot|kraken|yandexbot|twitterbot|tweetmemebot|openhosebot|queryseekerspider|linkdexbot|grokkit-crawler|livelapbot|germcrawler|domaintunocrawler|grapeshotcrawler|cloudflare-alwaysonline/i
2622            ];
2623
2624            const userAgent = navigator.userAgent;
2625            return botPatterns.some(pattern => pattern.test(userAgent));
2626        };
2627
2628        /**
2629         *
2630         * @returns {boolean}
2631         */
2632        Module.disabledLoadNext = function () {
2633
2634            if (this.themeSettings.crwLoadNext) {
2635                return false;
2636            }
2637
2638            return this.crwDetect();
2639        }
2640
2641        /** productQuantity */
2642        Module.productQuantity = function () {
2643            this._document.on('click', '.quantity .quantity-btn', function (e) {
2644
2645                e.preventDefault();
2646                e.stopPropagation();
2647
2648                const button = $(this);
2649                const input = button.parent().find('input');
2650
2651                let step = 1;
2652                let min = 1;
2653                let max = 9999;
2654                let value_old = parseInt(input.val());
2655                let value_new = parseInt(input.val());
2656
2657                if (input.attr('step')) {
2658                    step = parseInt(input.attr('step'));
2659                }
2660
2661                if (input.attr('min')) {
2662                    min = parseInt(input.attr('min'));
2663                }
2664
2665                if (input.attr('max')) {
2666                    max = parseInt(input.attr('max'));
2667                }
2668
2669                if (button.hasClass('up')) {
2670                    if (value_old < max) {
2671                        value_new = value_old + step;
2672                    } else {
2673                        value_new = 1;
2674                    }
2675                } else if (button.hasClass('down')) {
2676                    if (value_old > min) {
2677                        value_new = value_old - step;
2678                    } else {
2679                        value_new = 0;
2680                    }
2681                }
2682
2683                if (!input.attr('disabled')) {
2684                    input.val(value_new).change();
2685                }
2686            });
2687        }
2688
2689        Module.cartNotification = function () {
2690            const self = this;
2691            const element = $('#add-cart-popup');
2692
2693            self._body.on('added_to_cart', function () {
2694                element.fadeIn(200);
2695                self.cartNotificationTimeOut = setTimeout(function () {
2696                    element.fadeOut(200);
2697                }, 5000);
2698                self.hoveringNotification(element);
2699            });
2700        }
2701
2702        Module.hoveringNotification = function (element) {
2703            const self = this;
2704
2705            element.on('mouseenter', function () {
2706                clearTimeout(self.cartNotificationTimeOut);
2707            });
2708
2709            element.on('mouseleave', function () {
2710                setTimeout(function () {
2711                    element.fadeOut(200);
2712                }, 1500);
2713            });
2714        }
2715
2716        /** like/dislike */
2717        Module.likeToggle = function () {
2718
2719            const self = this;
2720            let reaction = '';
2721            self._body.on('click', '.like-trigger, .dislike-trigger', function (e) {
2722
2723                e.preventDefault();
2724                e.stopPropagation();
2725
2726                const target = $(this);
2727                const wrap = target.parent('[data-like]');
2728                const pid = wrap.data('like');
2729
2730                if (!pid || self.isProgress) return;
2731
2732                self.isProgress = true;
2733                const storageKey = self.getLikeKey(pid);
2734                const isLike = target.hasClass('like-trigger');
2735                const isDislike = target.hasClass('dislike-trigger');
2736                const sibEl = target.siblings();
2737                const likeCountEl = wrap.find('.like-count');
2738                const dislikeCountEl = wrap.find('.dislike-count');
2739                let likeCountText = likeCountEl.text();
2740                let dislikeCountText = dislikeCountEl.text();
2741
2742                if (isLike) {
2743                    if (!target.hasClass('triggered')) {
2744                        reaction = 'like';
2745                        if (!/[kKmM]/.test(likeCountText)) {
2746                            likeCountText = parseInt(likeCountText);
2747                            if (isNaN(likeCountText)) {
2748                                likeCountText = 0;
2749                            }
2750                            likeCountEl.text(likeCountText + 1);
2751                        }
2752                        target.addClass('triggered');
2753
2754                        if (sibEl.hasClass('triggered')) {
2755                            sibEl.removeClass('triggered');
2756                            if (!/[kKmM]/.test(dislikeCountText)) {
2757                                dislikeCountText = parseInt(dislikeCountText) - 1;
2758                                if (isNaN(dislikeCountText) || dislikeCountText < 1) {
2759                                    dislikeCountText = '';
2760                                }
2761                                dislikeCountEl.text(dislikeCountText);
2762                            }
2763                        }
2764                        self.setStorage(storageKey, 'like');
2765                    } else {
2766                        reaction = 'rmlike';
2767                        if (!/[kKmM]/.test(likeCountText)) {
2768                            likeCountText = parseInt(likeCountText) - 1;
2769                            if (isNaN(likeCountText) || likeCountText < 1) {
2770                                likeCountText = '';
2771                            }
2772                            likeCountEl.text(likeCountText);
2773                        }
2774                        target.removeClass('triggered');
2775                        self.deleteStorage(storageKey);
2776                    }
2777                } else if (isDislike) {
2778                    if (!target.hasClass('triggered')) {
2779                        reaction = 'dislike';
2780                        if (!/[kKmM]/.test(dislikeCountText)) {
2781                            dislikeCountText = parseInt(dislikeCountText);
2782                            if (isNaN(dislikeCountText)) {
2783                                dislikeCountText = 0;
2784                            }
2785                            dislikeCountEl.text(dislikeCountText + 1);
2786                        }
2787                        target.addClass('triggered');
2788                        if (sibEl.hasClass('triggered')) {
2789                            sibEl.removeClass('triggered');
2790                            if (!/[kKmM]/.test(likeCountText)) {
2791                                likeCountText = parseInt(likeCountText) - 1;
2792                                if (isNaN(likeCountText) || likeCountText < 1) {
2793                                    likeCountText = '';
2794                                }
2795                                likeCountEl.text(likeCountText);
2796                            }
2797                        }
2798                        self.setStorage(storageKey, 'dislike');
2799                    } else {
2800                        reaction = 'rmdislike';
2801                        if (!/[kKmM]/.test(dislikeCountText)) {
2802                            likeCountText = parseInt(likeCountText) - 1;
2803                            if (isNaN(likeCountText) || likeCountText < 1) {
2804                                likeCountText = '';
2805                            }
2806                            dislikeCountEl.text(likeCountText);
2807                        }
2808                        target.removeClass('triggered');
2809                        self.deleteStorage(storageKey);
2810                    }
2811                }
2812
2813                $.ajax({
2814                    type: 'GET',
2815                    url: self.ajaxURL,
2816                    data: {
2817                        uuid: self.personalizeUID,
2818                        action: 'rbvoting',
2819                        value: reaction,
2820                        pid: pid,
2821                    },
2822                    complete: () => {
2823                        self.isProgress = false;
2824                    }
2825                })
2826            })
2827        }
2828
2829        /** sync layout */
2830        Module.syncLayoutLike = function () {
2831
2832            this.isProgress = true;
2833            const likeElements = document.querySelectorAll('[data-like]:not(.loaded)');
2834            const jsCount = this._body.hasClass('is-jscount');
2835            let count, countEl;
2836
2837            for (const el of likeElements) {
2838                el.classList.add('loaded');
2839                const key = this.getLikeKey(el.getAttribute('data-like'));
2840                const triggered = this.getStorage(key);
2841
2842                if (!triggered) continue;
2843
2844                const likeEl = el.querySelector('.el-like');
2845                const dislikeEl = el.querySelector('.el-dislike');
2846
2847                if (!likeEl || !dislikeEl) continue;
2848
2849                if (triggered === 'like') {
2850                    likeEl.classList.add('triggered');
2851                    countEl = jsCount ? likeEl.querySelector('.like-count') : null;
2852                    if (countEl) {
2853                        count = parseInt(countEl.textContent.trim()) || 0;
2854                        countEl.textContent = count + 1;
2855                    }
2856                } else if (triggered === 'dislike') {
2857                    dislikeEl.classList.add('triggered');
2858                    countEl = jsCount ? dislikeEl.querySelector('.dislike-count') : null;
2859                    if (countEl) {
2860                        count = parseInt(countEl.textContent.trim()) || 0;
2861                        countEl.textContent = count + 1;
2862                    }
2863                }
2864            }
2865
2866            this.isProgress = false;
2867        };
2868
2869        /** like key */
2870        Module.getLikeKey = function (id) {
2871            return this.personalizeUID + '-like-' + id;
2872        }
2873
2874        /** live blog */
2875        Module.liveBlog = function () {
2876            const self = this;
2877
2878            const liveEntry = $('.rb-live-entry');
2879
2880            if (liveEntry.length === 0) {
2881                return false;
2882            }
2883
2884            let intervalId;
2885            const interval = Math.max(30, this.themeSettings.liveInterval || 0);
2886            const liveSwitcher = $('#live-interval-switcher');
2887            const storedSetting = this.getStorage('liveIntervalCheckbox');
2888
2889            const updateInterval = () => {
2890                clearInterval(intervalId);
2891                if (liveSwitcher.prop('checked')) {
2892                    intervalId = setInterval(() => this.updateLiveBlog(liveEntry), interval * 1000);
2893                    self.setStorage('liveIntervalCheckbox', 'yes');
2894                } else {
2895                    self.setStorage('liveIntervalCheckbox', 'no');
2896                }
2897            };
2898
2899            if (storedSetting !== null) {
2900                liveSwitcher.prop('checked', storedSetting === 'yes');
2901            } else {
2902                self.setStorage('liveIntervalCheckbox', 'yes');
2903            }
2904
2905            updateInterval();
2906            liveSwitcher.on('change', updateInterval);
2907        };
2908
2909        Module.updateLiveBlog = function (liveEntry) {
2910
2911            const self = this;
2912            const liveURL = new URL(window.location.href);
2913            liveURL.searchParams.set('rblive', '1');
2914            $.ajax({
2915                type: 'GET',
2916                url: liveURL.toString(),
2917                dataType: 'html',
2918                success: function (response) {
2919                    response = $('<div id="temp-dom"></div>').append($.parseHTML(response)).find('#rb-live-content');
2920                    liveEntry.html(response.html());
2921                    const liveCountElement = liveEntry.prev().find('.live-count');
2922                    if (liveCountElement.length) {
2923                        liveCountElement.text(response.data('total'));
2924                    }
2925                    setTimeout(function () {
2926                        self.reInitAll();
2927                        if (typeof FOXIZ_CORE_SCRIPT !== 'undefined') {
2928                            FOXIZ_CORE_SCRIPT.loadGoogleAds(response);
2929                            FOXIZ_CORE_SCRIPT.loadInstagram(response);
2930                            FOXIZ_CORE_SCRIPT.loadTwttr();
2931                        }
2932                    }, 1);
2933                }
2934            });
2935        }
2936
2937        Module.accordion = function () {
2938            $('.gb-accordion').each(function () {
2939                const accordion = $(this);
2940                if (accordion.hasClass('yesLoaded')) return;
2941
2942                accordion.addClass('yesLoaded');
2943                const accordionItems = accordion.find('.gb-accordion-item');
2944
2945                if (accordion.hasClass('yes-open')) {
2946                    accordionItems.first().addClass('active').find('.accordion-item-content').css('display', 'block');
2947                }
2948
2949                accordion.on('click', '.accordion-item-header', function (e) {
2950                    e.preventDefault();
2951
2952                    const header = $(this);
2953                    const item = header.closest('.gb-accordion-item');
2954                    const content = item.find('.accordion-item-content');
2955
2956                    if (item.hasClass('active')) {
2957                        item.removeClass('active');
2958                        content.stop().slideUp(200);
2959                    } else {
2960                        const activeItem = accordionItems.filter('.active');
2961                        activeItem.removeClass('active').find('.accordion-item-content').stop().slideUp(200);
2962                        item.addClass('active');
2963                        content.stop().slideDown(200);
2964                    }
2965                });
2966            });
2967        };
2968
2969        Module.resIframeClassic = function () {
2970
2971            if (!document.body.classList.contains('res-iframe-classic')) return
2972            const iframes = document.querySelectorAll('.rbct iframe');
2973            iframes.forEach(iframe => {
2974                const parent = iframe.parentElement;
2975                const grandParent = parent.parentElement;
2976                const greatGrandParent = grandParent.parentElement;
2977
2978                if ([parent, grandParent, greatGrandParent].some(element => {
2979                    const classNames = Array.from(element.classList);
2980                    return classNames.some(className => className.indexOf('wp-block') !== -1);
2981                })) return;
2982
2983                if (!iframe.parentElement.classList.contains('rb-video-ires')) {
2984                    if (iframe.src.includes('youtube.com') || iframe.src.includes('youtu.be') || iframe.src.includes('vimeo.com') || iframe.src.includes('dailymotion.com')) {
2985                        iframe.parentElement.classList.add('rb-video-ires');
2986                    }
2987                }
2988            });
2989        }
2990
2991        Module.taxBasedAccordion = function () {
2992
2993            const self = this;
2994            $('.block-tax-accordion').each(function () {
2995                const accordion = $(this);
2996                if (accordion.hasClass('is-loaded')) {
2997                    return;
2998                }
2999                accordion.addClass('is-loaded');
3000                const accordionItems = accordion.find('.tax-accordion-item');
3001                const lastOpenedTab = self.getStorage(accordion.attr('id') + '_lastOpenedTab', null);
3002
3003                if (lastOpenedTab) {
3004                    const tabToOpen = accordion.find('[data-tab="' + lastOpenedTab + '"] .tax-accordion-sub');
3005                    if (tabToOpen.length !== 0) {
3006                        tabToOpen.show();
3007                    }
3008                }
3009
3010                accordionItems.each(function () {
3011                    const item = $(this);
3012                    const trigger = item.find('.tax-accordion-trigger');
3013                    const subMenu = item.find('.tax-accordion-sub');
3014
3015                    trigger.click(function () {
3016                        if (!subMenu.is(':visible')) {
3017                            accordion.find('.tax-accordion-sub').not(subMenu).slideUp();
3018                        }
3019                        subMenu.slideToggle(function () {
3020                            if (subMenu.is(':visible')) {
3021                                self.setStorage(accordion.attr('id') + '_lastOpenedTab', item.attr('data-tab'));
3022                            } else {
3023                                self.deleteStorage(accordion.attr('id') + '_lastOpenedTab');
3024                            }
3025                        });
3026                    });
3027                });
3028            });
3029        };
3030
3031        return Module;
3032
3033    }(FOXIZ_MAIN_SCRIPT || {}, jQuery)
3034)
3035
3036/** init */
3037jQuery(document).ready(function ($) {
3038    FOXIZ_MAIN_SCRIPT.init();
3039});
3040
3041/** Elementor editor */
3042jQuery(window).on('elementor/frontend/init', function () {
3043
3044    if (typeof elementorFrontend !== 'undefined' && typeof elementorFrontend.isEditMode === 'function' && elementorFrontend.isEditMode()) {
3045        FOXIZ_MAIN_SCRIPT.isElementorEditor = true;
3046        FOXIZ_MAIN_SCRIPT.editorDarkModeInit = false;
3047
3048        elementorFrontend.hooks.addAction('frontend/element_ready/widget', FOXIZ_MAIN_SCRIPT.initElementor);
3049    }
3050});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.