You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pgfqe6ch8/public/javascripts/edu/syllabus.js

193 lines
5.7 KiB

6 years ago
var syMemberLastSearchCondition = '';
function g(o){return document.getElementById(o);}
function HoverLi(n){
$('.new-tab-nav').removeClass("background-orange");
for(var i=1;i<=2;i++){
//g('edu-tab-nav-'+i).className='edu-tab-nomal';
$('edu-tab-con-'+i).hide();
}
$('edu-tab-con-'+n).show();
$('#edu-tab-nav-'+n).addClass("background-orange");
//g('edu-tab-nav-'+n).className='edu-new-tab-hover';
}
// 课程首页
$(function(){
$("#edit_sy_des").live('click', function(){
$("#sy_des_show_div").hide();
$("#sy_des_edit_div").show();
$("#cancel_edit_sy_des").show();
$("#save_sy_des").show();
$("#edit_sy_des").hide();
});
$("#edit_sy_des_add").live('click', function(){
$("#sy_des_show_div").hide();
$("#sy_des_edit_div").show();
$("#cancel_edit_sy_des").show();
$("#save_sy_des").show();
$("#edit_sy_des").hide();
});
$("#cancel_edit_sy_des").live('click', function(){
$("#sy_des_show_div").show();
$("#sy_des_edit_div").hide();
$("#cancel_edit_sy_des").hide();
$("#save_sy_des").hide();
$("#edit_sy_des").show();
});
$("#save_sy_des").live('click', function(){
syllabus_description_editor.sync();
$("#syllabus-des-form").submit();
});
$("#cancel_edit_sy_ref").live('click', function(){
$("#sy_reference_show_box").show();
$("#sy_reference_edit_box").hide();
});
$("#sy_reference_edit_box").on("input", "input[name='syllabus[book][]']", function(){
$(this).parent().removeClass("edu-form-notice-border");
});
$("#save_sy_ref").live('click', function(){
var result = true;
$.each($("#sy_reference_edit_box input[name='syllabus[book][]']"), function(i, val){
if ($(val).val().length<=0) {
$(val).focus();
$(val).parent().addClass("edu-form-notice-border");
result = false;
return result;
}
});
if(result){
$("#syllabus-ref-form").submit();
}
});
$("#add_member_search_input").live('input', function(e){
throttle(sy_member_add_search, window, e);
});
$("#sy_search_course_input").live('input', function (e) {
throttle(sy_search_courses,window,e);
});
});
function delete_sy_member(id) {
$("#choose_sy_mem_"+id).remove();
}
function submit_add_sy_member(){
if($("#add_member_choose_ul input[name='member_id[]']").length > 0){
$("#syllabus_member_add_form").submit()
}else{
hideModal();
}
}
function sy_change_manager_submit(){
var list= $('input:radio[name="chooseteacher"]:checked').val();
if(list==null){
$("#sy_change_manager_notice").show();
}
else{
$("#change_syllabus_manager_form").submit();
}
}
function sy_member_add_search(e){
if ($(e.target).val().trim() == syMemberLastSearchCondition && $(e.target).val().trim() != '') {//如果输入框没有改变或者输入框为空就返回
return;
}
syMemberLastSearchCondition = $(e.target).val().trim();
$.ajax({
url: '/syllabuses/'+ $("#add_sy_member_syid").val() + '/search_not_sy_member?q=' + e.target.value,
type: 'post',
success: function (data) {
}
});
}
function choose_course_to_send(){
if($("input[name='check_resource[]']:checked").length >= 1){
$("#choose_course_to_send_notice").html("").hide();
$("#sy_search_course_form").submit();
}else{
$("#choose_course_to_send_notice").html("请先选择资源").show();
}
}
function choose_course_to_send_h(){
if($("input[name='check_homework[]']:checked").length >= 1){
$("#choose_course_to_send_notice_h").html("").hide();
$("#sy_search_course_h_form").submit();
}else{
$("#choose_course_to_send_notice_h").html("请先选择作业").show();
}
}
var lastSearchCondition = '';
function sy_search_courses(e){
if($(e.target).val().trim() == lastSearchCondition && lastSearchCondition != '')
{
return;
}
lastSearchCondition = $(e.target).val().trim();
$.ajax({
url: '/syllabuses/' + $("#syllabus_id").val() + '/choose_user_course',
type:'post',
data: {is_observe:true, search:e.target.value},
success: function(data){ }
});
}
function submit_send_resource_to_course(){
if($("input[name='course_id']:checked").length >= 1){
$("#search_course_notice").html("").hide();
$("#send_resource_to_course_form").submit();
hideModal();
}else{
$("#search_course_notice").html("请先选择一个班级").show();
}
}
function submit_send_homework_to_course(){
if($("input[name='course_id']:checked").length >= 1){
$("#search_course_notice_h").html("").hide();
$("#send_homework_to_course_form").submit();
hideModal();
}else{
$("#search_course_notice_h").html("请先选择一个班级").show();
}
}
function submit_send_r_and_h_to_course(){
if($("input[name='course_id']:checked").length >= 1){
$("#search_course_notice_r_and_h").html("").hide();
$("#send_r_and_h_to_course_form").submit();
hideModal();
}else{
$("#search_course_notice_r_and_h").html("请先选择一个班级").show();
}
}
$(function(){
var bt = baidu.template;
bt.LEFT_DELIMITER = '<!';
bt.RIGHT_DELIMITER = '!>';
$("#sy_reference_edit_box").on('click', 'a.add_refer', function(){
var html = bt('t:sy-refer-list', null);
$(this).parent('li').after(html);
});
$("#sy_reference_edit_box").on('click', 'a.delete_refer', function(){
$(this).parent('li').remove();
});
});