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