<div class="mailpoet-deactivate-survey-modal" id="mailpoet-deactivate-survey-modal">
  <div class="mailpoet-deactivate-survey-wrap">
    <div class="mailpoet-deactivate-survey">

      <script type="text/javascript">
        window.addEventListener('load', function() {
          var deactivateLink = document.querySelector('#the-list [data-slug="mailpoet"] span.deactivate a');
          var overlay = document.querySelector('#mailpoet-deactivate-survey-modal');
          var closeButton = document.querySelector('#mailpoet-deactivate-survey-close');
          var participateButton = document.querySelector('#mailpoet-deactivate-survey-participate');
          var formOpen = false;

          if (!deactivateLink || !overlay || !closeButton || !participateButton) {
            return;
          }

          deactivateLink.addEventListener('click', function (event) {
            event.preventDefault();
            overlay.style.display = 'table';
            formOpen = true;
          });

          closeButton.addEventListener('click', function (event) {
            event.preventDefault();
            overlay.style.display = 'none';
            formOpen = false;
            location.href = deactivateLink.getAttribute('href');
          });

          participateButton.addEventListener('click', function (event) {
                setTimeout(function() {closeButton.click(); }, 50);
          });

          document.addEventListener('keyup', function (event) {
            if ((event.keyCode === 27) && formOpen) {
              location.href = deactivateLink.getAttribute('href');
            }
          });
        });
      </script>

      <p><strong>

        <%= __("We're sorry to see you go. Would you be open to sharing how MailPoet didn't work for you so we could improve it?") %>
      </strong><br><%= __('It will take only a minute.') %></p>
      <a
        class="button button-primary"
        id="mailpoet-deactivate-survey-participate"
        href="https://poll.fm/11161195"
        target="_blank"
        rel="noopener nofollow"
      ><%= __("Yes") %> &rarr;</a>

      <a
        class="button"
        id="mailpoet-deactivate-survey-close"
      >
        <%= __('No') %>
      </a>
    </div>
  </div>
</div>
