socialforge/public/javascripts/syllabus.js

127 lines
3.2 KiB
JavaScript

//显示更多的班级
function show_more_course(url){
$.get(
url,
function (data) {
}
);
}
function regex_sylla_description() {
syllabus_description_editor.sync();
var name = syllabus_description_editor.html();
if (name.length == 0) {
$("#description_notice_span").text("描述不能为空");
$("#description_notice_span").css('color', '#ff0000');
$("#description_notice_span").focus();
return false;
}
else {
$("#description_notice_span").text("填写正确");
$("#description_notice_span").css('color', '#008000');
return true;
}
}
function submit_syllabus() {
if (regex_sylla_description()) {
$("#syllabus-form").submit();
}
}
//编辑英文名称
function show_edit_eng_name(str) {
EngEdit = true;
$("#syllabus_eng_name_show").hide();
$("#syllabus_eng_name_edit").show();
$("#syllabus_eng_name_edit").val(str);
$("#syllabus_eng_name_edit").focus();
}
//编辑英文名称之后提交
function edit_syllabus_eng_name(url){
if(EngEdit) {
EngEdit = false;
$.get(
url,
{ eng_name: $("#syllabus_eng_name_edit").val() },
function (data) {
}
);
}
}
//编辑课程名称
function show_edit_title(str) {
IsEdit = true;
$("#syllabus_title_show").hide();
$("#syllabus_title_edit").show();
$("#syllabus_title_edit").val(str);
$("#syllabus_title_edit").focus();
}
//编辑课程名称之后提交
function edit_syllabus_title(url){
if(IsEdit) {
IsEdit = false;
$.get(
url,
{ title: $("#syllabus_title_edit").val().trim() },
function (data) {
}
);
}
}
//展开所有属性
function toggle_all_syllabus_attr(){
var btn = $("#show_all_syllabus_attr");
var target = $("#all_syllabus_attr li");
var none = $("#all_syllabus_attr li.none_attr");
if(btn.data('init')=='0'){
btn.data('init',1);
btn.removeClass('homepageLeftMenuMoreIcon2');
btn.addClass('homepageLeftMenuHideIcon2');
target.show();
}else{
btn.data('init',0);
btn.addClass('homepageLeftMenuMoreIcon2');
btn.removeClass('homepageLeftMenuHideIcon2');
none.hide();
}
}
function update_syllabus_info(){
if(regex_syllabus_credit('credit') && regex_syllabus_credit('hours') && regex_syllabus_credit('theory_hours') && regex_syllabus_credit('practice_hours')) {
$("#submit_edit_info").parent().submit();
}
}
function regex_syllabus_credit(str){
var num = $.trim($("#syllabus_"+str+"_input").val());
var regex = /^\d*$/;
if(num.length > 0)
{
if (regex.test(num)) {
if(parseInt(num) > 0)
{
$("#syllabus_"+str+"_notice").hide();
return true;
} else
{
$("#syllabus_"+str+"_notice").show();
$("#syllabus_"+str+"_input").focus();
return false;
}
} else {
$("#syllabus_"+str+"_notice").show();
$("#syllabus_"+str+"_input").focus();
return false;
}
} else {
return true;
}
}