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