<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
      xml:lang="en" lang="en"
      metal:use-macro="here/main_template/macros/master"
      i18n:domain="cmfeditions">

  <tal:block metal:fill-slot="head_slot">
    <link rel="stylesheet" type="text/css" href="compare.css"
          tal:attributes="href string:${portal_url}/compare.css"/>
  </tal:block>

  <tal:block metal:fill-slot="javascript_head_slot">
    <script type="text/javascript">
      update_display = function() {
          var style = jq(this).attr('value');
          if (! this.checked) {
              return;
          }

          jq(".fieldDiff").hide();

          if (style=="visual") {
              jq(".inline-diff").show();
          }
          else {
              jq(".code-diff").show();
          }
      }

      jq(document).ready(function() {
          jq(".jsOnly").show();

          jq("#versionSelector select").change(function() { this.form.submit(); });
          jq("#diffTypeSelector input").click(update_display);
          jq("#diffTypeSelector input").each(update_display);
      });
</script>
  </tal:block>

  <body>
    <metal:main fill-slot="main">
      <h1 class="documentFirstHeading" tal:content="context/title_or_id">
        My Important Document
      </h1>

      <div id="content-core">
          <p tal:condition="not:view/history" i18n:translate="no_history">
            This object has no revision information.
          </p>

          <tal:block condition="view/history">
            <form id="versionSelector"
                  action="#"
                  tal:attributes="action string:${context/absolute_url}/@@history"
                  tal:define="toLocalizedTime nocall:context/@@plone/toLocalizedTime">
              <fieldset>
                <legend i18n:translate="legend_revisions">Revisions</legend>
                <label for="two"><span tal:omit-tag="" i18n:translate="">First revision</span>
                  <select id="two" name="two" tal:define="rev request/form/two|string:current">
                    <option i18n:translate="label_current" value="current" tal:attributes="selected python:rev=='current' and 'yes' or None">Current</option>
                    <option tal:repeat="version view/history"
                            tal:attributes="value version/version_id; selected python:str(rev)==str(version['version_id']) and 'yes' or None"
                            i18n:translate="label_history_version"><tal:version i18n:name="version" content="version/version_id">1</tal:version>
                            (<tal:date i18n:name="date" content="python:toLocalizedTime(version['sys_metadata']['timestamp'])">1975-12-24</tal:date>)</option>
                  </select>
                </label>

                <label for="one"><span tal:omit-tag="" i18n:translate="">Second revision</span>
                  <select id="one" name="one" tal:define="rev request/one|string:current">
                    <option i18n:translate="label_current" value="current" tal:attributes="selected python:rev=='current' and 'yes' or None">Current</option>
                    <option tal:repeat="version view/history"
                            tal:attributes="value version/version_id; selected python:str(rev)==str(version['version_id']) and 'yes' or None"
                            i18n:translate="label_history_version"><tal:version i18n:name="version" content="version/version_id">1</tal:version>
                            (<tal:date i18n:name="date" content="python:toLocalizedTime(version['sys_metadata']['timestamp'])">1975-12-24</tal:date>)</option>
                  </select>
                </label>
              </fieldset>

              <noscript>
                <input type="submit" i18n:attributes="value label_update" value="Update"/>
              </noscript>
            </form>

            <p tal:condition="not:view/changes" i18n:translate="">
              There are no changes between the selected revisions.
            </p>

            <tal:changes condition="view/changes">
              <form method="post" action="">
                <label for="diffstyle" class="jsOnly" style="display: none" i18n:translate="">Show differences</label>
                <ul class="radioRow" id="diffTypeSelector">
                  <li>
                    <input id="diffstylevisual" type="radio" name="diffstyle" value="visual" checked="checked" />
                    <label for="diffstylevisual" i18n:translate="">inline</label>
                  </li>
                  <li>
                    <input id="diffstylecode" type="radio" name="diffstyle" value="code" />
                    <label for="diffstylecode" i18n:translate="">as code</label>
                  </li>
                </ul>
              </form>

              <fieldset class="diff" tal:repeat="diff view/changes">
                <legend tal:content="diff/label">Body text</legend>

                <div class="fieldDiff inline-diff" tal:condition="exists:diff/inline_diff"
                     tal:content="structure python:diff.inline_diff()">
                  Inline changes
                </div>

                <p class="fieldDiff inline-diff" tal:condition="not:exists:diff/inline_diff" i18n:translate="">
                  This field has no inline difference view.
                </p>

                <div class="fieldDiff code-diff" style="display: none">
                  <pre tal:condition="exists:diff/html_diff" tal:content="structure python:diff.html_diff(wrapcolumn=80)">
                    HTML formatted differences
                  </pre>

                  <pre class="fieldDiff code-diff" tal:condition="python:not exists('diff/html_diff') and exists('diff/ndiff')" tal:content="diff/ndiff">
                    ndiff formatted differences
                  </pre>
                  <p class="fieldDiff" tal:condition="python:not exists('diff/html_diff') and not exists('diff/ndiff')">
                    This field has no code difference view.
                  </p>
                </div>
              </fieldset>
            </tal:changes>
          </tal:block>
      </div>
    </metal:main>
  </body>
</html>

