<script type="text/javascript">
    function submit_copy_course() {
        if(regex_course_name('new')&&regex_course_class_period('new')&&regex_time_term('new')&&regex_course_password('new'))
        {
            $("#new_course").submit();
            document.getElementById("submit_copy_course").onclick = "";
        }
    }
    $(document).ready(function(){
        $("#new_time").change(function(){
            document.getElementById("new_end_time").options[document.getElementById("new_time").selectedIndex].selected = true;
        });
        $("#new_term").change(function(){
            document.getElementById("new_end_term").options[document.getElementById("new_term").selectedIndex].selected = true;
        });

        var popupHeight = $(".referenceResourcesPopup").outerHeight(true);
        $(".referenceResourcesPopup").css("marginTop",-popupHeight/2);
        $(".resourcePopupClose").click(function(){
            hideModal();
        });
        $("#copyResource").click(function(){
            if ($("#allResource").is(":checked")){
                $("input[name='course_attachment_type[]']").attr("checked",true);
            }
            else{
                $("input[name='course_attachment_type[]']").attr("checked",false);
            }
        });
        $("#copyResource2").click(function(){
            if ($("input[name='course_attachment_type[]']:checked").length == 6){
                $("#allResource").attr("checked",true);
            }
            else{
                $("#allResource").attr("checked",false);
            }
        });
    });
</script>

<div>
  <div class="referenceText">信息配置</div>
