1( function( $, elementor ) { 2 3 "use strict"; 4 5 var WprPopups = { 6 7 init: function() { 8 $(document).ready(function() { 9 if ( ! $( '.wpr-template-popup' ).length || WprPopups.editorCheck() ) { 10 return; 11 } 12 13 WprPopups.openPopupInit(); 14 WprPopups.closePopupInit(); 15 }); 16 }, 17 18 openPopupInit: function() { 19 $( '.wpr-template-popup' ).each( function() { 20 var popup = $(this), 21 popupID = WprPopups.getID( popup ); 22 23 if ( ! WprPopups.checkAvailability( popupID ) ) { 24 return; 25 } 26 27 if ( ! WprPopups.checkStopShowingAfterDate( popup ) ) { 28 return; 29 } 30 31 // Set Local Storage 32 WprPopups.setLocalStorage( popup, 'show' ); 33 34 // Get Settings 35 var getLocalStorage = JSON.parse( localStorage.getItem( 'WprPopupSettings' ) ), 36 settings = getLocalStorage[ popupID ]; 37 38 if ( ! WprPopups.checkAvailableDevice( popup, settings ) ) { 39 return false; 40 } 41 42 // Trigger Button Init 43 WprPopups.popupTriggerInit( popup ); 44 45 // Page Load 46 if ( 'load' === settings.popup_trigger ) { 47 var loadDelay = settings.popup_load_delay * 1000; 48 49 $(window).on( 'load', function() { 50 setTimeout( function() { 51 WprPopups.openPopup( popup, settings ); 52 }, loadDelay ); 53 }); 54 55 // Page Scroll 56 } else if ( 'scroll' === settings.popup_trigger ) { 57 $(window).on( 'scroll', function() { 58 var scrollPercent = $(window).scrollTop() / ($(document).height() - $(window).height()), 59 scrollPercent = Math.round( scrollPercent * 100 ); 60 61 if ( scrollPercent >= settings.popup_scroll_progress && ! popup.hasClass( 'wpr-popup-open' ) ) { 62 WprPopups.openPopup( popup, settings ); 63 } 64 }); 65 66 // Scroll to Element 67 } else if ( 'element-scroll' === settings.popup_trigger ) { 68 $(window).on( 'scroll', function() { 69 var element = $( settings.popup_element_scroll ), 70 ScrollBottom = $(window).scrollTop() + $(window).height(); 71 72 if ( ! element.length ) { 73 return; 74 } 75 76 if ( element.offset().top < ScrollBottom && ! popup.hasClass( 'wpr-popup-open' ) ) { 77 WprPopups.openPopup( popup, settings ); 78 } 79 }); 80 81 // Specific Date 82 } else if ( 'date' === settings.popup_trigger ) { 83 var nowDate = Date.now(), 84 startDate = Date.parse( settings.popup_specific_date ); 85 86 if ( startDate < nowDate ) { 87 88 setTimeout( function() { 89 WprPopups.openPopup( popup, settings ); 90 }, 1000 ); 91 } 92 93 // User Inactivity 94 } else if ( 'inactivity' === settings.popup_trigger ) { 95 var idleTimer = null, 96 inactivityTime = settings.popup_inactivity_time * 1000; 97 98 $( '*' ).bind( 'mousemove click keyup scroll resize', function () { 99 if ( popup.hasClass( 'wpr-popup-open' ) ) { 100 return; 101 } 102 103 // Reset Timer 104 clearTimeout( idleTimer ); 105 106 // Open if Inactive 107 idleTimer = setTimeout( function() { 108 WprPopups.openPopup( popup, settings ); 109 }, inactivityTime ); 110 }); 111 112 $( 'body' ).trigger( 'mousemove' ); 113 114 // User Exit Intent 115 } else if ( 'exit' === settings.popup_trigger ) { 116 $(document).on( 'mouseleave', 'body', function( event ) { 117 if ( ! popup.hasClass( 'wpr-popup-open' ) ) { 118 WprPopups.openPopup( popup, settings ); 119 } 120 } ); 121 122 // Custom Trigger 123 } else if ( 'custom' === settings.popup_trigger ) { 124 $( settings.popup_custom_trigger ).on( 'click', function() { 125 WprPopups.openPopup( popup, settings ); 126 }); 127 128 $( settings.popup_custom_trigger ).css( 'cursor', 'pointer' ); 129 } 130 131 // Enable Scrollbar 132 if ( '0px' !== popup.find('.wpr-popup-container-inner').css('height') ) { 133 const ps = new PerfectScrollbar(popup.find('.wpr-popup-container-inner')[0], { 134 suppressScrollX: true 135 }); 136 } 137 }); 138 }, // End openPopup 139 140 openPopup: function( popup, settings ) { 141 if ( 'notification' === settings.popup_display_as ) { 142 popup.addClass( 'wpr-popup-notification' ); 143 144 setTimeout(function() { 145 $( 'body' ).animate({ 146 'padding-top' : popup.find( '.wpr-popup-container' ).outerHeight() +'px' 147 }, settings.popup_animation_duration * 1000, 'linear' ); 148 }, 10 ); 149 } 150 151 // Disable Page Scroll 152 if ( settings.popup_disable_page_scroll && 'modal' === settings.popup_display_as ) { 153 $( 'body' ).css( 'overflow', 'hidden' ); 154 } 155 156 // Open Popup 157 popup.addClass( 'wpr-popup-open' ).show(); 158 popup.find( '.wpr-popup-container' ).addClass( 'animated '+ settings.popup_animation ); 159 160 // goga 161 $(window).trigger('resize'); 162 163 // Overlay Fade In 164 $( '.wpr-popup-overlay' ).hide().fadeIn(); 165 166 // Close Button Show Up Delay 167 popup.find( '.wpr-popup-close-btn' ).css( 'opacity', '0' ); 168 setTimeout(function() { 169 popup.find( '.wpr-popup-close-btn' ).animate({ 170 'opacity' : '1' 171 }, 500 ); 172 }, settings.popup_close_button_display_delay * 1000 ); 173 174 175 // Close Automatically 176 if ( false !== settings.popup_automatic_close_switch ) { 177 setTimeout(function() { 178 WprPopups.closePopup( popup ); 179 }, settings.popup_automatic_close_delay * 1000 ); 180 } 181 }, // End openPopup 182 183 closePopupInit: function() { 184 // Close Button 185 $( '.wpr-popup-close-btn' ).on( 'click', function() { 186 WprPopups.closePopup( $(this).closest( '.wpr-template-popup' ) ); 187 }); 188 189 // Overlay Click 190 $( '.wpr-popup-overlay' ).on( 'click', function() { 191 var popup = $(this).closest( '.wpr-template-popup' ), 192 popupID = WprPopups.getID( popup ), 193 settings = WprPopups.getLocalStorage( popupID ); 194 195 if ( false == settings.popup_overlay_disable_close ) { 196 WprPopups.closePopup( popup ); 197 } 198 }); 199 200 // ESC Key Press 201 $(document).on( 'keyup', function( event ) { 202 var popup = $( '.wpr-popup-open' ); 203 204 if ( popup.length ) { 205 var popupID = WprPopups.getID( popup ), 206 settings = WprPopups.getLocalStorage( popupID ); 207 208 if ( 27 == event.keyCode && false == settings.popup_disable_esc_key ) { 209 WprPopups.closePopup( popup ); 210 } 211 } 212 }); 213 }, 214 215 closePopup: function( popup, ) { 216 var popupID = WprPopups.getID( popup ), 217 settings = WprPopups.getLocalStorage( popupID ); 218 219 // Notification 220 if ( 'notification' === settings.popup_display_as ) { 221 $( 'body' ).css( 'padding-top', 0 ); 222 } 223 224 // Update Local Storage 225 WprPopups.setLocalStorage( popup, 'hide' ); 226 227 // Close Pupup 228 if ( 'modal' === settings.popup_display_as ) { 229 popup.fadeOut(); 230 } else { 231 popup.hide(); 232 } 233 234 // Enable Page Scrolling 235 $( 'body' ).css( 'overflow', 'visible' ); 236 237 // goga 238 $(window).trigger('resize'); 239 }, 240 241 popupTriggerInit: function( popup ) { 242 var popupTrigger = popup.find( '.wpr-popup-trigger-button' ); 243 244 if ( ! popupTrigger.length ) { 245 return; 246 } 247 248 popupTrigger.on( 'click', function() { 249 // Get Settings 250 var settings = JSON.parse( localStorage.getItem( 'WprPopupSettings') ) || {}; 251 252 var popupTriggerType = $(this).attr( 'data-trigger' ), 253 popupShowDelay = $(this).attr( 'data-show-delay'), 254 popupRedirect = $(this).attr( 'data-redirect'), 255 popupRedirectURL = $(this).attr( 'data-redirect-url'), 256 popupID = WprPopups.getID( popup ); 257 258 if ( 'close' === popupTriggerType ) { 259 settings[popupID].popup_show_again_delay = parseInt( popupShowDelay, 10 ); 260 settings[popupID].popup_close_time = Date.now(); 261 } else if ( 'close-permanently' === popupTriggerType ) { 262 settings[popupID].popup_show_again_delay = parseInt( popupShowDelay, 10 ); 263 settings[popupID].popup_close_time = Date.now(); 264 } else if ( 'back' === popupTriggerType ) { 265 window.history.back(); 266 } 267 268 WprPopups.closePopup( popup ); 269 270 // Save Settings in Browser 271 localStorage.setItem( 'WprPopupSettings', JSON.stringify( settings ) ); 272 273 if ( 'back' !== popupTriggerType && 'yes' === popupRedirect ) { 274 setTimeout(function() { 275 window.location.href = popupRedirectURL; 276 }, 100); 277 } 278 }); 279 280 }, // End popupTriggerInit 281 282 getLocalStorage: function( id ) { 283 var getLocalStorage = JSON.parse( localStorage.getItem( 'WprPopupSettings' ) ); 284 285 if ( null == getLocalStorage ) { 286 return false;
287 } 288 289 // Get Settings 290 var settings = getLocalStorage[ id ]; 291 292 if ( null == settings ) { 293 return false; 294 } 295 296 return settings; 297 }, 298 299 setLocalStorage: function( popup, display ) { 300 var popupID = WprPopups.getID( popup ); 301 302 // Parse Settings 303 var dataSettings = JSON.parse( popup.attr( 'data-settings' ) ), 304 settings = JSON.parse( localStorage.getItem( 'WprPopupSettings') ) || {}; 305 306 // Merge With Defaults 307 settings[popupID] = dataSettings; 308 309 // Set Close Time 310 if ( 'hide' === display ) { 311 settings[popupID].popup_close_time = Date.now(); 312 } else { 313 settings[popupID].popup_close_time = false; 314 } 315 316 // Save Settings in Browser 317 localStorage.setItem( 'WprPopupSettings', JSON.stringify( settings ) ); 318 }, 319 320 checkStopShowingAfterDate: function( popup ) { 321 var settings = JSON.parse( popup.attr( 'data-settings' ) ); 322 323 // Current Date 324 var currentDate = Date.now(); 325 326 // Stop Showing after Date 327 if ( 'yes' === settings.popup_stop_after_date ) { 328 if ( currentDate >= Date.parse( settings.popup_stop_after_date_select ) ) { 329 return false; 330 } 331 } 332 333 return true; 334 }, 335 336 checkAvailability: function( id ) { 337 var popup = $( '#wpr-popup-id-'+ id ), 338 dataSettings = JSON.parse( popup.attr( 'data-settings' ) ), 339 currentURL = window.location.href; 340 341 if ( 'yes' === dataSettings.popup_show_via_referral && -1 === currentURL.indexOf('wpr_templates=user-popup') ) { 342 if ( currentURL.indexOf( dataSettings.popup_referral_keyword ) == -1 ) { 343 return; 344 } 345 } 346 347 // If Storage not set, continue 348 if ( false === WprPopups.getLocalStorage( id ) ) { 349 return true; 350 } 351 352 // Popup Trigger 353 var trigger = popup.find( '.wpr-popup-trigger-button' ), 354 triggerShowDelay = trigger.attr( 'data-show-delay' ); 355 356 // Current Date 357 var currentDate = Date.now(); 358 359 // Get Settings 360 var settings = WprPopups.getLocalStorage( id ); 361 362 // If delay has been changed 363 if ( triggerShowDelay ) { 364 365 var permanent = true; 366 367 trigger.each(function() { 368 var delay = $(this).attr( 'data-show-delay' ); 369 370 if ( settings.popup_show_again_delay == parseInt( delay, 10 ) ) { 371 permanent = false; 372 } 373 }); 374 375 if ( true === permanent ) { 376 return true; 377 } 378 } else { 379 if ( settings.popup_show_again_delay != dataSettings.popup_show_again_delay ) { 380 return true; 381 } 382 } 383 384 // Get Dates 385 var closeDate = settings.popup_close_time || 0, 386 showDelay = parseInt( settings.popup_show_again_delay, 10 ); 387 388 if ( closeDate + showDelay >= currentDate ) { 389 return false; 390 } else { 391 return true; 392 } 393 }, 394 395 checkAvailableDevice: function( popup, settings ) {//TODO: Add all 7 device support 396 var viewport = $( 'body' ).prop( 'clientWidth' ); 397 398 if ( viewport > 1024 ) { 399 return Boolean(settings.popup_show_on_device); 400 } else if ( viewport > 768 ) { 401 return Boolean(settings.popup_show_on_device_tablet); 402 } else { 403 return Boolean(settings.popup_show_on_device_mobile); 404 } 405 }, 406 407 getID: function( popup ) { 408 var id = popup.attr( 'id' ); 409 410 return id.replace( 'wpr-popup-id-', '' ); 411 }, 412 413 // Editor Check 414 editorCheck: function() { 415 return $( 'body' ).hasClass( 'elementor-editor-active' ) ? true : false; 416 } 417 } // End WprPopups 418 419 // Init 420 WprPopups.init(); 421 422}( 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.