PageSourceSearch

https://www.usglc.org/wp-content/plugins/wp-popups-lite/src/assets/js/wppopups.js?ver=2.2.0.3

js usglc.org collected 2026-09-24 08:49:44 UTC 49,455 bytes, 1,505 lines download raw bytes

1"use strict";
2
3;
4/* global wppopups_settings,*/
5
6(function ($) {
7  'use strict';
8
9  var WPPopups = {
10    popups: {},
11    byBind: {
12      'class': [],
13      'href': []
14    },
15
16    /**
17     * Start the engine.
18     *
19     * @since 2.0.0
20     */
21    init: function init() {
22      // Document ready
23      $(document).ready(WPPopups.ready); // Page load
24
25      $(window).on('load', WPPopups.load); // Document ready
26
27      $(document).on('wppopupsAjaxReady', WPPopups.ajaxStart);
28      WPPopups.bindUIActions();
29    },
30
31    /**
32    * Document ready.
33    *
34    * @since 2.0.0
35    */
36    ready: function ready() {
37      $(document).trigger('wppopupsBeforeReady');
38      if ($(".spu-box").length == 0) return false;
39      var data = {
40        action: 'wppopups_rules',
41        pid: wppopups_vars.pid,
42        referrer: document.referrer,
43        url: document.documentURI,
44        query_string: document.location.search,
45        is_category: wppopups_vars.is_category,
46        is_archive: wppopups_vars.is_archive,
47        is_singular: wppopups_vars.is_singular,
48        is_preview: wppopups_vars.is_preview,
49        is_search: wppopups_vars.is_search,
50        is_front_page: wppopups_vars.is_front_page,
51        is_blog_page: wppopups_vars.is_blog_page,
52        woo_is_shop: wppopups_vars.woo_is_shop,
53        woo_is_order_received: wppopups_vars.woo_is_order_received,
54        woo_is_product_category: wppopups_vars.woo_is_product_category,
55        woo_is_product_tag: wppopups_vars.woo_is_product_tag,
56        woo_is_product: wppopups_vars.woo_is_product,
57        woo_is_cart: wppopups_vars.woo_is_cart,
58        woo_is_checkout: wppopups_vars.woo_is_checkout,
59        woo_is_account_page: wppopups_vars.woo_is_account_page,
60        popups: []
61      }; // save all popups rules into data
62
63      $(".spu-box").each(function () {
64        var $popup = $(this),
65            $id = $popup.data('id'),
66            $need_ajax = $popup.data('need_ajax'),
67            $rules = WPPopups.settings($popup, 'rules'),
68            $global_rules = WPPopups.settings($popup, 'global_rules'); // if old popup it's enabled id will be empty and break things
69
70        if ($id && $need_ajax) {
71          data.popups.push({
72            id: $id,
73            rules: JSON.stringify($rules),
74            global_rules: JSON.stringify($global_rules),
75            parent: $popup.data('parent')
76          });
77        }
78      });
79      var ajax = {
80        url: wppopups_vars.ajax_url,
81        data: window.wp.hooks.applyFilters('wppopups_pre_ready_data', data),
82        cache: false,
83        type: 'POST',
84        dataType: 'json',
85        timeout: 30000,
86        success: function success(r) {
87          if (r.success) {
88            r.success.forEach(function (id) {
89              WPPopups.removePopup(id);
90            });
91          }
92
93          $(document).trigger('wppopupsAjaxReady');
94        },
95        error: function error(r) {
96          console.log(r);
97        }
98      };
99
100      if (data.popups.length) {
101        $.ajax(ajax);
102      }
103
104      WPPopups.initVideoSources();
105      WPPopups.resetPopupsContent();
106      WPPopups.hashTriggerPopups(); // init popups that doesn't need ajax
107
108      $(".spu-box").each(function () {
109        var $popup = $(this),
110            $need_ajax = $popup.data('need_ajax');
111
112        if ($need_ajax) {
113          $popup.hide();
114          return;
115        }
116
117        WPPopups.initPopup($popup);
118      });
119      WPPopups.loadValidation();
120      WPPopups.initSocialShortcodes();
121      $(document).trigger('wppopupsReady');
122    },
123
124    /**
125     * Page load.
126     *
127     * @since 2.0.0
128     */
129    load: function load() {
130      // center again once it's loaded
131      $(".spu-box").each(function () {
132        var $popup = $(this);
133        WPPopups.centerPopup($popup);
134      });
135    },
136    ajaxStart: function ajaxStart() {
137      $(".spu-box").each(function () {
138        var $popup = $(this),
139            $need_ajax = $popup.data('need_ajax');
140
141        if (!$need_ajax) {
142          return;
143        }
144
145        WPPopups.initPopup($popup);
146      });
147      $(document).trigger('wppopupsAjaxStarted');
148    },
149
150    /**
151     * Configure each popup
152     */
153    initPopup: function initPopup($popup) {
154      var $id = $popup.data('id'); // Save popup for later
155
156      WPPopups.popups[$id] = $popup; // all triggers added by users
157
158      WPPopups.bindPopupTriggers($popup); // click triggers
159
160      WPPopups.bindClickTriggers($popup); // Forms inside popups
161
162      WPPopups.formSubmissions($popup); // Forms Email Marketing
163      //WPPopups.formOptinSubmissions($popup);
164      // Events bindings
165
166      $(window).resize(function () {
167        WPPopups.checkPopupSize($popup);
168        WPPopups.centerPopup($popup);
169      });
170      $popup.find('input').on('change', function () {
171        WPPopups.checkPopupSize($popup);
172      }); // This hook will be used by third parties
173
174      window.wp.hooks.doAction('wppopups_loop', $popup);
175      window.wp.hooks.addAction('wppopups_show_popup', 'wppopups', WPPopups.centerPopup, 99); // hide it
176
177      $popup.hide();
178    },
179    // --------------------------------------------------------------------//
180    // Triggers
181    // --------------------------------------------------------------------//
182
183    /**
184    * Trigger popup after N seconds
185     * @param value
186     * @param $popup
187     */
188    triggerBySeconds: function triggerBySeconds(value, $popup) {
189      // if not value provided abort
190      if (value === '') {
191        return;
192      }
193
194      if ($popup.timer) {
195        clearTimeout($popup.timer);
196      }
197
198      $popup.timer = window.setTimeout(function () {
199        if (WPPopups.checkConvertion($popup)) {
200          WPPopups.showPopup($popup);
201        }
202      }, parseInt(value, 10) * 1000);
203    },
204
205    /**
206    * Trigger if scroll % amount of screen
207     * @param value
208     * @param $popup
209     */
210    triggerByPercentage: function triggerByPercentage(value, $popup) {
211      // if not value provided abort
212      if (value === '') {
213        return;
214      }
215
216      var $settings = WPPopups.settings($popup, 'settings'); // use custom namespace bind for off later
217
218      $(window).on('scroll.per' + $popup.data('id'), function () {
219        if ($popup.timer) {
220          clearTimeout($popup.timer);
221        }
222
223        $popup.timer = window.setTimeout(function () {
224          var triggerHeight = parseInt(value, 10) / 100 * $(document).height();
225          var scrollY = $(window).scrollTop(),
226              trigger = scrollY + $(window).height() >= triggerHeight; // show box when criteria for this box is matched
227
228          if (trigger && WPPopups.checkConvertion($popup)) {
229            // remove listen event if box shouldn't be hidden again. TODO: add auto hide in trigger settings
230            if (!$settings.auto_hide) {
231              $(window).off('scroll.per' + $popup.data('id'));
232            }
233
234            WPPopups.showPopup($popup);
235          } else if ($settings.auto_hide) {
236            WPPopups.hidePopup($popup, false, 10, false);
237          }
238        }, 100);
239      });
240    },
241
242    /**
243    * Bind TRigger after user scrolled X pixels
244     * @param value
245     * @param $popup
246     */
247    triggerByPixels: function triggerByPixels(value, $popup) {
248      // if not pixels provided abort
249      if (value === '') {
250        return;
251      }
252
253      var $settings = WPPopups.settings($popup, 'settings');
254      $(window).on('scroll.pix' + $popup.data('id'), function () {
255        if ($popup.timer) {
256          clearTimeout($popup.timer);
257        }
258
259        $popup.timer = window.setTimeout(function () {
260          var scrollY = $(window).scrollTop(),
261              trigger = scrollY >= parseInt(value, 10); //triggerSeconds equals to the number field really
262          // show box when criteria for this box is matched
263
264          if (trigger && WPPopups.checkConvertion($popup)) {
265            // remove listen event if box shouldn't be hidden again
266            if (!$settings.auto_hide) {
267              $(window).off('scroll.pix' + $popup.data('id'));
268            }
269
270            WPPopups.showPopup($popup);
271          } else if ($settings.auto_hide) {
272            WPPopups.hidePopup($popup, false, 10, false);
273          }
274        }, 100);
275      });
276    },
277    triggerByClass: function triggerByClass(value, $popup) {
278      // if not class provided abort
279      if (value === '') {
280        return;
281      } // add . to class attribute if missing
282
283
284      value = value.charAt(0) != '.' ? '.' + value : value;
285      WPPopups.setBindActions(value, 'class'); // Only add the trigger if not cookies are set for popup
286
287      if (WPPopups.hasCookies($popup)) {
288        return;
289      }
290
291      $(document.body).on('click', value, function (e) {
292        e.preventDefault();
293        WPPopups.showPopup($popup);
294      });
295    },
296    // --------------------------------------------------------------------//
297    // Binds
298    // --------------------------------------------------------------------//
299
300    /**
301    * Bind document triggers for popups
302     * @param $popup
303     */
304    bindClickTriggers: function bindClickTriggers($popup) {
305      var id = $popup.data('id');
306      WPPopups.setBindActions('.spu-open-' + id, 'class');
307      WPPopups.setBindActions('#spu-' + id, 'href'); // Only add the trigger if not cookies are set for popup
308
309      if (WPPopups.hasCookies($popup)) {
310        return;
311      } // add link listener for this box
312
313
314      $(document.body).on('click', 'a[href="#spu-' + id + '"], .spu-open-' + id, function (e) {
315        e.preventDefault();
316        WPPopups.showPopup($popup, true);
317      });
318      $('a[href="#spu-' + id + '"], .spu-open-' + id).css('cursor', 'pointer').addClass('spu-clickable');
319    },
320
321    /**
322    * Bind triggers set in popup settings
323     * @param $popup
324     */
325    bindPopupTriggers: function bindPopupTriggers($popup) {
326      if (window.wp.hooks.applyFilters('wppopups_disable_triggers', false, $popup)) return;
327      var $triggers = WPPopups.settings($popup, 'triggers');
328
329      if (Object.keys($triggers).length) {
330        for (var i in $triggers) {
331          var func = 'triggerBy' + $triggers[i].trigger.charAt(0).toUpperCase() + $triggers[i].trigger.substr(1),
332              settings = WPPopups.settings($popup, 'settings');
333
334          if (!WPPopups.hasCookies($popup) || wppopups_vars.is_preview || func == 'triggerByClass' || wppopups_vars.is_admin && settings.test_mode == '1') {
335            // only try if func really exist , may be premium one
336            if (typeof WPPopups[func] == 'function') {
337              WPPopups[func]($triggers[i].value, $popup);
338            } // hook for premium
339
340
341            window.wp.hooks.doAction('wppopups_trigger_popup', func, $triggers[i].value, $popup);
342          }
343        }
344      }
345    },
346
347    /**
348    * Element bindings.
349    *
350    * @since 2.0.0
351    */
352    bindUIActions: function bindUIActions() {
353      // Custom links inside popups conversion
354      $(document).on('click', '.spu-box a:not(".spu-close-popup, .spu-box .flp_wrapper a, .spu-box .spu-not-close, .spu-box .spu-not-close a, .spu-box .spu-gdpr a")', function () {
355        // hide the popup and track conversion
356        WPPopups.hidePopup($(this), true);
357      }); // Close and convert button, similar to above
358
359      $(document).on('click', '.spu-box .spu-close-convert,.spu-box .spu-close-convert a', function (e) {
360        e.preventDefault(); // hide the popup and track conversion
361
362        WPPopups.hidePopup($(this), true);
363      }); //close popup
364
365      $(document).on('click', '.spu-box .spu-close-popup', function (e) {
366        e.preventDefault(); // hide box, no conversion
367
368        WPPopups.hidePopup($(this), false);
369      }); //close with esc
370
371      $(document).on('keyup', function (e) {
372        if (e.keyCode == 27) {
373          WPPopups.togglePopups(false, false);
374        }
375      }); // close by clicking outside of popup
376      // get event by device or browser
377
378      var ua = navigator.userAgent,
379          event = ua.match(/iPad/i) || ua.match(/iPhone/i) ? "touchstart" : "click";
380      $('body').on(event, function (ev) {
381        var $target = $(ev.target); // TODO:
382        // for some reason ninja form not working, added this dirty workaround
383        // $target.is('.spu-box *, .spu-box') return false, same for .has .parents, etc
384        // so no popup closing when form is clicked
385
386        if ($target.is('input.nf-element')) return; // Forminator datepicker and also others it may be needed
387
388        if ($target.is(window.wp.hooks.applyFilters('wppopups_disable_click_out_classes', '.flatpickr-calendar,.flatpickr-calendar *, .ui-datepicker-header *,.ui-widget,.ui-widget *'))) return; // verify if some bindAction is present
389
390        if (WPPopups.checkBindActions($target)) return;
391        if (window.wp.hooks.applyFilters('wppopups_disable_click_out', false, $target)) return; // test that event is user triggered and not programatically,
392        // and that it is not fired  within the box
393
394        if (ev.originalEvent !== undefined && !$target.is('.spu-box *, .spu-box')) {
395          WPPopups.togglePopups(false, false);
396        }
397      });
398    },
399
400    /**
401    * Return setting from popup
402     * @param popup
403     * @param key
404     * @returns {*}
405     */
406    settings: function settings(popup, key) {
407      var settings = {};
408
409      if (popup.data('settings')) {
410        settings = popup.data('settings');
411      }
412
413      if (key) {
414        if (typeof settings[key] == 'undefined') return {};
415        return settings[key];
416      }
417
418      return settings;
419    },
420
421    /**
422    * Wrapper to execute toggle box on all popups
423     * @param elements
424     * @param show
425     * @param conversion
426     */
427    togglePopups: function togglePopups(show, conversion) {
428      $('.spu-box').each(function () {
429        if (show) {
430          WPPopups.showPopup($(this));
431        } else {
432          // premium version may disable advanced closing methods which use tooglePopups
433          if (window.wp.hooks.applyFilters('wppopups_allow_togglePopups', true, $(this))) {
434            WPPopups.hidePopup($(this), conversion);
435          }
436        }
437      });
438    },
439
440    /**
441    * Show given popup
442     * @param popup
443     * @param forse true/false
444     * @returns {boolean}
445     */
446    showPopup: function showPopup(popup) {
447      var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
448      var $popup = WPPopups.getPopup(popup),
449          $id = $popup.data('id'),
450          $bg = $('#spu-bg-' + $id); // don't do anything if box is undergoing an animation or already visible
451
452      if ($popup.is(":visible")) {
453        return false;
454      } // don't do anything if popup has any cookie created
455
456
457      if (!force && WPPopups.hasCookies($popup)) {
458        return false;
459      } // if has gf, make it visible to properly center
460
461
462      var gf = $popup.find('.gform_wrapper');
463
464      if (gf) {
465        gf.show();
466      } // Hook before the popup it's shown
467
468
469      window.wp.hooks.doAction('wppopups_before_show_popup', $popup); // show container and the popup
470
471      $popup.parent('.wppopups-whole').show(); // Overlay Blur
472
473      WPPopups.toggleBlur($popup, true);
474      WPPopups.centerPopup($popup); // I want to stop  supporting social shortcodes, let's see how many complain
475
476      /* setTimeout(function(){
477           WPPopups.centerShortcodes($popup);
478       },1500);*/
479      // Add scroll if needed
480
481      WPPopups.checkPopupSize($popup); // show box
482
483      var animation = WPPopups.settings($popup, 'animation');
484
485      switch (animation.animation) {
486        case 'fade':
487          $popup.hide().fadeIn('slow');
488          break;
489
490        case 'slide':
491          $popup.hide().slideDown('slow');
492          break;
493
494        default:
495          $popup.show();
496          break;
497      } //background only if not bottom/top bars
498
499
500      if (!$popup.hasClass('spu-position-top-bar') && !$popup.hasClass('spu-position-bottom-bar')) {
501        if (animation.animation === 'disable') {
502          $bg.show();
503        } else {
504          $bg.fadeIn();
505        }
506      } // Hook for show popup, used for example for premium animations
507
508
509      window.wp.hooks.doAction('wppopups_show_popup', $popup); // show videos if any
510
511      WPPopups.toggleVideoSources($popup, true); // trigger opening
512
513      $popup.trigger('wppopups.popup_opened', [$id]);
514    },
515
516    /**
517    * Hide given popup
518     * @param popup
519     * @param conversion
520     * @param time
521     * @returns {boolean}
522     */
523    hidePopup: function hidePopup(popup, conversion) {
524      var time = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
525      var cookie = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
526      var $popup = WPPopups.getPopup(popup),
527          $id = $popup.data('id'),
528          $bg = $('#spu-bg-' + $id); // don't do anything if box is undergoing an animation or already visible
529
530      if ($popup.is(":animated") || $popup.is(":hidden") || window.wp.hooks.applyFilters('wppopups_cancel_hide', false, $popup, conversion)) {
531        return false;
532      } // save cookie
533
534
535      if (conversion === true) {
536        WPPopups.popupConverted($popup, cookie);
537      }
538
539      var settings = WPPopups.settings($popup, 'settings');
540
541      if (settings.close_on_conversion == '1' && conversion || !conversion) {
542        setTimeout(function () {
543          var animation = WPPopups.settings($popup, 'animation'); // Hide with animation
544
545          switch (animation.animation) {
546            case 'slide':
547              $popup.slideUp('slow');
548              $bg.fadeOut();
549              break;
550
551            case 'disable':
552              $popup.hide();
553              $bg.hide();
554              break;
555
556            default:
557              $popup.removeClass('spu-animation-animated');
558              $popup.fadeOut('slow');
559              $bg.fadeOut();
560              break;
561          } // Hook for show popup, used for example for premium animations
562
563
564          window.wp.hooks.doAction('wppopups_hide_popup', $popup); // hide videos if any
565
566          WPPopups.toggleVideoSources($popup, false);
567        }, parseInt(time, 10));
568      } // Overlay Blur
569
570
571      WPPopups.toggleBlur($popup, false); // save cookie
572
573      WPPopups.popupClosed($popup, cookie);
574    },
575    centerPopup: function centerPopup(popup, animate) {
576      if (!popup.hasClass('spu-position-centered') && !popup.hasClass('spu-position-float-right') && !popup.hasClass('spu-position-float-left')) {
577        return;
578      }
579
580      if (popup.is(':animated')) {
581        return;
582      }
583
584      var ww = $(window).width(),
585          wh = $(window).height(),
586          pw = popup.outerWidth(),
587          ph = popup.outerHeight(); // To center the box
588
589      var boxLeft = ww / 2 - pw / 2,
590          boxTop = wh / 2 - ph / 2;
591      var css = {
592        top: boxTop
593      };
594
595      if (popup.hasClass('spu-position-centered')) {
596        css.left = boxLeft;
597      }
598
599      if (animate) {
600        popup.animate(css, {
601          queue: !1,
602          duration: 200
603        });
604      } else {
605        popup.css(css);
606      }
607    },
608
609    /**
610     * Removes the popup from DOM
611     * @param $popup
612     */
613    removePopup: function removePopup(popup) {
614      var $popup = WPPopups.getPopup(popup),
615          $id = $popup.data('id'),
616          $bg = $('#spu-bg-' + $id),
617          $css = $('#spu-css-' + $id);
618      $popup.remove();
619      $bg.remove();
620      $css.remove();
621    },
622
623    /**
624     * Track popup conversion (save cookie)
625     * @param $popup
626     */
627    popupConverted: function popupConverted($popup) {
628      var cookie = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
629
630      if (cookie) {
631        // set cookie
632        var settings = WPPopups.settings($popup, 'settings'),
633            duration = parseFloat(settings.conversion_cookie_duration),
634            _cookie = settings.conversion_cookie_name,
635            type = settings.conversion_cookie_type;
636
637        if (duration > 0) {
638          WPPopups.createCookie(_cookie, true, duration, type);
639        }
640      }
641
642      $popup.trigger('wppopups.popup_converted', [$popup.data('id')]);
643    },
644
645    /**
646     * Track popup closing (save cookie)
647     * @param $popup
648     */
649    popupClosed: function popupClosed($popup) {
650      var cookie = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
651
652      if (cookie) {
653        // set cookie
654        var settings = WPPopups.settings($popup, 'settings'),
655            duration = parseFloat(settings.closing_cookie_duration),
656            _cookie2 = settings.closing_cookie_name,
657            type = settings.closing_cookie_type;
658
659        if (duration > 0) {
660          WPPopups.createCookie(_cookie2, true, duration, type);
661        }
662      }
663
664      $popup.trigger('wppopups.popup_closed', [$popup.data('id')]);
665    },
666
667    /**
668     * Check if the popup has any cookies created.
669     * @param $popup
670     */
671    hasCookies: function hasCookies($popup) {
672      var $settings = WPPopups.settings($popup, 'settings'),
673          conversion_name = $settings.conversion_cookie_name,
674          closing_name = $settings.closing_cookie_name;
675      var hasCookies = false;
676
677      if (!(wppopups_vars.is_admin && $settings.test_mode == '1') && (WPPopups.getCookie(conversion_name) || WPPopups.getCookie(closing_name))) {
678        hasCookies = true;
679      }
680
681      return hasCookies;
682    },
683
684    /**
685     * Apply Overlay Blur
686     * @param  $popup
687     * @param  show   true/false
688     * @return        
689     */
690    toggleBlur: function toggleBlur($popup, show) {
691      // Overlay Blur
692      var colors = WPPopups.settings($popup, 'colors'),
693          $id = $popup.data('id'),
694          $box_css = $('#spu-css-' + $id);
695
696      if (colors.show_overlay == 'yes-blur') {
697        if (show) {
698          var blur_px = colors.overlay_blur ? colors.overlay_blur : 2,
699              blur_css = '/* ini:blur */body > *:not(.wppopups-whole) { -webkit-filter: blur(' + blur_px + 'px); -moz-filter: blur(' + blur_px + 'px); -o-filter: blur(' + blur_px + 'px); -ms-filter: blur(' + blur_px + 'px); filter: blur(' + blur_px + 'px); }/* fin:blur */';
700          $box_css.append(blur_css);
701        } else {
702          var css = $box_css.text(),
703              ini = css.indexOf('/* ini:blur */'),
704              pro = css.substring(ini);
705          $box_css.text(css.replace(pro, ''));
706        }
707      }
708    },
709
710    /**
711    * Check all iframes and set source to empty on page load
712     */
713    initVideoSources: function initVideoSources() {
714      var iframe = $('.spu-box iframe');
715
716      if (iframe && iframe.length) {
717        iframe.each(function () {
718          WPPopups.initSources($(this));
719        });
720      }
721
722      var video = $('.spu-box video');
723
724      if (video && video.length) {
725        video.each(function () {
726          WPPopups.initSources($(this));
727        });
728      }
729    },
730    initSources: function initSources(el) {
731      var iframeSrc = el.attr('src');
732
733      if (iframeSrc && iframeSrc.indexOf('recaptcha') !== -1) {// do nothing
734      } else {
735        el.attr('spusrc', iframeSrc);
736        el.attr('src', 'https://#');
737      }
738    },
739
740    /**
741    * Toggle a popup iframe source
742     * @param popup
743     * @param show
744     */
745    toggleVideoSources: function toggleVideoSources(popup, show) {
746      var iframe = popup.find('iframe');
747
748      if (iframe && iframe.length) {
749        iframe.each(function () {
750          WPPopups.toggleSource($(this), show);
751        });
752      }
753
754      var video = popup.find('video');
755
756      if (video && video.length) {
757        video.each(function () {
758          WPPopups.toggleSource($(this), show);
759        });
760      }
761    },
762    toggleSource: function toggleSource(el, show) {
763      if (show) {
764        if (el.attr('spusrc')) {
765          el.attr('src', el.attr('spusrc'));
766          el.css("width", "");
767          el.css("height", "");
768        }
769      } else {
770        var iframeSrc = el.attr('src');
771
772        if (iframeSrc && iframeSrc.indexOf('recaptcha') !== -1) {// do nothing
773        } else {
774          // destroy videos so they stop playing
775          el.attr('src', 'https://#');
776        }
777      }
778    },
779
780    /**
781    * remove paddings and margins from first and last items inside popups
782    * so it looks even with the given padding
783     */
784    resetPopupsContent: function resetPopupsContent() {
785      $(".spu-content").children().first().not('.spu-fields-container').css({
786        "margin-top": 0,
787        "padding-top": 0
788      }).end().last().not('.spu-fields-container').css({
789        'margin-bottom': 0,
790        'padding-bottom': 0
791      });
792    },
793
794    /**
795     * Trigger popup opening if anyone use #spu-open-123 in url
796     */
797    hashTriggerPopups: function hashTriggerPopups() {
798      // shows the box when hash refers to a box
799      if (window.location.hash && window.location.hash.length > 0) {
800        var hash = window.location.hash,
801            form_key = hash.substring(1).indexOf('spu-form'),
802            link_key = hash.substring(1).indexOf('spu-open'),
803            form_popup = form_key !== -1,
804            link_popup = link_key !== -1;
805        if (form_popup) var i = form_key + 10;else if (link_popup) var i = link_key + 10;
806
807        if ((link_popup || form_popup) && $('#spu-' + hash.substring(i)).is('.spu-box')) {
808          var popup = $('#spu-' + hash.substring(i)); // if triggered by a form add a close button if don't exist already one
809
810          if (form_popup && popup.find('.spu-close-popup').length < 2) {
811            popup.find('.spu-content').append('<p style="text-align: center"><button class="btn btn-primary spu-close-popup">Close</button></p>');
812          } // unbind regular triggers and set conversion
813
814
815          if (form_popup) {
816            $(window).off('scroll.per' + popup.data('id'));
817            $(window).off('scroll.pix' + popup.data('id'));
818            WPPopups.popupConverted(popup);
819          }
820
821          setTimeout(function () {
822            WPPopups.showPopup(popup, true);
823          }, 200);
824        }
825      }
826    },
827
828    /**
829    * Handle form submissions in two ways. Adding ajax most known forms callbacks
830     * and adding #spu-form to action for regular forms that will open on page load
831     * @param $popup
832     */
833    formSubmissions: function formSubmissions($popup) {
834      var popup_id = $popup.data('id');
835      $popup.find('form').each(function () {
836        var box_form = $(this),
837            action = box_form.attr('action') || '';
838
839        if (!wppopups_vars.disable_form_reopen) {
840          box_form.attr('action', action + '#spu-form-' + popup_id);
841        } // only run if not our form
842
843
844        if (box_form.hasClass('spu-optin-form')) {
845          return;
846        } // If url is external, we need to track popup before submission
847
848
849        if (WPPopups.isExternal(action)) {
850          box_form.on('submit', function () {
851            WPPopups.hidePopup($popup, true);
852          });
853        }
854      }); // Ninja forms don't use form elements O_o
855
856      $(document).on('nfFormSubmitResponse', function () {
857        $popup.trigger('wppopups.form_submitted', [popup_id]);
858        WPPopups.hidePopup($popup, true, 2000);
859      }); // Forminator
860
861      $(document).on('forminator:form:submit:success', function () {
862        $popup.trigger('wppopups.form_submitted', [popup_id]);
863        WPPopups.hidePopup($popup, true, 2000);
864      }); // Contact form 7
865
866      $popup.on('wpcf7mailsent', function () {
867        $popup.trigger('wppopups.form_submitted', [popup_id]);
868        WPPopups.hidePopup($popup, true, 2000);
869      }); // Gravity forms (ajax mode)
870
871      $(document).on('gform_post_render', function (jqXHR, form_id) {
872        var $form = $('#gform_ajax_frame_' + form_id);
873
874        if (!$form.is('.spu-box *')) {
875          return;
876        }
877
878        var contents = $form.contents().find('*').html(),
879            form_content = $form.contents().find('#gform_wrapper_' + form_id),
880            is_confirmation = $form.contents().find('#gform_confirmation_wrapper_' + form_id).length > 0,
881            is_redirect = contents.indexOf('gformRedirect(){') >= 0;
882
883        if (is_confirmation || is_redirect) {
884          $popup.trigger('wppopups.form_submitted', [popup_id]);
885          WPPopups.hidePopup($popup, true, 2000);
886        }
887      }); // Caldera Forms (ajax mode)
888
889      $(document).on('cf.submission', function () {
890        $popup.trigger('wppopups.form_submitted', [popup_id]);
891        WPPopups.hidePopup($popup, true, 2000);
892      }); // WPForms (ajax mode)
893
894      $(document).on('wpformsAjaxSubmitSuccess', function () {
895        $popup.trigger('wppopups.form_submitted', [popup_id]);
896        WPPopups.hidePopup($popup, true, 2000);
897      }); // Yikes form
898
899      $(document).on('yikes_mailchimp_ajax_submission', function (e, response) {
900        if (response.success) {
901          $popup.trigger('wppopups.form_submitted', [popup_id]);
902          WPPopups.hidePopup($popup, true, 2000);
903        }
904      });
905    },
906
907    /**
908     * Check if url is external
909     * @param url
910     * @returns {boolean}
911     */
912    isExternal: function isExternal(url) {
913      if (url.length === 0) {
914        return false;
915      }
916
917      var domain = function domain(url) {
918        return url.replace('http://', '').replace('https://', '').split('/')[0];
919      };
920
921      if (domain(url) == '') {
922        return false;
923      }
924
925      return domain(location.href) !== domain(url);
926    },
927
928    /**
929     * Forms to Email Marketing
930     * @param $popup
931     */
932    formOptinSubmissions: function formOptinSubmissions($popup) {
933      var popup_id = $popup.data('id'),
934          $form = $popup.find('.wppopups-form'),
935          $submit_btn = $form.find('.wppopups-submit-button');
936      WPPopups.toggleButton($submit_btn, true);
937      var data = $form.serializeArray();
938      data.push({
939        name: 'action',
940        value: 'wppopups_optin_submit'
941      });
942      data.push({
943        name: 'id',
944        value: popup_id
945      });
946      var ajax = {
947        url: wppopups_vars.ajax_url,
948        data: data,
949        cache: false,
950        type: 'POST',
951        dataType: 'json',
952        timeout: 30000,
953        success: function success(r) {
954          console.log(r);
955
956          if (r.success) {
957            // redirect if set in settings
958            if (r.data[1] && r.data[1].optin_redirect) {
959              $popup.trigger('wppopups.optin_on_redirect', [popup_id]);
960              var redirect = r.data[1].optin_redirect;
961
962              if (r.data[1].pass_lead_data && r.data[1].pass_lead_data == 1) {
963                var qstring = [];
964                var sep = redirect.match(/[\?]/g) ? '&' : '?';
965
966                for (var key in data) {
967                  if (data[key]['value'] == '') continue;
968                  qstring.push(encodeURIComponent(data[key]['name']) + '=' + encodeURIComponent(data[key]['value']));
969                }
970
971                redirect = redirect + sep + qstring.join('&');
972              }
973
974              WPPopups.hidePopup($popup, true);
975              window.location.href = redirect;
976              return;
977            } // clear errors
978
979
980            $popup.find('.optin-errors').html('').hide(); // success message
981
982            if (r.data[0] && r.data[0].optin_success) {
983              WPPopups.popupConverted($popup);
984              $popup.find('.spu-content').html(r.data[0].optin_success);
985              WPPopups.centerPopup($popup, true);
986
987              if (r.data[0].optin_success_seconds && parseInt(r.data[0].optin_success_seconds) > 0) {
988                var seconds = parseInt(r.data[0].optin_success_seconds, 10) * 1000;
989                WPPopups.hidePopup($popup, false, seconds);
990              }
991            } else {
992              WPPopups.hidePopup($popup, true);
993            }
994          } else {
995            $popup.find('.optin-errors').html(r.data).fadeIn();
996          }
997
998          $popup.trigger('wppopups.optin_form_submitted', [popup_id, r]);
999          WPPopups.toggleButton($submit_btn, false);
1000        },
1001        error: function error(r) {
1002          console.log(r);
1003          WPPopups.toggleButton($submit_btn, false);
1004        }
1005      };
1006      $.ajax(ajax);
1007    },
1008    loadValidation: function loadValidation() {
1009      // Only load if jQuery validation library exists.
1010      if (typeof $.fn.validate !== 'undefined') {
1011        // Prepend URL field contents with http:// if user input doesn't contain a schema.
1012        $('.wppopups-validate input[type=url]').change(function () {
1013          var url = $(this).val();
1014
1015          if (!url) {
1016            return false;
1017          }
1018
1019          if (url.substr(0, 7) !== 'http://' && url.substr(0, 8) !== 'https://') {
1020            $(this).val('http://' + url);
1021          }
1022        });
1023        $.validator.messages.required = wppopups_vars.val_required;
1024        $.validator.messages.url = wppopups_vars.val_url;
1025        $.validator.messages.email = wppopups_vars.val_email;
1026        $.validator.messages.number = wppopups_vars.val_number; // Validate email addresses.
1027
1028        $.validator.methods.email = function (value, element) {
1029          return this.optional(element) || /^[a-z0-9.!#$%&'*+\/=?^_`{|}~-]+@((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}$/i.test(value);
1030        }; // Validate checkbox choice limit.
1031
1032
1033        $.validator.addMethod('check-limit', function (value, element) {
1034          var $ul = $(element).closest('ul'),
1035              $checked = $ul.find('input[type="checkbox"]:checked'),
1036              choiceLimit = parseInt($ul.attr('data-choice-limit') || 0, 10);
1037
1038          if (0 === choiceLimit) {
1039            return true;
1040          }
1041
1042          return $checked.length <= choiceLimit;
1043        }, function (params, element) {
1044          var choiceLimit = parseInt($(element).closest('ul').attr('data-choice-limit') || 0, 10);
1045          return wppopups_vars.val_checklimit.replace('{#}', choiceLimit);
1046        }); // Finally load jQuery Validation library for our forms.
1047
1048        $('.wppopups-validate').each(function () {
1049          var form = $(this),
1050              popupID = form.data('popupid'),
1051              properties; // TODO: cleanup this BC with wppopups_validate.
1052
1053          if (typeof window['wppopups_' + popupID] !== 'undefined' && window['wppopups_' + popupID].hasOwnProperty('val
1053idate')) {
1054            properties = window['wppopups_' + popupID].validate;
1055          } else if (typeof wppopups_validate !== 'undefined') {
1056            properties = wppopups_validate;
1057          } else {
1058            properties = {
1059              errorClass: 'wppopups-error',
1060              validClass: 'wppopups-valid',
1061              errorPlacement: function errorPlacement(error, element) {
1062                if ('radio' === element.attr('type') || 'checkbox' === element.attr('type')) {
1063                  if (element.hasClass('wppopups-likert-scale-option')) {
1064                    if (element.closest('table').hasClass('single-row')) {
1065                      element.closest('table').after(error);
1066                    } else {
1067                      element.closest('tr').find('th').append(error);
1068                    }
1069                  } else if (element.hasClass('wppopups-net-promoter-score-option')) {
1070                    element.closest('table').after(error);
1071                  } else {
1072                    element.closest('.wppopups-field-checkbox').find('label.wppopups-error').remove();
1073                    element.parent().parent().parent().append(error);
1074                  }
1075                } else if (element.is('select') && element.attr('class').match(/date-month|date-day|date-year/)) {
1076                  if (0 === element.parent().find('label.wppopups-error:visible').length) {
1077                    element.parent().find('select:last').after(error);
1078                  }
1079                } else if (element.hasClass('wppopups-smart-phone-field')) {
1080                  element.parent().after(error);
1081                } else if (element.hasClass('wppopups-validation-group-member')) {
1082                  element.closest('.wppopups-field').append(error);
1083                } else {
1084                  error.insertAfter(element);
1085                }
1086              },
1087              highlight: function highlight(element, errorClass, validClass) {
1088                var $element = $(element),
1089                    $field = $element.closest('.wppopups-field'),
1090                    inputName = $element.attr('name');
1091
1092                if ('radio' === $element.attr('type') || 'checkbox' === $element.attr('type')) {
1093                  $field.find('input[name="' + inputName + '"]').addClass(errorClass).removeClass(validClass);
1094                } else {
1095                  $element.addClass(errorClass).removeClass(validClass);
1096                }
1097
1098                $field.addClass('wppopups-has-error');
1099              },
1100              unhighlight: function unhighlight(element, errorClass, validClass) {
1101                var $element = $(element),
1102                    $field = $element.closest('.wppopups-field'),
1103                    inputName = $element.attr('name');
1104
1105                if ('radio' === $element.attr('type') || 'checkbox' === $element.attr('type')) {
1106                  $field.find('input[name="' + inputName + '"]').addClass(validClass).removeClass(errorClass);
1107                } else {
1108                  $element.addClass(validClass).removeClass(errorClass);
1109                }
1110
1111                $field.removeClass('wppopups-has-error');
1112              },
1113              submitHandler: function submitHandler(form) {
1114                var $popup = $('#spu-' + popupID);
1115                WPPopups.formOptinSubmissions($popup);
1116              },
1117              invalidHandler: function invalidHandler(event, validator) {//if ( typeof validator.errorList[0] !== 'undefined' ) {
1118                //    app.scrollToError( $( validator.errorList[0].element ) );
1119                //}
1120              },
1121              onkeyup: function onkeyup(element, event) {
1122                // This code is copied from JQuery Validate 'onkeyup' method with only one change: 'wppopups-novalidate-onkeyup' class check.
1123                var excludedKeys = [16, 17, 18, 20, 35, 36, 37, 38, 39, 40, 45, 144, 225];
1124
1125                if ($(element).hasClass('wppopups-novalidate-onkeyup')) {
1126                  return; // Disable onkeyup validation for some elements (e.g. remote calls).
1127                }
1128
1129                if (9 === event.which && '' === this.elementValue(element) || $.inArray(event.keyCode, excludedKeys) !== -1) {
1130                  return;
1131                } else if (element.name in this.submitted || element.name in this.invalid) {
1132                  this.element(element);
1133                }
1134              },
1135              onfocusout: function onfocusout(element) {
1136                // This code is copied from JQuery Validate 'onfocusout' method with only one change: 'wppopups-novalidate-onkeyup' class check.
1137                var validate = false;
1138
1139                if ($(element).hasClass('wppopups-novalidate-onkeyup') && !element.value) {
1140                  validate = true; // Empty value error handling for elements with onkeyup validation disabled.
1141                }
1142
1143                if (!this.checkable(element) && (element.name in this.submitted || !this.optional(element))) {
1144                  validate = true;
1145                }
1146
1147                if (validate) {
1148                  this.element(element);
1149                }
1150              },
1151              onclick: function onclick(element) {
1152                var validate = false,
1153                    type = (element || {}).type,
1154                    $el = $(element);
1155
1156                if (['checkbox', 'radio'].indexOf(type) > -1) {
1157                  if ($el.hasClass('wppopups-likert-scale-option')) {
1158                    $el = $el.closest('tr');
1159                  } else {
1160                    $el = $el.closest('.wppopups-field');
1161                  }
1162
1163                  $el.find('label.wppopups-error').remove();
1164                  validate = true;
1165                }
1166
1167                if (validate) {
1168                  this.element(element);
1169                }
1170              }
1171            };
1172          }
1173
1174          form.validate(properties);
1175        });
1176      }
1177    },
1178
1179    /**
1180     * Helper func to toggle optin button
1181     * @param $submit_btn
1182     * @param disable
1183     */
1184    toggleButton: function toggleButton($submit_btn, disable) {
1185      var oldText = $submit_btn.data('submit-text'),
1186          altText = $submit_btn.data('alt-text');
1187
1188      if (disable) {
1189        // Display processing text.
1190        if (altText) {
1191          $submit_btn.text(altText);
1192        }
1193
1194        $submit_btn.addClass('spu-sending');
1195        $submit_btn.attr('disabled', 'disabled');
1196      } else {
1197        if (oldText) {
1198          $submit_btn.text(oldText);
1199        }
1200
1201        $submit_btn.removeClass('spu-sending');
1202        $submit_btn.removeAttr('disabled');
1203      }
1204    },
1205
1206    /**
1207     * Check if popup it's bigger than windows to add scroll bars
1208     * @param $popup
1209     */
1210    checkPopupSize: function checkPopupSize($popup) {
1211      // add 150 to give some margins on top/bottom
1212      if ($popup.outerHeight() + 150 >= $(window).height()) {
1213        $popup.css('overflow', 'auto').addClass('spu-scrollable');
1214        $popup.css('max-height', $(window).height());
1215      } else {
1216        $popup.css('overflow', 'initial').removeClass('spu-scrollable');
1217        $popup.css('max-height', '');
1218      }
1219    },
1220    initSocialShortcodes: function initSocialShortcodes() {
1221      // if facebook being used on any popup
1222      if (wppopups_vars.facebook) {
1223        var SPUfb = false,
1224            FbTimer = setInterval(function () {
1225          if (typeof FB !== 'undefined' && !SPUfb) {
1226            try {
1227              FB.Event.subscribe('edge.create', function (href, html_element) {
1228                var $popup = $(html_element).parents('.spu-box');
1229
1230                if ($popup.length) {
1231                  WPPopups.hidePopup($popup, true);
1232                }
1233              });
1234            } catch (ex) {
1235              console.log(ex);
1236            }
1237
1238            SPUfb = true;
1239            clearInterval(FbTimer);
1240          }
1241        }, 1000);
1242      }
1243
1244      if (wppopups_vars.twitter) {
1245        if (typeof twttr !== 'undefined') {
1246          try {
1247            twttr.ready(function (twttr) {
1248              twttr.events.bind('tweet', WPPopups.twitterCB);
1249              twttr.events.bind('follow', WPPopups.twitterCB);
1250            });
1251          } catch (ex) {}
1252        }
1253      }
1254
1255      if (wppopups_vars.google) {
1256        if (typeof twttr !== 'undefined') {
1257          try {
1258            twttr.ready(function (twttr) {
1259              twttr.events.bind('tweet', WPPopups.twitterCB);
1260              twttr.events.bind('follow', WPPopups.twitterCB);
1261            });
1262          } catch (ex) {}
1263        }
1264      }
1265    },
1266    googleCB: function googleCB(a) {
1267      if ("on" == a.state) {
1268        var box_id = $('.spu-gogl').data('box-id');
1269
1270        if (box_id) {
1271          WPPopups.hidePopup(box_id, true);
1272        }
1273      }
1274    },
1275    closeGoogle: function closeGoogle(a) {
1276      if ("confirm" == a.type) {
1277        var box_id = $('.spu-gogl').data('box-id');
1278
1279        if (box_id) {
1280          WPPopups.hidePopup(box_id, true);
1281        }
1282      }
1283    },
1284
1285    /**
1286     * Twitter callback function
1287     * @param intent_event
1288     */
1289    twitterCB: function twitterCB(intent_event) {
1290      var $popup = $(intent_event.target).parents('.spu-box');
1291
1292      if ($popup) {
1293        WPPopups.hidePopup($popup, true);
1294      }
1295    },
1296
1297    /**
1298     * Set cookie container user UUID.
1299     *
1300     */
1301    setUserIndentifier: function setUserIndentifier() {
1302      if (wppopups_settings.uuid_cookie && !WPPopups.getCookie('_wpfuuid')) {
1303        // Generate UUID - http://stackoverflow.com/a/873856/1489528
1304        var s = new Array(36),
1305            hexDigits = '0123456789abcdef',
1306            uuid;
1307
1308        for (var i = 0; i < 36; i++) {
1309          s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
1310        }
1311
1312        s[14] = "4";
1313        s[19] = hexDigits.substr(s[19] & 0x3 | 0x8, 1);
1314        s[8] = s[13] = s[18] = s[23] = '-';
1315        uuid = s.join("");
1316        WPPopups.createCookie('_wpfuuid', uuid, 3999);
1317      }
1318    },
1319
1320    /**
1321     * Set classes or href link in a global array
1322     * @param bind_name
1323     * @param bind_type
1324     */
1325    setBindActions: function setBindActions() {
1326      var bind_name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
1327      var bind_type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'class';
1328
1329      if (bind_name != '') {
1330        switch (bind_type) {
1331          case 'class':
1332            bind_name = bind_name.charAt(0) == '.' ? bind_name.substring(1) : bind_name;
1333            if ($.inArray(bind_name, WPPopups.byBind['class']) === -1) WPPopups.byBind['class'].push(bind_name);
1334            break;
1335
1336          case 'href':
1337            if ($.inArray(bind_name, WPPopups.byBind['href']) === -1) WPPopups.byBind['href'].push(bind_name);
1338            break;
1339        }
1340
1341        window.wp.hooks.doAction('wppopups_set_bindactions', bind_name, bind_type);
1342      }
1343    },
1344
1345    /**
1346     * Check if exists any BindActions when happen a event
1347     * @param target
1348     */
1349    checkBindActions: function checkBindActions(target) {
1350      var $classes = WPPopups.byBind['class'];
1351
1352      for (var i = 0; i < $classes.length; i++) {
1353        if ($classes[i]) {
1354          if (target.hasClass($classes[i]) || target.closest('.' + $classes[i]).length) {
1355            return true;
1356          }
1357        }
1358      }
1359
1360      var $href = WPPopups.byBind['href'];
1361
1362      for (var _i = 0; _i < $href.length; _i++) {
1363        if ($href[_i] && target.attr('href') == $href[_i]) {
1364          return true;
1365        }
1366      }
1367
1368      return false;
1369    },
1370
1371    /**
1372     * Create cookie.
1373     *
1374     * @since 2.0.0
1375     */
1376    createCookie: function createCookie(name, value) {
1377      var duration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 999;
1378      var type = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'd';
1379      var expires = ''; // If we have a duration value, set it in the expiry of the cookie.
1380
1381      if (duration && type) {
1382        // If -1 is our value, set a session based cookie instead of a persistent cookie.
1383        if ('-1' === duration) {
1384          expires = '';
1385        } else {
1386          var cookie_time;
1387
1388          switch (type) {
1389            case 'm':
1390              cookie_time = 60 * 1000;
1391              break;
1392
1393            case 'h':
1394              cookie_time = 60 * 60 * 1000;
1395              break;
1396
1397            default:
1398              cookie_time = 24 * 60 * 60 * 1000;
1399          }
1400
1401          var date = new Date();
1402          date.setTime(date.getTime() + parseInt(duration) * cookie_time);
1403          expires = '; expires=' + date.toGMTString();
1404        }
1405      } else {
1406        expires = '; expires=Thu, 01 Jan 1970 00:00:01 GMT';
1407      } // Write the cookie.
1408
1409
1410      document.cookie = name + '=' + value + expires + '; path=/';
1411    },
1412
1413    /**
1414     * Retrieve cookie.
1415     *
1416     * @since 2.0.0
1417     */
1418    getCookie: function getCookie(name) {
1419      var nameEQ = name + '=',
1420          ca = document.cookie.split(';');
1421
1422      for (var i = 0; i < ca.length; i++) {
1423        var c = ca[i];
1424
1425        while (c.charAt(0) === ' ') {
1426          c = c.substring(1, c.length);
1427        }
1428
1429        if (c.indexOf(nameEQ) == 0) {
1430          return c.substring(nameEQ.length, c.length);
1431        }
1432      }
1433
1434      return null;
1435    },
1436
1437    /**
1438     * Delete cookie.
1439     */
1440    removeCookie: function removeCookie(name) {
1441      WPPopups.createCookie(name, '', -1);
1442    },
1443
1444    /**
1445     * Check if it's a number. So (12) and ('12') will be good
1446     * @param n
1447     * @returns {boolean}
1448     */
1449    isNumber: function isNumber(n) {
1450      return !isNaN(parseFloat(n)) && !isNaN(n - 0);
1451    },
1452
1453    /**
1454     * Get a popup from a string, or selector or inner selector such as coming from event
1455     * @param popup
1456     */
1457    getPopup: function getPopup(popup) {
1458      if (WPPopups.isNumber(popup)) {
1459        return $('#spu-' + parseInt(popup));
1460      }
1461
1462      if (popup.is('.spu-box')) {
1463        return popup;
1464      }
1465
1466      return popup.closest('.spu-box');
1467    },
1468
1469    /**
1470     * Check if the popup has convertion rules and fire if needed
1471     * We need to runt his check on js because some popups fire when other convert in the same page load
1472     * Eg: Show exit popup A if popup B fails
1473     * @param $popup
1474     * @returns {boolean}
1475     */
1476    checkConvertion: function checkConvertion($popup) {
1477      // if no class trigger as normal
1478      if (!$popup.hasClass('yes-convert') && !$popup.hasClass('no-convert')) return true;
1479      var $settings = WPPopups.settings($('#spu-' + $popup.data('convert-id')), 'settings');
1480      var popup_converted = false;
1481
1482      if (WPPopups.getCookie($settings.conversion_cookie_name)) {
1483        popup_converted = true;
1484      }
1485
1486      if ($popup.hasClass('yes-convert')) {
1487        return popup_converted;
1488      } else {
1489        return !popup_converted;
1490      }
1491    },
1492    isMobile: function isMobile() {
1493      var Android = navigator.userAgent.match(/Android/i),
1494          BlackBerry = navigator.userAgent.match(/BlackBerry/i),
1495          iOS = navigator.userAgent.match(/iPhone|iPad|iPod/i),
1496          Opera = navigator.userAgent.match(/Opera Mini/i),
1497          Windows = navigator.userAgent.match(/IEMobile/i) || navigator.userAgent.match(/WPDesktop/i);
1498      return Android || BlackBerry || iOS || Opera || Windows;
1499    }
1500  }; // Initialize.
1501
1502  WPPopups.init(); // Add to global scope.
1503
1504  window.wppopups = WPPopups;
1505})(jQuery);

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.