</div>
<ul class="mt10">
  <%=labelled_form_for @new_course do |f| %>
    <input name="copy_course" value="<%=@course.id %>" style="display: none"/>
    <li class="ml45 mb10">
      <a href="javascript:void(0)" class="upimg fl">
        <%= image_tag(url_to_avatar(@course), id: "avatar_image", :width =>"60", :height =>"60",:alt=>"上传图片")%>
      </a> <!--<a href="javascript:void(0)" class="upbtn fl ml30" onclick="$('#upload_course_logo').click();">上传图片</a>-->
      <!--</span>-->
      <div class="cl"></div>
    </li>
    <li class="ml45">

      <input type="text" style="display: none"/> <!--阻止表单自动填充 -->
      <input type="password" style="display: none"/> <!--阻止表单自动填充 -->
      <label><span class="c_red">*</span>&nbsp;<%= l(:label_tags_course_name)%>&nbsp;&nbsp;：</label>
      <input  type="text" name="course[name]" id="new_course_name" class="courses_input grey_border" maxlength="100" onkeyup="regex_course_name('new');" value="<%=@course.name %>">
      <span class="c_red" id="new_course_name_notice" style="display: none;">课程名称不能为空</span>
    <div class="cl"></div>
    <li class="ml45">
      <label><span class="c_red">*</span>&nbsp;<%= l(:label_class_period)%>&nbsp;&nbsp;：</label>
      <input  type="text" name="class_period" id="new_class_period" class="hwork_input02 grey_border" onkeyup="regex_course_class_period('new');" maxlength="6" value="<%=@course.class_period %>">
      <span class="c_red" id="new_course_class_period_notice" style="display: none;"></span>
    </li>
    <div class="cl"></div>
    <li class="ml45 mb10">
      <label><span class="c_red">*</span>&nbsp;<%= l(:label_course_term)%>&nbsp;&nbsp;：</label>
      <%= select_tag :time,options_for_select(course_time_option(@new_course.time),@new_course.time), {:id=>"new_time"}  %>
      <%= select_tag :term,options_for_select(course_term_option,@new_course.term || cur_course_term),{:id=>"new_term"}  %>
      <span class="c_red" id="new_course_time_term_notice"></span>
    </li>
    <div class="cl"></div>
    <li class="ml45 mb10">
      <label><span class="c_red">*</span>&nbsp;结束学期&nbsp;&nbsp;：</label>
      <%= select_tag :end_time,options_for_select(course_time_option(@new_course.end_time),@new_course.end_time), {:id=>"new_end_time"}  %>
      <%= select_tag :end_term,options_for_select(course_term_option,@new_course.end_term || cur_course_term),{:id=>"new_end_term"}  %>
      <span class="mr15 c_red">仅针对跨越多个学期的班级，否则不用修改。</span>
    </li>
    <div class="cl"></div>
    <li class="ml45 mb10">
      <label><span class="c_red">*</span>&nbsp;<%= l(:label_new_course_password)%>&nbsp;&nbsp;：</label>
      <input type="text" style="display: none;">
      <input  type="text" name="course[password]" id="new_course_course_password" class="hwork_input02 grey_border" onkeyup="regex_course_password('new');" value="<%=@course.password %>">
      <!--<a id="psw_btn" href="javascript:void(0)">显示明码</a>-->
      <span class="c_red" id="new_course_course_password_notice"></span>
      <div class="cl"></div>
      <span class="ml95 c_red">学生或其他成员申请加入课程时候需要使用该口令，该口令可以由老师在课堂上公布。</span>
    </li>
    <li class="ml50">
      <label class="fl" >&nbsp;&nbsp;<%= l(:label_new_course_description)%>&nbsp;&nbsp;：</label>
      <textarea  name="course[description]" placeholder="最多3000个汉字(或6000个英文字符)"  class="courses_text fl grey_border"  ><%= @course.description.nil? ? "" : @course.description %></textarea>
      <div class="cl"></div>
    </li>
    <li class=" mb5 ml85">
      <label >公开&nbsp;&nbsp;：</label>
      <input <%= @course.is_public == 1 ? 'checked' : ''%> id="course_is_public" name="course[is_public]"  type="checkbox" value="<%=@course.is_public.to_i %>">
      <span class="c_grey">（选中后课外用户可见该课程，否则仅对课内成员可见）</span>
      <div class="cl"></div>
    </li>
    <li class="ml85">
      <label class="fl">复制&nbsp;&nbsp;：</label>
      <ul class="fl" id="copyResource" style="width:544px;">
        <li class="sendCourseName fl ml5">
          <label class="fl">
            <input name="course_content_type[]" type="checkbox" value="0" class="resourceCopy"/>
            作业</label>
            <span class="c_red ml5 fl mb10 w490">复制到新课中的作业将在1个月后发布、2个月后提交截止，请您调整作业的发布时间、截止时间等时间节点。</span>
        </li>
        <li class="sendCourseName fl ml5">
          <label class="fl">
            <input name="course_content_type[]" type="checkbox" value="1" class="resourceCopy"/>
            资源</label>
            <span class="c_red ml5 fl mb10">复制到新课的资源将在1个月后发布，请您调整资源的发布时间，否则学生可能看不到资源。</span>
        </li>
      </ul>
      <!--<ul class="fl" id="copyResource2">
        <li class="sendCourseName fl mr15">
          <label>
            <input name="course_attachment_type[]" type="checkbox" value="1" class="resourceCopy"/>
            课件</label>
        </li>
        <li class="sendCourseName fl mr15">
          <label>
            <input name="course_attachment_type[]" type="checkbox" value="2" class="resourceCopy"/>
            软件</label>
        </li>
        <li class="sendCourseName fl mr15">
          <label>
            <input name="course_attachment_type[]" type="checkbox" value="3" class="resourceCopy"/>
            媒体</label>
        </li>
        <li class="sendCourseName fl mr15">
          <label>
            <input name="course_attachment_type[]" type="checkbox" value="4" class="resourceCopy"/>
            代码</label>
        </li>
        <li class="sendCourseName fl mr15">
          <label>
            <input name="course_attachment_type[]" type="checkbox" value="6" class="resourceCopy"/>
            论文</label>
        </li>
        <li class="sendCourseName fl mr15">
          <label>
            <input name="course_attachment_type[]" type="checkbox" value="5" class="resourceCopy"/>
            其它</label>
        </li>
        <div class="cl"></div>
      </ul>
      <span class="c_red ml5 fl mb10">您可以通过选择类型，将对应类型复制到新课程中。</span>-->
      <div class="cl"></div>
    </li>
  <% end %>
</ul>
<div>
 <a href="javascript:void(0);" class="greyBtn fr mr40 f12" id="submit_copy_course" onclick="submit_copy_course();">完成</a>
 <a href="javascript:void(0);" class="greyBtn fr mr10 f12" onclick="hideResource();">取消</a>
</div>
<div class="cl"></div>