<%= content_for(:header_tags) do %>
    <%= import_ke(enable_at: true, prettify: false) %>
<% end %>

<%= error_messages_for 'message' %>
<div class="resources mt10">
  <div id="new_course_topic">
    <div class="homepagePostBrief c_grey">
      <div>
        <input  type="text" name="message[subject]" id="message_subject" class="InputBox  w713" maxlength="255" onfocus="$('#topic_editor').show()" onkeyup="regexTopicSubject();" placeholder="发布帖子，请先输入帖子标题" value="<%= topic.subject%>" >
        <p id="subjectmsg"></p>
      </div>
      <div id="topic_editor" style="display: none;">
        <%if User.current.member_of?(project)%>
            <div class="mt10">
              <%= f.check_box :sticky, :value => topic.sticky%>
              <%= label_tag 'message_sticky', l(:label_board_sticky) %>
              <%= f.check_box :locked, :value => topic.locked%>
              <%= label_tag 'message_locked', l(:label_board_locked) %>
              <div class="cl"></div>
            </div>
        <% end %>
        <div class="mt10">
          <div id="message_quote" class="wiki" style="width: 92%;word-break: break-all;word-wrap: break-word;margin-left: 40px;"></div>
          <%= text_area :quote,:quote,:style => 'display:none' %>
          <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>

          <%= f.kindeditor :content, :editor_id => 'message_content_editor',
                           :owner_id => topic.nil? ? 0: topic.id,
                           :owner_type => OwnerTypeHelper::MESSAGE,
                           :width => '100%',
                           :height => 300,
                           :minHeight=>300,
                           :class => 'talk_text fl',
                           :input_html => { :id => 'message_content',
                                            :class => 'talk_text fl',
                                            :maxlength => 5000 },
                           at_id: topic.id, at_type: topic.class.to_s
          %>
          <div class="cl"></div>
          <p id="message_content_span"></p>
        </div>
        <div class="cl"></div>
        <div class="mt10">
          <div class="fl" id="topic_attachments">
            <%= render :partial => 'attachments/form_course', :locals => {:container => topic, :isReply => @isReply} %>
          </div>
        </div>
        <div class="cl"></div>
        <div class="mt5">
          <%if !edit_mode %>
              <a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="message_content_editor.sync();$('#message-form').submit();">确定</a>
              <span class="fr mr10 mt3">或</span>
              <a href="javascript:void(0);" class="fr mr10 mt3" onclick="reset_topic();">取消</a>
          <% else %>
              <a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="message_content_editor.sync();$('#message-form').submit();">确定</a>
              <span class="fr mr10 mt3">或</span>
              <%= link_to "取消",board_message_url(topic.board, topic.root, :r => (topic.parent_id && topic.id)), :class => "fr mr10 mt3"%>
          <% end %>
        </div>
        <div class="cl"></div>
      </div>
    </div>
  </div>
</div>