<div tal:omit-tag=""
  tal:define="
    form context/tab_status_form_mailing;
    is_editor context/is_editor"
  i18n:domain="silva_mailing">

<form action="." method="post">
  <table class="listing sublisting">
    <tr class="inter-controls">
      <td colspan="2">
        <h3 i18n:translate="">
          send as mailing
        </h3>
      </td>
    </tr>

    <tr tal:condition="is_editor">
      <th class="align-right" i18n:translate="">
        settings
      </th>
      <th style="width:40%" i18n:translate="">
        notes
      </th>
    </tr>

    <tr class="even"
        tal:define="field form/testemail"
        tal:condition="is_editor">
      <td class="align-right">
        <label tal:content="field/title"
          tal:attributes="for field/id"
          >
          test email address
        </label>
        <input tal:replace="structure python: field.render(REQUEST=request)" />
      </td>
      <td tal:content="structure field/description">
        description
      </td>
    </tr>

    <tr class="odd"
      tal:define="field form/testemailaddress"
      tal:condition="is_editor">
      <td class="align-right">
        <label tal:content="field/title"
          tal:attributes="for field/id"
          >
          test email address
        </label>
        <input tal:replace="structure python: field.render(REQUEST=request)" />
      </td>
      <td tal:content="structure field/description">
        description
      </td>
    </tr>

    <tr class="inter-controls">
      <td class="align-right"
        colspan="2">
        <tal:comment replace="nothing">
          <!-- XXX confusing... we present the previewable when the author uses
               this button, and the viewable when editor or up presses it, this
               because in the latter case the rest of the controls are dealing
               with the viewable, while in the former there may not even be a
               viewable, and it makes more sense to let authors preview the
               previewable anyway... (but tbh, i think it's messy and could do
               with some smart person thinking it over a bit...)
          -->
        </tal:comment>
        <input class="button"
          type="button"
          value="preview mailing"
          title="access key: alt-i"
          accesskey="i"
          onclick="window.open('')"
          tal:condition="not:is_editor"
          tal:attributes="onclick string:window.open('${context/absolute_url}/mail.html?view_method=preview', 'mailview', 'width=615,height=400,scrollbars=yes,resizable=yes')"
          i18n:attributes="value;title"
        /><tal:comment replace="nothing">
          <!-- What about: if the doc is not published, the editor will see the
               previewable since that's what needs to be checked. But if the doc is
               published, the editor sees the doc as it will be sent.
          -->
        </tal:comment><input class="button"
          type="button"
          value="preview mailing"
          title="access key: alt-i"
          accesskey="i"
          onclick="window.open('')"
          tal:define="viewmethod python:context.is_published() and 'view' or 'preview'"
          tal:condition="is_editor"
          tal:attributes="onclick string:window.open('${context/absolute_url}/mail.html?view_method=$viewmethod', 'mailview', 'width=615,height=400,scrollbars=yes,resizable=yes')"
          i18n:attributes="value;title"
        /><input class="executor"
          type="submit"
          name="tab_status_send_as_mailing:method"
          value="send mailing"
          title="access key: alt-s"
          accesskey="s"
          i18n:attributes="value;title"
          tal:condition="python:is_editor and context.is_published()"
        />
      </td>
    </tr>

  </table>
</form>

</div>
