<%inherit file="base.html" />
<%namespace name='static' file='static_content.html'/>

<%! from django.core.urlresolvers import reverse %>
<%block name="title">Export</%block>
<%block name="bodyclass">export</%block>

<%block name="content">
<div class="main-wrapper">
  <div class="inner-wrapper">
    <article class="export-overview">
      <div class="description">
        <h2>About Exporting Courses</h2>
        <p>When exporting your course, you will receive a .tar.gz formatted file that contains the following course data:</p>

        <ul>
          <li>Course Structure (Sections and sub-section ordering)</li>
          <li>Individual Units</li>
          <li>Individual Problems</li>
          <li>Static Pages</li>
          <li>Course Assets</li>
        </ul>

        <p>Your course export <strong>will not include</strong>: student data, forum/discussion data, course settings, certificates, grading information, or user data.</p>
      </div>

      <!-- default state -->
      <div class="export-form-wrapper">
        <form action="${reverse('generate_export_course', kwargs=dict(org=context_course.location.org, course=context_course.location.course, name=context_course.location.name))}" method="post" enctype="multipart/form-data" class="export-form">
          <h2>Export Course:</h2>
          
          <p class="error-block"></p>
          
          <a href="${reverse('generate_export_course', kwargs=dict(org=context_course.location.org, course=context_course.location.course, name=context_course.location.name))}" class="button-export">Download Files</a>
        </form>
      </div>

      <!-- download state: after user clicks download buttons -->
      <%doc>
      <div class="export-form-wrapper is-downloading">
        <form action="${reverse('export_course', kwargs=dict(org=context_course.location.org, course=context_course.location.course, name=context_course.location.name))}" method="post" enctype="multipart/form-data" class="export-form">
          <h2>Export Course:</h2>
          
          <p class="error-block"></p>
          
          <a href="#" class="button-export disabled">Files Downloading</a>
          <p class="message-status">Download not start? <a href="#" class="text-export">Try again</a></p>          
        </form>
      </div>
      </%doc>
    </article>
  </div>
</div>
</%block>

<%block name="jsextra">
<script>
(function() {
    
var bar = $('.progress-bar');
var fill = $('.progress-fill');
var percent = $('.percent');
var status = $('#status');
var submitBtn = $('.submit-button');
   
$('form').ajaxForm({
    beforeSend: function() {
        status.empty();
        var percentVal = '0%';
        bar.show();
        fill.width(percentVal);
        percent.html(percentVal);
        submitBtn.hide();
    },
    uploadProgress: function(event, position, total, percentComplete) {
        var percentVal = percentComplete + '%';
        fill.width(percentVal);
        percent.html(percentVal);
    },
    complete: function(xhr) {
      if (xhr.status == 200) {
        alert('Your import was successful.');
        window.location = '${successful_import_redirect_url}';
      }
      else
        alert('Your import has failed.\n\n' + xhr.responseText);
        submitBtn.show();
        bar.hide();
    }
  }); 
})();       
</script>
</%block>