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 constantly = popupData.constantly; 511 512 if ( popupUniqId == popupId ) { 513 if ( $popup.hasClass( 'jet-popup--hide-state' )) { 514 self.showPopup( popupData, triggeredBy ); 515 } else { 516 self.hidePopup( { 517 constantly: constantly, 518 popupId: popupUniqId, 519 } ); 520 } 521 } 522 }); 523 524 $window.on( 'jet-popup-close-trigger', function( event ) { 525 var popupData = event.popupData || {}, 526 popupUniqId = popupData.popupId, 527 constantly = popupData.constantly; 528 529 if ( popupUniqId == popupId ) { 530 self.hidePopup( { 531 popupId: popupUniqId, 532 constantly: constantly, 533 } ); 534 } 535 }); 536 537 $window.trigger( 'jet-popup/init-events/after', { 538 self: self, 539 settings: popupSettings 540 } ); 541 }; 542 543 /** 544 * [initOnCloseEvent description] 545 * @return {[type]} [description] 546 */ 547 self.initOnCloseEvent = function() { 548 549 var $htmlBody = $( 'html, body' ); 550 551 if ( 'scroll-to-top' === popupSettings['close-event'] ) { 552 $htmlBody.animate( { scrollTop: 0 }, 'slow' ); 553 } 554 555 if ( 'scroll-to-anchor' === popupSettings['close-event'] ) { 556 var anchor = $( '#' + popupSettings['Ñlose-event-anchor'] ); 557 558 if ( anchor.length ) { 559 $htmlBody.animate( { scrollTop: anchor.offset().top }, 'slow' ); 560 } 561 } 562 } 563 564 /** 565 * [initCloseEvent description] 566 * @return {[type]} [description] 567 */ 568 self.initCloseEvent = function() { 569 570 $popup.on( 'click', '.jet-popup__close-button', function( event ) { 571 var target = event.currentTarget; 572 573 self.hidePopup( { 574 constantly: popupSettings['show-once'], 575 popupId: popupSettings['jet-popup-id'] 576 } ); 577 self.initOnCloseEvent(); 578 } ); 579 580 if ( popupSettings['close-on-overlay-click'] ) { 581 $popup.on( 'click', '.jet-popup__overlay', function( event ) { 582 var target = event.currentTarget; 583 584 self.hidePopup( { 585 constantly: popupSettings['show-once'], 586 popupId: popupSettings['jet-popup-id'] 587 } ); 588 self.initOnCloseEvent(); 589 } ); 590 } 591 592 $document.on( 'keyup.jetPopup', function( event ) { 593 var key = event.keyCode; 594 595 if ( 27 === key && isOpen ) { 596 self.hidePopup( { 597 constantly: popupSettings['show-once'], 598 popupId: popupSettings['jet-popup-id'] 599 } ); 600 } 601 } ); 602 }; 603 604 /** 605 * [initCompatibilityHandler description] 606 * @return {[type]} [description] 607 */ 608 self.initCompatibilityHandler = function() { 609 var $elementorProFormWidget = $( '.elementor-widget-form', $popup ); 610 611 if ( $elementorProFormWidget[0] ) { 612 $elementorProFormWidget.each( function() { 613 var $this = $( this ), 614 $form = $( '.elementor-form', $this ); 615 616 $form.on( 'submit_success', function( data ) { 617 618 setTimeout( function() { 619 $window.trigger( { 620 type: 'jet-popup-close-trigger', 621 popupData: { 622 popupId: popupId, 623 constantly: false 624 } 625 } ); 626 }, 3000 ); 627 628 } ); 629 } ); 630 } 631 }; 632 633 /** 634 * Page on load event 635 * 636 * @param {int} openDelay Open delay time. 637 * @return {void} 638 */ 639 self.pageLoadEvent = function( openDelay ) {
640 var delay = +openDelay || 0; 641 642 delay = delay * 1000; 643 644 $( function() { 645 setTimeout( function() { 646 self.showPopup(); 647 }, delay ); 648 } ); 649 }; 650 651 /** 652 * User Inactivity event 653 * 654 * @param {int} inactiveDelay [description] 655 * @return {void} 656 */ 657 self.userInactiveEvent = function( inactiveDelay ) { 658 var delay = +inactiveDelay || 0, 659 isInactive = true; 660 661 delay = delay * 1000; 662 663 setTimeout( function() { 664 if ( isInactive ) { 665 self.showPopup(); 666 } 667 }, delay ); 668 669 $( document ).on( 'click focus resize keyup scroll', function() { 670 isInactive = false; 671 } ); 672 }; 673 674 /** 675 * Scrolling Page Event 676 * 677 * @param {int} scrollingValue Scrolling porgress value 678 * @return {void} 679 */ 680 self.scrollPageEvent = function( scrollingValue ) { 681 var scrolledValue = +scrollingValue || 0; 682 683 $window.on( 'scroll.cherryJetScrollEvent resize.cherryJetResizeEvent', function() { 684 var $window = $( window ), 685 windowHeight = $window.height(), 686 documentHeight = $( document ).height(), 687 scrolledHeight = documentHeight - windowHeight, 688 scrolledProgress = Math.max( 0, Math.min( 1, $window.scrollTop() / scrolledHeight ) ) * 100; 689 690 if ( scrolledProgress >= scrolledValue ) { 691 $window.off( 'scroll.cherryJetScrollEvent resize.cherryJetResizeEvent' ); 692 self.showPopup(); 693 } 694 } ).trigger( 'scroll.cherryJetResizeEvent' ); 695 }; 696 697 /** 698 * Viewport leave event 699 * 700 * @return {void} 701 */ 702 self.tryExitEvent = function() { 703 var pageY = 0; 704 705 $( document ).on( 'mouseleave', 'body', function( event ) { 706 707 pageY = event.pageY - $window.scrollTop(); 708 709 if ( 0 > pageY && $popup.hasClass( 'jet-popup--hide-state' ) ) { 710 self.showPopup(); 711 } 712 } ); 713 }; 714 715 /** 716 * onDateEvent Event 717 * 718 * @return {void} 719 */ 720 self.onDateEvent = function( date ) { 721 var nowDate = Date.now(), 722 startDate = Date.parse( date ); 723 724 if ( startDate < nowDate ) { 725 726 setTimeout( function() { 727 self.showPopup(); 728 }, 500 ); 729 } 730 } 731 732 self.onTimeEvent = function( startTime = '00:00', endTime = '23:59' ) { 733 var startTime = '' !== startTime ? startTime : '00:00', 734 endTime = '' !== endTime ? endTime : '23:59', 735 nowTimeStamp = Date.now(), 736 dateTimeFormat = new Intl.DateTimeFormat( 'en', { year: 'numeric', month: 'short', day: '2-digit' } ), 737 [ { value: month },,{ value: day },,{ value: year } ] = dateTimeFormat.formatToParts( nowTimeStamp ), 738 startTime = `${ month }. ${ day }, ${ year } ${ startTime }`, 739 endTime = `${ month }. ${ day }, ${ year } ${ endTime }`, 740 startTimeStamp = Date.parse( startTime ), 741 endTimeStamp = Date.parse( endTime ); 742 743 if ( ( startTimeStamp < nowTimeStamp ) && ( nowTimeStamp < endTimeStamp ) ) { 744 setTimeout( function() { 745 self.showPopup(); 746 }, 500 ); 747 } 748 } 749 750 751 self.onTimeAndDateEvent = function( start, end ) { 752 753 var nowDateStamp = Date.now(), 754 startDateStamp = Date.parse( start ), 755 endDateStamp = Date.parse( end ); 756 757 if ( ( startDateStamp < nowDateStamp ) && ( nowDateStamp < endDateStamp ) ) { 758 setTimeout( function() { 759 self.showPopup(); 760 }, 500 ); 761 } 762 763 } 764 765 /** 766 * Check DOM Loaded Selector 767 * @param {[type]} selector [description] 768 * @return {[type]} [description] 769 */ 770 771 self.checkLoadedSelector = function( selector ) { 772 773 //Check Listing Grid Lazy Load 774 $( document ).on( 'jet-engine/listing-grid/after-lazy-load', function() { 775 self.onCustomSelector ( selector ); 776 }); 777 778 //Check Open Mobile Menu 779 $( '.jet-mobile-menu__toggle' ).closest( '.jet-mobile-menu__instance--slide-out-layout' ).on( 'click', function() { 780 self.onCustomSelector ( selector ); 781 }); 782 783 } 784 785 /** 786 * [onCustomSelector description] 787 * @param {[type]} selector [description] 788 * @return {[type]} [description] 789 */ 790 self.onCustomSelector = function( selector ) { 791 792 let $selector = $( selector ); 793 794 if ( $selector[0] ) { 795 $( 'body' ).on( 'click', selector, function( event ) { 796 event.preventDefault(); 797 798 let $this = $( this ); 799 let popupId = $this.data( 'popup' ); 800 801 if ( $this.data( 'opened' ) ) { 802 self.hidePopup( popupId, false ); 803 $this.data( 'opened', false ); 804 } else { 805 self.showPopup( popupId, $this ); 806 $this.data( 'opened', true ); 807 } 808 } ); 809 } else { 810 self.checkLoadedSelector( selector ); 811 } 812 } 813 814 /** 815 * Show Popup 816 * 817 * @return {void} 818 */ 819 self.showPopup = function( data, $trigger ) { 820 var popupData = data || {}, 821 animeOverlay = null,
822 animeContainer = null, 823 animeOverlaySettings = jQuery.extend( 824 { 825 targets: $( '.jet-popup__overlay', $popup )[0] 826 }, 827 self.avaliableEffects[ 'fade' ][ 'show' ] 828 ); 829 830 $trigger = $trigger || false; 831 832 if ( ! self.popupAvailableCheck() ) { 833 return false; 834 } 835 836 animeOverlay = anime( animeOverlaySettings ); 837 838 $popup.toggleClass( 'jet-popup--hide-state jet-popup--show-state' ); 839 840 if ( popupSettings['prevent-scrolling'] ) { 841 $( 'body' ).addClass( 'jet-popup-prevent-scroll' ); 842 } 843 844 popupData = window.JetPlugins.hooks.applyFilters( 'jet-popup.show-popup.data', popupData, $popup, $trigger ); 845 846 self.showContainer( popupData ); 847 }; 848 849 /** 850 * [showContainer description] 851 * @return {[type]} [description] 852 */ 853 self.showContainer = function( data ) { 854 var popupData = data || {}, 855 popupDefaultData = { 856 forceLoad: popupSettings['force-ajax'] || false, // Trigger Ajax Every Time 857 customContent: '' // Show Popup with Custom Content 858 }, 859 animeContainerInstance = null, 860 $popupContainer = $( '.jet-popup__container', $popup ), 861 $content = $( '.jet-popup__container-content', $popup ), 862 animeContainer = jQuery.extend( 863 { 864 targets: $( '.jet-popup__container', $popup )[0], 865 begin: function( anime ) { 866 isAnimation = true; 867 868 $window.trigger( 'jet-popup/show-event/before-show', { 869 self: self, 870 data: popupData, 871 anime: anime 872 } ); 873 }, 874 complete: function( anime ) { 875 isAnimation = false; 876 isOpen = true; 877 878 $window.trigger( 'jet-popup/show-event/after-show', { 879 self: self, 880 data: popupData, 881 anime: anime 882 } ); 883 } 884 }, 885 self.avaliableEffects[ popupSettings['animation'] ][ 'show' ] 886 ); 887 888 popupData = jQuery.extend( popupDefaultData, popupData ); 889 890 // init Custom popup content 891 if ( '' !== popupData.customContent ) { 892 $content.html( popupData.customContent ); 893 self.elementorFrontendInit(); 894 895 // Show Popup Container
896 animeContainerInstance = anime( animeContainer ); 897 898 $window.trigger( 'jet-popup/render-content/render-custom-content', { 899 self: self, 900 popup_id: id, 901 data: popupData, 902 } ); 903 904 return false; 905 } 906 907 if ( ! popupSettings['use-ajax'] ) { 908 // Show Popup Container 909 animeContainerInstance = anime( animeContainer ); 910 911 $window.trigger( 'jet-popup/render-content/render-custom-content', { 912 self: self, 913 popup_id: id, 914 data: popupData, 915 } ); 916 917 return false; 918 } 919 920 if ( popupData.forceLoad ) { 921 ajaxContentLoaded = false; 922 } 923 924 if ( ajaxContentLoaded ) { 925 // Show Popup Container 926 animeContainerInstance = anime( animeContainer ); 927 928 $window.trigger( 'jet-popup/render-content/show-content', { 929 self: self, 930 popup_id: id, 931 data: popupData, 932 } ); 933 934 return false; 935 } 936 937 popupData = jQuery.extend( popupData, { 938 'popup_id': id, 939 'page_url': window.location.href 940 } ); 941 942 ajaxGetContentHanler = jQuery.ajax( { 943 type: 'POST', 944 url: window.jetPopupData.ajax_url, 945 data: { 946 'action': 'jet_popup_get_content', 947 'data': popupData 948 }, 949 beforeSend: function( jqXHR, ajaxSettings ) { 950 951 if ( null !== ajaxGetContentHanler ) { 952 ajaxGetContentHanler.abort(); 953 } 954 955 // Before ajax send Trigger 956 $window.trigger( 'jet-popup/render-content/ajax/before-send', { 957 self: self, 958 popup_id: id, 959 data: popupData 960 } ); 961 962 $popup.addClass( 'jet-popup--loading-state' ); 963 }, 964 error: function( jqXHR, ajaxSettings ) {}, 965 success: function( data, textStatus, jqXHR ) { 966 var successType = data.type, 967 contentData = data.content || false, 968 $popupContainer = $( '.jet-popup__container-content', $popup ); 969 970 $popup.removeClass( 'jet-popup--loading-state' ); 971 972 if ( 'error' === successType ) { 973 var message = data.message; 974 975 $content.html( '<h3>' + message + '</h3>' ); 976 977 // Show Popup Container 978 animeContainerInstance = anime( animeContainer ); 979 } 980 981 if ( 'success' === successType ) { 982 let popupContent = contentData['content'], 983 popupContentElements = contentData['contentElements'], 984 popupScripts = contentData['scripts'], 985 popupStyles = contentData['styles'], 986 popupAfterScripts = contentData['afterScripts']; 987 988 for ( let { handle: scriptHandler, src: scriptSrc } of popupScripts ) { 989 JetPopupFrontend.addedAssetsPromises.push( JetPopupFrontend.loadScriptAsync( scriptHandler, scriptSrc ) ); 990 } 991 992 if ( popupStyles && Object.keys( popupStyles ).length > 0 ) { 993 for ( let styleHandler in popupStyles ) { 994 JetPopupFrontend.addedAssetsPromises.push( JetPopupFrontend.loadStyle( styleHandler, popupStyles[ styleHandler ] ) ); 995 } 996 } 997 998 JetPopupFrontend.assetsLoaderPromise().then( async function( value ) { 999 ajaxContentLoaded = true; 1000 1001 // Ajax Success Trigger 1002 $window.trigger( 'jet-popup/render-content/ajax/success', { 1003 self: self, 1004 popup_id: id, 1005 data: popupData, 1006 request: data 1007 } ); 1008 1009 // Render content 1010 if ( popupContent ) { 1011 $popupContainer.html( popupContent ); 1012 } 1013 1014 if ( popupAfterScripts.length ) { 1015 await Promise.all( popupAfterScripts.map( 1016 ( { handle, src } ) => JetPopupFrontend.loadScriptAsync( handle, src ) 1017 ) ); 1018 } 1019 1020 // Before ajax frontend init 1021 $( window ).trigger( 'jet-popup/ajax/frontend-init/before', { 1022 $container: $popupContainer, 1023 content: popupContent, 1024 contentElements: popupContentElements, 1025 contentType: popupSettings['content-type'], 1026 } ); 1027 1028 // Frontend init 1029 $( window ).trigger( 'jet-popup/ajax/frontend-init', { 1030 $container: $popupContainer, 1031 content: popupContent, 1032 contentElements: popupContentElements, 1033 contentType: popupSettings['content-type'], 1034 } ); 1035 1036 // after ajax frontend init 1037 $( window ).trigger( 'jet-popup/ajax/frontend-init/after', { 1038 $container: $popupContainer, 1039 content: popupContent, 1040 contentElements: popupContentElements, 1041 contentType: popupSettings['content-type'], 1042 } ); 1043 1044 // Show Popup Container
1045 animeContainerInstance = anime( animeContainer ); 1046 1047 }, function( reason ) { 1048 console.log( 'Assets Loaded Error' ); 1049 } ); 1050 } 1051 } 1052 } ); 1053 }; 1054 1055 /** 1056 * Hide Popup 1057 * 1058 * @return {void} 1059 */ 1060 self.hidePopup = function ( data ) { 1061 var popupData = data || {}, 1062 $content = $( '.jet-popup__container-content', $popup ), 1063 constantly = popupData.constantly || false, 1064 animeOverlay = null, 1065 animeContainer = null, 1066 animeOverlaySettings = jQuery.extend( { targets: $( '.jet-popup__overlay', $popup )[0] }, self.avaliableEffects[ 'fade' ][ 'hide' ] ), 1067 animeContainerSettings = jQuery.extend( 1068 { 1069 targets: $( '.jet-popup__container', $popup )[0], 1070 begin: function( anime ) { 1071 isAnimation = true; 1072 1073 $window.trigger( 'jet-popup/hide-event/before-hide', { 1074 self: self, 1075 data: popupData, 1076 anime: anime 1077 } ); 1078 }, 1079 complete: function( anime ) { 1080 isAnimation = false; 1081 isOpen = false; 1082 $popup.toggleClass( 'jet-popup--show-state jet-popup--hide-state' ); 1083 1084 if ( popupSettings['use-ajax'] && popupSettings['force-ajax'] ) { 1085 $content.html( '' ); 1086 } 1087 1088 if ( popupSettings['prevent-scrolling'] && !$( '.jet-popup--show-state' )[0] ) { 1089 $( 'body' ).removeClass( 'jet-popup-prevent-scroll' ); 1090 } 1091 // After Popup Hide Action 1092 $window.trigger( 'jet-popup/hide-event/after-hide', { 1093 self: self, 1094 data: popupData, 1095 anime: anime 1096 } ); 1097 } 1098 }, 1099 self.avaliableEffects[ popupSettings['animation'] ][ 'hide' ] 1100 ); 1101 1102 if ( constantly ) { 1103 self.setLocalStorageData( popupId, 'disable' ); 1104 } 1105 1106 if ( isAnimation ){ 1107 return false; 1108 } 1109 1110 if ( $popup.hasClass('jet-popup--show-state') ) { 1111 animeOverlay = anime( animeOverlaySettings );
1112 animeContainer = anime( animeContainerSettings ); 1113 } 1114 1115 // On Hide Handler 1116 self.onHidePopupAction(); 1117 1118 // Before Popup Hide Action 1119 $window.trigger( 'jet-popup/close-hide-event/before-hide', { 1120 self: self, 1121 data: popupData 1122 } ); 1123 }; 1124 1125 /** 1126 * [elementorFrontendInit description] 1127 * @return {[type]} [description] 1128 */ 1129 self.elementorFrontendInit = function() { 1130 var $content = $( '.jet-popup__container-content', $popup ); 1131 1132 $content.find( 'div[data-element_type]' ).each( function() { 1133 var $this = $( this ), 1134 elementType = $this.data( 'element_type' ); 1135 1136 if (!elementType) { 1137 return; 1138 } 1139 1140 try { 1141 if( 'widget' === elementType ){ 1142 elementType = $this.data( 'widget_type' ); 1143 window.elementorFrontend.hooks.doAction( 'frontend/element_ready/widget', $this, $ ); 1144 } 1145 window.elementorFrontend.hooks.doAction( 'frontend/element_ready/' + elementType, $this, $ ); 1146 1147 } catch( err ) { 1148 console.log(err); 1149 1150 $this.remove(); 1151 1152 return false; 1153 } 1154 1155 }); 1156 1157 // On Show Handler 1158 self.onShowPopupAction(); 1159 } 1160 1161 /** 1162 * [onShowPopupAction description] 1163 * @return {[type]} [description] 1164 */ 1165 self.onShowPopupAction = function() {}; 1166 1167 /** 1168 * [onHidePopupAction description] 1169 * @return {[type]} [description] 1170 */ 1171 self.onHidePopupAction = function() {}; 1172 1173 /** 1174 * Avaliable Effects 1175 */ 1176 self.avaliableEffects = { 1177 'fade' : { 1178 'show': { 1179 opacity: { 1180 value: [ 0, 1 ], 1181 duration: 600, 1182 easing: 'easeOutQuart', 1183 }, 1184 }, 1185 'hide': { 1186 easing: 'easeOutQuart', 1187 opacity: { 1188 value: [ 1, 0 ], 1189 easing: 'easeOutQuart', 1190 duration: 400, 1191 }, 1192 } 1193 }, 1194 1195 'zoom-in' : { 1196 'show': { 1197 duration: 500, 1198 easing: 'easeOutQuart', 1199 opacity: { 1200 value: [ 0, 1 ], 1201 1202 }, 1203 scale: { 1204 value: [ 0.75, 1 ], 1205 } 1206 }, 1207 'hide': { 1208 duration: 400, 1209 easing: 'easeOutQuart', 1210 opacity: { 1211 value: [ 1, 0 ], 1212 }, 1213 scale: { 1214 value: [ 1, 0.75 ], 1215 } 1216 } 1217 }, 1218 1219 'zoom-out' : { 1220 'show': { 1221 duration: 500, 1222 easing: 'easeOutQuart', 1223 opacity: { 1224 value: [ 0, 1 ], 1225 1226 }, 1227 scale: { 1228 value: [ 1.25, 1 ], 1229 } 1230 }, 1231 'hide': { 1232 duration: 400, 1233 easing: 'easeOutQuart', 1234 opacity: { 1235 value: [ 1, 0 ], 1236 }, 1237 scale: { 1238 value: [ 1, 1.25 ], 1239 } 1240 } 1241 }, 1242 1243 'rotate' : { 1244 'show': { 1245 duration: 500, 1246 easing: 'easeOutQuart', 1247 opacity: { 1248 value: [ 0, 1 ], 1249 1250 }, 1251 scale: { 1252 value: [ 0.75, 1 ], 1253 }, 1254 rotate: { 1255 value: [ -65, 0 ], 1256 } 1257 }, 1258 'hide': { 1259 duration: 400, 1260 easing: 'easeOutQuart', 1261 opacity: { 1262 value: [ 1, 0 ], 1263 }, 1264 scale: { 1265 value: [ 1, 0.9 ], 1266 }, 1267 } 1268 }, 1269 1270 'move-up' : { 1271 'show': { 1272 duration: 500, 1273 easing: 'easeOutExpo', 1274 opacity: { 1275 value: [ 0, 1 ], 1276 1277 }, 1278 translateY: { 1279 value: [ 50, 1 ], 1280 } 1281 }, 1282 'hide': { 1283 duration: 400, 1284 easing: 'easeOutQuart', 1285 opacity: { 1286 value: [ 1, 0 ], 1287 }, 1288 translateY: { 1289 value: [ 1, 50 ], 1290 } 1291 } 1292 }, 1293 1294 'flip-x' : { 1295 'show': { 1296 duration: 500, 1297 easing: 'easeOutExpo', 1298 opacity: { 1299 value: [ 0, 1 ], 1300 1301 }, 1302 rotateX: { 1303 value: [ 65, 0 ], 1304 } 1305 }, 1306 'hide': { 1307 duration: 400, 1308 easing: 'easeOutQuart', 1309 opacity: { 1310 value: [ 1, 0 ], 1311 } 1312 } 1313 }, 1314 1315 'flip-y' : { 1316 'show': { 1317 duration: 500, 1318 easing: 'easeOutExpo', 1319 opacity: { 1320 value: [ 0, 1 ], 1321 1322 }, 1323 rotateY: { 1324 value: [ 65, 0 ], 1325 } 1326 }, 1327 'hide': { 1328 duration: 400, 1329 easing: 'easeOutQuart', 1330 opacity: { 1331 value: [ 1, 0 ], 1332 } 1333 } 1334 }, 1335 1336 'bounce-in' : { 1337 'show': { 1338 opacity: { 1339 value: [ 0, 1 ], 1340 duration: 500, 1341 easing: 'easeOutQuart', 1342 }, 1343 scale: { 1344 value: [ 0.2, 1 ], 1345 duration: 800, 1346 elasticity: function(el, i, l) { 1347 return (400 + i * 200); 1348 }, 1349 } 1350 }, 1351 'hide': { 1352 duration: 400, 1353 easing: 'easeOutQuart', 1354 opacity: { 1355 value: [ 1, 0 ], 1356 }, 1357 scale: { 1358 value: [ 1, 0.8 ], 1359 } 1360 } 1361 }, 1362 1363 'bounce-out' : { 1364 'show': { 1365 opacity: { 1366 value: [ 0, 1 ], 1367 duration: 500, 1368 easing: 'easeOutQuart', 1369 }, 1370 scale: { 1371 value: [ 1.8, 1 ],
1372 duration: 800, 1373 elasticity: function(el, i, l) { 1374 return (400 + i * 200); 1375 }, 1376 } 1377 }, 1378 'hide': { 1379 duration: 400, 1380 easing: 'easeOutQuart', 1381 opacity: { 1382 value: [ 1, 0 ], 1383 }, 1384 scale: { 1385 value: [ 1, 1.5 ], 1386 } 1387 } 1388 }, 1389 1390 'slide-in-up' : { 1391 'show': { 1392 opacity: { 1393 value: [ 0, 1 ], 1394 duration: 400, 1395 easing: 'easeOutQuart', 1396 }, 1397 translateY: { 1398 value: ['100vh', 0], 1399 duration: 750, 1400 easing: 'easeOutQuart', 1401 } 1402 }, 1403 'hide': { 1404 duration: 400, 1405 easing: 'easeInQuart', 1406 opacity: { 1407 value: [ 1, 0 ], 1408 }, 1409 translateY: { 1410 value: [0,'100vh'], 1411 } 1412 } 1413 }, 1414 1415 'slide-in-right' : { 1416 'show': { 1417 opacity: { 1418 value: [ 0, 1 ], 1419 duration: 400, 1420 easing: 'easeOutQuart', 1421 }, 1422 translateX: { 1423 value: ['100vw', 0], 1424 duration: 750, 1425 easing: 'easeOutQuart', 1426 } 1427 }, 1428 'hide': { 1429 duration: 400, 1430 easing: 'easeInQuart', 1431 opacity: { 1432 value: [ 1, 0 ], 1433 }, 1434 translateX: { 1435 value: [0,'100vw'], 1436 } 1437 } 1438 }, 1439 1440 'slide-in-down' : { 1441 'show': { 1442 opacity: { 1443 value: [ 0, 1 ], 1444 duration: 400, 1445 easing: 'easeOutQuart', 1446 }, 1447 translateY: { 1448 value: ['-100vh', 0], 1449 duration: 750, 1450 easing: 'easeOutQuart', 1451 } 1452 }, 1453 'hide': { 1454 duration: 400, 1455 easing: 'easeInQuart', 1456 opacity: { 1457 value: [ 1, 0 ], 1458 }, 1459 translateY: { 1460 value: [0,'-100vh'], 1461 } 1462 } 1463 }, 1464 1465 'slide-in-left' : { 1466 'show': { 1467 opacity: { 1468 value: [ 0, 1 ], 1469 duration: 400, 1470 easing: 'easeOutQuart', 1471 }, 1472 translateX: { 1473 value: ['-100vw', 0], 1474 duration: 750, 1475 easing: 'easeOutQuart', 1476 } 1477 }, 1478 'hide': { 1479 duration: 400, 1480 easing: 'easeInQuart', 1481 opacity: { 1482 value: [ 1, 0 ], 1483 }, 1484 translateX: { 1485 value: [0,'-100vw'], 1486 } 1487 } 1488 } 1489 1490 }; 1491 1492 /** 1493 * Get localStorage data. 1494 * 1495 * @return {object|boolean} 1496 */ 1497 self.getLocalStorageData = function() { 1498 1499 try { 1500 return JSON.parse( localStorage.getItem( 'jetPopupData' ) ); 1501 } catch ( e ) { 1502 return false; 1503 } 1504 }; 1505 1506 /** 1507 * Set localStorage data. 1508 * 1509 * @return {object|boolean} 1510 */ 1511 self.setLocalStorageData = function( id, status ) { 1512 1513 var jetPopupData = self.getLocalStorageData() || {}, 1514 newData = {}; 1515 1516 newData['status'] = status; 1517 1518 if ( 'disable' === status ) { 1519 1520 var nowDate = Date.now(), 1521 showAgainDelay = popupSettings['show-again-delay'], 1522 showAgainDate = 'none' !== showAgainDelay ? ( nowDate + showAgainDelay ) : 'none'; 1523 1524 newData['show-again-date'] = showAgainDate; 1525 } 1526 1527 jetPopupData[ id ] = newData; 1528 1529 localStorage.setItem( 'jetPopupData', JSON.stringify( jetPopupData ) ); 1530 } 1531 1532 } 1533 1534 window.JetPopupFrontend.init(); 1535 1536}( 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.