{% extends "_base_email.html" %}

{% from 'macros/form.html' import render_field %}
{% from 'macros/form.html' import render_button %}
{% from 'macros/nav.html' import email_subnav with context %}

{% block libs %}{{ super() }}
<script type="text/javascript" src="{{ url_for('static', filename='js/fileinput.min.js') }}"></script>
<script type="text/javascript" src="{{ url_for('static', filename='js/bootstrap3-wysihtml5.all.min.js') }}"></script>
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/fileinput.min.css') }}">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/bootstrap3-wysihtml5.min.css') }}">
<link rel="stylesheet" type="text/css" href="{{ 'css/email_new.css' | asset_url }}">
{% endblock %}

{% block content %}{{ super() }}
{{ email_subnav() }}

<main>
<form action="{{ url_for('email_new', **request.args) }}" method="post" name="{{ form.name }}" enctype="multipart/form-data">
  {{ form.hidden_tag() }}

  <div class="row">
    <div class="col-sm-12 col-md-4">{{ render_field(form.to, _('To')) }}</div>
    <div class="col-sm-12 col-md-4">{{ render_field(form.cc, _('Cc')) }}</div>
    <div class="col-sm-12 col-md-4">{{ render_field(form.bcc, _('Bcc')) }}</div>
  </div>
  {{ render_field(form.subject, _('Subject')) }}
  {{ render_field(form.body, _('Message')) }}
  {% if form.forwarded_attachments.choices %}
  {{ render_field(form.forwarded_attachments, _('Forwarded attachments')) }}
  {% endif %}
  {{ render_field(form.attachments, _('Attachments')) }}
  {{ render_button(form.submit, _('Send')) }}
</form>
</main>
{% endblock %}

{% block scripts %}{{ super() }}
<script>
window.flask_jinja_context__email_new = {
  config: {
    max_upload_size_mb: {{ max_upload_size_mb }},
  },
  selectors: {
    attachments: "#{{ form.attachments.id }}",
    formBody: "#{{ form.body.id }}"
  },
  i8n: {
    filesSelected: "{{ _('files selected') }}",
    fileTooLarge: "{{ _('The file is too large. Maximum allowed upload size is:') }} {{ max_upload_size_mb }} MB.",
    remove: "{{ _('Remove') }}",
    chooseFiles: "{{ _('Choose files') }}",
    bold: "{{ _('Bold') }}",
    italic: "{{ _('Italic') }}",
    underline: "{{ _('Underline') }}",
    unorderedList: "{{ _('Un-ordered list') }}",
    orderedList: "{{ _('Ordered list') }}"
  }
};
</script>
<script type="text/javascript" src="{{ 'js/email_new.js' | asset_url }}"></script>
{% endblock %}
