Advertisement
NikolayBezay

Partner show address validation campaign

Oct 25th, 2021
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.20 KB | None | 0 0
  1. <script>
  2. (function () {
  3.     if (window.Element && !Element.prototype.closest) {
  4.        Element.prototype.closest = function(s) {
  5.            var matches = (this.document || this.ownerDocument).querySelectorAll(s),
  6.                i,
  7.                el = this;
  8.             do {
  9.                 i = matches.length;
  10.                 while (--i >= 0 && matches.item(i) !== el) {};
  11.             } while ((i < 0) && (el = el.parentElement));
  12.            return el;
  13.        };
  14.    }
  15.  
  16.    var i = 100;
  17.  
  18.    function waitForHideForm() {
  19.      var form = document.querySelector("#myForm");
  20.  
  21.      if (form.offsetHeight > 0 && i > 0) {
  22.        i--;
  23.  
  24.         setTimeout(waitForHideForm, 100);
  25.       } else {
  26.         var detailsBlock = document.querySelector('#AfibersSectionLead .sucMsg');
  27.  
  28.         if (detailsBlock && !detailsBlock.parentNode.parentNode.classList.contains('ng-hide')) {
  29.            adoric.trigger('address_valid');
  30.         }
  31.       }
  32.     }
  33.  
  34.     document.querySelector('body').addEventListener('click', function(event) {
  35.         var ctaButton = event.target.closest('#sendBtn');
  36.         if(ctaButton) {
  37.             waitForHideForm();
  38.         }
  39.     });
  40.   })();
  41. </script>
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement