496 lines
19 KiB
JavaScript
496 lines
19 KiB
JavaScript
$(function() {
|
||
$("#search_not_teacher").live('input', function (e) {
|
||
throttle(search_not_teacher_f,window,e);
|
||
});
|
||
|
||
$("#search_not_student").live('input', function (e) {
|
||
throttle(search_not_student_f,window,e);
|
||
});
|
||
|
||
//模块切换
|
||
$(".stud-class-set .news .nav").click(function(e) {
|
||
var $a = $(e.target);
|
||
var $b = $a.attr("data-option");
|
||
console.log($b);
|
||
if($b){
|
||
$(".stud-class-set .news .nav p").removeClass("sheet");
|
||
$(".stud-class-set .news .nav p i").hide();
|
||
$a.addClass("sheet");
|
||
$a.find("i").show();
|
||
$(".stud-class-set .news .container").children().hide();
|
||
$(".stud-class-set .news .container").find("." + $b + "").show();
|
||
}
|
||
});
|
||
//操作弹框中单选复选框的选中与否
|
||
$(".tip li").click(function(e) {
|
||
|
||
if($(this).find(".blue").css("display") == "none") {
|
||
|
||
$(this).find(".grey").hide();
|
||
$(this).find(".blue").show();
|
||
|
||
} else {
|
||
|
||
$(this).find(".blue").hide();
|
||
$(this).find(".grey").show();
|
||
|
||
}
|
||
});
|
||
$(".student .fa").click(function() {
|
||
console.log(1);
|
||
});
|
||
//教师学生模块切换
|
||
$(".stud-class-set .news .container .member .people .left ul li").live('click', function(e) {
|
||
$(".stud-class-set .news .container .member .people .left ul li").removeClass("sheet");
|
||
$(this).addClass("sheet");
|
||
if($(this).attr("data-option") == "teacher") {
|
||
$("#setting_teacher_list").show();
|
||
$("#setting_student_list").html("");
|
||
}
|
||
if($(this).attr("data-option") == "allstudent") {
|
||
var $course_id = $(this).attr("data-course-id");
|
||
$.get(
|
||
'/courses/'+$course_id+'/all_student_list'
|
||
)
|
||
}
|
||
if($(this).attr("data-option") == "noclass") {
|
||
var $course_id = $(this).attr("data-course-id");
|
||
$.get(
|
||
'/courses/'+$course_id+'/no_group_student_list'
|
||
)
|
||
}
|
||
|
||
if($(this).attr("data-option") == "hasclass") {
|
||
var $course_id = $(this).attr("data-course-id");
|
||
var $group_id = $(this).attr("data-group-id");
|
||
$.get(
|
||
'/courses/'+$course_id+'/has_group_student_list?group_id='+$group_id
|
||
)
|
||
}
|
||
|
||
});
|
||
|
||
// $(".stud-class-set .news .container .member .people .left ul li .p1 i").hover(function () {
|
||
// $(this).parent().next().show().hover(function () { clearTimeout(window.timer); }, function () { $(this).hide(); });
|
||
// }, function (e) {
|
||
// var dom = $(this).parent().next();
|
||
// window.timer = setTimeout(function () { dom.hide(); }, 200); //延时隐藏,以便鼠标移动到div上时clear掉计时器
|
||
// });
|
||
|
||
$(".stud-class-set .news .container .member .people .left ul li .p1 i").live({
|
||
mouseenter:
|
||
function()
|
||
{
|
||
$(this).parent().next().show().hover(function () { clearTimeout(window.timer); }, function () { $(this).hide(); });
|
||
},
|
||
mouseleave:
|
||
function(e)
|
||
{
|
||
var dom = $(this).parent().next();
|
||
window.timer = setTimeout(function () { dom.hide(); }, 200); //延时隐藏,以便鼠标移动到div上时clear掉计时器
|
||
}
|
||
});
|
||
|
||
$("#choose_course_group_submit").live('click', function(){
|
||
if($("#course_group_id").val() == '0'){
|
||
$("#choose_course_group_notice").show();
|
||
} else{
|
||
$("#teacher_assign_group_form").submit();
|
||
$("#choose_course_group_notice").hide();
|
||
}
|
||
});
|
||
|
||
$(".join .handle").live('click', function(){
|
||
if($("input[name='member_ids[]']:checked").length > 0){
|
||
$("#choose_course_group_form").submit();
|
||
}
|
||
});
|
||
|
||
$("input[name='member_ids[]']").live('click', function(){
|
||
if($("input[name='member_ids[]']:checked").length > 0){
|
||
$(".join .handle_no").hide();
|
||
$(".join .handle").show();
|
||
} else{
|
||
$(".join .handle_no").show();
|
||
$(".join .handle").hide();
|
||
}
|
||
if($("input[name='member_ids[]']:checked").length == $("input[name='member_ids[]']").length){
|
||
$("#all_member_select").attr("checked", "checked");
|
||
} else{
|
||
$("#all_member_select").removeAttr("checked");
|
||
}
|
||
});
|
||
|
||
$("#all_member_select").live('click', function(){
|
||
if($("#all_member_select").is(':checked')){
|
||
$("input[name='member_ids[]']").attr("checked", "checked");
|
||
$(".join .handle_no").hide();
|
||
$(".join .handle").show();
|
||
} else {
|
||
$("input[name='member_ids[]']").removeAttr("checked");
|
||
$(".join .handle_no").show();
|
||
$(".join .handle").hide();
|
||
}
|
||
});
|
||
|
||
|
||
// var changeColor = function(c){
|
||
// if(c.find(".blue").css("display") == "none") {
|
||
// c.find(".blue").show();
|
||
// c.find(".grey").hide();
|
||
// c.find("input").attr("checked", "checked");
|
||
//
|
||
// } else {
|
||
// c.find(".blue").hide();
|
||
// c.find(".grey").show();
|
||
// c.find("input").removeAttr("checked");
|
||
//
|
||
// }
|
||
// };
|
||
// $(".open-select").click(function() {
|
||
// changeColor($(this));
|
||
// if($("#allselect").find("input").is(':checked')) {
|
||
// //console.log(1);
|
||
// $(".member .student .newstudent .open-select").find("input").attr("checked", "checked");
|
||
// $(".member .student .newstudent .open-select").find(".blue").show();
|
||
// $(".member .student .newstudent .open-select").find(".grey").hide();
|
||
// }
|
||
// var $length = $(".member .student .newstudent .open-select input").length;
|
||
// var flag = true;
|
||
// for(i = 0; i < $length; i++) {
|
||
// var $b = $(".member .student .newstudent .open-select input").eq(i);
|
||
// if(! $b.is(':checked')) {
|
||
// //console.log(1)
|
||
// flag = false;
|
||
// break;
|
||
// }
|
||
// if(flag) {
|
||
// $("#allselect").find("input").attr("checked", "checked");
|
||
// $("#allselect").find(".blue").show();
|
||
// $("#allselect").find(".grey").hide();
|
||
// }
|
||
// }
|
||
// });
|
||
// var RadioButton = function(b,c){
|
||
// $(b).find(".grey").show();
|
||
// $(b).find(".blue").hide();
|
||
// $(b).find("input").removeAttr("checked");
|
||
// changeColor(c);
|
||
// };
|
||
// $(".single-choice1").click(function(){
|
||
//
|
||
// RadioButton(".single-choice1",$(this));
|
||
// });
|
||
// $(".single-choice2").click(function(){
|
||
//
|
||
// RadioButton(".single-choice2",$(this));
|
||
// });
|
||
});
|
||
|
||
function add_new_group(id){
|
||
var htmlvalue = '<div class="task-popup newclass" style="width:450px;">' +
|
||
'<div class="task-popup-title clearfix task-popup-bggrey">' +
|
||
'<h3 class="fl">新建分班</h3>' +
|
||
'<a href="javascript:void(0);" onclick="hideModal();"><i class="fa fa-times-circle font-18 link-color-grey fr mt5"></i></a>' +
|
||
'</div>' +
|
||
'<div class="task_popup_con clearfix">' +
|
||
'<div class="pt20 clearfix mb20" style="width:400px;">' +
|
||
'<label class="panel-form-label label fl">分班名称 </label>' +
|
||
'<input type="text" name="group_name" id="new_group_name" style="width:300px;" maxlength="20" class="pl10 task task-height-40 panel-box-sizing fl color-grey">' +
|
||
'<div class="cl"></div>' +
|
||
'<span class="color-orange fl none" id="add_new_group_notice" style="margin-left:22.5%;"><i class="fa fa-exclamation-circle mr5" ></i>该分班已存在</span></div>' +
|
||
'<a href="javascript:void(0);" class="task-btn task-btn-blue fr mr20" onclick="submit_new_group_form('+id+');">确定</a>' +
|
||
'<a href="javascript:void(0);" onclick="hideModal();" class="task-btn fr mr10">取消</a>' +
|
||
'</div>' +
|
||
'</div>';
|
||
pop_box_new(htmlvalue, 450, 205);
|
||
}
|
||
|
||
function submit_new_group_form(id){
|
||
var val = $.trim($("#new_group_name").val());
|
||
if(val == ""){
|
||
$("#add_new_group_notice").html('<i class="fa fa-exclamation-circle mr5" ></i>名称不能为空').show();
|
||
return false;
|
||
} else{
|
||
$.ajax({
|
||
url: "/courses/"+ id +"/addgroups",
|
||
type: 'post',
|
||
data: {group_name: val},
|
||
success: function(data){
|
||
if(data.result == 0){
|
||
$("#add_new_group_notice").html('<i class="fa fa-exclamation-circle mr5" ></i>该分组已存在').show();
|
||
} else{
|
||
$("#add_new_group_notice").hide();
|
||
hideModal();
|
||
window.location.href = "/courses/"+id+"/settings/member";
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
function update_choose_group_allow(id){
|
||
$.ajax({
|
||
url: "/courses/"+ id +"/choose_group_allow",
|
||
type: 'get',
|
||
success: function(data){
|
||
|
||
}
|
||
});
|
||
}
|
||
|
||
function rename_group_name(course_id, group_id){
|
||
var htmlvalue = '<div class="task-popup rename" style="width:450px">' +
|
||
'<div class=" task-popup-title clearfix task-popup-bggrey">' +
|
||
'<h3 class="fl color-grey">重命名</h3>' +
|
||
'<a href="javascript:void(0);" onclick="hideModal();"><i class="fa fa-times-circle font-18 link-color-grey fr mt5"></i></a>' +
|
||
'</div>' +
|
||
'<div class="task-popup-content clearfix">' +
|
||
'<div class="pt20 clearfix mb20">' +
|
||
'<label class="fl font-16 color-grey" style="line-height:40px;"> 名 称: </label>' +
|
||
'<input type="text" id="edit_group_name" maxlength="20" class="task-form-80 task-height-40 panel-box-sizing fl">' +
|
||
'<div class="cl"></div>' +
|
||
'<span class="color-orange fl none" id="edit_new_group_notice" style="margin-left:14%;"><i class="fa fa-exclamation-circle mr5" ></i>该分班已存在</span></div>' +
|
||
'<a href="javascript:void(0);" class="task-btn task-btn-blue fr mr25" onclick="submit_rename_group_form('+course_id+', '+ group_id +');">确定</a>' +
|
||
'<a href="javascript:void(0);" onclick="hideModal();" class="task-btn fr mr10">取消</a>' +
|
||
'</div>' +
|
||
'</div>';
|
||
pop_box_new(htmlvalue, 450, 195);
|
||
}
|
||
|
||
function submit_rename_group_form(course_id, group_id){
|
||
var val = $.trim($("#edit_group_name").val());
|
||
if(val == ""){
|
||
$("#edit_new_group_notice").html('<i class="fa fa-exclamation-circle mr5" ></i>名称不能为空').show();
|
||
return false;
|
||
} else{
|
||
$.ajax({
|
||
url: "/courses/"+ course_id +"/updategroupname",
|
||
type: 'post',
|
||
data: {group_name: val,
|
||
group_id: group_id},
|
||
success: function(data){
|
||
if(data.result == 0){
|
||
$("#edit_new_group_notice").html('<i class="fa fa-exclamation-circle mr5" ></i>该分组已存在').show();
|
||
} else{
|
||
$("#edit_new_group_notice").hide();
|
||
hideModal();
|
||
window.location.href = "/courses/"+course_id+"/settings/member";
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
function delete_group(course_id, group_id){
|
||
var htmlvalue = '<div class="task-popup twohint" style="width:450px">' +
|
||
'<div class=" task-popup-title clearfix">' +
|
||
'<h3 class="fl color-grey">提示</h3>' +
|
||
'<a href="javascript:void(0);" onclick="hideModal();"><i class="fa fa-times-circle font-18 link-color-grey fr mt5"></i></a>' +
|
||
'</div>' +
|
||
'<div class="task-popup-content">' +
|
||
'<p class="task-popup-text-center font-16">确定要删除吗?<br/> 删除分班后,该分班的学生需要重新选择分班。' +
|
||
'</div>' +
|
||
'<div class="task-popup-submit02 clearfix" style="width:120px;">' +
|
||
'<a href="/courses/'+ course_id +'/deletegroup?group_id='+ group_id +'" data-method="delete" class="task-btn task-btn-blue fr">确定</a>' +
|
||
'<a href="javascript:void(0);" onclick="hideModal();" class="task-btn fr mr10">取消</a>' +
|
||
'</div>' +
|
||
'</div>';
|
||
pop_box_new(htmlvalue, 450, 300);
|
||
}
|
||
|
||
function submit_change_manager_form(){
|
||
if($("input[name='chooseteacher']:checked").length == 0) {
|
||
$("#change_manager_notice").show();
|
||
} else{
|
||
$("#change_manager_form").submit();
|
||
hideModal();
|
||
}
|
||
}
|
||
|
||
var lastteSearchCondition = '';
|
||
function search_not_teacher_f(e){
|
||
if($(e.target).val().trim() == "" || ($(e.target).val().trim() == lastteSearchCondition && lastteSearchCondition != ''))
|
||
{
|
||
return;
|
||
}
|
||
lastteSearchCondition = $(e.target).val().trim();
|
||
$.ajax({
|
||
url: '/courses/' + $("#course_search_not_teacher_id").val() + '/search_not_teachers',
|
||
type:'post',
|
||
data: {is_observe:true, search:e.target.value},
|
||
success: function(data){ }
|
||
});
|
||
}
|
||
|
||
function submit_add_teacher_form(){
|
||
if($("input[name='membership[user_ids][]']:checked").length >= 1){
|
||
if($("input[name='membership[role_ids][]']:checked").length >= 1){
|
||
$("#add_teacher_notice").html("").hide();
|
||
$("#add_teacher_form").submit();
|
||
hideModal();
|
||
} else{
|
||
$("#add_teacher_notice").html("请先选择一个角色").show();
|
||
}
|
||
}else{
|
||
$("#add_teacher_notice").html("请至少选择一个用户").show();
|
||
}
|
||
}
|
||
|
||
function submit_all_student_list_search(id){
|
||
$.get(
|
||
'/courses/'+id+'/all_student_list?search='+$("#all_student_list_search").val().trim()
|
||
)
|
||
}
|
||
|
||
function submit_no_group_student_search(id){
|
||
$.get(
|
||
'/courses/'+id+'/no_group_student_list?search='+$("#no_group_student_list_search").val().trim()
|
||
)
|
||
}
|
||
|
||
function submit_has_group_student_search(id, group_id){
|
||
$.get(
|
||
'/courses/'+id+'/has_group_student_list?group_id='+group_id+'&search='+$("#has_group_student_list_search").val().trim()
|
||
)
|
||
}
|
||
|
||
var laststSearchCondition = '';
|
||
function search_not_student_f(e){
|
||
if($(e.target).val().trim() == "" || ($(e.target).val().trim() == laststSearchCondition && laststSearchCondition != ''))
|
||
{
|
||
return;
|
||
}
|
||
laststSearchCondition = $(e.target).val().trim();
|
||
$.ajax({
|
||
url: '/courses/' + $("#course_search_not_student_id").val() + '/search_not_students',
|
||
type:'post',
|
||
data: {is_observe:true, search:e.target.value},
|
||
success: function(data){ }
|
||
});
|
||
}
|
||
|
||
function submit_add_student_form(){
|
||
if($("input[name='membership[user_ids][]']:checked").length >= 1){
|
||
$("#add_student_notice").html("").hide();
|
||
$("#add_student_form").submit();
|
||
hideModal();
|
||
}else{
|
||
$("#add_student_notice").html("请至少选择一个用户").show();
|
||
}
|
||
}
|
||
|
||
function res_send_to_course(id, user_id, send_type){
|
||
$.ajax({
|
||
type: 'get',
|
||
url: '/users/' + user_id + '/search_user_course',
|
||
data:{send_id:id, send_type:send_type}
|
||
});
|
||
}
|
||
|
||
//滑动打分
|
||
$.fn.peSlider = function(settings){
|
||
//configurable options (none so far)
|
||
var o = $.extend({},settings);
|
||
if( !$('body').is('[role]') ){ $('body').attr('role','application'); }
|
||
return $(this).each(function(){
|
||
var thisLabel = $('label[for=' + $(this).attr('id') + ']').attr('id', $(this).attr('id') + '-label').attr('id');
|
||
var thisUnits = $(this).attr('data-units') || '';
|
||
var slider = $('<div></div>');
|
||
if( $(this).is('input') ){
|
||
var input = $(this);
|
||
var thisUnits = input.attr('data-units');
|
||
var friendlyVal = input.val() + ' ' + thisUnits;
|
||
var sliderOptions = $.extend(o,{
|
||
min: parseFloat(input.attr('min')),
|
||
max: parseFloat(input.attr('max')),
|
||
value: parseFloat(input.val())
|
||
});
|
||
if(parseFloat(input.val()) == -1){
|
||
input.css("color", "#fff");
|
||
input.next().next().html("未评分");
|
||
input.next().next().show();
|
||
} else{
|
||
input.css("color", "#000");
|
||
input.next().next().hide();
|
||
}
|
||
slider
|
||
.insertBefore(input)
|
||
.slider(sliderOptions)
|
||
.bind('slide', function(e, ui){
|
||
if(ui.value == -1){
|
||
input.css("color", "#fff");
|
||
input.next().next().html("未评分");
|
||
input.next().next().show();
|
||
} else {
|
||
input.css("color", "#000");
|
||
input.next().next().hide();
|
||
}
|
||
input.val(ui.value);
|
||
friendlyVal = input.val() + ' ' + thisUnits;
|
||
slider.find('a').attr({
|
||
'aria-valuenow': ui.value,
|
||
'aria-valuetext': friendlyVal
|
||
});
|
||
})
|
||
.find('a')
|
||
.attr({
|
||
'role': 'slider',
|
||
'aria-valuemin': input.attr('min'),
|
||
'aria-valuemax': input.attr('max'),
|
||
'aria-valuenow': input.val(),
|
||
'aria-valuetext': friendlyVal,
|
||
'aria-labelledby': thisLabel
|
||
});
|
||
input
|
||
.keyup(function(){
|
||
var inVal = parseFloat(input.val());
|
||
if( !isNaN(inVal) ){
|
||
if(inVal == -1){
|
||
input.css("color", "#fff");
|
||
input.next().next().html("未评分");
|
||
input.next().next().show();
|
||
} else {
|
||
input.css("color", "#000");
|
||
input.next().next().hide();
|
||
}
|
||
slider.slider('value', inVal);
|
||
input.val(slider.slider('value'));
|
||
}
|
||
})
|
||
.change(function(){
|
||
var inVal = parseFloat(input.val());
|
||
if( !isNaN(inVal) ){
|
||
if(inVal == -1){
|
||
input.css("color", "#fff");
|
||
input.next().next().html("未评分");
|
||
input.next().next().show();
|
||
} else {
|
||
input.css("color", "#000");
|
||
input.next().next().hide();
|
||
}
|
||
slider.slider('value', inVal);
|
||
input.val(slider.slider('value'));
|
||
}
|
||
})
|
||
.blur(function(){
|
||
var inVal = parseFloat(input.val());
|
||
if( isNaN(inVal) ){
|
||
input.val(-1);
|
||
}
|
||
if(input.val() == -1){
|
||
input.css("color", "#fff");
|
||
input.next().next().html("未评分");
|
||
input.next().next().show();
|
||
} else {
|
||
input.css("color", "#000");
|
||
input.next().next().hide();
|
||
}
|
||
});
|
||
if( !settings.step ){
|
||
var step = Math.round( parseFloat(input.attr('max')) / slider.width());
|
||
if(step > 1){ slider.slider('option','step',step); }
|
||
}
|
||
}
|
||
});
|
||
}; |