80 lines
2.7 KiB
Plaintext
80 lines
2.7 KiB
Plaintext
<%= stylesheet_link_tag "member_select" %>
|
|
<%= stylesheet_link_tag "lib/checkbox-card" %>
|
|
<style>
|
|
.checkbox-card li .member-pic {
|
|
float: left;
|
|
margin-right: 5px;
|
|
width: 40px;
|
|
height: 40px;
|
|
}
|
|
</style>
|
|
<div class="modal hide fade" tabindex="-1" role="dialog" id="<%=name%>_modal">
|
|
<div class="modal-dialog" role="document">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title"><%=t("ruling_timer.member")%></h5>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="member-filter-result nano">
|
|
<div>
|
|
<ul class="checkbox-card clearfix">
|
|
<% @selected_user_ids = @selected_user_ids.to_a.map{|id| id.to_s} %>
|
|
<% instance_variable_set("@selected_#{name}s",[]) %>
|
|
<% tmp = instance_variable_get("@selected_#{name}s") %>
|
|
<% @users.each do |user| %>
|
|
<% if @selected_user_ids.include?(user.id.to_s) %>
|
|
<% tmp << render(:partial => "user_card",:locals=>{:user=>user,:checked=>true}) %>
|
|
<%= tmp[-1] if @display_selected %>
|
|
<% else %>
|
|
<%= render :partial => "user_card",:locals=>{:user=>user} %>
|
|
<% end %>
|
|
<% end %>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-primary save_button">Save changes</button>
|
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
$(document).ready(function(){
|
|
function set_modal_max_height(){
|
|
var modal_body = $(this).find(".modal-body");
|
|
modal_body.css("max-height","auto");
|
|
var window_height = $(window).height();
|
|
var max_height = window_height - $(".modal-header").height() - $(".modal-footer").height() - 20 - window_height * 0.2 - 15 * 2;
|
|
modal_body.css("max-height",max_height);
|
|
}
|
|
$("#<%=name%>_modal").on("shown.bs.modal",set_modal_max_height);
|
|
$(window).resize(function(){
|
|
set_modal_max_height.call($(".modal"));
|
|
})
|
|
$("#<%=name%>_modal .save_button").off("click").on("click",function(){
|
|
var modal = $(this).parents(".modal");
|
|
var li_selected = modal.find(".check-item input:checked").parents("li");
|
|
<% if @user_params_name[-2..-1] != "[]" %>
|
|
if(li_selected.length > 1){
|
|
alert("<%=t('ruling_timer.can_only_choose_one')%>");
|
|
li_selected[0].scrollIntoView()
|
|
return false;
|
|
}
|
|
<% if @must_select %>
|
|
else if(li_selected.length == 0){
|
|
alert("<%=t('ruling_timer.must_select_one')%>");
|
|
}
|
|
<% end %>
|
|
<% end %>
|
|
<% if @display_selected %>
|
|
$("<%=@target%>").empty();
|
|
$("<%=@target%>").append(li_selected.clone());
|
|
<% else %>
|
|
$("<%=@target%>").append(li_selected);
|
|
<% end %>
|
|
modal.modal('hide');
|
|
})
|
|
})
|
|
</script> |