<% provide :title, @forum_post.title %>
<% if @forum_post.is_locked? %>
  <div class="status-notice">
    <p><%= t('.locked') %></p>
  </div>
<% end %>

<div id="forum" class="response-list">
  <% unless page_number > 1 %>
    <%= render :partial => "post", :locals => {:post => @forum_post} %>
  <% end %>

  <% @children.each do |c| %>
    <%= render :partial => "post", :locals => {:post => c} %>
  <% end %>
</div>

<% unless @forum_post.is_locked? %>
  <div style="clear: both;">

    <div id="preview" class="response-list" style="display: none; margin: 1em 0;">
    </div>

    <div id="reply" style="display: none; clear: both;">
      <%= form_tag({:action => "create"}, level: :member, class: 'forum-post-form forum-post-form--reply') do %>
        <%= render "shared/filter_spam" %>
        <%= hidden_field "forum_post", "title", :value => "" %>
        <%= hidden_field "forum_post", "parent_id", :value => @forum_post.root_id %>
        <%= text_area 'forum_post', 'body', class: 'forum-post-form__row--body', value: '' %>
        <div class="forum-post-form__row forum-post-form__row--buttons">
          <%= submit_tag t('.post') %>
          <%= submit_to_remote "preview", t('.preview'), :url => {:action => "preview"}, :update => "preview", :success => "$('preview').show()" %>
        </div>
      <% end %>
    </div>
  </div>
<% end %>

<div id="paginator">
  <%= will_paginate(@children) %>
</div>

<script type="text/javascript">
  <%= avatar_init %>
  InlineImage.init();
</script>

<% content_for :subnavbar do %>
  <% unless @forum_post.is_locked? %>
    <li><%= link_to_function t('.reply'), "Element.toggle('reply')" %></li>
  <% end %>
  <li><%= link_to t('.list'), :action => "index" %></li>
  <li><%= link_to t('.new'), :action => "new" %></li>
  <% unless @forum_post.is_parent? %>
    <li><%= link_to t('.parent'), :action => "show", :id => @forum_post.parent_id %></li>
  <% end %>
  <li><%= link_to t('.help'), help_path("forum") %></li>
<% end %>
