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