Clean up toggleMultiSelect js function (#32813).

Patch by Mizuki ISHIKAWA.


git-svn-id: http://svn.redmine.org/redmine/trunk@19604 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2020-03-22 05:25:39 +00:00
parent 6acc439704
commit fb7d3bf7ce
3 changed files with 25 additions and 43 deletions

View File

@@ -15,13 +15,13 @@
<p>
<label><%=l(:label_role)%>:
<%= options_for_workflow_select 'role_id[]', Role.sorted.select(&:consider_workflow?), @roles, :id => 'role_id', :class => 'expandable' %>
<span class="toggle-multiselect icon-only"></span>
</label>
<a href="#" data-expands="#role_id"><span class="toggle-multiselect icon-only icon-toggle-plus"></span></a>
<label><%=l(:label_tracker)%>:
<%= options_for_workflow_select 'tracker_id[]', Tracker.sorted, @trackers, :id => 'tracker_id', :class => 'expandable' %>
<span class="toggle-multiselect icon-only"></span>
</label>
<a href="#" data-expands="#tracker_id"><span class="toggle-multiselect icon-only icon-toggle-plus"></span></a>
<%= submit_tag l(:button_edit), :name => nil %>
@@ -57,21 +57,4 @@
</div>
<%= submit_tag l(:button_save) %>
<% end %>
<% end %>
<%= javascript_tag do %>
$("a[data-expands]").click(function(e){
e.preventDefault();
var target = $($(this).attr("data-expands"));
if (target.attr("multiple")) {
$(this).find('span').switchClass('icon-toggle-minus', 'icon-toggle-plus');
target.attr("multiple", false);
target.find("option[value=all]").show();
} else {
$(this).find('span').switchClass('icon-toggle-plus', 'icon-toggle-minus');
target.attr("multiple", true);
target.find("option[value=all]").attr("selected", false).hide();
}
});
<% end %>
<% end %>

View File

@@ -15,14 +15,13 @@
<p>
<label><%=l(:label_role)%>:
<%= options_for_workflow_select 'role_id[]', Role.sorted.select(&:consider_workflow?), @roles, :id => 'role_id', :class => 'expandable' %>
<span class="toggle-multiselect icon-only"></span>
</label>
<a href="#" data-expands="#role_id"><span class="toggle-multiselect icon-only icon-toggle-plus"></span></a>
<label><%=l(:label_tracker)%>:
<%= options_for_workflow_select 'tracker_id[]', Tracker.sorted, @trackers, :id => 'tracker_id', :class => 'expandable' %>
<span class="toggle-multiselect icon-only"></span>
</label>
<a href="#" data-expands="#tracker_id"><span class="toggle-multiselect icon-only icon-toggle-plus"></span></a>
<%= submit_tag l(:button_edit), :name => nil %>
<%= hidden_field_tag 'used_statuses_only', '0', :id => nil %>
@@ -107,19 +106,4 @@ $("a.repeat-value").click(function(e){
var selected = td.find("select").find(":selected").val();
td.nextAll('td').find("select").val(selected);
});
$("a[data-expands]").click(function(e){
e.preventDefault();
var target = $($(this).attr("data-expands"));
if (target.attr("multiple")) {
$(this).find('span').switchClass('icon-toggle-minus', 'icon-toggle-plus');
target.attr("multiple", false);
target.find("option[value=all]").show();
} else {
$(this).find('span').switchClass('icon-toggle-plus', 'icon-toggle-minus');
target.attr("multiple", true);
target.find("option[value=all]").attr("selected", false).hide();
}
});
<% end %>