2015-08-24 11:03:09 +08:00
|
|
|
$(function(){
|
2015-08-24 16:16:07 +08:00
|
|
|
//右侧最小高度 = 左侧高度 - 15px 保证两边高度基本一样,页面美观
|
2015-08-28 17:27:51 +08:00
|
|
|
$("#RSide").css("min-height",$("#LSide").height()-35);
|
|
|
|
$("#users_setting").css("min-height",$("#LSide").height()-100);
|
2015-08-24 16:16:07 +08:00
|
|
|
|
2015-08-24 11:03:09 +08:00
|
|
|
//头像相关
|
2015-08-29 11:59:52 +08:00
|
|
|
$("#homepage_portrait_image").on("mouseover",function(){
|
2015-08-24 11:03:09 +08:00
|
|
|
$("#edit_user_file_btn").show();
|
|
|
|
$("#watch_user_btn").show();
|
2015-08-29 11:59:52 +08:00
|
|
|
}).on("mouseout",function(){
|
2015-08-24 11:03:09 +08:00
|
|
|
$("#edit_user_file_btn").hide();
|
|
|
|
$("#watch_user_btn").hide();
|
|
|
|
});
|
2015-08-26 13:56:37 +08:00
|
|
|
|
|
|
|
//日历选择样式
|
|
|
|
//$(".ui-datepicker-trigger").replaceWith("<div class='fl DateBorder mr10'><img class='ui-datepicker-trigger'></div>")
|
2015-08-24 11:03:09 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
//编辑个人简介
|
|
|
|
function show_edit_user_introduction() {
|
|
|
|
$("#user_brief_introduction_show").hide();
|
|
|
|
$("#user_brief_introduction_edit").show();
|
|
|
|
$("#user_brief_introduction_edit").focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
//编辑个人简介完成之后提交
|
|
|
|
function edit_user_introduction(url){
|
|
|
|
$.get(
|
|
|
|
url,
|
|
|
|
{ brief_introduction: $("#user_brief_introduction_edit").val() },
|
|
|
|
function (data) {
|
|
|
|
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-08-24 14:44:22 +08:00
|
|
|
//显示更多的课程
|
|
|
|
function show_more_course(url){
|
|
|
|
$.get(
|
|
|
|
url,
|
|
|
|
{ page: $("#course_page_num").val() },
|
|
|
|
function (data) {
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
//显示更多的项目
|
|
|
|
function show_more_project(url){
|
|
|
|
$.get(
|
|
|
|
url,
|
2015-08-24 14:53:35 +08:00
|
|
|
{ page: $("#project_page_num").val() },
|
2015-08-24 14:44:22 +08:00
|
|
|
function (data) {
|
|
|
|
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2015-08-26 17:29:47 +08:00
|
|
|
|
|
|
|
//老师提交 新建/修改 作业
|
|
|
|
function submit_homework(id)
|
|
|
|
{
|
|
|
|
if(!regex_homework_name())
|
|
|
|
{
|
|
|
|
$("#homework_name").focus();
|
|
|
|
}
|
2015-09-02 16:12:33 +08:00
|
|
|
else if(!regex_homework_end_time())
|
|
|
|
{
|
|
|
|
$("#homework_end_time").focus();
|
|
|
|
}
|
|
|
|
else if(!regex_course_id())
|
2015-08-26 17:29:47 +08:00
|
|
|
{
|
2015-09-02 16:12:33 +08:00
|
|
|
$("#course_id").focus();
|
|
|
|
}
|
|
|
|
else{
|
2015-09-11 09:36:44 +08:00
|
|
|
|
2015-08-26 17:29:47 +08:00
|
|
|
homework_description_editor.sync();
|
|
|
|
$("#"+id).submit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//验证新建作业的名字
|
|
|
|
function regex_homework_name()
|
|
|
|
{
|
|
|
|
var name = $.trim($("#homework_name").val());
|
|
|
|
|
|
|
|
if(name=="")
|
|
|
|
{
|
|
|
|
$("#homework_name_span").text("名称不能为空");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$("#homework_name_span").text("");
|
|
|
|
return true;
|
|
|
|
}
|
2015-08-28 10:00:48 +08:00
|
|
|
}
|
2015-09-02 16:12:33 +08:00
|
|
|
//验证截止时间
|
|
|
|
function regex_homework_end_time()
|
|
|
|
{
|
|
|
|
var name = $.trim($("#homework_end_time").val());
|
|
|
|
if(name=="")
|
|
|
|
{
|
|
|
|
$("#homework_end_time_span").text("截止时间不能为空");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$("#homework_end_time_span").text("");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//验证发送到课程
|
|
|
|
function regex_course_id(){
|
|
|
|
var course_id = $("#course_id").val();
|
|
|
|
if(course_id == -1)
|
|
|
|
{
|
|
|
|
$("#homework_course_id_span").text("发布课程不能为空");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$("#homework_course_id_span").text("");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2015-08-28 10:00:48 +08:00
|
|
|
|
|
|
|
//老师导入作业时查询作业
|
|
|
|
function search_homework_by_name(url){
|
|
|
|
$.get(
|
|
|
|
url,
|
|
|
|
{ name: $("#search_homework_name").val() },
|
|
|
|
function (data) {
|
|
|
|
}
|
|
|
|
);
|
2015-09-02 19:52:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//提交新建作品
|
|
|
|
function new_student_work()
|
|
|
|
{
|
|
|
|
if(regexStudentWorkName()&®exStudentWorkDescription())
|
|
|
|
{$("#new_student_work").submit();}
|
|
|
|
}
|
|
|
|
|
|
|
|
function edit_student_work(id)
|
|
|
|
{
|
|
|
|
if(regexStudentWorkName()&®exStudentWorkDescription())
|
|
|
|
{$("#edit_student_work_" + id).submit();}
|
|
|
|
}
|
|
|
|
|
|
|
|
//验证作品名称
|
|
|
|
function regexStudentWorkName()
|
|
|
|
{
|
|
|
|
var name = $.trim($("#student_work_name").val());
|
|
|
|
|
|
|
|
if(name=="")
|
|
|
|
{
|
|
|
|
$("#student_work_name_span").text("作品名称不能为空");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$("#student_work_name_span").text("");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function regexStudentWorkDescription()
|
|
|
|
{
|
|
|
|
var name = $.trim($("#student_work_description").val());
|
|
|
|
|
|
|
|
if(name=="")
|
|
|
|
{
|
|
|
|
$("#student_work_description_textarea").text("作品描述不能为空");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$("#student_work_description_textarea").text("");
|
|
|
|
return true;
|
|
|
|
}
|
2015-09-09 16:10:11 +08:00
|
|
|
}
|
|
|
|
|
2015-09-09 16:50:46 +08:00
|
|
|
//textarea自适应高度 纯js写的 有浏览器判断
|
|
|
|
/**
|
|
|
|
* 文本框根据输入内容自适应高度
|
|
|
|
* @param {HTMLElement} 输入框元素
|
|
|
|
* @param {Number} 设置光标与输入框保持的距离(默认0)
|
|
|
|
* @param {Number} 设置最大高度(可选)
|
|
|
|
*/
|
|
|
|
var autoTextarea = function (elem, extra, maxHeight) {
|
|
|
|
extra = extra || 0;
|
|
|
|
var isFirefox = !!document.getBoxObjectFor || 'mozInnerScreenX' in window,
|
|
|
|
isOpera = !!window.opera && !!window.opera.toString().indexOf('Opera'),
|
|
|
|
addEvent = function (type, callback) {
|
|
|
|
elem.addEventListener ?
|
|
|
|
elem.addEventListener(type, callback, false) :
|
|
|
|
elem.attachEvent('on' + type, callback);
|
|
|
|
},
|
|
|
|
getStyle = elem.currentStyle ? function (name) {
|
|
|
|
var val = elem.currentStyle[name];
|
|
|
|
|
|
|
|
if (name === 'height' && val.search(/px/i) !== 1) {
|
|
|
|
var rect = elem.getBoundingClientRect();
|
|
|
|
return rect.bottom - rect.top -
|
|
|
|
parseFloat(getStyle('paddingTop')) -
|
|
|
|
parseFloat(getStyle('paddingBottom')) + 'px';
|
|
|
|
};
|
|
|
|
|
|
|
|
return val;
|
|
|
|
} : function (name) {
|
|
|
|
return getComputedStyle(elem, null)[name];
|
|
|
|
},
|
|
|
|
minHeight = parseFloat(getStyle('height'));
|
|
|
|
|
|
|
|
|
|
|
|
elem.style.resize = 'none';
|
|
|
|
|
|
|
|
var change = function () {
|
|
|
|
var scrollTop, height,
|
|
|
|
padding = 0,
|
|
|
|
style = elem.style;
|
|
|
|
|
|
|
|
if (elem._length === elem.value.length) return;
|
|
|
|
elem._length = elem.value.length;
|
|
|
|
|
|
|
|
if (!isFirefox && !isOpera) {
|
|
|
|
padding = parseInt(getStyle('paddingTop')) + parseInt(getStyle('paddingBottom'));
|
|
|
|
};
|
|
|
|
scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
|
|
|
|
|
|
|
|
elem.style.height = minHeight + 'px';
|
|
|
|
if (elem.scrollHeight > minHeight) {
|
|
|
|
if (maxHeight && elem.scrollHeight > maxHeight) {
|
|
|
|
height = maxHeight - padding;
|
|
|
|
style.overflowY = 'auto';
|
|
|
|
} else {
|
|
|
|
height = elem.scrollHeight - padding;
|
|
|
|
style.overflowY = 'hidden';
|
|
|
|
};
|
|
|
|
style.height = height + extra + 'px';
|
|
|
|
scrollTop += parseInt(style.height) - elem.currHeight;
|
|
|
|
document.body.scrollTop = scrollTop;
|
|
|
|
document.documentElement.scrollTop = scrollTop;
|
|
|
|
elem.currHeight = parseInt(style.height);
|
|
|
|
};
|
2015-09-09 16:10:11 +08:00
|
|
|
};
|
|
|
|
|
2015-09-09 16:50:46 +08:00
|
|
|
addEvent('propertychange', change);
|
|
|
|
addEvent('input', change);
|
|
|
|
addEvent('focus', change);
|
|
|
|
change();
|
|
|
|
};
|