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