1( function( $ ) { 2 3 'use strict'; 4 5 window.JetPopupFrontend = { 6 7 addedScripts: {}, 8 9 addedStyles: {}, 10 11 addedAssetsPromises: [], 12 13 getLoopItemData: function( $trigger ) { 14 15 let $loopItem = $(); 16 17 if ( ! $trigger || ! $trigger.length ) { 18 return {}; 19 } 20 21 $loopItem = $trigger.closest( '[data-elementor-type="loop-item"], .e-loop-item' ); 22 23 if ( ! $loopItem.length ) { 24 $loopItem = $trigger.find( '[data-elementor-type="loop-item"], .e-loop-item' ).first(); 25 } 26 27 if ( ! $loopItem.length ) { 28 return {}; 29 } 30 31 let postId = $loopItem.data( 'post-id' ) || false, 32 className = $loopItem.attr( 'class' ) || '', 33 matches = [ 34 className.match( /\be-loop-item-(\d+)\b/ ), 35 className.match( /\bpost-(\d+)\b/ ), 36 className.match( /\bpage-id-(\d+)\b/ ), 37 className.match( /\battachment-(\d+)\b/ ), 38 ]; 39 40 if ( ! postId ) { 41 for ( let match of matches ) { 42 if ( match && match[1] ) { 43 postId = match[1]; 44 break; 45 } 46 } 47 } 48 49 if ( ! postId ) { 50 return {}; 51 } 52 53 return { 54 postId: +postId, 55 }; 56 }, 57 58 maybeExtendPopupData: function( popupData, $trigger ) { 59 popupData = popupData || {}; 60 61 if ( ! popupData.loopDynamicPopup || popupData.postId || ! $trigger || ! $trigger.length ) { 62 return popupData; 63 } 64 65 return jQuery.extend( {}, popupData, JetPopupFrontend.getLoopItemData( $trigger ) ); 66 }, 67 68 init: function() { 69 let $popup_list = $( '.jet-popup.jet-popup--front-mode' ); 70 71 $popup_list.each( function( index ) { 72 let $target = $( this ), 73 instance = null, 74 settings = $target.data( 'settings' ); 75 76 instance = new window.jetPopup( $target, settings ); 77 instance.init(); 78 } ); 79 80 JetPopupFrontend.initAttachedPopups(); 81 82 JetPopupFrontend.initBlocks(); 83 84 $( window ).on( 'jet-popup/ajax/frontend-init', ( event, payload ) => { 85 86 switch ( payload.contentType ) { 87 case 'elementor': 88 JetPopupFrontend.maybeElementorFrontendInit( payload.$container ); 89 break; 90 case 'default': 91 JetPopupFrontend.maybeDefaultFrontendInit( payload ); 92 break 93 } 94 } ); 95 }, 96 97 initAttachedPopups: function ( $scope ) { 98 $scope = $scope || $( 'body' ); 99 100 $scope.find( '[data-popup-instance]' ).each( ( index, el ) => { 101 let $this = $( el ), 102 popupId = $this.data( 'popup-instance' ) || 'none', 103 triggerType = $this.data( 'popup-trigger-type' ) || 'none', 104 clickedCustomClass = $this.data( 'popup-custom-selector' ) || '', 105 popupData = { 106 popupId: `jet-popup-${ popupId }`, 107 }; 108 109 if ( $this.hasClass( 'jet-popup-attach-event-inited' ) ) { 110 return; 111 } 112 113 $this.addClass( 'jet-popup-attach-event-inited' ); 114 115 switch( triggerType ) { 116 case 'click-self': 117 $this.addClass( 'jet-popup-cursor-pointer' ); 118 JetPopupFrontend.makeTriggerAccessible( $this, popupData.popupId ); 119 120 $this.on( 'click.JetPopup', function( event ) { 121 event.preventDefault(); 122 123 $( window ).trigger( { 124 type: 'jet-popup-open-trigger', 125 popupData: popupData, 126 triggeredBy: $( event.currentTarget ), 127 } ); 128 129 return false; 130 } ); 131 break; 132 case 'click-selector': 133 134 if ( '' !== clickedCustomClass ) { 135 $this.find( clickedCustomClass ).addClass( 'jet-popup-cursor-pointer' ); 136 JetPopupFrontend.makeTriggerAccessible( $this.find( clickedCustomClass ), popupData.popupId ); 137 138 $this.on( 'click.JetPopup', clickedCustomClass, function( event ) { 139 event.preventDefault(); 140 141 $( window ).trigger( { 142 type: 'jet-popup-open-trigger', 143 popupData: popupData, 144 triggeredBy: $( event.currentTarget ), 145 } ); 146 147 return false; 148 } ); 149 } 150 break; 151 case 'hover': 152 $this.on( 'mouseenter.JetPopup', function( event ) { 153 154 $( window ).trigger( { 155 type: 'jet-popup-open-trigger', 156 popupData: popupData, 157 triggeredBy: $this, 158 } ); 159 } ); 160 break; 161 case 'scroll-to': 162 const observer = new IntersectionObserver(( entries ) => { 163 entries.forEach(( entry ) => { 164 165 if ( entry.isIntersecting ) { 166 167 $( window ).trigger( { 168 type: 'jet-popup-open-trigger', 169 popupData: popupData, 170 triggeredBy: $this, 171 } ); 172 } 173 }) 174 }, 175 { 176 threshold: 0.5 177 }); 178 179 for ( let i = 0; i < $( $this ).length; i++ ) { 180 const elements = $( $this )[i]; 181 observer.observe( elements ); 182 } 183 184 break; 185 } 186 } ); 187 }, 188 189 initBlocks: function( $scope ) { 190 $scope = $scope || $( 'body' ); 191 192 window.JetPlugins.init( $scope, [ 193 { 194 block: 'jet-popup/action-button', 195 callback: ( $scope ) => { 196 let $button = $( '.jet-popup-action-button__instance', $scope ), 197 actionType = $scope.data( 'action-type' ); 198 199 JetPopupFrontend.actionButtonHandle( $button, actionType ); 200 } 201 } 202 ] ); 203 }, 204 205 actionButtonBlock: function( $scope ) { 206 var $button = $( '.jet-popup-action-button__instance', $scope ), 207 actionType = $scope.data( 'action-type' ); 208 209 JetPopupFrontend.actionButtonHandle( $button, actionType ); 210 }, 211 212 actionButtonHandle: function ( $button, actionType = 'link' ) { 213 214 switch ( actionType ) { 215 216 case 'link': 217 218 $button.on( 'click.JetPopup', function( event ) { 219 event.preventDefault(); 220 221 var $currentPopup = $button.closest( '.jet-popup' ), 222 link = $( this ).attr( 'href' ), 223 target = $( this ).attr( 'target' ), 224 popupId = $currentPopup.attr( 'id' ); 225 226 $( window ).trigger( { 227 type: 'jet-popup-close-trigger', 228 popupData: { 229 popupId: popupId, 230 constantly: false 231 } 232 } ); 233 234 if ( '_blank' === target ) { 235 window.open( link, '_blank' ); 236 } else { 237 window.open( link, '_self' ); 238 } 239 240 return false;
241 } ); 242 break; 243 244 case 'leave': 245 $button.on( 'click.JetPopup', function( event ) { 246 event.preventDefault(); 247 248 window.history.back(); 249 } ); 250 break; 251 252 case 'close-popup': 253 $button.on( 'click.JetPopup', function( event ) { 254 event.preventDefault(); 255 256 var $currentPopup = $button.closest( '.jet-popup' ), 257 popupId = $currentPopup.attr( 'id' ); 258 259 $( window ).trigger( { 260 type: 'jet-popup-close-trigger', 261 popupData: { 262 popupId: popupId, 263 constantly: false 264 } 265 } ); 266 } ); 267 break; 268 269 case 'close-all-popups': 270 $button.on( 'click.JetPopup', function( event ) { 271 event.preventDefault(); 272 273 var $popups = $( '.jet-popup' ); 274 275 if ( $popups[0] ) { 276 $popups.each( function( index ) { 277 var $popup = $( this ), 278 popupId = $popup.attr( 'id' ); 279 280 $( window ).trigger( { 281 type: 'jet-popup-close-trigger', 282 popupData: { 283 popupId: popupId, 284 constantly: false 285 } 286 } ); 287 } ); 288 } 289 } ); 290 break; 291 292 case 'close-constantly': 293 $button.on( 'click.JetPopup', function( event ) { 294 event.preventDefault(); 295 296 var $currentPopup = $button.closest( '.jet-popup' ), 297 popupId = $currentPopup.attr( 'id' ); 298 299 $( window ).trigger( { 300 type: 'jet-popup-close-trigger', 301 popupData: { 302 popupId: popupId, 303 constantly: true 304 } 305 } ); 306 } ); 307 break; 308 309 case 'close-all-constantly': 310 $button.on( 'click.JetPopup', function( event ) { 311 event.preventDefault(); 312 313 var $popups = $( '.jet-popup' ); 314 315 if ( $popups[0] ) { 316 $popups.each( function( index ) { 317 var $popup = $( this ), 318 popupId = $popup.attr( 'id' ); 319 320 $( window ).trigger( { 321 type: 'jet-popup-close-trigger', 322 popupData: { 323 popupId: popupId, 324 constantly: true 325 } 326 } ); 327 } ); 328 } 329 } ); 330 break; 331 } 332 }, 333 334 isNativeInteractiveElement: function( element ) { 335 if ( ! element || ! element.tagName ) { 336 return false; 337 } 338 339 const tagName = element.tagName.toLowerCase(); 340 341 return -1 !== [ 'a', 'button', 'input', 'select', 'textarea', 'option', 'summary' ].indexOf( tagName ); 342 }, 343 344 makeTriggerAccessible: function( $elements, popupId ) { 345 if ( ! $elements || ! $elements.length ) { 346 return; 347 } 348 349 $elements.each( function() { 350 const $element = $( this ); 351 352 if ( popupId ) { 353 $element.attr( { 354 'aria-haspopup': 'dialog', 355 'aria-controls': popupId, 356 'aria-expanded': 'false', 357 } ); 358 } 359 360 if ( JetPopupFrontend.isNativeInteractiveElement( this ) ) { 361 return; 362 } 363 364 if ( ! $element.is( '[role]' ) ) { 365 $element.attr( 'role', 'button' ); 366 } 367 368 if ( ! $element.is( '[tabindex]' ) ) { 369 $element.attr( 'tabindex', '0' ); 370 } 371 } ); 372 373 $elements.off( 'keydown.jetPopupA11yTrigger' ).on( 'keydown.jetPopupA11yTrigger', function( event ) { 374 const key = event.key || ''; 375 376 if ( JetPopupFrontend.isNativeInteractiveElement( event.currentTarget ) ) { 377 return; 378 } 379 380 if ( 'Enter' === key || ' ' === key || 'Spacebar' === key || 13 === event.keyCode || 32 === event.keyCode ) { 381 event.preventDefault(); 382 $( this ).trigger( 'click' ); 383 } 384 } ); 385 }, 386 387 loadScriptAsync: function( script, uri ) { 388 389 if ( JetPopupFrontend.addedScripts.hasOwnProperty( script ) ) { 390 return script; 391 } 392 393 JetPopupFrontend.addedScripts[ script ] = uri; 394 395 const asset = document.getElementById( script + '-js' ); 396 397 if ( asset ) { 398 return script; 399 } 400 401 return new Promise( function( resolve, reject ) { 402 var tag = document.createElement( 'script' ); 403 404 tag.src = uri; 405 tag.async = false; 406 tag.onload = function() { 407 resolve( script ); 408 }; 409 410 document.head.appendChild( tag ); 411 } ); 412 }, 413 414 loadStyle: function( style, uri ) { 415 416 if ( JetPopupFrontend.addedStyles.hasOwnProperty( style ) && JetPopupFrontend.addedStyles[ style ] === uri) { 417 return style; 418 } 419 420 JetPopupFrontend.addedStyles[ style ] = uri; 421 422 return new Promise( function( resolve, reject ) { 423 var tag = document.createElement( 'link' ); 424 425 tag.id = style; 426 tag.rel = 'stylesheet'; 427 tag.href = uri; 428 tag.type = 'text/css'; 429 tag.media = 'all'; 430 tag.onload = function() { 431 resolve( style ); 432 }; 433 434 document.head.appendChild( tag ); 435 }); 436 }, 437 438 assetsLoaderPromise: function() { 439 return Promise.all( JetPopupFrontend.addedAssetsPromises ); 440 }, 441 442 maybeElementorFrontendInit: function( $popupContainer ) { 443 $popupContainer.find( 'div[data-element_type]' ).each( function() { 444 var $this = $( this ), 445 elementType = $this.data( 'element_type' ); 446 447 if ( ! elementType ) { 448 return; 449 } 450 451 try { 452 if ( 'widget' === elementType ) { 453 elementType = $this.data( 'widget_type' ); 454 455 if ( window.elementorFrontend && window.elementorFrontend.hooks ) { 456 window.elementorFrontend.hooks.doAction( 'frontend/element_ready/widget', $this, $ ); 457 } 458 } 459 460 if ( window.elementorFrontend && window.elementorFrontend.hooks ) { 461 window.elementorFrontend.hooks.doAction( 'frontend/element_ready/global', $this, $ ); 462 window.elementorFrontend.hooks.doAction( 'frontend/element_ready/' + elementType, $this, $ ); 463 } 464 465 } catch ( err ) { 466 console.log(err); 467 $this.remove(); 468 469 return false;
470 } 471 } ); 472 }, 473 474 maybeDefaultFrontendInit: function ( payload ) { 475 const contentElements = payload.contentElements || [], 476 $container = payload.$container; 477 478 $container.find( '[data-is-block*="/"]' ).each( ( index, el ) => { 479 window.JetPlugins.hooks.doAction( window.JetPlugins.hookNameFromBlock( el.dataset.isBlock ), jQuery( el ) ); 480 } ); 481 } 482 }; 483 484 /** 485 * [jetPopup description] 486 * @param {[type]} $popup [description] 487 * @param {[type]} settings [description] 488 * @return {[type]} [description] 489 */ 490 window.jetPopup = function( $popup, settings ) { 491 var self = this, 492 $window = $( window ), 493 $document = $( document ), 494 popupSettings = settings, 495 id = popupSettings['id'], 496 popupId = popupSettings['jet-popup-id'], 497 popupsLocalStorageData = {}, 498 //editMode = Boolean( window.elementorFrontend.isEditMode() ), 499 isAnimation = false, 500 isOpen = false, 501 ajaxGetContentHanler = null, 502 ajaxContentLoaded = false, 503 focusedBeforeOpen = null, 504 $lastTrigger = $(); 505 506 self.getAccessibilityConfig = function() { 507 return window.jetPopupData && window.jetPopupData.accessibility ? window.jetPopupData.accessibility : {}; 508 }; 509 510 self.getPopupLabel = function() { 511 return self.getAccessibilityConfig().popupLabel || 'Popup dialog'; 512 }; 513 514 self.getCloseButtonLabel = function() { 515 return self.getAccessibilityConfig().closeButtonLabel || 'Close popup'; 516 }; 517 518 self.isFocusableElement = function( element ) { 519 let $element = $( element ), 520 tabIndex = $element.attr( 'tabindex' ); 521 522 if ( ! element || ! $element.length ) { 523 return false; 524 } 525 526 if ( $element.is( '[disabled], [hidden], [aria-hidden="true"]' ) || $element.hasClass( 'elementor-hidden' ) ) { 527 return false; 528 } 529 530 if ( undefined !== tabIndex && 0 > parseInt( tabIndex, 10 ) ) { 531 return false; 532 } 533 534 return !! ( element.offsetWidth || element.offsetHeight || element.getClientRects().length ); 535 }; 536 537 self.getFocusableElements = function() { 538 return $popup.find( 'a[href], area[href], input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [contenteditable="true"], [tabindex], .elementor-swiper-button, .jet-listing-dynamic-link__link' ).filter( function() { 539 return self.isFocusableElement( this ); 540 } ); 541 }; 542 543 self.ensureDialogLabel = function() { 544 let $heading = $popup.find( '.jet-popup__container-content :header:visible:first, .jet-popup__container-content [role="heading"]:visible:first' ).first(), 545 generatedId = popupId + '-title'; 546 547 $popup.removeAttr( 'aria-labelledby' ); 548 549 if ( $heading.length ) { 550 if ( ! $heading.attr( 'id' ) ) { 551 $heading.attr( 'id', generatedId ); 552 } 553 554 $popup.attr( 'aria-labelledby', $heading.attr( 'id' ) ); 555 $popup.removeAttr( 'aria-label' ); 556 } else { 557 $popup.attr( 'aria-label', self.getPopupLabel() ); 558 } 559 }; 560 561 self.preparePopupAccessibility = function() { 562 let $closeButton = $( '.jet-popup__close-button', $popup ).first(); 563 564 $popup.attr( { 565 'role': 'dialog',
566 'aria-modal': 'true', 567 'aria-hidden': isOpen ? 'false' : 'true', 568 'tabindex': '-1', 569 } ); 570 571 $( '.jet-popup__overlay, .jet-popup__container-overlay', $popup ).attr( 'aria-hidden', 'true' ); 572 573 if ( $closeButton.length ) { 574 $closeButton.attr( { 575 'aria-label': self.getCloseButtonLabel(), 576 } ); 577 578 if ( ! JetPopupFrontend.isNativeInteractiveElement( $closeButton[0] ) && ! $closeButton.is( '[tabindex]' ) ) { 579 $closeButton.attr( 'tabindex', '0' ); 580 } 581 582 $closeButton.find( 'svg, i' ).attr( { 583 'aria-hidden': 'true', 584 'focusable': 'false', 585 } ); 586 587 } 588 589 $popup.find( '.elementor-swiper-button' ).each( function() { 590 let $button = $( this ); 591 592 if ( ! $button.is( '[tabindex]' ) ) { 593 $button.attr( 'tabindex', '0' ); 594 } 595 596 if ( ! $button.is( '[role]' ) ) { 597 $button.attr( 'role', 'button' ); 598 } 599 } ); 600 601 self.ensureDialogLabel(); 602 }; 603 604 self.storeFocusContext = function( $trigger ) { 605 let activeElement = document.activeElement; 606 607 if ( $trigger && $trigger.length ) { 608 $lastTrigger = $trigger.first(); 609 focusedBeforeOpen = $lastTrigger[0]; 610 } else { 611 $lastTrigger = $(); 612 focusedBeforeOpen = activeElement && document.body !== activeElement ? activeElement : null; 613 } 614 615 if ( $lastTrigger.length ) { 616 $lastTrigger.attr( 'aria-expanded', 'true' ); 617 } 618 }; 619 620 self.focusDefaultElement = function() { 621 let $closeButton = $( '.jet-popup__close-button', $popup ).first(), 622 $focusable = self.getFocusableElements(), 623 $target = $closeButton.length ? $closeButton : $focusable.first(); 624 625 if ( ! $target.length ) { 626 $target = $( '.jet-popup__container', $popup ).first(); 627 } 628 629 if ( $target.length && $target[0].focus ) { 630 window.setTimeout( function() { 631 try { 632 $target[0].focus( { preventScroll: true } ); 633 } catch ( error ) { 634 $target[0].focus(); 635 } 636 }, 0 ); 637 } 638 }; 639 640 self.restoreFocus = function() { 641 if ( $lastTrigger.length ) { 642 $lastTrigger.attr( 'aria-expanded', 'false' ); 643 } 644 645 if ( focusedBeforeOpen && document.contains( focusedBeforeOpen ) && focusedBeforeOpen.focus ) { 646 try { 647 focusedBeforeOpen.focus( { preventScroll: true } ); 648 } catch ( error ) { 649 focusedBeforeOpen.focus(); 650 } 651 } 652 653 focusedBeforeOpen = null; 654 $lastTrigger = $(); 655 }; 656 657 self.moveFocusByOffset = function( offset ) { 658 let $focusable = self.getFocusableElements(), 659 activeIndex = $focusable.index( document.activeElement ); 660 661 if ( ! $focusable.length ) { 662 return; 663 } 664 665 if ( -1 === activeIndex ) { 666 activeIndex = 0; 667 } else { 668 activeIndex = ( activeIndex + offset + $focusable.length ) % $focusable.length; 669 } 670 671 if ( $focusable.eq( activeIndex )[0] && $focusable.eq( activeIndex )[0].focus ) { 672 $focusable.eq( activeIndex )[0].focus(); 673 } 674 }; 675 676 self.handlePopupTabKey = function( event ) { 677 let $focusable = self.getFocusableElements(), 678 $firstElement = $focusable.first(), 679 $lastElement = $focusable.last(); 680 681 if ( ! $focusable.length ) { 682 event.preventDefault(); 683 $popup.trigger( 'focus' ); 684 685 return; 686 } 687 688 if ( event.shiftKey && document.activeElement === $firstElement[0] ) { 689 event.preventDefault(); 690 $lastElement[0].focus(); 691 } else if ( ! event.shiftKey && document.activeElement === $lastElement[0] ) { 692 event.preventDefault(); 693 $firstElement[0].focus(); 694 } 695 }; 696 697 self.handlePopupKeydown = function( event ) { 698 let key = event.key || '', 699 $target = $( event.target ), 700 isTypingControl = $target.is( 'input, textarea, select, [contenteditable="true"]' ); 701 702 if ( ! isOpen ) { 703 return; 704 } 705 706 if ( 'Tab' === key || 9 === event.keyCode ) { 707 self.handlePopupTabKey( event ); 708 709 return; 710 } 711 712 if ( ! isTypingControl && ( 'ArrowDown' === key || 40 === event.keyCode ) ) { 713 event.preventDefault(); 714 self.moveFocusByOffset( 1 ); 715 716 return; 717 } 718 719 if ( ! isTypingControl && ( 'ArrowUp' === key || 38 === event.keyCode ) ) { 720 event.preventDefault(); 721 self.moveFocusByOffset( -1 ); 722 723 return; 724 } 725 726 if ( 'Escape' === key || 27 === event.keyCode ) { 727 event.preventDefault(); 728 self.hidePopup( { 729 constantly: popupSettings['show-once'], 730 popupId: popupSettings['jet-popup-id'] 731 } ); 732 } 733 }; 734 735 self.onPopupShown = function() { 736 isOpen = true; 737 $popup.attr( 'aria-hidden', 'false' ); 738 self.preparePopupAccessibility(); 739 self.focusDefaultElement(); 740 }; 741 742 self.onPopupHidden = function() { 743 isOpen = false;
744 $popup.attr( 'aria-hidden', 'true' ); 745 self.restoreFocus(); 746 }; 747 748 self.init = function() { 749 var popupAvailable = self.popupAvailableCheck(); 750 751 if ( ! popupAvailable ) { 752 return false; 753 } 754 755 self.setLocalStorageData( popupId, 'enable' ); 756 757 self.initCompatibilityHandler(); 758 759 self.initOpenEvent(); 760 761 self.initCloseEvent(); 762 self.preparePopupAccessibility(); 763 $popup.on( 'keydown.jetPopupA11y', self.handlePopupKeydown ); 764 765 $window.trigger( 'jet-popup/init/after', { 766 self: self, 767 settings: popupSettings 768 } ); 769 }; 770 771 /** 772 * [popupAvailableCheck description] 773 * @return {[type]} [description] 774 */ 775 self.popupAvailableCheck = function() { 776 var storageData = self.getLocalStorageData() || {}; 777 778 if ( ! storageData.hasOwnProperty( popupId ) ) { 779 return true; 780 } 781 782 var popupData = storageData[ popupId ], 783 status = 'enable', 784 showAgainDate = 'none'; 785 786 if ( 'disable' === popupData ) { 787 return false; 788 } 789 790 if ( 'enable' === popupData ) { 791 return true; 792 } 793 794 if ( popupData.hasOwnProperty( 'status' ) ) { 795 status = popupData['status']; 796 } 797 798 if ( 'enable' === status ) { 799 return true; 800 } 801 802 if ( popupData.hasOwnProperty( 'show-again-date' ) ) { 803 showAgainDate = popupData['show-again-date']; 804 } 805 806 if ( 'none' === showAgainDate && 'disable' === status ) { 807 return false; 808 } 809 810 if ( showAgainDate < Date.now() ) { 811 return true; 812 } else { 813 return false; 814 } 815 }; 816 817 /** 818 * [initOpenEvent description] 819 * @return {[type]} [description] 820 */ 821 self.initOpenEvent = function() { 822 823 $window.trigger( 'jet-popup/init-events/before', { 824 self: self, 825 settings: popupSettings 826 } ); 827 828 switch ( popupSettings['open-trigger'] ) { 829 case 'page-load': 830 self.pageLoadEvent( popupSettings['page-load-delay'] ); 831 break; 832 833 case 'user-inactive': 834 self.userInactiveEvent( popupSettings['user-inactivity-time'] ); 835 break; 836 837 case 'scroll-trigger': 838 self.scrollPageEvent( popupSettings['scrolled-to'] ); 839 break; 840 841 case 'try-exit-trigger': 842 self.tryExitEvent(); 843 break; 844 845 case 'on-date': 846 self.onDateEvent( popupSettings['on-date'] ); 847 break; 848 849 case 'on-time': 850 self.onTimeEvent( popupSettings['on-time-start'], popupSettings['on-time-end'] ); 851 break; 852 853 case 'on-date-and-time': 854 self.onTimeAndDateEvent( popupSettings['start-date-and-time'], popupSettings['end-date-and-time'] ); 855 break; 856 857 case 'weekly-schedule': 858 self.onWeekdaysAndTimeEvent( 859 popupSettings['on-weekdays'], 860 popupSettings['on-week-time-start'], 861 popupSettings['on-week-time-end'] 862 ); 863 break; 864 865 case 'custom-selector': 866 self.onCustomSelector( popupSettings['custom-selector'] ); 867 break;$scope 868 } 869 870 $window.on('jet-popup-open-trigger', function( event ) { 871 var popupData = event.popupData || {}, 872 triggeredBy = event.triggeredBy || false, 873 popupUniqId = popupData.popupId || false, 874 constantly = popupData.constantly; 875 876 if ( popupUniqId == popupId ) { 877 if ( $popup.hasClass( 'jet-popup--hide-state' )) { 878 self.showPopup( popupData, triggeredBy ); 879 } else { 880 self.hidePopup( { 881 constantly: constantly, 882 popupId: popupUniqId, 883 } ); 884 } 885 } 886 }); 887 888 $window.on( 'jet-popup-close-trigger', function( event ) { 889 var popupData = event.popupData || {}, 890 popupUniqId = popupData.popupId, 891 constantly = popupData.constantly; 892 893 if ( popupUniqId == popupId ) { 894 self.hidePopup( { 895 popupId: popupUniqId, 896 constantly: constantly, 897 } ); 898 } 899 }); 900 901 $window.trigger( 'jet-popup/init-events/after', { 902 self: self, 903 settings: popupSettings 904 } ); 905 }; 906 907 /** 908 * [initOnCloseEvent description] 909 * @return {[type]} [description] 910 */ 911 self.initOnCloseEvent = function() { 912 913 var $htmlBody = $( 'html, body' ); 914 915 if ( 'scroll-to-top' === popupSettings['close-event'] ) { 916 $htmlBody.animate( { scrollTop: 0 }, 'slow' ); 917 } 918 919 if ( 'scroll-to-anchor' === popupSettings['close-event'] ) { 920 var anchor = $( '#' + popupSettings['Ñlose-event-anchor'] ); 921 922 if ( anchor.length ) { 923 $htmlBody.animate( { scrollTop: anchor.offset().top }, 'slow' ); 924 } 925 } 926 } 927 928 /** 929 * [initCloseEvent description] 930 * @return {[type]} [description] 931 */ 932 self.initCloseEvent = function() { 933 934 $popup.on( 'click', '.jet-popup__close-button', function( event ) { 935 var target = event.currentTarget; 936 937 self.hidePopup( { 938 constantly: popupSettings['show-once'], 939 popupId: popupSettings['jet-popup-id'] 940 } ); 941 self.initOnCloseEvent(); 942 } ); 943 944 if ( popupSettings['close-on-overlay-click'] ) { 945 $popup.on( 'click', '.jet-popup__overlay', function( event ) { 946 var target = event.currentTarget; 947 948 self.hidePopup( { 949 constantly: popupSettings['show-once'], 950 popupId: popupSettings['jet-popup-id'] 951 } ); 952 self.initOnCloseEvent(); 953 } ); 954 } 955 956 $document.on( 'keyup.jetPopup', function( event ) { 957 var key = event.keyCode; 958 959 if ( 27 === key && isOpen ) { 960 self.hidePopup( { 961 constantly: popupSettings['show-once'], 962 popupId: popupSettings['jet-popup-id'] 963 } ); 964 } 965 } ); 966 }; 967 968 /** 969 * [initCompatibilityHandler description] 970 * @return {[type]} [description] 971 */ 972 self.initCompatibilityHandler = function() { 973 var $elementorProFormWidget = $( '.elementor-widget-form', $popup ); 974 975 if ( $elementorProFormWidget[0] ) { 976 $elementorProFormWidget.each( function() { 977 var $this = $( this ), 978 $form = $( '.elementor-form', $this ); 979 980 $form.on( 'submit_success', function() { 981 982 if ( true !== popupSettings['close-after-form-submit'] ) { 983 return; 984 } 985 986 let delay = parseInt( popupSettings['close-after-form-delay'] || 0 );
987 delay = delay * 1000; 988 989 setTimeout( function() { 990 $window.trigger( { 991 type: 'jet-popup-close-trigger', 992 popupData: { 993 popupId: popupId, 994 constantly: false 995 } 996 } ); 997 }, delay ); 998 999 }); 1000 } ); 1001 } 1002 1003 $( document ).on( 'jet-form-builder/ajax/on-success', function( event ) { 1004 1005 if ( true !== popupSettings['close-after-form-submit'] ) { 1006 return; 1007 } 1008 1009 let delay = parseInt( popupSettings['close-after-form-delay'] || 0 ); 1010 delay = delay * 1000; 1011 1012 setTimeout( function() { 1013 $window.trigger({ 1014 type: 'jet-popup-close-trigger', 1015 popupData: { 1016 popupId: popupId, 1017 constantly: false 1018 } 1019 }); 1020 }, delay ); 1021 1022 }); 1023 }; 1024 1025 /** 1026 * Handle popup opening on page load event. 1027 * 1028 * @param {number} openDelay Delay before opening the popup (in seconds). 1029 * @return {void} 1030 */ 1031 self.autoClosePopup = function() { 1032 1033 if ( ! popupSettings['automatically-close'] ) { 1034 return; 1035 } 1036 1037 let delay = parseInt( popupSettings['automatically-close'], 10 ); 1038 1039 if ( ! delay ) { 1040 return; 1041 } 1042 1043 setTimeout( function() { 1044 1045 if ( isOpen ) { 1046 self.hidePopup( { 1047 popupId: popupId, 1048 constantly: false 1049 } ); 1050 } 1051 1052 }, delay * 1000 ); 1053 1054 }; 1055 1056 /** 1057 * Page on load event 1058 * 1059 * @param {int} openDelay Open delay time. 1060 * @return {void} 1061 */ 1062 self.pageLoadEvent = function( openDelay ) { 1063 var delay = +openDelay || 0; 1064 1065 delay = delay * 1000; 1066 1067 $( function() { 1068 setTimeout( function() { 1069 self.showPopup(); 1070 }, delay ); 1071 } ); 1072 }; 1073 1074 /** 1075 * User Inactivity event 1076 * 1077 * @param {int} inactiveDelay [description] 1078 * @return {void} 1079 */ 1080 self.userInactiveEvent = function( inactiveDelay ) { 1081 var delay = +inactiveDelay || 0, 1082 isInactive = true; 1083 1084 delay = delay * 1000; 1085 1086 setTimeout( function() { 1087 if ( isInactive ) { 1088 self.showPopup(); 1089 } 1090 }, delay ); 1091 1092 $( document ).on( 'click focus resize keyup scroll', function() { 1093 isInactive = false; 1094 } ); 1095 }; 1096 1097 /** 1098 * Scrolling Page Event 1099 * 1100 * @param {int} scrollingValue Scrolling porgress value 1101 * @return {void} 1102 */ 1103 self.scrollPageEvent = function( scrollingValue ) { 1104 var scrolledValue = +scrollingValue || 0; 1105 1106 $window.on( 'scroll.cherryJetScrollEvent resize.cherryJetResizeEvent', function() { 1107 var $window = $( window ), 1108 windowHeight = $window.height(), 1109 documentHeight = $( document ).height(), 1110 scrolledHeight = documentHeight - windowHeight, 1111 scrolledProgress = Math.max( 0, Math.min( 1, $window.scrollTop() / scrolledHeight ) ) * 100; 1112 1113 if ( scrolledProgress >= scrolledValue ) { 1114 $window.off( 'scroll.cherryJetScrollEvent resize.cherryJetResizeEvent' ); 1115 self.showPopup(); 1116 } 1117 } ).trigger( 'scroll.cherryJetResizeEvent' ); 1118 }; 1119 1120 /** 1121 * Viewport leave event 1122 * 1123 * @return {void} 1124 */ 1125 self.tryExitEvent = function() { 1126 var pageY = 0; 1127 1128 $( document ).on( 'mouseleave', 'body', function( event ) { 1129 1130 pageY = event.pageY - $window.scrollTop(); 1131 1132 if ( 0 > pageY && $popup.hasClass( 'jet-popup--hide-state' ) ) { 1133 self.showPopup(); 1134 } 1135 } ); 1136 }; 1137 1138 /** 1139 * onDateEvent Event 1140 * 1141 * @return {void} 1142 */ 1143 self.onDateEvent = function( date ) { 1144 var nowDate = Date.now(), 1145 startDate = Date.parse( date ); 1146 1147 if ( startDate < nowDate ) { 1148 1149 setTimeout( function() { 1150 self.showPopup(); 1151 }, 500 ); 1152 } 1153 } 1154 1155 self.onWeekdaysAndTimeEvent = function( days = [], startTime = '00:00', endTime = '23:59' ) { 1156 1157 if ( ! days || ! days.length ) { 1158 return; 1159 } 1160 1161 var nowTimeStamp = Date.now(), 1162 nowDate = new Date(), 1163 currentDay = nowDate.toLocaleString('en-US', { weekday: 'short' }).toLowerCase(); 1164 1165 1166 days = days.map( day => day.toLowerCase() ); 1167 1168 if ( ! days.includes( currentDay ) ) { 1169 return; 1170 } 1171 1172 startTime = '' !== startTime ? startTime : '00:00'; 1173 endTime = '' !== endTime ? endTime : '23:59'; 1174 1175 var dateTimeFormat = new Intl.DateTimeFormat( 'en', { year: 'numeric', month: 'short', day: '2-digit' } ), 1176 [ { value: month },,{ value: day },,{ value: year } ] = dateTimeFormat.formatToParts( nowTimeStamp ); 1177 1178 var startDateTime = `${ month }. ${ day }, ${ year } ${ startTime }`, 1179 endDateTime = `${ month }. ${ day }, ${ year } ${ endTime }`; 1180 1181 var startTimeStamp = Date.parse( startDateTime ), 1182 endTimeStamp = Date.parse( endDateTime ); 1183 1184 if ( startTimeStamp < nowTimeStamp && nowTimeStamp < endTimeStamp ) { 1185 setTimeout( function() { 1186 self.showPopup(); 1187 }, 500 ); 1188 } 1189 }; 1190 1191 self.onTimeEvent = function( startTime = '00:00', endTime = '23:59' ) { 1192 var startTime = '' !== startTime ? startTime : '00:00', 1193 endTime = '' !== endTime ? endTime : '23:59', 1194 nowTimeStamp = Date.now(), 1195 dateTimeFormat = new Intl.DateTimeFormat( 'en', { year: 'numeric', month: 'short', day: '2-digit' } ), 1196 [ { value: month },,{ value: day },,{ value: year } ] = dateTimeFormat.formatToParts( nowTimeStamp ), 1197 startTime = `${ month }. ${ day }, ${ year } ${ startTime }`, 1198 endTime = `${ month }. ${ day }, ${ year } ${ endTime }`, 1199 startTimeStamp = Date.parse( startTime ), 1200 endTimeStamp = Date.parse( endTime ); 1201 1202 if ( ( startTimeStamp < nowTimeStamp ) && ( nowTimeStamp < endTimeStamp ) ) { 1203 setTimeout( function() { 1204 self.showPopup(); 1205 }, 500 ); 1206 } 1207 } 1208 1209 1210 self.onTimeAndDateEvent = function( start, end ) { 1211 1212 var nowDateStamp = Date.now(), 1213 startDateStamp = Date.parse( start ), 1214 endDateStamp = Date.parse( end ); 1215 1216 if ( ( startDateStamp < nowDateStamp ) && ( nowDateStamp < endDateStamp ) ) { 1217 setTimeout( function() { 1218 self.showPopup(); 1219 }, 500 ); 1220 } 1221 1222 } 1223 1224 /** 1225 * Check DOM Loaded Selector 1226 * @param {[type]} selector [description] 1227 * @return {[type]} [description] 1228 */ 1229 1230 self.checkLoadedSelector = function( selector ) { 1231 1232 //Check Listing Grid Lazy Load 1233 $( document ).on( 'jet-engine/listing-grid/after-lazy-load', function() { 1234 self.onCustomSelector ( selector ); 1235 }); 1236 1237 //Check Open Mobile Menu 1238 $( '.jet-mobile-menu__toggle' ).closest( '.jet-mobile-menu__instance--slide-out-layout' ).on( 'click', function() { 1239 self.onCustomSelector ( selector ); 1240 }); 1241 1242 } 1243 1244 /** 1245 * [onCustomSelector description] 1246 * @param {[type]} selector [description] 1247 * @return {[type]} [description] 1248 */ 1249 self.onCustomSelector = function( selector ) { 1250 1251 let $selector = $( selector ); 1252 1253 if ( $selector[0] ) { 1254 $( 'body' ).off( 'click.jetPopup', selector ).on( 'click.jetPopup', selector, function( event ) { 1255 event.preventDefault(); 1256 1257 let $this = $( this ); 1258 let popupId = $this.data( 'popup' ); 1259 let $popup = $( '#jet-popup-' + popupId ); 1260 1261 if ( $popup.length && $popup.hasClass( 'jet-popup--show-state' ) ) { 1262 self.hidePopup( popupId, false ); 1263 } else { 1264 self.showPopup( popupId, $this ); 1265 } 1266 } ); 1267 } else { 1268 self.checkLoadedSelector( selector ); 1269 } 1270 } 1271 1272 /** 1273 * Show Popup 1274 * 1275 * @return {void} 1276 */ 1277 self.showPopup = function( data, $trigger ) { 1278 var popupData = data || {}, 1279 animeOverlay = null,
1280 animeContainer = null, 1281 animeOverlaySettings = jQuery.extend( 1282 { 1283 targets: $( '.jet-popup__overlay', $popup )[0] 1284 }, 1285 self.avaliableEffects[ 'fade' ][ 'show' ] 1286 ); 1287 1288 $trigger = $trigger || false; 1289 1290 if ( ! self.popupAvailableCheck() ) { 1291 return false; 1292 } 1293 1294 self.storeFocusContext( $trigger ); 1295 1296 animeOverlay = anime( animeOverlaySettings ); 1297 1298 $popup.toggleClass( 'jet-popup--hide-state jet-popup--show-state' ); 1299 1300 if ( popupSettings['prevent-scrolling'] ) { 1301 $( 'body' ).addClass( 'jet-popup-prevent-scroll' ); 1302 } 1303 1304 popupData = JetPopupFrontend.maybeExtendPopupData( popupData, $trigger ); 1305 popupData = window.JetPlugins.hooks.applyFilters( 'jet-popup.show-popup.data', popupData, $popup, $trigger ); 1306 1307 self.showContainer( popupData ); 1308 }; 1309 1310 /** 1311 * [showContainer description] 1312 * @return {[type]} [description] 1313 */ 1314 self.showContainer = function( data ) { 1315 var popupData = data || {}, 1316 popupDefaultData = { 1317 forceLoad: popupSettings['force-ajax'] || false, // Trigger Ajax Every Time 1318 customContent: '' // Show Popup with Custom Content 1319 }, 1320 animeContainerInstance = null, 1321 $popupContainer = $( '.jet-popup__container', $popup ), 1322 $content = $( '.jet-popup__container-content', $popup ), 1323 animeContainer = jQuery.extend( 1324 { 1325 targets: $( '.jet-popup__container', $popup )[0], 1326 begin: function( anime ) { 1327 isAnimation = true; 1328 1329 $window.trigger( 'jet-popup/show-event/before-show', { 1330 self: self, 1331 data: popupData, 1332 anime: anime 1333 } ); 1334 }, 1335 complete: function( anime ) { 1336 isAnimation = false; 1337 1338 self.autoClosePopup(); 1339 self.onPopupShown(); 1340 1341 $window.trigger( 'jet-popup/show-event/after-show', { 1342 self: self, 1343 data: popupData, 1344 anime: anime 1345 } ); 1346 } 1347 }, 1348 self.avaliableEffects[ popupSettings['animation'] ][ 'show' ] 1349 1350 ); 1351 1352 popupData = jQuery.extend( popupDefaultData, popupData ); 1353 1354 // init Custom popup content 1355 if ( '' !== popupData.customContent ) { 1356 $content.html( popupData.customContent ); 1357 self.elementorFrontendInit(); 1358 1359 // Show Popup Container
1360 animeContainerInstance = anime( animeContainer ); 1361 1362 $window.trigger( 'jet-popup/render-content/render-custom-content', { 1363 self: self, 1364 popup_id: id, 1365 data: popupData, 1366 } ); 1367 1368 return false; 1369 } 1370 1371 if ( ! popupSettings['use-ajax'] ) { 1372 // Show Popup Container 1373 animeContainerInstance = anime( animeContainer ); 1374 1375 $window.trigger( 'jet-popup/render-content/render-custom-content', { 1376 self: self, 1377 popup_id: id, 1378 data: popupData, 1379 } ); 1380 1381 return false; 1382 } 1383 1384 if ( popupData.forceLoad ) { 1385 ajaxContentLoaded = false; 1386 } 1387 1388 if ( ajaxContentLoaded ) { 1389 // Show Popup Container 1390 animeContainerInstance = anime( animeContainer ); 1391 1392 $window.trigger( 'jet-popup/render-content/show-content', { 1393 self: self, 1394 popup_id: id, 1395 data: popupData, 1396 } ); 1397 1398 return false; 1399 } 1400 1401 popupData = jQuery.extend( popupData, { 1402 'popup_id': id, 1403 'page_url': window.location.href 1404 } ); 1405 1406 ajaxGetContentHanler = jQuery.ajax( { 1407 type: 'POST', 1408 url: window.jetPopupData.ajax_url, 1409 data: { 1410 'action': 'jet_popup_get_content', 1411 'data': popupData 1412 }, 1413 beforeSend: function( jqXHR, ajaxSettings ) { 1414 1415 if ( null !== ajaxGetContentHanler ) { 1416 ajaxGetContentHanler.abort(); 1417 } 1418 1419 // Before ajax send Trigger 1420 $window.trigger( 'jet-popup/render-content/ajax/before-send', { 1421 self: self, 1422 popup_id: id, 1423 data: popupData 1424 } ); 1425 1426 $popup.addClass( 'jet-popup--loading-state' ); 1427 }, 1428 error: function( jqXHR, ajaxSettings ) {}, 1429 success: function( data, textStatus, jqXHR ) { 1430 var successType = data.type, 1431 contentData = data.content || false, 1432 $popupContainer = $( '.jet-popup__container-content', $popup ); 1433 1434 $popup.removeClass( 'jet-popup--loading-state' ); 1435 1436 if ( 'error' === successType ) { 1437 var message = data.message; 1438 1439 $content.html( '<h3>' + message + '</h3>' ); 1440 1441 // Show Popup Container 1442 animeContainerInstance = anime( animeContainer ); 1443 } 1444 1445 if ( 'success' === successType ) { 1446 let popupContent = contentData['content'], 1447 popupContentElements = contentData['contentElements'], 1448 popupScripts = contentData['scripts'], 1449 popupStyles = contentData['styles'], 1450 popupAfterScripts = contentData['afterScripts']; 1451 1452 for ( let { handle: scriptHandler, src: scriptSrc } of popupScripts ) { 1453 JetPopupFrontend.addedAssetsPromises.push( JetPopupFrontend.loadScriptAsync( scriptHandler, scriptSrc ) ); 1454 } 1455 1456 if ( popupStyles && Object.keys( popupStyles ).length > 0 ) { 1457 for ( let styleHandler in popupStyles ) { 1458 JetPopupFrontend.addedAssetsPromises.push( JetPopupFrontend.loadStyle( styleHandler, popupStyles[ styleHandler ] ) ); 1459 } 1460 } 1461 1462 JetPopupFrontend.assetsLoaderPromise().then( async function( value ) { 1463 ajaxContentLoaded = true; 1464 1465 // Ajax Success Trigger 1466 $window.trigger( 'jet-popup/render-content/ajax/success', { 1467 self: self, 1468 popup_id: id, 1469 data: popupData, 1470 request: data 1471 } ); 1472 1473 // Render content 1474 if ( popupContent ) { 1475 $popupContainer.html( popupContent ); 1476 } 1477 1478 if ( popupAfterScripts.length ) { 1479 await Promise.all( popupAfterScripts.map( 1480 ( { handle, src } ) => JetPopupFrontend.loadScriptAsync( handle, src ) 1481 ) ); 1482 } 1483 1484 // Before ajax frontend init 1485 $( window ).trigger( 'jet-popup/ajax/frontend-init/before', { 1486 $container: $popupContainer, 1487 content: popupContent, 1488 contentElements: popupContentElements, 1489 contentType: popupSettings['content-type'], 1490 } ); 1491 1492 // Frontend init 1493 $( window ).trigger( 'jet-popup/ajax/frontend-init', { 1494 $container: $popupContainer, 1495 content: popupContent, 1496 contentElements: popupContentElements, 1497 contentType: popupSettings['content-type'], 1498 } ); 1499 1500 // after ajax frontend init 1501 $( window ).trigger( 'jet-popup/ajax/frontend-init/after', { 1502 $container: $popupContainer, 1503 content: popupContent, 1504 contentElements: popupContentElements, 1505 contentType: popupSettings['content-type'], 1506 } ); 1507 1508 // Show Popup Container
1509 animeContainerInstance = anime( animeContainer ); 1510 1511 }, function( reason ) { 1512 console.log( 'Assets Loaded Error' ); 1513 } ); 1514 } 1515 } 1516 } ); 1517 }; 1518 1519 /** 1520 * Hide Popup 1521 * 1522 * @return {void} 1523 */ 1524 self.hidePopup = function ( data ) { 1525 var popupData = data || {}, 1526 $content = $( '.jet-popup__container-content', $popup ), 1527 constantly = popupData.constantly || false, 1528 animeOverlay = null, 1529 animeContainer = null, 1530 animeOverlaySettings = jQuery.extend( { targets: $( '.jet-popup__overlay', $popup )[0] }, self.avaliableEffects[ 'fade' ][ 'hide' ] ), 1531 animeContainerSettings = jQuery.extend( 1532 { 1533 targets: $( '.jet-popup__container', $popup )[0], 1534 begin: function( anime ) { 1535 isAnimation = true; 1536 1537 $window.trigger( 'jet-popup/hide-event/before-hide', { 1538 self: self, 1539 data: popupData, 1540 anime: anime 1541 } ); 1542 }, 1543 complete: function( anime ) { 1544 isAnimation = false; 1545 $popup.toggleClass( 'jet-popup--show-state jet-popup--hide-state' ); 1546 1547 if ( popupSettings['use-ajax'] && popupSettings['force-ajax'] ) { 1548 $content.html( '' ); 1549 } 1550 1551 if ( popupSettings['prevent-scrolling'] && !$( '.jet-popup--show-state' )[0] ) { 1552 $( 'body' ).removeClass( 'jet-popup-prevent-scroll' ); 1553 } 1554 1555 self.onPopupHidden(); 1556 1557 // After Popup Hide Action 1558 $window.trigger( 'jet-popup/hide-event/after-hide', { 1559 self: self, 1560 data: popupData, 1561 anime: anime 1562 } ); 1563 } 1564 }, 1565 self.avaliableEffects[ popupSettings['animation'] ][ 'hide' ] 1566 ); 1567 1568 if ( constantly ) { 1569 self.setLocalStorageData( popupId, 'disable' ); 1570 } 1571 1572 if ( isAnimation ){ 1573 return false; 1574 } 1575 1576 if ( $popup.hasClass('jet-popup--show-state') ) { 1577 animeOverlay = anime( animeOverlaySettings );
1578 animeContainer = anime( animeContainerSettings ); 1579 } 1580 1581 // On Hide Handler 1582 self.onHidePopupAction(); 1583 1584 // Before Popup Hide Action 1585 $window.trigger( 'jet-popup/close-hide-event/before-hide', { 1586 self: self, 1587 data: popupData 1588 } ); 1589 }; 1590 1591 /** 1592 * [elementorFrontendInit description] 1593 * @return {[type]} [description] 1594 */ 1595 self.elementorFrontendInit = function() { 1596 var $content = $( '.jet-popup__container-content', $popup ); 1597 1598 $content.find( 'div[data-element_type]' ).each( function() { 1599 var $this = $( this ), 1600 elementType = $this.data( 'element_type' ); 1601 1602 if (!elementType) { 1603 return; 1604 } 1605 1606 try { 1607 if( 'widget' === elementType ){ 1608 elementType = $this.data( 'widget_type' ); 1609 window.elementorFrontend.hooks.doAction( 'frontend/element_ready/widget', $this, $ ); 1610 } 1611 window.elementorFrontend.hooks.doAction( 'frontend/element_ready/' + elementType, $this, $ ); 1612 1613 } catch( err ) { 1614 console.log(err); 1615 1616 $this.remove(); 1617 1618 return false; 1619 } 1620 1621 }); 1622 1623 // On Show Handler 1624 self.onShowPopupAction(); 1625 } 1626 1627 /** 1628 * [onShowPopupAction description] 1629 * @return {[type]} [description] 1630 */ 1631 self.onShowPopupAction = function() {}; 1632 1633 /** 1634 * [onHidePopupAction description] 1635 * @return {[type]} [description] 1636 */ 1637 self.onHidePopupAction = function() {}; 1638 1639 /** 1640 * Avaliable Effects 1641 */ 1642 1643 const useCustomDuration = popupSettings['animation_custom_duration'] === true; 1644 1645 let inDuration = false; 1646 let outDuration = false; 1647 1648 if ( useCustomDuration ) { 1649 inDuration = popupSettings['animation_in_duration']; 1650 outDuration = popupSettings['animation_out_duration']; 1651 } 1652 1653 self.avaliableEffects = { 1654 'none': { 1655 'show': { 1656 duration: inDuration || 0, 1657 opacity: { value: [1, 1] } 1658 }, 1659 'hide': { 1660 duration: outDuration || 0, 1661 opacity: { value: [1, 1] } 1662 } 1663 }, 1664 1665 'fade': { 1666 'show': { 1667 opacity: { value: [0, 1], duration: inDuration || 600, easing: 'easeOutQuart' } 1668 }, 1669 'hide': { 1670 opacity: { value: [1, 0], duration: outDuration || 400, easing: 'easeOutQuart' } 1671 } 1672 }, 1673 1674 'zoom-in': { 1675 'show': { 1676 duration: inDuration || 500, 1677 easing: 'easeOutQuart', 1678 opacity: { value: [0, 1] }, 1679 scale: { value: [0.75, 1] } 1680 }, 1681 'hide': { 1682 duration: outDuration || 400, 1683 easing: 'easeOutQuart', 1684 opacity: { value: [1, 0] }, 1685 scale: { value: [1, 0.75] } 1686 } 1687 }, 1688 1689 'zoom-out': { 1690 'show': { 1691 duration: inDuration || 500, 1692 easing: 'easeOutQuart', 1693 opacity: { value: [0, 1] }, 1694 scale: { value: [1.25, 1] } 1695 }, 1696 'hide': { 1697 duration: outDuration || 400, 1698 easing: 'easeOutQuart', 1699 opacity: { value: [1, 0] }, 1700 scale: { value: [1, 1.25] } 1701 } 1702 }, 1703 1704 'rotate': { 1705 'show': { 1706 duration: inDuration || 500, 1707 easing: 'easeOutQuart', 1708 opacity: { value: [0, 1] }, 1709 scale: { value: [0.75, 1] }, 1710 rotate: { value: [-65, 0] } 1711 }, 1712 'hide': { 1713 duration: outDuration || 400, 1714 easing: 'easeOutQuart', 1715 opacity: { value: [1, 0] }, 1716 scale: { value: [1, 0.9] } 1717 } 1718 }, 1719 1720 'move-up': { 1721 'show': { 1722 duration: inDuration || 500, 1723 easing: 'easeOutExpo', 1724 opacity: { value: [0, 1] }, 1725 translateY: { value: [50, 1] } 1726 }, 1727 'hide': { 1728 duration: outDuration || 400, 1729 easing: 'easeOutQuart', 1730 opacity: { value: [1, 0] }, 1731 translateY: { value: [1, 50] } 1732 } 1733 }, 1734 1735 'flip-x': { 1736 'show': { 1737 duration: inDuration || 500, 1738 easing: 'easeOutExpo', 1739 opacity: { value: [0, 1] }, 1740 rotateX: { value: [65, 0] } 1741 }, 1742 'hide': { 1743 duration: outDuration || 400, 1744 easing: 'easeOutQuart', 1745 opacity: { value: [1, 0] } 1746 } 1747 }, 1748 1749 'flip-y': { 1750 'show': { 1751 duration: inDuration || 500, 1752 easing: 'easeOutExpo', 1753 opacity: { value: [0, 1] }, 1754 rotateY: { value: [65, 0] } 1755 }, 1756 'hide': { 1757 duration: outDuration || 400, 1758 easing: 'easeOutQuart', 1759 opacity: { value: [1, 0] } 1760 } 1761 }, 1762 1763 'bounce-in': { 1764 'show': { 1765 opacity: { value: [0, 1], duration: inDuration || 500, easing: 'easeOutQuart' }, 1766 scale: { 1767 value: [0.2, 1], 1768 duration: inDuration || 800, 1769 elasticity: function(el, i, l) { return (400 + i * 200); } 1770 } 1771 }, 1772 'hide': { 1773 duration: outDuration || 400, 1774 easing: 'easeOutQuart', 1775 opacity: { value: [1, 0] }, 1776 scale: { value: [1, 0.8] } 1777 } 1778 }, 1779 1780 'bounce-out': { 1781 'show': { 1782 opacity: { value: [0, 1], duration: inDuration || 500, easing: 'easeOutQuart' }, 1783 scale: { 1784 value: [1.8, 1], 1785 duration: inDuration || 800, 1786 elasticity: function(el, i, l) { return (400 + i * 200); } 1787 } 1788 }, 1789 'hide': { 1790 duration: outDuration || 400, 1791 easing: 'easeOutQuart', 1792 opacity: { value: [1, 0] }, 1793 scale: { value: [1, 1.5] } 1794 } 1795 }, 1796 1797 'slide-in-up': { 1798 'show': { 1799 opacity: { value: [0, 1], duration: inDuration || 400, easing: 'easeOutQuart' }, 1800 translateY: { value: ['100vh', 0], duration: inDuration || 750, easing: 'easeOutQuart' } 1801 }, 1802 'hide': { 1803 duration: outDuration || 400, 1804 easing: 'easeInQuart', 1805 opacity: { value: [1, 0] }, 1806 translateY: { value: [0, '100vh'] } 1807 } 1808 }, 1809 1810 'slide-in-right': { 1811 'show': { 1812 opacity: { value: [0, 1], duration: inDuration || 400, easing: 'easeOutQuart' }, 1813 translateX: { value: ['100vw', 0], duration: inDuration || 750, easing: 'easeOutQuart' } 1814 }, 1815 'hide': { 1816 duration: outDuration || 400, 1817 easing: 'easeInQuart', 1818 opacity: { value: [1, 0] }, 1819 translateX: { value: [0, '100vw'] } 1820 } 1821 }, 1822 1823 'slide-in-down': { 1824 'show': { 1825 opacity: { value: [0, 1], duration: inDuration || 400, easing: 'easeOutQuart' }, 1826 translateY: { value: ['-100vh', 0], duration: inDuration || 750, easing: 'easeOutQuart' } 1827 }, 1828 'hide': { 1829 duration: outDuration || 400, 1830 easing: 'easeInQuart', 1831 opacity: { value: [1, 0] }, 1832 translateY: { value: [0, '-100vh'] } 1833 } 1834 }, 1835 1836 'slide-in-left': { 1837 'show': { 1838 opacity: { value: [0, 1], duration: inDuration || 400, easing: 'easeOutQuart' }, 1839 translateX: { value: ['-100vw', 0], duration: inDuration || 750, easing: 'easeOutQuart' } 1840 }, 1841 'hide': { 1842 duration: outDuration || 400, 1843 easing: 'easeInQuart', 1844 opacity: { value: [1, 0] }, 1845 translateX: { value: [0, '-100vw'] } 1846 } 1847 } 1848 }; 1849 1850 1851 /** 1852 * Get localStorage data. 1853 * 1854 * @return {object|boolean} 1855 */ 1856 self.getLocalStorageData = function() { 1857 1858 try { 1859 return JSON.parse( localStorage.getItem( 'jetPopupData' ) ); 1860 } catch ( e ) { 1861 return false;
1862 } 1863 }; 1864 1865 /** 1866 * Set localStorage data. 1867 * 1868 * @return {object|boolean} 1869 */ 1870 self.setLocalStorageData = function( id, status ) { 1871 1872 var jetPopupData = self.getLocalStorageData() || {}, 1873 newData = {}; 1874 1875 newData['status'] = status; 1876 1877 if ( 'disable' === status ) { 1878 1879 var nowDate = Date.now(), 1880 showAgainDelay = popupSettings['show-again-delay'], 1881 showAgainDate = 'none' !== showAgainDelay ? ( nowDate + showAgainDelay ) : 'none'; 1882 1883 newData['show-again-date'] = showAgainDate; 1884 } 1885 1886 jetPopupData[ id ] = newData; 1887 1888 localStorage.setItem( 'jetPopupData', JSON.stringify( jetPopupData ) ); 1889 } 1890 1891 } 1892 1893 window.JetPopupFrontend.init(); 1894 1895}( 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.