<% extends 'layout.html' %>

<% block content %>

<div class="wrap mailpoet-about-wrap">
  <h1><%= __('Thanks for updating MailPoet') %></h1>

  <div class="feature-section one-col mailpoet_centered">
    <a class="button button-primary go-to-plugin" href="<%= redirect_url %>"><%= __('Thanks, now take me to where I was going.') %> &rarr;</a>
  </div>

  <div id="mailpoet-changelog" class="feature-section one-col">
    <h2 class="mailpoet-feature-top"><%= __('List of Changes') %></h2>
    <% if changelog %>
      <% for item in changelog %>
        <h3><%= item.version %></h3>
        <ul>
          <% for change in item.changes %>
            <li><%= change %></li>
          <% endfor %>
        </ul>
      <% endfor %>
    <% else %>
      <p style="text-align: center"><%= __('See readme.txt for a changelog.') %></p>
    <% endif %>
    <a class="button button-secondary" href="https://wordpress.org/plugins/mailpoet/#developers" target="_blank"><%= __('View all changes') %> &rarr;</a>
  </div>

  <div class="feature-section one-col mailpoet_centered">

    <% if(is_new_user) %>
      <h2><%= __('Care to Give Your Opinion?') %></h2>
      <div class="pd-embed" id="pd_1519225570"></div>
      <script type="text/javascript">
        var _polldaddy = [] || _polldaddy;

        _polldaddy.push( {
          type: "iframe",
          auto: "1",
          domain: "mailpoet.polldaddy.com/s/",
          id: "improvements-first-steps",
          placeholder: "pd_1519225570"
        } );

        (function(d,c,j){if(!document.getElementById(j)){var pd=d.createElement(c),s;pd.id=j;pd.src=('https:'==document.location.protocol)?'https://polldaddy.com/survey.js':'http://i0.poll.fm/survey.js';s=document.getElementsByTagName(c)[0];s.parentNode.insertBefore(pd,s);}}(document,'script','pd-embed'));
      </script><br>
    <% elseif(is_old_user and not stop_call_for_rating) %>
      <h2><%= __('Do you enjoy using MailPoet?') %></h2>
      <p>
        <%= __('If you have the time, we’d really appreciate it if you left us a review on the WordPress Plugin Directory.') %>
        <br><%= __('Every star counts.') %>

      <p>
        <a class="button" id="no-thanks"><%= __('No thanks') %></a>
        <a class="button" href="admin.php?page=mailpoet-newsletters"><%= __('Next time') %></a>
        <a class="button button-primary" id="rate-now" href="https://wordpress.org/support/plugin/mailpoet/reviews/?rate=5#new-post" target="_blank"><%= __('Rate now') %></a>
      <p>
        <%= __('Care to share criticism or a feature request instead?') %>
        <br><%= __('Click on the question mark (?) in the blue circle at the bottom right of this page to send us a message.') %>
    <% else %>
      <h2><%= __('Care to Give Your Opinion?') %></h2>
      <script type="text/javascript" charset="utf-8" src="https://secure.polldaddy.com/p/9957416.js"></script>
      <noscript><a href="https://polldaddy.com/poll/9957416/">How would you rate the reliability of MailPoet?</a></noscript>
    <% endif %>

  <hr>

  <div class="feature-section one-col mailpoet_centered">
    <a class="button button-primary go-to-plugin" href="<%= redirect_url %>"><%= __('Thanks, now take me to where I was going.') %> &rarr;</a>
  </div>

</div>

<script type="text/javascript">
  jQuery(function($) {
    function stopShowingCallForRating() {
      return MailPoet.Ajax.post({
        api_version: window.mailpoet_api_version,
        endpoint: 'settings',
        action: 'set',
        data: {
          stop_call_for_rating: true,
        }
      });
    }
    $('#no-thanks').click(function (e) {
      e.preventDefault();
      stopShowingCallForRating().done(function () {
        window.location.href = 'admin.php?page=mailpoet-newsletters';
      });
      return false;
    });
    $('#rate-now').click(stopShowingCallForRating);

    $(function() {
      MailPoet.trackEvent(
        'User has updated MailPoet',
        {'MailPoet Free version': window.mailpoet_version}
      );
    });
    $('#mailpoet_analytics_enabled').on('click', function() {
      var is_enabled = $(this).is(':checked') ? true : '';
      MailPoet.Ajax.post({
        api_version: window.mailpoet_api_version,
        endpoint: 'settings',
        action: 'set',
        data: {
          analytics: { enabled: (is_enabled)}
        }
      }).fail(function(response) {
        if (response.errors.length > 0) {
          MailPoet.Notice.error(
            response.errors.map(function(error) { return error.message; }),
            { scroll: true }
          );
        }
      });
    });

  });


</script>
<% endblock %>
