mirror of
https://github.com/redmine/redmine.git
synced 2025-11-15 17:56:03 +01:00
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:
@@ -15,13 +15,13 @@
|
|||||||
<p>
|
<p>
|
||||||
<label><%=l(:label_role)%>:
|
<label><%=l(:label_role)%>:
|
||||||
<%= options_for_workflow_select 'role_id[]', Role.sorted.select(&:consider_workflow?), @roles, :id => 'role_id', :class => 'expandable' %>
|
<%= 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>
|
</label>
|
||||||
<a href="#" data-expands="#role_id"><span class="toggle-multiselect icon-only icon-toggle-plus"></span></a>
|
|
||||||
|
|
||||||
<label><%=l(:label_tracker)%>:
|
<label><%=l(:label_tracker)%>:
|
||||||
<%= options_for_workflow_select 'tracker_id[]', Tracker.sorted, @trackers, :id => 'tracker_id', :class => 'expandable' %>
|
<%= options_for_workflow_select 'tracker_id[]', Tracker.sorted, @trackers, :id => 'tracker_id', :class => 'expandable' %>
|
||||||
|
<span class="toggle-multiselect icon-only"></span>
|
||||||
</label>
|
</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 %>
|
<%= submit_tag l(:button_edit), :name => nil %>
|
||||||
|
|
||||||
@@ -58,20 +58,3 @@
|
|||||||
<%= submit_tag l(:button_save) %>
|
<%= submit_tag l(:button_save) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% 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 %>
|
|
||||||
|
|||||||
@@ -15,14 +15,13 @@
|
|||||||
<p>
|
<p>
|
||||||
<label><%=l(:label_role)%>:
|
<label><%=l(:label_role)%>:
|
||||||
<%= options_for_workflow_select 'role_id[]', Role.sorted.select(&:consider_workflow?), @roles, :id => 'role_id', :class => 'expandable' %>
|
<%= 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>
|
</label>
|
||||||
<a href="#" data-expands="#role_id"><span class="toggle-multiselect icon-only icon-toggle-plus"></span></a>
|
|
||||||
|
|
||||||
<label><%=l(:label_tracker)%>:
|
<label><%=l(:label_tracker)%>:
|
||||||
<%= options_for_workflow_select 'tracker_id[]', Tracker.sorted, @trackers, :id => 'tracker_id', :class => 'expandable' %>
|
<%= options_for_workflow_select 'tracker_id[]', Tracker.sorted, @trackers, :id => 'tracker_id', :class => 'expandable' %>
|
||||||
|
<span class="toggle-multiselect icon-only"></span>
|
||||||
</label>
|
</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 %>
|
<%= submit_tag l(:button_edit), :name => nil %>
|
||||||
|
|
||||||
<%= hidden_field_tag 'used_statuses_only', '0', :id => 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();
|
var selected = td.find("select").find(":selected").val();
|
||||||
td.nextAll('td').find("select").val(selected);
|
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 %>
|
<% end %>
|
||||||
|
|||||||
@@ -120,10 +120,6 @@ function initFilters() {
|
|||||||
$('#filters-table').on('click', 'td.field input[type=checkbox]', function() {
|
$('#filters-table').on('click', 'td.field input[type=checkbox]', function() {
|
||||||
toggleFilter($(this).val());
|
toggleFilter($(this).val());
|
||||||
});
|
});
|
||||||
$('#filters-table').on('click', '.toggle-multiselect', function() {
|
|
||||||
toggleMultiSelect($(this).siblings('select'))
|
|
||||||
$(this).toggleClass('icon-toggle-plus icon-toggle-minus')
|
|
||||||
});
|
|
||||||
$('#filters-table').on('keypress', 'input[type=text]', function(e) {
|
$('#filters-table').on('keypress', 'input[type=text]', function(e) {
|
||||||
if (e.keyCode == 13) $(this).closest('form').submit();
|
if (e.keyCode == 13) $(this).closest('form').submit();
|
||||||
});
|
});
|
||||||
@@ -151,6 +147,7 @@ function addFilter(field, operator, values) {
|
|||||||
}
|
}
|
||||||
$('#cb_'+fieldId).prop('checked', true);
|
$('#cb_'+fieldId).prop('checked', true);
|
||||||
toggleFilter(field);
|
toggleFilter(field);
|
||||||
|
toggleMultiSelectIconInit();
|
||||||
$('#add_filter_select').val('').find('option').each(function() {
|
$('#add_filter_select').val('').find('option').each(function() {
|
||||||
if ($(this).attr('value') == field) {
|
if ($(this).attr('value') == field) {
|
||||||
$(this).attr('disabled', true);
|
$(this).attr('disabled', true);
|
||||||
@@ -189,7 +186,7 @@ function buildFilterRow(field, operator, values) {
|
|||||||
case "list_subprojects":
|
case "list_subprojects":
|
||||||
tr.find('td.values').append(
|
tr.find('td.values').append(
|
||||||
'<span style="display:none;"><select class="value" id="values_'+fieldId+'_1" name="v['+field+'][]"></select>' +
|
'<span style="display:none;"><select class="value" id="values_'+fieldId+'_1" name="v['+field+'][]"></select>' +
|
||||||
' <span class="toggle-multiselect icon-only icon-toggle-plus"> </span></span>'
|
' <span class="toggle-multiselect icon-only '+(values.length > 1 ? 'icon-toggle-minus' : 'icon-toggle-plus')+'"> </span></span>'
|
||||||
);
|
);
|
||||||
select = tr.find('td.values select');
|
select = tr.find('td.values select');
|
||||||
if (values.length > 1) { select.attr('multiple', true); }
|
if (values.length > 1) { select.attr('multiple', true); }
|
||||||
@@ -336,11 +333,14 @@ function toggleOperator(field) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function toggleMultiSelect(el) {
|
function toggleMultiSelect(el) {
|
||||||
|
var isWorkflow = el.closest('.controller-workflows');
|
||||||
if (el.attr('multiple')) {
|
if (el.attr('multiple')) {
|
||||||
el.removeAttr('multiple');
|
el.removeAttr('multiple');
|
||||||
|
if (isWorkflow) { el.find("option[value=all]").show(); }
|
||||||
el.attr('size', 1);
|
el.attr('size', 1);
|
||||||
} else {
|
} else {
|
||||||
el.attr('multiple', true);
|
el.attr('multiple', true);
|
||||||
|
if (isWorkflow) { el.find("option[value=all]").attr("selected", false).hide(); }
|
||||||
if (el.children().length > 10)
|
if (el.children().length > 10)
|
||||||
el.attr('size', 10);
|
el.attr('size', 10);
|
||||||
else
|
else
|
||||||
@@ -891,6 +891,15 @@ function toggleDisabledOnChange() {
|
|||||||
function toggleDisabledInit() {
|
function toggleDisabledInit() {
|
||||||
$('input[data-disables], input[data-enables], input[data-shows]').each(toggleDisabledOnChange);
|
$('input[data-disables], input[data-enables], input[data-shows]').each(toggleDisabledOnChange);
|
||||||
}
|
}
|
||||||
|
function toggleMultiSelectIconInit() {
|
||||||
|
$('.toggle-multiselect:not(.icon-toggle-minus), .toggle-multiselect:not(.icon-toggle-plus)').each(function(){
|
||||||
|
if ($(this).siblings('select').find('option:selected').size() > 1){
|
||||||
|
$(this).addClass('icon-toggle-minus');
|
||||||
|
} else {
|
||||||
|
$(this).addClass('icon-toggle-plus');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function toggleNewObjectDropdown() {
|
function toggleNewObjectDropdown() {
|
||||||
var dropdown = $('#new-object + ul.menu-children');
|
var dropdown = $('#new-object + ul.menu-children');
|
||||||
@@ -931,6 +940,12 @@ $(document).ready(function(){
|
|||||||
$('#content').on('change', 'input[data-disables], input[data-enables], input[data-shows]', toggleDisabledOnChange);
|
$('#content').on('change', 'input[data-disables], input[data-enables], input[data-shows]', toggleDisabledOnChange);
|
||||||
toggleDisabledInit();
|
toggleDisabledInit();
|
||||||
|
|
||||||
|
$('#content').on('click', '.toggle-multiselect', function() {
|
||||||
|
toggleMultiSelect($(this).siblings('select'));
|
||||||
|
$(this).toggleClass('icon-toggle-plus icon-toggle-minus');
|
||||||
|
});
|
||||||
|
toggleMultiSelectIconInit();
|
||||||
|
|
||||||
$('#history .tabs').on('click', 'a', function(e){
|
$('#history .tabs').on('click', 'a', function(e){
|
||||||
var tab = $(e.target).attr('id').replace('tab-','');
|
var tab = $(e.target).attr('id').replace('tab-','');
|
||||||
document.cookie = 'history_last_tab=' + tab
|
document.cookie = 'history_last_tab=' + tab
|
||||||
|
|||||||
Reference in New Issue
Block a user