1( function( $ ) { 2 3 'use strict'; 4 5 window.JetPopupFrontend = { 6 7 addedScripts: {}, 8 9 addedStyles: {}, 10 11 addedAssetsPromises: [], 12 13 init: function() { 14 let $popup_list = $( '.jet-popup.jet-popup--front-mode' ); 15 16 $popup_list.each( function( index ) { 17 let $target = $( this ), 18 instance = null, 19 settings = $target.data( 'settings' ); 20 21 instance = new window.jetPopup( $target, settings ); 22 instance.init(); 23 } ); 24 25 JetPopupFrontend.initAttachedPopups(); 26 27 JetPopupFrontend.initBlocks(); 28 29 $( window ).on( 'jet-popup/ajax/frontend-init', ( event, payload ) => { 30 31 switch ( payload.contentType ) { 32 case 'elementor': 33 JetPopupFrontend.maybeElementorFrontendInit( payload.$container ); 34 break; 35 case 'default': 36 JetPopupFrontend.maybeDefaultFrontendInit( payload ); 37 break 38 } 39 } ); 40 }, 41 42 initAttachedPopups: function ( $scope ) { 43 $scope = $scope || $( 'body' ); 44 45 $scope.find( '[data-popup-instance]' ).each( ( index, el ) => { 46 let $this = $( el ), 47 popupId = $this.data( 'popup-instance' ) || 'none', 48 triggerType = $this.data( 'popup-trigger-type' ) || 'none', 49 clickedCustomClass = $this.data( 'popup-custom-selector' ) || '', 50 popupData = { 51 popupId: `jet-popup-${ popupId }`, 52 }; 53 54 if ( $this.hasClass( 'jet-popup-attach-event-inited' ) ) { 55 return; 56 } 57 58 $this.addClass( 'jet-popup-attach-event-inited' ); 59 60 switch( triggerType ) { 61 case 'click-self': 62 $this.addClass( 'jet-popup-cursor-pointer' ); 63 64 $this.on( 'click.JetPopup', function( event ) { 65 event.preventDefault(); 66 67 $( window ).trigger( { 68 type: 'jet-popup-open-trigger', 69 popupData: popupData, 70 triggeredBy: $this, 71 } ); 72 73 return false; 74 } ); 75 break; 76 case 'click-selector': 77 78 if ( '' !== clickedCustomClass ) { 79 $this.find( clickedCustomClass ).addClass( 'jet-popup-cursor-pointer' ); 80 81 $this.on( 'click.JetPopup', clickedCustomClass, function( event ) { 82 event.preventDefault(); 83 84 $( window ).trigger( { 85 type: 'jet-popup-open-trigger', 86 popupData: popupData, 87 triggeredBy: $this, 88 } ); 89 90 return false; 91 } ); 92 } 93 break; 94 case 'hover': 95 $this.on( 'mouseenter.JetPopup', function( event ) { 96 97 $( window ).trigger( { 98 type: 'jet-popup-open-trigger', 99 popupData: popupData, 100 triggeredBy: $this, 101 } ); 102 } ); 103 break; 104 case 'scroll-to': 105 const observer = new IntersectionObserver(( entries ) => { 106 entries.forEach(( entry ) => { 107 108 if ( entry.isIntersecting ) { 109 110 $( window ).trigger( { 111 type: 'jet-popup-open-trigger', 112 popupData: popupData, 113 triggeredBy: $this, 114 } ); 115 } 116 }) 117 }, 118 { 119 threshold: 0.5 120 }); 121 122 for ( let i = 0; i < $( $this ).length; i++ ) { 123 const elements = $( $this )[i]; 124 observer.observe( elements ); 125 } 126 127 break; 128 } 129 } ); 130 }, 131 132 initBlocks: function( $scope ) { 133 $scope = $scope || $( 'body' ); 134 135 window.JetPlugins.init( $scope, [ 136 { 137 block: 'jet-popup/action-button', 138 callback: ( $scope ) => { 139 let $button = $( '.jet-popup-action-button__instance', $scope ), 140 actionType = $scope.data( 'action-type' ); 141 142 JetPopupFrontend.actionButtonHandle( $button, actionType ); 143 } 144 } 145 ] ); 146 }, 147 148 actionButtonBlock: function( $scope ) { 149 var $button = $( '.jet-popup-action-button__instance', $scope ), 150 actionType = $scope.data( 'action-type' ); 151 152 JetPopupFrontend.actionButtonHandle( $button, actionType ); 153 }, 154 155 actionButtonHandle: function ( $button, actionType = 'link' ) { 156 157 switch ( actionType ) { 158 159 case 'link': 160 161 $button.on( 'click.JetPopup', function( event ) { 162 event.preventDefault(); 163 164 var $currentPopup = $button.closest( '.jet-popup' ), 165 link = $( this ).attr( 'href' ), 166 target = $( this ).attr( 'target' ), 167 popupId = $currentPopup.attr( 'id' ); 168 169 $( window ).trigger( { 170 type: 'jet-popup-close-trigger', 171 popupData: { 172 popupId: popupId, 173 constantly: false 174 } 175 } ); 176 177 if ( '_blank' === target ) { 178 window.open( link, '_blank' ); 179 } else { 180 window.open( link, '_self' ); 181 } 182 183 return false;
184 } ); 185 break; 186 187 case 'leave': 188 $button.on( 'click.JetPopup', function( event ) { 189 event.preventDefault(); 190 191 window.history.back(); 192 } ); 193 break; 194 195 case 'close-popup': 196 $button.on( 'click.JetPopup', function( event ) { 197 event.preventDefault(); 198 199 var $currentPopup = $button.closest( '.jet-popup' ), 200 popupId = $currentPopup.attr( 'id' ); 201 202 $( window ).trigger( { 203 type: 'jet-popup-close-trigger', 204 popupData: { 205 popupId: popupId, 206 constantly: false 207 } 208 } ); 209 } ); 210 break; 211 212 case 'close-all-popups': 213 $button.on( 'click.JetPopup', function( event ) { 214 event.preventDefault(); 215 216 var $popups = $( '.jet-popup' ); 217 218 if ( $popups[0] ) { 219 $popups.each( function( index ) { 220 var $popup = $( this ), 221 popupId = $popup.attr( 'id' ); 222 223 $( window ).trigger( { 224 type: 'jet-popup-close-trigger', 225 popupData: { 226 popupId: popupId, 227 constantly: false 228 } 229 } ); 230 } ); 231 } 232 } ); 233 break; 234 235 case 'close-constantly': 236 $button.on( 'click.JetPopup', function( event ) { 237 event.preventDefault(); 238 239 var $currentPopup = $button.closest( '.jet-popup' ), 240 popupId = $currentPopup.attr( 'id' ); 241 242 $( window ).trigger( { 243 type: 'jet-popup-close-trigger', 244 popupData: { 245 popupId: popupId, 246 constantly: true 247 } 248 } ); 249 } ); 250 break; 251 252 case 'close-all-constantly': 253 $button.on( 'click.JetPopup', function( event ) { 254 event.preventDefault(); 255 256 var $popups = $( '.jet-popup' ); 257 258 if ( $popups[0] ) { 259 $popups.each( function( index ) { 260 var $popup = $( this ), 261 popupId = $popup.attr( 'id' ); 262 263 $( window ).trigger( { 264 type: 'jet-popup-close-trigger', 265 popupData: { 266 popupId: popupId, 267 constantly: true 268 } 269 } ); 270 } ); 271 } 272 } ); 273 break; 274 } 275 }, 276 277 loadScriptAsync: function( script, uri ) { 278 279 if ( JetPopupFrontend.addedScripts.hasOwnProperty( script ) ) { 280 return script; 281 } 282 283 JetPopupFrontend.addedScripts[ script ] = uri; 284 285 const asset = document.getElementById( script + '-js' ); 286 287 if ( asset ) { 288 return script; 289 } 290 291 return new Promise( function( resolve, reject ) { 292 var tag = document.createElement( 'script' ); 293 294 tag.src = uri; 295 tag.async = false; 296 tag.onload = function() { 297 resolve( script ); 298 }; 299 300 document.head.appendChild( tag ); 301 } ); 302 }, 303 304 loadStyle: function( style, uri ) { 305 306 if ( JetPopupFrontend.addedStyles.hasOwnProperty( style ) && JetPopupFrontend.addedStyles[ style ] === uri) { 307 return style; 308 } 309 310 JetPopupFrontend.addedStyles[ style ] = uri; 311 312 return new Promise( function( resolve, reject ) { 313 var tag = document.createElement( 'link' ); 314 315 tag.id = style; 316 tag.rel = 'stylesheet'; 317 tag.href = uri; 318 tag.type = 'text/css'; 319 tag.media = 'all'; 320 tag.onload = function() { 321 resolve( style ); 322 }; 323 324 document.head.appendChild( tag ); 325 }); 326 }, 327 328 assetsLoaderPromise: function() { 329 return Promise.all( JetPopupFrontend.addedAssetsPromises ); 330 }, 331 332 maybeElementorFrontendInit: function( $popupContainer ) { 333 $popupContainer.find( 'div[data-element_type]' ).each( function() { 334 var $this = $( this ), 335 elementType = $this.data( 'element_type' ); 336 337 if ( ! elementType ) { 338 return; 339 } 340 341 try { 342 if ( 'widget' === elementType ) { 343 elementType = $this.data( 'widget_type' ); 344 345 if ( window.elementorFrontend && window.elementorFrontend.hooks ) { 346 window.elementorFrontend.hooks.doAction( 'frontend/element_ready/widget', $this, $ ); 347 } 348 } 349 350 if ( window.elementorFrontend && window.elementorFrontend.hooks ) { 351 window.elementorFrontend.hooks.doAction( 'frontend/element_ready/global', $this, $ ); 352 window.elementorFrontend.hooks.doAction( 'frontend/element_ready/' + elementType, $this, $ ); 353 } 354 355 } catch ( err ) { 356 console.log(err); 357 $this.remove(); 358 359 return false;
360 } 361 } ); 362 }, 363 364 maybeDefaultFrontendInit: function ( payload ) { 365 const contentElements = payload.contentElements || [], 366 $container = payload.$container; 367 368 $container.find( '[data-is-block*="/"]' ).each( ( index, el ) => { 369 window.JetPlugins.hooks.doAction( window.JetPlugins.hookNameFromBlock( el.dataset.isBlock ), jQuery( el ) ); 370 } ); 371 } 372 }; 373 374 /** 375 * [jetPopup description] 376 * @param {[type]} $popup [description] 377 * @param {[type]} settings [description] 378 * @return {[type]} [description] 379 */ 380 window.jetPopup = function( $popup, settings ) { 381 var self = this, 382 $window = $( window ), 383 $document = $( document ), 384 popupSettings = settings, 385 id = popupSettings['id'], 386 popupId = popupSettings['jet-popup-id'], 387 popupsLocalStorageData = {}, 388 //editMode = Boolean( window.elementorFrontend.isEditMode() ), 389 isAnimation = false, 390 isOpen = false, 391 ajaxGetContentHanler = null, 392 ajaxContentLoaded = false; 393 394 self.init = function() { 395 var popupAvailable = self.popupAvailableCheck(); 396 397 if ( ! popupAvailable ) { 398 return false; 399 } 400 401 self.setLocalStorageData( popupId, 'enable' ); 402 403 self.initCompatibilityHandler(); 404 405 self.initOpenEvent(); 406 407 self.initCloseEvent(); 408 409 $window.trigger( 'jet-popup/init/after', { 410 self: self, 411 settings: popupSettings 412 } ); 413 }; 414 415 /** 416 * [popupAvailableCheck description] 417 * @return {[type]} [description] 418 */ 419 self.popupAvailableCheck = function() { 420 var storageData = self.getLocalStorageData() || {}; 421 422 if ( ! storageData.hasOwnProperty( popupId ) ) { 423 return true; 424 } 425 426 var popupData = storageData[ popupId ], 427 status = 'enable', 428 showAgainDate = 'none'; 429 430 if ( 'disable' === popupData ) { 431 return false; 432 } 433 434 if ( 'enable' === popupData ) { 435 return true; 436 } 437 438 if ( popupData.hasOwnProperty( 'status' ) ) { 439 status = popupData['status']; 440 } 441 442 if ( 'enable' === status ) { 443 return true; 444 } 445 446 if ( popupData.hasOwnProperty( 'show-again-date' ) ) { 447 showAgainDate = popupData['show-again-date']; 448 } 449 450 if ( 'none' === showAgainDate && 'disable' === status ) { 451 return false; 452 } 453 454 if ( showAgainDate < Date.now() ) { 455 return true; 456 } else { 457 return false; 458 } 459 }; 460 461 /** 462 * [initOpenEvent description] 463 * @return {[type]} [description] 464 */ 465 self.initOpenEvent = function() { 466 467 $window.trigger( 'jet-popup/init-events/before', { 468 self: self, 469 settings: popupSettings 470 } ); 471 472 switch ( popupSettings['open-trigger'] ) { 473 case 'page-load': 474 self.pageLoadEvent( popupSettings['page-load-delay'] ); 475 break; 476 477 case 'user-inactive': 478 self.userInactiveEvent( popupSettings['user-inactivity-time'] ); 479 break; 480 481 case 'scroll-trigger': 482 self.scrollPageEvent( popupSettings['scrolled-to'] ); 483 break; 484 485 case 'try-exit-trigger': 486 self.tryExitEvent(); 487 break; 488 489 case 'on-date': 490 self.onDateEvent( popupSettings['on-date'] ); 491 break; 492 493 case 'on-time': 494 self.onTimeEvent( popupSettings['on-time-start'], popupSettings['on-time-end'] ); 495 break; 496 497 case 'on-date-and-time': 498 self.onTimeAndDateEvent( popupSettings['start-date-and-time'], popupSettings['end-date-and-time'] ); 499 break; 500 501 case 'custom-selector': 502 self.onCustomSelector( popupSettings['custom-selector'] ); 503 break;$scope 504 } 505 506 $window.on( 'jet-popup-open-trigger', function( event ) { 507 var popupData = event.popupData || {}, 508 triggeredBy = event.triggeredBy || false, 509 popupUniqId = popupData.popupId || false; 510 511 if ( popupUniqId == popupId ) { 512 self.showPopup( popupData, triggeredBy ); 513 } 514 }); 515 516 $window.on( 'jet-popup-close-trigger', function( event ) { 517 var popupData = event.popupData || {}, 518 popupUniqId = popupData.popupId, 519 constantly = popupData.constantly; 520 521 if ( popupUniqId == popupId ) { 522 self.hidePopup( { 523 popupId: popupUniqId, 524 constantly: constantly, 525 } ); 526 } 527 }); 528 529 $window.trigger( 'jet-popup/init-events/after', { 530 self: self, 531 settings: popupSettings 532 } ); 533 }; 534 535 /** 536 * [initOnCloseEvent description] 537 * @return {[type]} [description] 538 */ 539 self.initOnCloseEvent = function() { 540 541 var $htmlBody = $( 'html, body' ); 542 543 if ( 'scroll-to-top' === popupSettings['close-event'] ) { 544 $htmlBody.animate( { scrollTop: 0 }, 'slow' ); 545 } 546 547 if ( 'scroll-to-anchor' === popupSettings['close-event'] ) { 548 var anchor = $( '#' + popupSettings['Ñlose-event-anchor'] ); 549 550 if ( anchor.length ) { 551 $htmlBody.animate( { scrollTop: anchor.offset().top }, 'slow' ); 552 } 553 } 554 } 555 556 /** 557 * [initCloseEvent description] 558 * @return {[type]} [description] 559 */ 560 self.initCloseEvent = function() { 561 562 $popup.on( 'click', '.jet-popup__close-button', function( event ) { 563 var target = event.currentTarget; 564 565 self.hidePopup( { 566 constantly: popupSettings['show-once'], 567 popupId: popupSettings['jet-popup-id'] 568 } ); 569 self.initOnCloseEvent(); 570 } ); 571 572 if ( popupSettings['close-on-overlay-click'] ) { 573 $popup.on( 'click', '.jet-popup__overlay', function( event ) { 574 var target = event.currentTarget; 575 576 self.hidePopup( { 577 constantly: popupSettings['show-once'], 578 popupId: popupSettings['jet-popup-id'] 579 } ); 580 self.initOnCloseEvent(); 581 } ); 582 } 583 584 $document.on( 'keyup.jetPopup', function( event ) { 585 var key = event.keyCode; 586 587 if ( 27 === key && isOpen ) { 588 self.hidePopup( { 589 constantly: popupSettings['show-once'], 590 popupId: popupSettings['jet-popup-id'] 591 } ); 592 } 593 } ); 594 }; 595 596 /** 597 * [initCompatibilityHandler description] 598 * @return {[type]} [description] 599 */ 600 self.initCompatibilityHandler = function() { 601 var $elementorProFormWidget = $( '.elementor-widget-form', $popup ); 602 603 if ( $elementorProFormWidget[0] ) { 604 $elementorProFormWidget.each( function() { 605 var $this = $( this ), 606 $form = $( '.elementor-form', $this ); 607 608 $form.on( 'submit_success', function( data ) { 609 610 setTimeout( function() { 611 $window.trigger( { 612 type: 'jet-popup-close-trigger', 613 popupData: { 614 popupId: popupId, 615 constantly: false 616 } 617 } ); 618 }, 3000 ); 619 620 } ); 621 } ); 622 } 623 }; 624 625 /** 626 * Page on load event 627 * 628 * @param {int} openDelay Open delay time. 629 * @return {void} 630 */ 631 self.pageLoadEvent = function( openDelay ) {
632 var delay = +openDelay || 0; 633 634 delay = delay * 1000; 635 636 $( function() { 637 setTimeout( function() { 638 self.showPopup(); 639 }, delay ); 640 } ); 641 }; 642 643 /** 644 * User Inactivity event 645 * 646 * @param {int} inactiveDelay [description] 647 * @return {void} 648 */ 649 self.userInactiveEvent = function( inactiveDelay ) { 650 var delay = +inactiveDelay || 0, 651 isInactive = true; 652 653 delay = delay * 1000; 654 655 setTimeout( function() { 656 if ( isInactive ) { 657 self.showPopup(); 658 } 659 }, delay ); 660 661 $( document ).on( 'click focus resize keyup scroll', function() { 662 isInactive = false; 663 } ); 664 }; 665 666 /** 667 * Scrolling Page Event 668 * 669 * @param {int} scrollingValue Scrolling porgress value 670 * @return {void} 671 */ 672 self.scrollPageEvent = function( scrollingValue ) { 673 var scrolledValue = +scrollingValue || 0; 674 675 $window.on( 'scroll.cherryJetScrollEvent resize.cherryJetResizeEvent', function() { 676 var $window = $( window ), 677 windowHeight = $window.height(), 678 documentHeight = $( document ).height(), 679 scrolledHeight = documentHeight - windowHeight, 680 scrolledProgress = Math.max( 0, Math.min( 1, $window.scrollTop() / scrolledHeight ) ) * 100; 681 682 if ( scrolledProgress >= scrolledValue ) { 683 $window.off( 'scroll.cherryJetScrollEvent resize.cherryJetResizeEvent' ); 684 self.showPopup(); 685 } 686 } ).trigger( 'scroll.cherryJetResizeEvent' ); 687 }; 688 689 /** 690 * Viewport leave event 691 * 692 * @return {void} 693 */ 694 self.tryExitEvent = function() { 695 var pageY = 0; 696 697 $( document ).on( 'mouseleave', 'body', function( event ) { 698 699 pageY = event.pageY - $window.scrollTop(); 700 701 if ( 0 > pageY && $popup.hasClass( 'jet-popup--hide-state' ) ) { 702 self.showPopup(); 703 } 704 } ); 705 }; 706 707 /** 708 * onDateEvent Event 709 * 710 * @return {void} 711 */ 712 self.onDateEvent = function( date ) { 713 var nowDate = Date.now(), 714 startDate = Date.parse( date ); 715 716 if ( startDate < nowDate ) { 717 718 setTimeout( function() { 719 self.showPopup(); 720 }, 500 ); 721 } 722 } 723 724 self.onTimeEvent = function( startTime = '00:00', endTime = '23:59' ) { 725 var startTime = '' !== startTime ? startTime : '00:00', 726 endTime = '' !== endTime ? endTime : '23:59', 727 nowTimeStamp = Date.now(), 728 dateTimeFormat = new Intl.DateTimeFormat( 'en', { year: 'numeric', month: 'short', day: '2-digit' } ), 729 [ { value: month },,{ value: day },,{ value: year } ] = dateTimeFormat.formatToParts( nowTimeStamp ), 730 startTime = `${ month }. ${ day }, ${ year } ${ startTime }`, 731 endTime = `${ month }. ${ day }, ${ year } ${ endTime }`, 732 startTimeStamp = Date.parse( startTime ), 733 endTimeStamp = Date.parse( endTime ); 734 735 if ( ( startTimeStamp < nowTimeStamp ) && ( nowTimeStamp < endTimeStamp ) ) { 736 setTimeout( function() { 737 self.showPopup(); 738 }, 500 ); 739 } 740 } 741 742 743 self.onTimeAndDateEvent = function( start, end ) { 744 745 var nowDateStamp = Date.now(), 746 startDateStamp = Date.parse( start ), 747 endDateStamp = Date.parse( end ); 748 749 if ( ( startDateStamp < nowDateStamp ) && ( nowDateStamp < endDateStamp ) ) { 750 setTimeout( function() { 751 self.showPopup(); 752 }, 500 ); 753 } 754 755 } 756 757 /** 758 * Check DOM Loaded Selector 759 * @param {[type]} selector [description] 760 * @return {[type]} [description] 761 */ 762 763 self.checkLoadedSelector = function( selector ) { 764 765 //Check Listing Grid Lazy Load 766 $( document ).on( 'jet-engine/listing-grid/after-lazy-load', function() { 767 self.onCustomSelector ( selector ); 768 }); 769 770 //Check Open Mobile Menu 771 $( '.jet-mobile-menu__toggle' ).closest( '.jet-mobile-menu__instance--slide-out-layout' ).on( 'click', function() { 772 self.onCustomSelector ( selector ); 773 }); 774 775 } 776 777 /** 778 * [onCustomSelector description] 779 * @param {[type]} selector [description] 780 * @return {[type]} [description] 781 */ 782 self.onCustomSelector = function( selector ) { 783 784 let $selector = $( selector ); 785 786 if ( $selector[0] ) { 787 $( 'body' ).on( 'click', selector, function( event ) { 788 event.preventDefault(); 789 790 self.showPopup( $( this ).data( 'popup' ), $( this ) ); 791 } ); 792 } else { 793 self.checkLoadedSelector( selector ); 794 } 795 } 796 797 /** 798 * Show Popup 799 * 800 * @return {void} 801 */ 802 self.showPopup = function( data, $trigger ) { 803 var popupData = data || {}, 804 animeOverlay = null,
805 animeContainer = null, 806 animeOverlaySettings = jQuery.extend( 807 { 808 targets: $( '.jet-popup__overlay', $popup )[0] 809 }, 810 self.avaliableEffects[ 'fade' ][ 'show' ] 811 ); 812 813 $trigger = $trigger || false; 814 815 if ( ! self.popupAvailableCheck() ) { 816 return false; 817 } 818 819 animeOverlay = anime( animeOverlaySettings ); 820 821 $popup.toggleClass( 'jet-popup--hide-state jet-popup--show-state' ); 822 823 if ( popupSettings['prevent-scrolling'] ) { 824 $( 'body' ).addClass( 'jet-popup-prevent-scroll' ); 825 } 826 827 popupData = window.JetPlugins.hooks.applyFilters( 'jet-popup.show-popup.data', popupData, $popup, $trigger ); 828 829 self.showContainer( popupData ); 830 }; 831 832 /** 833 * [showContainer description] 834 * @return {[type]} [description] 835 */ 836 self.showContainer = function( data ) { 837 var popupData = data || {}, 838 popupDefaultData = { 839 forceLoad: popupSettings['force-ajax'] || false, // Trigger Ajax Every Time 840 customContent: '' // Show Popup with Custom Content 841 }, 842 animeContainerInstance = null, 843 $popupContainer = $( '.jet-popup__container', $popup ), 844 $content = $( '.jet-popup__container-content', $popup ), 845 animeContainer = jQuery.extend( 846 { 847 targets: $( '.jet-popup__container', $popup )[0], 848 begin: function( anime ) { 849 isAnimation = true; 850 851 $window.trigger( 'jet-popup/show-event/before-show', { 852 self: self, 853 data: popupData, 854 anime: anime 855 } ); 856 }, 857 complete: function( anime ) { 858 isAnimation = false; 859 isOpen = true; 860 861 $window.trigger( 'jet-popup/show-event/after-show', { 862 self: self, 863 data: popupData, 864 anime: anime 865 } ); 866 } 867 }, 868 self.avaliableEffects[ popupSettings['animation'] ][ 'show' ] 869 ); 870 871 popupData = jQuery.extend( popupDefaultData, popupData ); 872 873 // init Custom popup content 874 if ( '' !== popupData.customContent ) { 875 $content.html( popupData.customContent ); 876 self.elementorFrontendInit(); 877 878 // Show Popup Container
879 animeContainerInstance = anime( animeContainer ); 880 881 $window.trigger( 'jet-popup/render-content/render-custom-content', { 882 self: self, 883 popup_id: id, 884 data: popupData, 885 } ); 886 887 return false; 888 } 889 890 if ( ! popupSettings['use-ajax'] ) { 891 // Show Popup Container 892 animeContainerInstance = anime( animeContainer ); 893 894 $window.trigger( 'jet-popup/render-content/render-custom-content', { 895 self: self, 896 popup_id: id, 897 data: popupData, 898 } ); 899 900 return false; 901 } 902 903 if ( popupData.forceLoad ) { 904 ajaxContentLoaded = false; 905 } 906 907 if ( ajaxContentLoaded ) { 908 // Show Popup Container 909 animeContainerInstance = anime( animeContainer ); 910 911 $window.trigger( 'jet-popup/render-content/show-content', { 912 self: self, 913 popup_id: id, 914 data: popupData, 915 } ); 916 917 return false; 918 } 919 920 popupData = jQuery.extend( popupData, { 921 'popup_id': id, 922 'page_url': window.location.href 923 } ); 924 925 ajaxGetContentHanler = jQuery.ajax( { 926 type: 'POST', 927 url: window.jetPopupData.ajax_url, 928 data: { 929 'action': 'jet_popup_get_content', 930 'data': popupData 931 }, 932 beforeSend: function( jqXHR, ajaxSettings ) { 933 934 if ( null !== ajaxGetContentHanler ) { 935 ajaxGetContentHanler.abort(); 936 } 937 938 // Before ajax send Trigger 939 $window.trigger( 'jet-popup/render-content/ajax/before-send', { 940 self: self, 941 popup_id: id, 942 data: popupData 943 } ); 944 945 $popup.addClass( 'jet-popup--loading-state' ); 946 }, 947 error: function( jqXHR, ajaxSettings ) {}, 948 success: function( data, textStatus, jqXHR ) { 949 var successType = data.type, 950 contentData = data.content || false, 951 $popupContainer = $( '.jet-popup__container-content', $popup ); 952 953 $popup.removeClass( 'jet-popup--loading-state' ); 954 955 if ( 'error' === successType ) { 956 var message = data.message; 957 958 $content.html( '<h3>' + message + '</h3>' ); 959 960 // Show Popup Container 961 animeContainerInstance = anime( animeContainer ); 962 } 963 964 if ( 'success' === successType ) { 965 let popupContent = contentData['content'], 966 popupContentElements = contentData['contentElements'], 967 popupScripts = contentData['scripts'], 968 popupStyles = contentData['styles'], 969 popupAfterScripts = contentData['afterScripts']; 970 971 for ( let { handle: scriptHandler, src: scriptSrc } of popupScripts ) { 972 JetPopupFrontend.addedAssetsPromises.push( JetPopupFrontend.loadScriptAsync( scriptHandler, scriptSrc ) ); 973 } 974 975 for ( let styleHandler in popupStyles ) { 976 JetPopupFrontend.addedAssetsPromises.push( JetPopupFrontend.loadStyle( styleHandler, popupStyles[ styleHandler ] ) ); 977 } 978 979 JetPopupFrontend.assetsLoaderPromise().then( async function( value ) { 980 ajaxContentLoaded = true; 981 982 // Ajax Success Trigger 983 $window.trigger( 'jet-popup/render-content/ajax/success', { 984 self: self, 985 popup_id: id, 986 data: popupData, 987 request: data 988 } ); 989 990 // Render content 991 if ( popupContent ) { 992 $popupContainer.html( popupContent ); 993 } 994 995 if ( popupAfterScripts.length ) { 996 await Promise.all( popupAfterScripts.map( 997 ( { handle, src } ) => JetPopupFrontend.loadScriptAsync( handle, src ) 998 ) ); 999 } 1000 1001 // Before ajax frontend init 1002 $( window ).trigger( 'jet-popup/ajax/frontend-init/before', { 1003 $container: $popupContainer, 1004 content: popupContent, 1005 contentElements: popupContentElements, 1006 contentType: popupSettings['content-type'], 1007 } ); 1008 1009 // Frontend init 1010 $( window ).trigger( 'jet-popup/ajax/frontend-init', { 1011 $container: $popupContainer, 1012 content: popupContent, 1013 contentElements: popupContentElements, 1014 contentType: popupSettings['content-type'], 1015 } ); 1016 1017 // after ajax frontend init 1018 $( window ).trigger( 'jet-popup/ajax/frontend-init/after', { 1019 $container: $popupContainer, 1020 content: popupContent, 1021 contentElements: popupContentElements, 1022 contentType: popupSettings['content-type'], 1023 } ); 1024 1025 // Show Popup Container
1026 animeContainerInstance = anime( animeContainer ); 1027 1028 }, function( reason ) { 1029 console.log( 'Assets Loaded Error' ); 1030 } ); 1031 } 1032 } 1033 } ); 1034 }; 1035 1036 /** 1037 * Hide Popup 1038 * 1039 * @return {void} 1040 */ 1041 self.hidePopup = function ( data ) { 1042 var popupData = data || {}, 1043 $content = $( '.jet-popup__container-content', $popup ), 1044 constantly = popupData.constantly || false, 1045 animeOverlay = null, 1046 animeContainer = null, 1047 animeOverlaySettings = jQuery.extend( { targets: $( '.jet-popup__overlay', $popup )[0] }, self.avaliableEffects[ 'fade' ][ 'hide' ] ), 1048 animeContainerSettings = jQuery.extend( 1049 { 1050 targets: $( '.jet-popup__container', $popup )[0], 1051 begin: function( anime ) { 1052 isAnimation = true; 1053 1054 $window.trigger( 'jet-popup/hide-event/before-hide', { 1055 self: self, 1056 data: popupData, 1057 anime: anime 1058 } ); 1059 }, 1060 complete: function( anime ) { 1061 isAnimation = false; 1062 isOpen = false; 1063 $popup.toggleClass( 'jet-popup--show-state jet-popup--hide-state' ); 1064 1065 if ( popupSettings['use-ajax'] && popupSettings['force-ajax'] ) { 1066 $content.html( '' ); 1067 } 1068 1069 if ( popupSettings['prevent-scrolling'] && !$( '.jet-popup--show-state' )[0] ) { 1070 $( 'body' ).removeClass( 'jet-popup-prevent-scroll' ); 1071 } 1072 console.log(popupData) 1073 // After Popup Hide Action 1074 $window.trigger( 'jet-popup/hide-event/after-hide', { 1075 self: self, 1076 data: popupData, 1077 anime: anime 1078 } ); 1079 } 1080 }, 1081 self.avaliableEffects[ popupSettings['animation'] ][ 'hide' ] 1082 ); 1083 1084 if ( constantly ) { 1085 self.setLocalStorageData( popupId, 'disable' ); 1086 } 1087 1088 if ( isAnimation ){ 1089 return false; 1090 } 1091 1092 if ( $popup.hasClass('jet-popup--show-state') ) { 1093 animeOverlay = anime( animeOverlaySettings );
1094 animeContainer = anime( animeContainerSettings ); 1095 } 1096 1097 // On Hide Handler 1098 self.onHidePopupAction(); 1099 1100 // Before Popup Hide Action 1101 $window.trigger( 'jet-popup/close-hide-event/before-hide', { 1102 self: self, 1103 data: popupData 1104 } ); 1105 }; 1106 1107 /** 1108 * [elementorFrontendInit description] 1109 * @return {[type]} [description] 1110 */ 1111 self.elementorFrontendInit = function() { 1112 var $content = $( '.jet-popup__container-content', $popup ); 1113 1114 $content.find( 'div[data-element_type]' ).each( function() { 1115 var $this = $( this ), 1116 elementType = $this.data( 'element_type' ); 1117 1118 if (!elementType) { 1119 return; 1120 } 1121 1122 try { 1123 if( 'widget' === elementType ){ 1124 elementType = $this.data( 'widget_type' ); 1125 window.elementorFrontend.hooks.doAction( 'frontend/element_ready/widget', $this, $ ); 1126 } 1127 window.elementorFrontend.hooks.doAction( 'frontend/element_ready/' + elementType, $this, $ ); 1128 1129 } catch( err ) { 1130 console.log(err); 1131 1132 $this.remove(); 1133 1134 return false; 1135 } 1136 1137 }); 1138 1139 // On Show Handler 1140 self.onShowPopupAction(); 1141 } 1142 1143 /** 1144 * [onShowPopupAction description] 1145 * @return {[type]} [description] 1146 */ 1147 self.onShowPopupAction = function() {}; 1148 1149 /** 1150 * [onHidePopupAction description] 1151 * @return {[type]} [description] 1152 */ 1153 self.onHidePopupAction = function() {}; 1154 1155 /** 1156 * Avaliable Effects 1157 */ 1158 self.avaliableEffects = { 1159 'fade' : { 1160 'show': { 1161 opacity: { 1162 value: [ 0, 1 ], 1163 duration: 600, 1164 easing: 'easeOutQuart', 1165 }, 1166 }, 1167 'hide': { 1168 easing: 'easeOutQuart', 1169 opacity: { 1170 value: [ 1, 0 ], 1171 easing: 'easeOutQuart', 1172 duration: 400, 1173 }, 1174 } 1175 }, 1176 1177 'zoom-in' : { 1178 'show': { 1179 duration: 500, 1180 easing: 'easeOutQuart', 1181 opacity: { 1182 value: [ 0, 1 ], 1183 1184 }, 1185 scale: { 1186 value: [ 0.75, 1 ], 1187 } 1188 }, 1189 'hide': { 1190 duration: 400, 1191 easing: 'easeOutQuart', 1192 opacity: { 1193 value: [ 1, 0 ], 1194 }, 1195 scale: { 1196 value: [ 1, 0.75 ], 1197 } 1198 } 1199 }, 1200 1201 'zoom-out' : { 1202 'show': { 1203 duration: 500, 1204 easing: 'easeOutQuart', 1205 opacity: { 1206 value: [ 0, 1 ], 1207 1208 }, 1209 scale: { 1210 value: [ 1.25, 1 ], 1211 } 1212 }, 1213 'hide': { 1214 duration: 400, 1215 easing: 'easeOutQuart', 1216 opacity: { 1217 value: [ 1, 0 ], 1218 }, 1219 scale: { 1220 value: [ 1, 1.25 ], 1221 } 1222 } 1223 }, 1224 1225 'rotate' : { 1226 'show': { 1227 duration: 500, 1228 easing: 'easeOutQuart', 1229 opacity: { 1230 value: [ 0, 1 ], 1231 1232 }, 1233 scale: { 1234 value: [ 0.75, 1 ], 1235 }, 1236 rotate: { 1237 value: [ -65, 0 ], 1238 } 1239 }, 1240 'hide': { 1241 duration: 400, 1242 easing: 'easeOutQuart', 1243 opacity: { 1244 value: [ 1, 0 ], 1245 }, 1246 scale: { 1247 value: [ 1, 0.9 ], 1248 }, 1249 } 1250 }, 1251 1252 'move-up' : { 1253 'show': { 1254 duration: 500, 1255 easing: 'easeOutExpo', 1256 opacity: { 1257 value: [ 0, 1 ], 1258 1259 }, 1260 translateY: { 1261 value: [ 50, 1 ], 1262 } 1263 }, 1264 'hide': { 1265 duration: 400, 1266 easing: 'easeOutQuart', 1267 opacity: { 1268 value: [ 1, 0 ], 1269 }, 1270 translateY: { 1271 value: [ 1, 50 ], 1272 } 1273 } 1274 }, 1275 1276 'flip-x' : { 1277 'show': { 1278 duration: 500, 1279 easing: 'easeOutExpo', 1280 opacity: { 1281 value: [ 0, 1 ], 1282 1283 }, 1284 rotateX: { 1285 value: [ 65, 0 ], 1286 } 1287 }, 1288 'hide': { 1289 duration: 400, 1290 easing: 'easeOutQuart', 1291 opacity: { 1292 value: [ 1, 0 ], 1293 } 1294 } 1295 }, 1296 1297 'flip-y' : { 1298 'show': { 1299 duration: 500, 1300 easing: 'easeOutExpo', 1301 opacity: { 1302 value: [ 0, 1 ], 1303 1304 }, 1305 rotateY: { 1306 value: [ 65, 0 ], 1307 } 1308 }, 1309 'hide': { 1310 duration: 400, 1311 easing: 'easeOutQuart', 1312 opacity: { 1313 value: [ 1, 0 ], 1314 } 1315 } 1316 }, 1317 1318 'bounce-in' : { 1319 'show': { 1320 opacity: { 1321 value: [ 0, 1 ], 1322 duration: 500, 1323 easing: 'easeOutQuart', 1324 }, 1325 scale: { 1326 value: [ 0.2, 1 ], 1327 duration: 800, 1328 elasticity: function(el, i, l) { 1329 return (400 + i * 200); 1330 }, 1331 } 1332 }, 1333 'hide': { 1334 duration: 400, 1335 easing: 'easeOutQuart', 1336 opacity: { 1337 value: [ 1, 0 ], 1338 }, 1339 scale: { 1340 value: [ 1, 0.8 ], 1341 } 1342 } 1343 }, 1344 1345 'bounce-out' : { 1346 'show': { 1347 opacity: { 1348 value: [ 0, 1 ], 1349 duration: 500, 1350 easing: 'easeOutQuart', 1351 }, 1352 scale: { 1353 value: [ 1.8, 1 ],
1354 duration: 800, 1355 elasticity: function(el, i, l) { 1356 return (400 + i * 200); 1357 }, 1358 } 1359 }, 1360 'hide': { 1361 duration: 400, 1362 easing: 'easeOutQuart', 1363 opacity: { 1364 value: [ 1, 0 ], 1365 }, 1366 scale: { 1367 value: [ 1, 1.5 ], 1368 } 1369 } 1370 }, 1371 1372 'slide-in-up' : { 1373 'show': { 1374 opacity: { 1375 value: [ 0, 1 ], 1376 duration: 400, 1377 easing: 'easeOutQuart', 1378 }, 1379 translateY: { 1380 value: ['100vh', 0], 1381 duration: 750, 1382 easing: 'easeOutQuart', 1383 } 1384 }, 1385 'hide': { 1386 duration: 400, 1387 easing: 'easeInQuart', 1388 opacity: { 1389 value: [ 1, 0 ], 1390 }, 1391 translateY: { 1392 value: [0,'100vh'], 1393 } 1394 } 1395 }, 1396 1397 'slide-in-right' : { 1398 'show': { 1399 opacity: { 1400 value: [ 0, 1 ], 1401 duration: 400, 1402 easing: 'easeOutQuart', 1403 }, 1404 translateX: { 1405 value: ['100vw', 0], 1406 duration: 750, 1407 easing: 'easeOutQuart', 1408 } 1409 }, 1410 'hide': { 1411 duration: 400, 1412 easing: 'easeInQuart', 1413 opacity: { 1414 value: [ 1, 0 ], 1415 }, 1416 translateX: { 1417 value: [0,'100vw'], 1418 } 1419 } 1420 }, 1421 1422 'slide-in-down' : { 1423 'show': { 1424 opacity: { 1425 value: [ 0, 1 ], 1426 duration: 400, 1427 easing: 'easeOutQuart', 1428 }, 1429 translateY: { 1430 value: ['-100vh', 0], 1431 duration: 750, 1432 easing: 'easeOutQuart', 1433 } 1434 }, 1435 'hide': { 1436 duration: 400, 1437 easing: 'easeInQuart', 1438 opacity: { 1439 value: [ 1, 0 ], 1440 }, 1441 translateY: { 1442 value: [0,'-100vh'], 1443 } 1444 } 1445 }, 1446 1447 'slide-in-left' : { 1448 'show': { 1449 opacity: { 1450 value: [ 0, 1 ], 1451 duration: 400, 1452 easing: 'easeOutQuart', 1453 }, 1454 translateX: { 1455 value: ['-100vw', 0], 1456 duration: 750, 1457 easing: 'easeOutQuart', 1458 } 1459 }, 1460 'hide': { 1461 duration: 400, 1462 easing: 'easeInQuart', 1463 opacity: { 1464 value: [ 1, 0 ], 1465 }, 1466 translateX: { 1467 value: [0,'-100vw'], 1468 } 1469 } 1470 } 1471 1472 }; 1473 1474 /** 1475 * Get localStorage data. 1476 * 1477 * @return {object|boolean} 1478 */ 1479 self.getLocalStorageData = function() { 1480 1481 try { 1482 return JSON.parse( localStorage.getItem( 'jetPopupData' ) ); 1483 } catch ( e ) { 1484 return false; 1485 } 1486 }; 1487 1488 /** 1489 * Set localStorage data. 1490 * 1491 * @return {object|boolean} 1492 */ 1493 self.setLocalStorageData = function( id, status ) { 1494 1495 var jetPopupData = self.getLocalStorageData() || {}, 1496 newData = {}; 1497 1498 newData['status'] = status; 1499 1500 if ( 'disable' === status ) { 1501 1502 var nowDate = Date.now(), 1503 showAgainDelay = popupSettings['show-again-delay'], 1504 showAgainDate = 'none' !== showAgainDelay ? ( nowDate + showAgainDelay ) : 'none'; 1505 1506 newData['show-again-date'] = showAgainDate; 1507 } 1508 1509 jetPopupData[ id ] = newData; 1510 1511 localStorage.setItem( 'jetPopupData', JSON.stringify( jetPopupData ) ); 1512 } 1513 1514 } 1515 1516 window.JetPopupFrontend.init(); 1517 1518}( jQuery ) );
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.