PageSourceSearch

https://www.hologic.es/themes/custom/hologic/global/js/modal.js?tm4wcr

js hologic.es collected 2026-10-08 20:33:08 UTC 3,588 bytes, 94 lines download raw bytes

1(function ($, Drupal, once) {
2  'use strict';
3
4  Drupal.behaviors.ModalPriorToDownload = {
5    attach: function (context, settings) {
6
7      // Get url parameters and update the iframe source.
8      $(once('modal-container', '.modal-prior-to-download-container', context)).each(function(index) {
9        var closeModalButton = $(this).find('.coh-modal-close-button');
10        var openModalButton = $(this).find('#modal-prior-to-download-button');
11        var linktoDownload = $(this).find('.link-to-open-after-modal');
12        var hardGated = Boolean($(this).data('hard-gated'));
13
14        openModalButton.on( "click", function(e) {
15          // if the cookie is set with true value, remove attribute to show the modal and redirect the user to the link
16          if (hideModal(hardGated)) {
17            $(this).attr('data-modal-open', '')
18            $(this).attr('data-trigger', false)
19            linktoDownload[0].click();
20          }
21        });
22
23        closeModalButton.on( "click", function() {
24          setCookieOnCloseModal(hardGated)
25          // continue with the link
26          if (hideModal(hardGated)) {
27            linktoDownload[0].click();
28          }
29        });
30
31        // Action when the user click out of the form
32        //clickOutOfModal(isModalOpen, hardGated);
33
34        // Communication with Pardot
35        window.addEventListener("message", receiveMessage, false);
36      });
37
38      function receiveMessage(event) {
39        // Form was submitted and validated
40        if (event.data && event.data.message === "PARDOT_FORM_SUCCESS") {
41          Cookies.set('hide-modal', true, { expires: Infinity });
42          Cookies.set('modal-success', true, { expires: Infinity });
43          $('#modal-prior-to-download_heading').hide()
44          $('#modal-prior-to-download_subheading').hide()
45        }
46      }
47
48      function hideModal(hardGated){
49        var hideModal = Cookies.get('hide-modal');
50        var hide = typeof hideModal === 'undefined' ? false : hideModal;
51        if (hardGated) {
52          var modalSuccess = Cookies.get('modal-success');
53          hide = typeof modalSuccess === 'undefined' ? false : modalSuccess;
54        }
55
56        return hardGated ? hide : true;
57      }
58
59      function getCookieAttempts(){
60        var cookieAttempts = Cookies.get('modal-prior-to-download-attempts');
61        return typeof cookieAttempts === 'undefined' ? false : Number(cookieAttempts);
62      }
63
64      function setCookieOnCloseModal(hardGated){
65        var cookieAttempts = getCookieAttempts();
66        if (!hideModal(hardGated)) {
67          if (cookieAttempts && cookieAttempts === 3) {
68            // Remove cookie when the hide modal cookie expired, init again
69            Cookies.remove('modal-prior-to-download-attempts');
70            Cookies.set('hide-modal', true, { expires: 60 });
71          } else {
72            cookieAttempts = cookieAttempts ? (cookieAttempts + 1) : 1
73            Cookies.set('modal-prior-to-download-attempts', cookieAttempts, { expires: Infinity });
74            Cookies.set('hide-modal', true, { expires: 1 });
75          }
76        }
77      }
78
79      function clickOutOfModal(isModalOpen, hardGated){
80        // Close menu on click outside of the mega menu
81        document.addEventListener("click", (e) => {
82          // Check if the filter list parent element exist
83          var isClosest = e.target.closest('.is-open', context);
84
85          // If `isClosest` equals falsy then hide the modal
86          if (!isClosest) {
87            setCookieOnCloseModal(hardGated)
88          }
89        });
90      }
91    }
92  };
93
94})(jQuery, Drupal, once);

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.