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