PageSourceSearch

https://cdn.searchenginejournal.com/wp-content/plugins/abm-sej/includes/promos/assets/pp.js?ver=1789989470

js searchenginejournal.com collected 2026-09-24 06:23:42 UTC 22,144 bytes, 532 lines download raw bytes

1/* Production artifact: mirrors pop-no-min.js. Verified by verify_popup_handoff.cjs. */
2window.sej_pop_fits_viewport = function (entry) {
3    // Can this popup actually be SEEN at the current viewport?
4    //
5    // Two separate things silently blank the slot after the loop has already
6    // committed to an entry, so both have to be asked here instead:
7    //
8    //   1. pop-css.css hides .popup-lg at <=1000px and .popup-sm at <=767px.
9    //      The element mounts, computes display:none, and the reader sees
10    //      nothing -- while a smaller, eligible popup sat next in the list.
11    //   2. sej_show_popup() returns early when the popup is taller than the
12    //      window (its `pop_h < 0` guard), with the same result.
13    //
14    // Breakpoints are duplicated from pop-css.css deliberately: the element
15    // does not exist in the DOM yet at selection time, so its computed style
16    // cannot be measured. Keep the two in step if that CSS ever changes.
17    if (!entry || typeof entry[0] !== "string") { return true; }
18    var w = window.innerWidth, h = window.innerHeight;
19    if (entry[0].indexOf("popup-lg") !== -1 && w <= 1000) { return false; }
20    if (entry[0].indexOf("popup-sm") !== -1 && w <= 767) { return false; }
21    var ph = (typeof entry[2] === "number" && isFinite(entry[2])) ? entry[2] : 0;
22    if (ph > 0 && h < ph) { return false; }
23    return true;
24};
25
26window.sej_pop_eligible = function (entry) {
27    // Is this popup inside its own live window RIGHT NOW?
28    //
29    // The popup list lives in one static assets/disp.js that every visitor
30    // shares and the CDN caches, so no server rebuild can retire a finished
31    // popup mid-flight -- the reader's own clock is the only one available at
32    // display time. Bounds are absolute epoch seconds computed server-side
33    // from Eastern, so there is no timezone maths here: a 3pm ET end means
34    // 3pm ET for a reader in any timezone.
35    //
36    // A MISSING window means eligible. Legacy 6-element tuples pushed by
37    // includes/pop/webinar.php have no indices 10/11, and they must keep
38    // working. A PRESENT but passed window means skip. Never confuse the two:
39    // absent is not expired.
40    if (!entry) { return false; }
41    var now = Math.floor(Date.now() / 1000);
42    // A usable bound is a FINITE positive number. Everything else -- absent,
43    // null, a string, NaN, Infinity, zero or negative -- means "no bound", so
44    // the popup stays eligible. Infinity in particular is a number and passes
45    // a bare `> 0`, which would hide a live popup forever; JSON cannot carry
46    // it, but the sentinel should not depend on that.
47    var bound = function (v) {
48        return (typeof v === "number" && isFinite(v) && v > 0) ? v : 0;
49    };
50    var start = bound(entry[10]);
51    var end = bound(entry[11]);
52    if (start && now < start) { return false; }
53    if (end && now > end) { return false; }
54    // Appended metadata; old tuples default to all regions, as before.
55    var regions = typeof entry[12] === 'string' ? entry[12].toUpperCase().split(',').map(function (v) { return v.trim(); }).filter(Boolean) : ['ALL'];
56    var country = String(window.sglob_country || '').toUpperCase();
57    if (country && regions.indexOf('-' + country) !== -1) { return false; }
58    var allowed = regions.filter(function (v) { return v.charAt(0) !== '-'; });
59    if (allowed.length && allowed.indexOf('ALL') === -1 && allowed.indexOf(country) === -1) { return false; }
60    return true;
61};
62
63// Selection runs again at mount/show time, not only when the page first loads.
64// Preserve the planner's priority, slot, date window, viewport and cookie caps.
65window.sej_pop_pick = function (entries) {
66    if (!Array.isArray(entries)) { return null; }
67    for (var i = 0; i < entries.length; i++) {
68        var entry = entries[i];
69        if (entry && typeof entry[1] !== "undefined" &&
70                !abm_sej_getCookie(entry[1]) && window.sej_pop_eligible(entry) &&
71                window.sej_pop_fits_viewport(entry)) {
72            return entry;
73        }
74    }
75    return null;
76};
77// Loading an iframe is not proof that its creative or image rendered. Keep
78// failed/blocked requests and empty documents out of the visible popup shell.
79window.sej_pop_content_ready = function (wrapper) {
80    if (!wrapper) { return false; }
81    var iframe = wrapper.querySelector('iframe');
82    if (!iframe) { return true; } // Legacy popups render their content inline.
83    try {
84        var doc = iframe.contentDocument;
85        var content = doc && doc.querySelector('.sej-pop-iframe-inner');
86        if (!content) { return false; }
87        var images = content.querySelectorAll('img');
88        for (var i = 0; i < images.length; i++) {
89            if (images[i].complete && images[i].naturalWidth > 0) { return true; }
90        }
91        return Boolean(content.querySelector('form input:not([type="hidden"]), form select, form button'));
92    } catch (error) {
93        return false;
94    }
95};
96window.sej_popup_lifecycle_version = 2;
97
98window.addEventListener('pop_ready', function () {
99
100    $(document).ready(function () {
101
102        // Generic popup
103        //console.log('pop_ready222');
104        var popup_cookie = '';
105        var popup_exit_cookie = '';
106        var popup_html = '';
107        var popup_exit_html = '';
108        window.pop_h_diff = 70;
109        window.pop_h_exit_diff = 70;
110        var pop_time_out = 9000;
111        var pop_time_out_exit = 20000;
112        var popup_closed_once = false;
113        var popup_cookie_expire = 7;
114        var pop_h_exit_expire = 7;
115        var popup_entry = null;
116        var popup_exit_entry = null;
117        var mounted_entry = null;
118        var expiry_timer = null;
119        var readiness_timer = null;
120        var failed_entries = [];
121        var popup_cookie_prev = '', popup_exit_cookie_prev = '';
122        var popup_cta = '', popup_exit_cta = '';
123        window.form_popup_test = '';
124
125        function refresh_popup_choice(isExit) {
126            var entries = isExit ? window.s_ex_popup : window.s_en_popup;
127            var entry = window.sej_pop_pick(Array.isArray(entries) ? entries.filter(function (candidate) {
128                return failed_entries.indexOf(candidate) === -1;
129            }) : []);
130            if (isExit) {
131                popup_exit_entry = entry;
132                popup_exit_html = entry ? entry[0] : '';
133                popup_exit_cookie = entry ? entry[1] : '';
134                window.pop_h_exit_diff = entry ? entry[2] : 70;
135                popup_exit_cookie_prev = entry ? entry[4] : '';
136                pop_h_exit_expire = entry ? entry[5] : 7;
137                popup_exit_cta = entry ? entry[6] : '';
138            } else {
139                popup_entry = entry;
140                popup_html = entry ? entry[0] : '';
141                popup_cookie = entry ? entry[1] : '';
142                window.pop_h_diff = entry ? entry[2] : 70;
143                popup_cookie_prev = entry ? entry[4] : '';
144                popup_cookie_expire = entry ? entry[5] : 7;
145                popup_cta = entry ? entry[6] : '';
146            }
147            return entry;
148        }
149
150        function mount_popup(isExit) {
151            var entry = refresh_popup_choice(isExit);
152            if (mounted_entry !== entry) {
153                $('#sej-pop-wrapper_v4').remove();
154                mounted_entry = entry;
155                if (entry) {
156                    // Preload without showing an empty white frame or taking focus.
157                    var $wrapper = $(entry[0]).css('visibility', 'hidden').attr('aria-hidden', 'true');
158                    $('body').append($wrapper);
159                }
160            }
161            return entry;
162        }
163
164        function show_current_popup(isExit) {
165            if (window.no_popup) { return false; }
166            var entry = mount_popup(isExit);
167            if (!entry) { return false; }
168            clearTimeout(readiness_timer);
169            var started = Date.now();
170            function show_when_ready() {
171                if (mounted_entry !== entry || window.no_popup) { return; }
172                var eligible = window.sej_pop_eligible(entry) && window.sej_pop_fits_viewport(entry);
173                if (eligible && window.sej_pop_content_ready(document.querySelector('#sej-pop-wrapper_v4'))) {
174                    if (isExit) {
175                        sej_show_popup(popup_exit_html, pop_h_exit_diff, popup_exit_cookie, popup_exit_cookie_prev, pop_h_exit_expire, popup_exit_cta, 'Exit Intent');
176                    } else {
177                        sej_show_popup(popup_html, pop_h_diff, popup_cookie, popup_cookie_prev, popup_cookie_expire, popup_cta, 'Entrance');
178                    }
179                    return;
180                }
181                if (!eligible || Date.now() - started >= 8000) {
182                    // Skip only for this visit. No impression cookie is consumed
183                    // until a real creative becomes visible; a later visit retries.
184                    failed_entries.push(entry);
185                    $('#sej-pop-wrapper_v4').remove();
186                    mounted_entry = null;
187                    if (!show_current_popup(isExit) && !isExit) {
188                        $(document).trigger('main_popup_close');
189                    }
190                    return;
191                }
192                readiness_timer = setTimeout(show_when_ready, 100);
193            }
194            show_when_ready();
195            return true;
196        }
197
198        if ($("#mobileheadermenu").length == 0 && $(window).width() >= 768) {
199
200            refresh_popup_choice(false);
201
202
203            refresh_popup_choice(true);
204
205
206            if (popup_html != '') {
207                // add popup content to HTML few seonds earlier to avoid images loading  blink issues
208
209                setTimeout(function () {
210                    //in case of window.no_popup defined don't show popup
211                    if (window.no_popup) {
212                        return;
213                    }
214                    mount_popup(false);
215                }, (pop_time_out - 5000));
216
217
218                setTimeout(function () {
219                    //in case of window.no_popup defined don't show popup
220                    if (window.no_popup) {
221                        return;
222                    }
223                    if (!show_current_popup(false)) {
224                        $(document).trigger("main_popup_close");
225                        return;
226                    }
227
228
229                    // close on touchscreen devises
230                    if (window.innerWidth <= 1190) {
231                        $("body").click(function (b) {
232                            var c = $("#sej-popup-inner");
233                            if (c.is(b.target) || 0 === c.find(b.target).length) {
234                                $(document).trigger("main_popup_close");
235                                sej_close_popup();
236
237                            }
238
239                        });
240                    }
241
242                }, pop_time_out);
243            }
244
245
246
247            $(document).bind('main_popup_close', function () {
248                // Bind exit intent poopup after main popup is closed,
249                // Don't run exit intent on IE
250                if (Array.isArray(window.s_ex_popup) && window.s_ex_popup.length && $(window).width() > 1024) {
251
252                    //append html of popup earlier so images load until we show
253                    setTimeout(function () {
254                        //in case of window.no_popup defined don't show popup
255                        if (window.no_popup) {
256                            return;
257                        }
258
259                        mount_popup(true);
260                    }, (pop_time_out_exit - 3000));
261
262                    //show popup
263                    setTimeout(function () {
264                        //in case of window.no_popup defined don't show popup
265                        if (window.no_popup) {
266                            return;
267                        }
268
269                        $(document).bind('mouseout', { popup_exit_cta: popup_exit_cta }, sej_exit_intent_popup);
270                    }, pop_time_out_exit);
271                }
272            });
273
274            // Schedule exit intent popup if main popup will not be show
275            if (popup_html == '' && Array.isArray(window.s_ex_popup) && window.s_ex_popup.length && $(window).width() > 1024) {
276                // If cookie doesn't set
277                //append html of popup earlier so images load until we show
278                setTimeout(function () {
279                    //in case of window.no_popup defined don't show popup
280                    if (window.no_popup) {
281                        return;
282                    }
283
284                    mount_popup(true);
285                }, (pop_time_out_exit - 3000));
286                //show popup
287                setTimeout(function () {
288                    //in case of window.no_popup defined don't show popup
289                    if (window.no_popup) {
290                        return;
291                    }
292
293                    if (pop_h_exit_diff > 0) {
294                        $(document).bind('mouseout', sej_exit_intent_popup);
295                    }
296                }, pop_time_out_exit);
297                console.log('exit pop');
298            }
299
300        }//popup_closed_once, 768 $("#mobileheadermenu")
301
302        function sej_exit_intent_popup(e) {
303            if (window.no_popup) {
304                $(document).unbind('mouseout', sej_exit_intent_popup);
305                return;
306            }
307            if (e.clientY < 25) { // Re-select after a long dwell or a webinar cutoff.
308                if (!show_current_popup(true)) { return; }
309                console.log('sej_exit_intent_popup');
310                /*setTimeout(function(){
311                    __gaTrackers('send', 'event', 'Exit Popup Impression' );
312                }, 50 );*/
313
314                if (window.innerWidth <= 1190) {
315                    $("body").click(function (b) {
316                        var c = $("#sej-popup-inner");
317                        if (c.is(b.target) || 0 === c.find(b.target).length) {
318                            sej_close_popup();
319                        }
320
321                    });
322                }
323
324                $(document).unbind('mouseout', sej_exit_intent_popup);
325
326            }
327        }
328
329        function sej_show_popup(pop_html, pop_h, popup_cookie, popup_cookie_prev, popup_cookie_expire, popup_cta, pop_type) {
330            var active_entry = pop_type === 'Exit Intent' ? popup_exit_entry : popup_entry;
331            if (!active_entry || !window.sej_pop_eligible(active_entry)) { return; }
332            pop_h = $(window).height() - pop_h;
333            if (pop_h <= 0 && pop_h >= -30) {
334                pop_h = 20;
335            }
336
337            if (pop_h < 0 || pop_html == '' || $('.ovr-hide').length > 0) {
338                return; // exit if unexpected issues
339            }
340
341
342            // stop popup show if cookies were set
343            if (abm_sej_getCookie(popup_cookie) || window.no_popup) {
344                $('#sej-pop-wrapper_v4').remove();
345                return;
346            }
347
348            /*if( pop_type != 'Exit Intent' ){
349                setTimeout(function(){
350                    __gaTrackers('send', 'event', 'Entrance Popup Impression' );
351                }, 50 );
352            }*/
353
354            abm_sej_setCookie(popup_cookie, 1, popup_cookie_expire);
355            abm_delete_Cookie(popup_cookie_prev);
356            //console.log('pop_h', pop_h);
357            //console.log(' window.pop_h_diff',  window.pop_h_diff);
358            //console.log('  window.pop_h_exit_diff',   window.pop_h_exit_diff );
359            window.pop_h_diff = 70;
360            window.pop_h_exit_diff = 70;
361            //console.log(popup_cookie);
362            $('#sej-pop-wrapper_v4').css('visibility', 'visible').attr('aria-hidden', 'false');
363            $('#sej-popup-inner').addClass('pshow');
364
365            // A form already open at the cutoff must also retire. Reuse the
366            // approved rotation, never generate copy or change a campaign here.
367            clearTimeout(expiry_timer);
368            function expire_visible_popup() {
369                if (mounted_entry !== active_entry) { return; }
370                var end = active_entry[11];
371                if (typeof end !== 'number' || !isFinite(end) || end <= 0) { return; }
372                var remaining = (end + 1) * 1000 - Date.now();
373                if (remaining > 0) {
374                    expiry_timer = setTimeout(expire_visible_popup, Math.min(remaining, 2147483647));
375                    return;
376                }
377                $('#sej-pop-wrapper_v4').remove();
378                mounted_entry = null;
379                if (!show_current_popup(pop_type === 'Exit Intent') && pop_type !== 'Exit Intent') {
380                    $(document).trigger('main_popup_close');
381                }
382            }
383            expire_visible_popup();
384
385            // Fix logic for vertical centering: measure actual height instead of relying on config height
386            var $pInner = $('#sej-popup-inner');
387            var realHeight = $pInner.outerHeight();
388            var topPos = Math.floor(pop_h / 2); // Default fallback using the previously calculated difference
389
390            if (realHeight && realHeight > 0) {
391                // Recalculate based on actual DOM height: (Window - RealHeight) / 2
392                topPos = Math.floor(($(window).height() - realHeight) / 2);
393                // Ensure we don't push it off-screen if it's too tall
394                if (topPos < 0) topPos = 0;
395            }
396
397            $pInner.css({ 'top': topPos + 'px' });
398            // Select the iframe
399            // Select the iframe
400            var iframe = document.querySelector('#sej-popup-inner iframe');
401
402            var iframeDoc = null;
403            if (iframe) {
404                try {
405                    iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
406                } catch (e) {
407                    // Likely cross-origin or not yet accessible
408                    iframeDoc = null;
409                }
410            }
411
412            // The popup iframe (and its Turnstile widget) loads ~17s into the
413            // visit and can sit hidden long past the token's 300s TTL. Mint a
414            // fresh token the moment the form becomes visible, so an
415            // interactive re-challenge can also actually render.
416            if (iframe) {
417                try {
418                    if (iframe.contentWindow && typeof iframe.contentWindow.sej_captcha_reset_bm === 'function') {
419                        iframe.contentWindow.sej_captcha_reset_bm();
420                    }
421                } catch (err) {
422                }
423            }
424
425            if (iframeDoc) {
426
427                // Find the element inside the iframe to receive focus
428                var sfocus = iframeDoc.querySelector('.sej_pop_action');
429
430                if (sfocus) {
431                    // Find the close button in the parent document
432                    var closeBtn = document.querySelector('.no_exit_close');
433
434                    // Set initial focus
435                    sfocus.focus();
436
437                    // Listen for keydown on the initially focused element
438                    sfocus.addEventListener('keydown', function (event) {
439                        // Check if TAB key is pressed (without Shift)
440                        if (event.key === 'Tab' && !event.shiftKey) {
441                            event.preventDefault();
442                            if (closeBtn) {
443                                closeBtn.focus();
444                            }
445                        }
446
447
448                    });
449
450                    document.addEventListener('keydown', function (event) {
451                        if (event.key === 'Escape') { // Check if Esc key is pressed
452                            if (closeBtn.getAttribute('data-mainp') == 'yes') {
453                                $(document).trigger("main_popup_close");
454                            }
455                            sej_close_popup();
456                            console.log('keydown 1');
457                        }
458                    });
459
460                    iframeDoc.addEventListener('keydown', function (event) {
461                        if (event.key === 'Escape') { // Check if Esc key is pressed
462                            if (closeBtn.getAttribute('data-mainp') == 'yes') {
463                                $(document).trigger("main_popup_close");
464                            }
465                            sej_close_popup();
466                            console.log('keydown 2');
467                        }
468                    });
469                }
470            }
471
472
473
474
475
476
477            $('.no_exit_close').click(function () {
478                sej_close_popup();
479                if ($(this).attr('data-mainp') == 'yes') {
480                    $(document).trigger("main_popup_close");
481                }
482                popup_closed_once = true;
483                console.log('no_exit_close click');
484            });
485            // Use jQuery or plain JavaScript
486            $('.no_exit_close').on('keydown', function (e) {
487                if (e.key === 'Enter') {
488                    $(this).click();
489                }
490            });
491
492            window.addEventListener('iframe_pop_click', function (event) {
493                sej_close_popup();
494                if (!event.detail.is_exit) {
495                    $(document).trigger("main_popup_close");
496                }
497
498                popup_closed_once = true;
499            });
500
501
502
503        }// end of sej_show_popup
504
505
506
507        function sej_close_popup() {
508            clearTimeout(expiry_timer);
509            clearTimeout(readiness_timer);
510            mounted_entry = null;
511            $('#sej-pop-wrapper_v4').fadeOut(500, function () {
512                $(this).remove();
513
514            });
515        }
516
517
518        function sej_msieversion() {
519
520            var ua = window.navigator.userAgent;
521            var msie = ua.indexOf("MSIE ");
522
523            if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) {
524                return true;
525            }
526
527            return false;
528        }
529
530    });//end of jQuery ready
531
532});// pop_ready end

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.