summaryrefslogtreecommitdiffstats
path: root/public
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2020-03-22 05:25:39 +0000
committerGo MAEDA <maeda@farend.jp>2020-03-22 05:25:39 +0000
commitfb7d3bf7cefa9aa7d2d3ef5ee8dd1613be42dd9b (patch)
tree9aaa3adaa261fc17d91c2b972cd55af9f390dd9c /public
parent6acc4397048b2d22413655e18afdf4cd1009ad9c (diff)
downloadredmine-fb7d3bf7cefa9aa7d2d3ef5ee8dd1613be42dd9b.tar.gz
redmine-fb7d3bf7cefa9aa7d2d3ef5ee8dd1613be42dd9b.zip
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
Diffstat (limited to 'public')
-rw-r--r--public/javascripts/application.js25
1 files changed, 20 insertions, 5 deletions
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index c9b7bb6b5..f33c9caf8 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -120,10 +120,6 @@ function initFilters() {
$('#filters-table').on('click', 'td.field input[type=checkbox]', function() {
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) {
if (e.keyCode == 13) $(this).closest('form').submit();
});
@@ -151,6 +147,7 @@ function addFilter(field, operator, values) {
}
$('#cb_'+fieldId).prop('checked', true);
toggleFilter(field);
+ toggleMultiSelectIconInit();
$('#add_filter_select').val('').find('option').each(function() {
if ($(this).attr('value') == field) {
$(this).attr('disabled', true);
@@ -189,7 +186,7 @@ function buildFilterRow(field, operator, values) {
case "list_subprojects":
tr.find('td.values').append(
'<span style="display:none;"><select class="value" id="values_'+fieldId+'_1" name="v['+field+'][]"></select>' +
- ' <span class="toggle-multiselect icon-only icon-toggle-plus">&nbsp;</span></span>'
+ ' <span class="toggle-multiselect icon-only '+(values.length > 1 ? 'icon-toggle-minus' : 'icon-toggle-plus')+'">&nbsp;</span></span>'
);
select = tr.find('td.values select');
if (values.length > 1) { select.attr('multiple', true); }
@@ -336,11 +333,14 @@ function toggleOperator(field) {
}
function toggleMultiSelect(el) {
+ var isWorkflow = el.closest('.controller-workflows');
if (el.attr('multiple')) {
el.removeAttr('multiple');
+ if (isWorkflow) { el.find("option[value=all]").show(); }
el.attr('size', 1);
} else {
el.attr('multiple', true);
+ if (isWorkflow) { el.find("option[value=all]").attr("selected", false).hide(); }
if (el.children().length > 10)
el.attr('size', 10);
else
@@ -891,6 +891,15 @@ function toggleDisabledOnChange() {
function toggleDisabledInit() {
$('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() {
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);
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){
var tab = $(e.target).attr('id').replace('tab-','');
document.cookie = 'history_last_tab=' + tab