<%= content_for(:header_tags) do %>
    <%= import_ke(enable_at: false, prettify: false, init_activity: false) %>
    <%= javascript_include_tag "des_kindEditor"  %>
<% end %>

<script>
    $(function(){
        init_des_data(150);
    });
    function check_org_title()
    {
        if($("#document_title").val().trim() == "")
        {
            $("#doc_title_hint").html("<span class='c_red'>标题不能为空</span>").show();
            return false;
        }
        else
        {
            $("#doc_title_hint").hide();
            return true;
        }
    }
    function create_org_document()
    {
        if(check_org_title() == true)
        {
            org_document_description_editor.sync();
            $('#new_sub_document_form').submit();
        }
    }
    function cancel_create_org_document(){
        $("#document_title").val("");
        //org_document_description_editor.html("");
        //org_document_description_editor.sync();
        $('#sub_document_editor').hide();
        $('#doc_title_hint').hide();
    }
</script>
<div class="resources" nhname="new_topic_form">
  <%= form_tag org_subfield_sub_domain_sub_document_comments_path(:org_subfield_id => @org_subfield.id, :sub_domain_id => @subdomain.id), :id => 'new_sub_document_form' do |f| %>
      <div>
        <input class="postDetailInput fl" maxlength="250" name="sub_document_comment[title]" id="document_title" style="resize:none;" onfocus = "$('#sub_document_editor').show();" placeholder="请输入文章标题" />
      </div>
      <div id="doc_title_hint"></div>
      <div class="cl"></div>
      <div id="sub_document_editor" class="mt10" style="display: none">
        <div>
          <textarea placeholder="有问题或有建议，请直接给我留言吧！" style="display: none" nhname='description_textarea' name="sub_document_comment[content]"></textarea>
          <%#= kindeditor_tag 'sub_document_comment[content]','', :editor_id => 'org_document_description_editor', :height => "150px" %>
        </div>
        <div class="cl"></div>
        <p id="homework_course_id_span" class="c_red mt5"></p>
        <p id="e_tip" class="c_grey"></p>
        <p id="e_tips" class="c_grey"></p>
        <div class="cl"></div>
        <div class="mt10">
          <div class="fl" id="topic_attachments">
            <%#= render :partial => 'sub_document_comments/attachment', :locals => {:container => nil} %>
          </div>
        </div>
        <div class="cl"></div>
        <div class="mt5">
          <a href="javascript:void(0);" class="BlueCirBtnMini fr" id="new_topic_submit_btn">确定</a>
          <span class="fr mr10 mt3">或</span>
          <a href="javascript:void(0);" id="new_topic_cancel_btn" class="fr mr10 mt3">取消</a>
          <div class="cl"></div>
        </div>
      </div>
  <% end %>
</div>
