socialforge/app/views/courses/_add_members.html.erb

88 lines
3.4 KiB
Plaintext

<div id="muban_popup_box" style="width:400px;">
<div class="muban_popup_top">
<h3 class="fl">添加成员</h3>
<a href="javascript:void(0);" class="muban_icons_close fr"></a>
<div class="cl"></div>
</div>
<div class="muban_popup_con clear">
<div class="f14 fb fontGrey3 mb10 mt15 ml20">选择成员加入分班</div>
<div class="fl mr10 ml20 w350">
<input type="text" name="search" value="<%=@search %>" placeholder="输入学生登录名/姓名/学号进行搜索" class="subjectSearch" />
<div class="cl"></div>
<%= form_tag(add_members_course_path(@course, :group_id => @group.id), method: 'post',:class => "",:id => "add_group_members") do %>
<div id="search_member_list">
<%=render :partial => 'search_member_list', :locals => {:members => members} %>
</div>
<% end %>
<div class="cl"></div>
<span class="c_red none" id="add_members_notice"></span>
<div class="cl"></div>
<div class="mt10">
<a href="javascript:void(0);" class="fl sy_btn_blue mr10" onclick="submit_add_members_form();">确定</a>
<a href="javascript:void(0);" class="fl sy_btn_grey" onclick="hideModal();">取消</a>
<div class="cl"></div>
</div>
</div>
<div class="cl"></div>
</div>
</div>
<script>
var lastSearchCondition = '';
var count = 0;
function search_mems(e){
if($(e.target).val().trim() == lastSearchCondition && lastSearchCondition != '')
{
return;
}
lastSearchCondition = $(e.target).val().trim();
$.ajax({
url: '<%= url_for(:controller => 'courses', :action => 'search_not_group_member', :id => @group.course.id) %>'+'?search='+ e.target.value+'&group_id=<%=@group.id %>&is_search=1',
type:'get'
});
}
function throttle(method,context,e){
clearTimeout(method.tId);
method.tId=setTimeout(function(){
method.call(context,e);
},500);
}
//查询项目
$("input[name='search']").on('input', function (e) {
throttle(search_mems,window,e);
});
$(document).ready(function(){
<% if members.empty? %>
$("#add_members_notice").show();
$("#add_members_notice").html("不存在未分班的成员");
<% end %>
$("input[name='chooseAll']").live('click',function(){
if($("input[name='chooseAll']").attr("checked")){
$("input[name='chooseStudent[]']").attr("checked",true);
};
if(!$("input[name='chooseAll']").attr("checked")){
$("input[name='chooseStudent[]']").attr("checked",false);
};
});
$("input[name='chooseStudent[]']").live('click',function(){
if(!$(this).attr("checked")){
$("input[name='chooseAll']").attr("checked",false);
}
if($("input[name='chooseStudent[]']:checked").length == $("input[name='chooseStudent[]']").length){
$("input[name='chooseAll']").attr("checked",true);
}
});
});
function submit_add_members_form(){
if($("input[name='chooseStudent[]']:checked").length == 0) {
$("#add_members_notice").show();
$("#add_members_notice").html("请先选择学生");
} else{
$("#add_group_members").submit();
hideModal();
}
}
</script>