PageSourceSearch

https://itszotar.hu/wp-content/themes/foxiz/assets/js/global.js?ver=2.3.3

js itszotar.hu collected 2026-10-08 07:51:26 UTC 114,889 bytes, 2,783 lines download raw bytes

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

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.