socialforge/app/views/courses/settings/_join_org.html.erb

84 lines
3.4 KiB
Plaintext

<%= stylesheet_link_tag 'css/org' %>
<% if @orgs_not_in_course.empty? && @course.organizations.empty? %>
<div class="icons_tishi"><img src="/images/new_project/icons_smile.png" width="110" height="110" alt="" ></div>
<p class="sy_tab_con_p">您没有创建组织,请先 <%=link_to '新建组织', new_organization_path, :class => 'sy_btn_green', :target => '_blank' %>,再关联</p>
<% else %>
<div class="sy_new_tchbox clear mt10">
<div class="course_setting_org_fl fl">
<h3 class="mb10 fl" style="color: #8f8f8f;">关联组织</h3>
<div class="cl mb5"></div>
<%= form_tag url_for(:controller => 'org_courses', :action => 'create', :course_id => @course.id), :id => 'join_orgs_for_course', :remote => true do %>
<input type="text" name="orgs" class="sy_new_search" style="height: 28px; width: 300px;" placeholder="请输入组织名称" />
<div class="cl mb5"></div>
<div id="search_orgs_result_list" ></div>
<ul id="paginator" class="wlist ml20" style="float:none;"></ul>
<a href="javascript:void(0);" class="fl sy_btn_blue mr5" onclick="course_join_org(<%= @course.id %>);">关联</a>
<a href="javascript:void(0);" class="fl sy_btn_grey mr5" onclick="cancel_join_orgs();">取消</a>
<% end %>
</div>
<div class="course_setting_org_fr fr">
<h3 class="mb20" style="color: #8f8f8f;">已关联组织</h3>
<ul>
<div id="added_orgs">
<%= render :partial => 'courses/settings/added_orgs', :locals => {:orgs => @course.organizations, :course_id => @course.id} %>
</div>
</ul>
</div>
</div>
<script type="text/javascript">
var lastSearchCondition = '';
var page = 1;
var count = 0;
var maxPage = 0;
function search_orgs(e){
if($(e.target).val().trim() == lastSearchCondition && lastSearchCondition != '')
{
return;
}
lastSearchCondition = $(e.target).val().trim();
page = 1;
$.ajax({
url: '<%= url_for(:controller => 'courses', :action => 'search_public_orgs_not_in_course') %>'+'?name='+ e.target.value+'&page='+page,
type:'get'
});
}
function throttle(method,context,e){
clearTimeout(method.tId);
method.tId=setTimeout(function(){
method.call(context,e);
},500);
}
//查询组织
$("input[name='orgs']").on('input', function (e) {
throttle(search_orgs,window,e);
});
$(document).ready(function(){
$.ajax({
url: "/courses/<%=@course.id.to_s %>/search_public_orgs_not_in_course?page=1" ,
type:'get'
});
});
function cancel_join_orgs() {
$("#join_orgs_for_course input:checked").attr("checked", false);
}
function course_join_org(courseId) {
$.ajax({
url: "/org_courses?" + $("#join_orgs_for_course").serialize() + "&course_id=" + courseId,
type: "post",
success: function (data) {
$.ajax({
url: "/courses/" + courseId + "/search_public_orgs_not_in_course?hint_flag=true&name=" + $("input[name='orgs']").val().trim(),
type: "get"
});
}
});
}
</script>
<% end %>