<% extends 'layout.html' %>

<% block content %>

<div class="wrap mailpoet-about-wrap">
  <h1><%= __('Greetings, humans.') %></h1>

  <p class="about-text"><%= __('Thanks for using MailPoet! We really appreciate all of your love, affection, [link]and (good) plugin reviews.[/link]')
    |replaceLinkTags('https://wordpress.org/support/plugin/mailpoet/reviews/', {'target' : '_blank'})
    |raw
    %>
  </p>
  <div class="mailpoet-logo"><img src="<%= image_url('welcome_template/mailpoet-logo.png') %>" alt="MailPoet Logo" /></div>

  <h2 class="nav-tab-wrapper wp-clearfix">
    <a href="admin.php?page=mailpoet-welcome" class="nav-tab"><%= __('Welcome') %></a>
    <a href="admin.php?page=mailpoet-update" class="nav-tab nav-tab-active"><%= __("What's New") %></a>
  </h2>

  <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>

  <hr>
  <div id="mailpoet_random_order">
    <div>
      <% if(not settings.analytics.enabled) %>
        <div class="feature-section one-col mailpoet_centered">
          <h2><%= __('Do Your Part to Make MailPoet Better') %></h2>
          <div class="lead-description">

            <label>
              <input type="checkbox" id="mailpoet_analytics_enabled" value="1">&nbsp;
              <%= __('Yes, share my data anonymously.') %>
            </label>
          </div>
          <p class="top-space-triple"><%= __("By sharing your data with us, you can help us understand what our users like (and don't like).") %>
            <%= __('We use it to prioritize and develop new plugin features.') %><br>
            <%= __('Share your data to help shape the future of MailPoet! [link]Read more.[/link]')
              |replaceLinkTags('http://beta.docs.mailpoet.com/article/130-sharing-your-data-with-us', {'target' : '_blank'})
              |raw
              %>
          </p>
        </div>
        <hr>
      <% endif %>
    </div>

    <div>
      <div class="feature-section one-col mailpoet_centered">
        <h2><%= __("Subscribe To Our Newsletter") %></h2>
        <p><%= __("About once a month, we send out a pretty cool newsletter ourselves.") %></p>
        <p><%= __("Sign up to get a curated selection of awesome links, tips and tricks for using MailPoet, special offers, and important plugin updates!") %></p>
        <iframe width="380" scrolling="no" frameborder="0" src="http://www.mailpoet.com/?wysija-page=1&controller=subscribers&action=wysija_outter&wysija_form=5&external_site=1&wysijap=subscriptions-3" class="iframe-wysija" vspace="0" tabindex="0" style="border-style: none; visibility: visible; background-color: #f1f1f1!important;" marginwidth="0" marginheight="0" hspace="0" allowtransparency="true" title="<%= __("Subscribe To Our Newsletter") %>"></iframe>
      </div>
      <hr>
    </div>

    <div>
      <div class="feature-section one-col mailpoet_centered">
        <h2><%= __("Learn the Ropes") %></h2>
        <p><%= __("New to MailPoet? Check out our brand new email course. Over the course of a week, we'll teach you how to create and send your first MailPoet email newsletter. Sign up below!") %></p>
        <iframe width="380" height="100%" scrolling="no" frameborder="0" src="http://newsletters.mailpoet.com?mailpoet_form_iframe=4" class="mailpoet_form_iframe" vspace="0" tabindex="0" onload="if(window['MailPoet']) MailPoet.Iframe.autoSize(this);" marginwidth="0" marginheight="0" hspace="0" allowtransparency="true"></iframe>
      </div>
      <hr>
    </div>

    <div>
      <div class="feature-section one-col mailpoet_centered">
        <h2><%= __("Leave a Review, Make Us Happy") %></h2>
        <p><%= __('We love to read reviews, either critical or positive. Take 3 minutes and make our day. [link]Write a review[/link]. :)')
          |replaceLinkTags('https://wordpress.org/support/plugin/mailpoet/reviews/', {'target' : '_blank'})
          |raw
          %>
        </p>
      </div>
      <hr>
    </div>
  </div>

  <div class="feature-section one-col mailpoet_centered">
    <h2><%= __('Care to Give Your Opinion?') %></h2>

    <div class="pd-embed" id="pd_1510025011"></div>
    <script type="text/javascript">
      var _polldaddy = [] || _polldaddy;

      _polldaddy.push( {
        type: "iframe",
        auto: "1",
        domain: "mailpoet.polldaddy.com/s/",
        id: "mailpoet-interview-sign-up-form",
        placeholder: "pd_1510025011"
      } );

      (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>
  </div>

  <hr>

  <div class="feature-section one-col mailpoet_centered">
    <a class="button button-primary go-to-plugin" href="admin.php?page=mailpoet-newsletters"><%= __('Awesome! Now, take me to MailPoet') %> &rarr;</a>
  </div>

</div>

<script type="text/javascript">
  jQuery(function($) {
    $(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 }
          );
        }
      });
    });

    var $random = $('#mailpoet_random_order');
    var divs = $random.children().toArray();
    $random.empty();
    _.shuffle(divs).forEach(function(div) {
      $random.append(div)
    });

  });

</script>
<% endblock %>
