<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      xmlns:tal="http://xml.zope.org/namespaces/tal"
      i18n:domain="ploneintranet"
>
  <tal:headers tal:define="
                 dummy view/portal/@@http-cache-headers;
               " />

  <tal:block tal:define="
               portal_url view/portal_url;
             ">
    <div class="shouldnotbeherebutweneedahookforinjection"
         id="${python:post_id and 'microblog-%s' % post_id or None}"
         tal:define="
           form_id view/form_id;
           post_id view/post_id;
           microblog_context_url view/microblog_context_url;
           plone_portal_state nocall: view/portal/@@plone_portal_state;
         "
         tal:omit-tag="not:post_id"
    >

      <form class="pat-inject update-social post-box ${python:'status-active' if view.should_autofocus else None}"
            id="${form_id}"
            action="${view/form_action}"
            enctype="multipart/form-data"
            method="post"
            data-pat-inject="${view/form_data_pat_inject}"
      >

        <tal:reply condition="view/container_id">
          <input name="container_id"
                 type="hidden"
                 value="${view/container_id}"
          />
        </tal:reply>
        <input name="post_id"
               type="hidden"
               value="${view/post_id}"
        />

        <fieldset>
          <tal:comment condition="nothing">
            Warning! Be careful when applying auto formatting inside the .content-mirror element.
            It has a CSS rule "white-space: pre-wrap" that makes the wrap on new lines.
          </tal:comment>

          <fieldset
              class="pat-rich pat-switch post-box-post"
              data-pat-switch="#${form_id} status-inactive status-active">

            <textarea
                class="pat-tiptap"
                data-pat-tiptap="
                    mentions-menu: ${microblog_context_url}/@@panel-users#document-content?usersearch=;
                    tags-menu: ${microblog_context_url}/@@panel-tags#document-content?tagsearch=;
                "
                name="form.widgets.text"
                autofocus="${python:'autofocus' if view.should_autofocus else None}"
                placeholder="${view/placeholder|nothing}"
                ></textarea>

            <fieldset class="attachments pat-subform pat-autosubmit pat-inject"
                      data-pat-inject="url:${microblog_context_url}/@@upload-statusupdate-attachments; source: #attachments; target: #${form_id}-attachment-previews"
            >
              <label class="iconified icon-attach pat-switch"
                     data-pat-switch="#${form_id} status-* status-attach"
              ><input
                       accept="image/*,.docx,.doc,.xlsx,.xls,.pptx,.ppt,.pdf"
                       multiple
                       name="form.widgets.attachments"
                       title="Attach a file"
                       type="file"
                       i18n:attributes="title"
                />
                <span tal:omit-tag=""
                      i18n:translate=""
                >Attach a file (or create a picture)</span></label>
              <p class="attachment-previews"
                 id="${form_id}-attachment-previews"
                 i18n:translate=""
              >
                No attachments selected.
              </p>

              <input id="${view/attachment_form_token}"
                     name="attachment-form-token"
                     type="hidden"
                     value="${view/attachment_form_token}"
              />
              <span tal:replace="structure view/microblog_context/@@authenticator/authenticator"></span>

              <tal:comment condition="nothing">
                <!-- The proto conditionally includes the share_tile in this place. Since
                               there's no design for it yet in PI, the markup has not been copied. -->
              </tal:comment>
            </fieldset>

          </fieldset>

          <div class="button-bar post-box-button-bar">
            <a class="iconified icon-user-add pat-tooltip"
               href="#${form_id}-mentions-toggle-help"
               data-pat-tooltip="position: tl; source: ajax; class: rich info mentions;"
               i18n:translate=""
            >Mention people</a>
            <template id="${form_id}-mentions-toggle-help">
                <p i18n:translate="message_mentioning_people">You can now simply type ‘@Name of user’ to mention someone in your post or comment.</p>
                <p i18n:translate="message_mentioning_groups">It’s also possible to mention an entire group of people by writing ‘@Name of the group’.</p>
            </template>

            <a class="iconified icon-tags pat-tooltip"
               href="#${form_id}-tags-toggle-help"
               data-pat-tooltip="position: tl; source: ajax; class: rich info tags;"
               i18n:translate=""
            >
              Add tags
            </a>
            <template id="${form_id}-tags-toggle-help">
                <p i18n:translate="message_tagging">You can now simply type ‘#Your tag’ to add a tag to your post or comment.</p>
            </template>

            <button class="pat-button default pat-switch close-panel"
                    name="form.buttons.statusupdate"
                    type="submit"
                    data-pat-switch="selector: #${form_id}; remove: status-*; add: status-inactive &amp;&amp; selector: #microblog-${context/id}-reply-button; remove: executed"
                    i18n:translate="button_post"
            >Post</button>
            <button class="pat-button pat-switch close-panel"
                    type="reset"
                    data-pat-switch="selector: #${form_id}; remove: status-*; add: status-inactive &amp;&amp; selector: #microblog-${context/id}-reply-button; remove: executed"
                    i18n:translate=""
            >Cancel</button>

            <tal:comment condition="nothing">
              <!-- The proto conditionally includes the visibility selection in this place. Since
                               there's no design for it yet in PI, the markup has not been copied. -->
            </tal:comment>
          </div>
        </fieldset>
      </form>
    </div>

  </tal:block>

</html>
