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

86 lines
3.2 KiB
Plaintext

<!--<div class="members_left">-->
<!--<input type="text" id="orgs_not_project_member_search" name="orgAddSearch" placeholder="支持姓名、邮箱、昵称搜索" class="orgAddSearch mb20" />-->
<!--<%#= javascript_tag "observeSearchfield('orgs_not_project_member_search', null, '#{ escape_javascript autocomplete_search_organizations_path(:project_id=> @project.id, :format => 'js') }')" %>-->
<!--<div id="new_orgs_for_project">-->
<!--</div>-->
<!--</div>-->
<%= stylesheet_link_tag 'org' %>
<div>
<div class="relateOrg fl">
<span class="pic_add fl mr5 mt3"></span><span class="f14 fontBlue fl">关联组织</span>
<div class="cl mb5"></div>
<%= form_tag url_for(:controller => 'org_projects', :action => 'create', :project_id => @project.id), :id => 'join_orgs_for_project', :remote => true do %>
<input type="text" name="orgs" class="searchOrg mb5 ml20" placeholder="请输入组织名称" />
<div id="search_orgs_result_list" class="ml20"></div>
<ul id="paginator" class="wlist ml20" style="float:none;"></ul>
<a href="javascript:void(0);" class="saveBtn db fl ml20 mr15 mb5" onclick="join_org(<%= @project.id %>);">关联</a>
<a href="javascript:void(0);" class="cancelBtn db fl" onclick="cancel_join_orgs();">取消</a>
<% end %>
</div>
<div class="relatedList fr">
<div class="fr mr15">
<span class="f14 fontBlue">已关联组织</span>
<div id="added_orgs">
<%= render :partial => 'projects/settings/added_orgs', :locals => {:orgs => @project.organizations, :project_id => params[:id]} %>
</div>
<div>
</div>
</div>
</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 => 'projects', :action => 'search_public_orgs_not_in_project') %>'+'?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: '<%= url_for(:controller => 'projects', :action => 'search_public_orgs_not_in_project') %>'+'?page=1',
type:'get'
});
});
function cancel_join_orgs() {
$("#search_orgs_result_list").html("");
$("#paginator").html("");
$("#paginator").css("display", "none");
}
function join_org(projectId) {
$.ajax({
url: '/org_projects' + "?" + $('#join_orgs_for_project').serialize() + "&project_id=" + projectId,
type: 'post',
success: function (data) {
$.ajax({
url: '/projects/'+projectId+'/search_public_orgs_not_in_project',
type: 'get'
});
}
});
}
</script>