1( function( $, elementor ) { 2 3 'use strict'; 4 5 window.JetPopupElementorFrontend = { 6 7 getLoopItemPopupData: function( popupData, $trigger, $scope ) { 8 let popupBaseData = $.extend( {}, popupData || {} ); 9 10 if ( ! popupBaseData.loopDynamicPopup || popupBaseData.postId ) { 11 return popupBaseData; 12 } 13 14 if ( window.JetPopupFrontend && window.JetPopupFrontend.getLoopItemData ) { 15 popupBaseData = $.extend( 16 {}, 17 popupBaseData, 18 window.JetPopupFrontend.getLoopItemData( $trigger ), 19 window.JetPopupFrontend.getLoopItemData( $scope ) 20 ); 21 } 22 23 return popupBaseData; 24 }, 25 26 init: function() { 27 28 if ( ! elementor ) { 29 return false; 30 } 31 32 elementor.hooks.addAction( 'frontend/element_ready/widget', JetPopupElementorFrontend.elementorWidget ); 33 34 const widgets = { 35 'jet-popup-action-button.default' : JetPopupElementorFrontend.widgetPopupActionButton, 36 'jet-popup-mailchimp.default' : JetPopupElementorFrontend.widgetPopupMailchimp 37 }; 38 39 $.each( widgets, function( widget, callback ) { 40 elementor.hooks.addAction( 'frontend/element_ready/' + widget, callback ); 41 } ); 42 43 elementor.hooks.addAction( 'frontend/element_ready/section', JetPopupElementorFrontend.elementorWidget ); 44 elementor.hooks.addAction( 'frontend/element_ready/container', JetPopupElementorFrontend.elementorWidget ); 45 46 JetPopupElementorFrontend.initTooltipPopups(); 47 }, 48 49 initTooltipPopups: function() { 50 const initialized = new WeakSet(); 51 const initTriggers = function( root ) { 52 if ( root.nodeType !== 1 ) { 53 return; 54 } 55 56 $( root ).find( '[data-jet-popup]' ).addBack( '[data-jet-popup]' ).each( function() { 57 const $scope = $( this ); 58 59 if ( initialized.has( this ) || ! window.JetPopupFrontend.getTooltipReference( $scope ).length ) { 60 return; 61 } 62 63 initialized.add( this ); 64 // JetTricks copies innerHTML, including the initialized class but 65 // without the original popup event handlers. 66 $scope.off( '.JetPopup' ).removeClass( 'jet-popup-attach-event-inited' ); 67 JetPopupElementorFrontend.elementorWidget( $scope ); 68 } ); 69 }; 70 71 const observer = new MutationObserver( function( mutations ) { 72 mutations.forEach( function( mutation ) { 73 mutation.addedNodes.forEach( initTriggers ); 74 } ); 75 } ); 76 77 observer.observe( document.body, { childList: true, subtree: true } ); 78 initTriggers( document.body ); 79 }, 80 81 elementorWidget: function( $scope ) { 82 let widget_id = $scope.data( 'id' ), 83 widgetType = $scope.data( 'element_type' ), 84 popupSettings = $scope.data( 'jet-popup' ) || false; 85 86 if ( popupSettings ) { 87 let openEvent = popupSettings[ 'trigger-type' ], 88 customSelector = popupSettings[ 'trigger-custom-selector' ], 89 popupData = { 90 popupId: popupSettings[ 'attached-popup' ], 91 loopDynamicPopup: !! popupSettings[ 'loop-dynamic-popup' ] 92 }; 93 94 if ( $scope.hasClass( 'jet-popup-attach-event-inited' ) ) { 95 return false; 96 } 97 98 $scope.addClass( 'jet-popup-attach-event-inited' ); 99 100 switch( openEvent ) { 101 case 'click-self': 102 $scope.addClass( 'jet-popup-cursor-pointer' ); 103 if ( window.JetPopupFrontend && window.JetPopupFrontend.makeTriggerAccessible ) { 104 window.JetPopupFrontend.makeTriggerAccessible( $scope, popupData.popupId ); 105 } 106 107 $scope.on( 'click.JetPopup', function( event ) { 108 event.preventDefault(); 109 110 var $target = $( event.currentTarget ), 111 eventPopupData = JetPopupElementorFrontend.getLoopItemPopupData( popupData, $target, $scope ); 112 113 if ( elementor.hooks ) { 114 eventPopupData = elementor.hooks.applyFilters( 115 'jet-popup/widget-extensions/popup-data', 116 eventPopupData, 117 popupSettings, 118 $scope, 119 event 120 ); 121 } 122 123 $( window ).trigger( { 124 type: 'jet-popup-open-trigger', 125 popupData: eventPopupData, 126 triggeredBy: $scope, 127 } ); 128 129 return false; 130 } ); 131 break; 132 case 'click': 133 $scope.on( 'click.JetPopup', '.elementor-button, .jet-button__instance, .jet-popup-action-button__instance', function( event ) { 134 event.preventDefault(); 135 136 let eventPopupData = JetPopupElementorFrontend.getLoopItemPopupData( popupData, $( this ), $scope ); 137 138 if ( elementor.hooks ) { 139 eventPopupData = elementor.hooks.applyFilters( 140 'jet-popup/widget-extensions/popup-data', 141 eventPopupData, 142 popupSettings, 143 $scope, 144 event 145 ); 146 } 147 148 $( window ).trigger( { 149 type: 'jet-popup-open-trigger', 150 popupData: eventPopupData, 151 triggeredBy: $( this ), 152 } ); 153 154 return false;
155 } ); 156 break; 157 case 'click-selector': 158 159 if ( '' !== customSelector ) { 160 $( customSelector ).addClass( 'jet-popup-cursor-pointer' ); 161 if ( window.JetPopupFrontend && window.JetPopupFrontend.makeTriggerAccessible ) { 162 window.JetPopupFrontend.makeTriggerAccessible( $( customSelector ), popupData.popupId ); 163 } 164 165 $scope.on( 'click.JetPopup', customSelector, function( event ) { 166 event.preventDefault(); 167 168 var $target = $( event.currentTarget ), 169 eventPopupData = JetPopupElementorFrontend.getLoopItemPopupData( popupData, $target, $scope ); 170 171 $target.addClass( 'jet-popup-cursor-pointer' ); 172 173 if ( elementor.hooks ) { 174 eventPopupData = elementor.hooks.applyFilters( 175 'jet-popup/widget-extensions/popup-data', 176 eventPopupData, 177 popupSettings, 178 $scope, 179 event 180 ); 181 } 182 183 $( window ).trigger( { 184 type: 'jet-popup-open-trigger', 185 popupData: eventPopupData, 186 triggeredBy: $target, 187 } ); 188 189 return false; 190 } ); 191 } 192 break; 193 case 'hover': 194 $scope.on( 'mouseenter.JetPopup', function( event ) { 195 let eventPopupData = JetPopupElementorFrontend.getLoopItemPopupData( popupData, $scope, $scope ); 196 197 if ( elementor.hooks ) { 198 eventPopupData = elementor.hooks.applyFilters( 199 'jet-popup/widget-extensions/popup-data', 200 eventPopupData, 201 popupSettings, 202 $scope, 203 event 204 ); 205 } 206 207 $( window ).trigger( { 208 type: 'jet-popup-open-trigger', 209 popupData: eventPopupData, 210 triggeredBy: $scope, 211 } ); 212 } ); 213 break; 214 case 'scroll-to': 215 const observer = new IntersectionObserver(( entries ) => { 216 entries.forEach(( entry ) => { 217 218 if ( entry.isIntersecting ) { 219 let eventPopupData = JetPopupElementorFrontend.getLoopItemPopupData( popupData, $scope, $scope ); 220 221 if ( elementor.hooks ) { 222 eventPopupData = elementor.hooks.applyFilters( 223 'jet-popup/widget-extensions/popup-data', 224 eventPopupData, 225 popupSettings, 226 $scope, 227 ); 228 } 229 230 $( window ).trigger( { 231 type: 'jet-popup-open-trigger', 232 popupData: eventPopupData, 233 triggeredBy: $scope, 234 } ); 235 } 236 }) 237 }, 238 { 239 threshold: 0.5 240 }); 241 242 for ( let i = 0; i < $( $scope ).length; i++ ) { 243 const elements = $( $scope )[i]; 244 observer.observe( elements ); 245 } 246 break; 247 } 248 } 249 }, 250 251 widgetPopupActionButton: function( $scope ) { 252 var $button = $( '.jet-popup-action-button__instance', $scope ), 253 settings = $button.data( 'settings' ), 254 actionType = settings['action-type']; 255 256 window.JetPopupFrontend.actionButtonHandle( $button, actionType ); 257 }, 258 259 widgetPopupMailchimp: function( $scope ) { 260 var $target = $scope.find( '.jet-popup-mailchimp' ), 261 scoreId = $scope.data( 'id' ), 262 settings = $target.data( 'settings' ), 263 $subscribeForm = $( '.jet-popup-mailchimp__form', $target ), 264 $fields = $( '.jet-popup-mailchimp__fields', $target ), 265 $mailField = $( '.jet-popup-mailchimp__mail-field', $target ), 266 $inputData = $mailField.data( 'instance-data' ), 267 $submitButton = $( '.jet-popup-mailchimp__submit', $target ), 268 $subscribeFormMessage = $( '.jet-popup-mailchimp__message', $target ), 269 invalidMailMessage = 'Please specify a valid email', 270 timeout = null, 271 ajaxRequest = null, 272 $currentPopup = $target.closest( '.jet-popup' ); 273 274 $mailField.on( 'focus', function() { 275 $mailField.removeClass( 'mail-invalid' ); 276 } ); 277 278 $( document ).keydown( function( event ) { 279 280 if ( 13 === event.keyCode && $mailField.is( ':focus' ) ) { 281 subscribeHandle(); 282 283 return false; 284 } 285 } ); 286 287 $submitButton.on( 'click', function() { 288 subscribeHandle(); 289 290 return false;
291 } ); 292 293 self.subscribeHandle = function() { 294 var inputValue = $mailField.val(), 295 sendData = { 296 'email': inputValue, 297 'target_list_id': settings['target_list_id'] || '', 298 'data': $inputData 299 }, 300 serializeArray = $subscribeForm.serializeArray(), 301 additionalFields = {}; 302 303 if ( validateEmail( inputValue ) ) { 304 305 $.each( serializeArray, function( key, fieldData ) { 306 if ( 'email' === fieldData.name ) { 307 sendData[ fieldData.name ] = fieldData.value; 308 } else { 309 additionalFields[ fieldData.name ] = fieldData.value; 310 } 311 } ); 312 313 sendData['additional'] = additionalFields; 314 315 ajaxRequest = jQuery.ajax( { 316 type: 'POST', 317 url: window.jetPopupData.ajax_url, 318 data: { 319 'action': 'jet_popup_mailchimp_ajax', 320 'data': sendData 321 }, 322 beforeSend: function( jqXHR, ajaxSettings ) { 323 if ( null !== ajaxRequest ) { 324 ajaxRequest.abort(); 325 } 326 }, 327 error: function( jqXHR, ajaxSettings ) { 328 329 }, 330 success: function( data, textStatus, jqXHR ) { 331 var successType = data.type, 332 message = data.message || '', 333 responceClass = 'jet-popup-mailchimp--response-' + successType; 334 335 $submitButton.removeClass( 'loading' ); 336 337 $target.removeClass( 'jet-popup-mailchimp--response-error' ); 338 $target.addClass( responceClass ); 339 340 $( 'span', $subscribeFormMessage ).html( message ); 341 $subscribeFormMessage.css( { 'visibility': 'visible' } ); 342 343 timeout = setTimeout( function() { 344 $subscribeFormMessage.css( { 'visibility': 'hidden' } ); 345 $target.removeClass( responceClass ); 346 }, 10000 ); 347 348 if ( settings['redirect'] ) { 349 window.location.href = settings['redirect_url']; 350 } 351 352 $( window ).trigger( { 353 type: 'jet-popup/mailchimp', 354 elementId: scoreId, 355 successType: successType, 356 inputData: $inputData 357 } ); 358 359 if ( true === settings['close_popup_when_success'] && $currentPopup[0] && 'success' === successType ) { 360 var popupId = $currentPopup.attr( 'id' ); 361 362 timeout = setTimeout( function() { 363 $( window ).trigger( { 364 type: 'jet-popup-close-trigger', 365 popupData: { 366 popupId: popupId, 367 constantly: false 368 } 369 } ); 370 }, 3000 ); 371 372 } 373 } 374 } ); 375 376 377 $submitButton.addClass( 'loading' ); 378 } else { 379 $mailField.addClass( 'mail-invalid' ); 380 381 $target.addClass( 'jet-popup-mailchimp--response-error' ); 382 $( 'span', $subscribeFormMessage ).html( invalidMailMessage ); 383 $subscribeFormMessage.css( { 'visibility': 'visible' } ); 384 385 timeout = setTimeout( function() { 386 $target.removeClass( 'jet-popup-mailchimp--response-error' ); 387 $subscribeFormMessage.css( { 'visibility': 'hidden' } ); 388 $mailField.removeClass( 'mail-invalid' ); 389 }, 10000 ); 390 } 391 } 392 393 function validateEmail( email ) { 394 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,}))$/; 395 396 return re.test( email ); 397 } 398 }, 399 }; 400 401 // Elementor front init 402 $( window ).on( 'elementor/frontend/init', () => { 403 window.JetPopupElementorFrontend.init(); 404 } ); 405 406}( 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.