|
1044 | 1044 | },
|
1045 | 1045 |
|
1046 | 1046 | _addSelectionDisplayItem: function ($changedItem) {
|
1047 |
| - var solOptionItem = $changedItem.data('sol-item'), |
1048 |
| - $existingDisplayItem = solOptionItem.displaySelectionItem, |
1049 |
| - $displayItemText; |
1050 |
| - |
1051 | 1047 | this.numSelected = 1 + this.numSelected;
|
1052 | 1048 |
|
1053 | 1049 | if (this.config.maxShow !== 0 && this.numSelected > this.config.maxShow) {
|
1054 | 1050 | if (this.valMap == null) {
|
1055 | 1051 | this._setXItemsSelected();
|
1056 | 1052 | }
|
1057 | 1053 | } else {
|
1058 |
| - /* |
1059 |
| - * Modified for OpenGrok in 2016, 2019. |
1060 |
| - */ |
1061 |
| - var label = solOptionItem.label; |
1062 |
| - if ($changedItem.data('messages-available')) { |
1063 |
| - label += ' <span class="'; |
1064 |
| - label += 'note-' + $changedItem.data('messages-level'); |
1065 |
| - label += ' important-note important-note-rounded" '; |
1066 |
| - label += 'title="Some message is present for this project.'; |
1067 |
| - label += ' Find more info in the project list.">!</span>' |
1068 |
| - } |
| 1054 | + this._buildSelectionDisplayItem($changedItem); |
| 1055 | + } |
| 1056 | + }, |
1069 | 1057 |
|
1070 |
| - $displayItemText = $('<span class="sol-selected-display-item-text" />').html(label); |
1071 |
| - $existingDisplayItem = $('<div class="sol-selected-display-item"/>') |
1072 |
| - .append($displayItemText) |
1073 |
| - .attr('title', solOptionItem.tooltip) |
1074 |
| - .data('label', solOptionItem.label) |
1075 |
| - .appendTo(this.$showSelectionContainer) |
1076 |
| - .dblclick(function () { // Modified for OpenGrok in 2017. |
1077 |
| - $changedItem.dblclick(); |
1078 |
| - }); |
| 1058 | + _buildSelectionDisplayItem: function ($changedItem) { |
| 1059 | + var solOptionItem = $changedItem.data('sol-item'), |
| 1060 | + $existingDisplayItem, |
| 1061 | + $displayItemText; |
1079 | 1062 |
|
1080 |
| - // show remove button on display items if not disabled and null selection allowed |
1081 |
| - if ((this.config.multiple || this.config.allowNullSelection) && !$changedItem.prop('disabled')) { |
1082 |
| - $('<span class="sol-quick-delete"/>') |
1083 |
| - .html(this.config.texts.quickDelete) |
1084 |
| - .click(function () { // deselect the project and refresh the search |
1085 |
| - $changedItem |
1086 |
| - .prop('checked', false) |
1087 |
| - .trigger('change'); |
1088 |
| - /* |
1089 |
| - * Modified for OpenGrok in 2017. |
1090 |
| - */ |
1091 |
| - if (isOnSearchPage()) { |
1092 |
| - $('#sbox').submit(); |
1093 |
| - } |
1094 |
| - }) |
1095 |
| - .prependTo($existingDisplayItem); |
1096 |
| - } |
| 1063 | + /* |
| 1064 | + * Modified for OpenGrok in 2016, 2019. |
| 1065 | + */ |
| 1066 | + var label = solOptionItem.label; |
| 1067 | + if ($changedItem.data('messages-available')) { |
| 1068 | + label += ' <span class="'; |
| 1069 | + label += 'note-' + $changedItem.data('messages-level'); |
| 1070 | + label += ' important-note important-note-rounded" '; |
| 1071 | + label += 'title="Some message is present for this project.'; |
| 1072 | + label += ' Find more info in the project list.">!</span>' |
| 1073 | + } |
1097 | 1074 |
|
1098 |
| - solOptionItem.displaySelectionItem = $existingDisplayItem; |
| 1075 | + $displayItemText = $('<span class="sol-selected-display-item-text" />').html(label); |
| 1076 | + $existingDisplayItem = $('<div class="sol-selected-display-item"/>') |
| 1077 | + .append($displayItemText) |
| 1078 | + .attr('title', solOptionItem.tooltip) |
| 1079 | + .data('label', solOptionItem.label) |
| 1080 | + .appendTo(this.$showSelectionContainer) |
| 1081 | + .dblclick(function () { // Modified for OpenGrok in 2017. |
| 1082 | + $changedItem.dblclick(); |
| 1083 | + }); |
| 1084 | + |
| 1085 | + // show remove button on display items if not disabled and null selection allowed |
| 1086 | + if ((this.config.multiple || this.config.allowNullSelection) && !$changedItem.prop('disabled')) { |
| 1087 | + $('<span class="sol-quick-delete"/>') |
| 1088 | + .html(this.config.texts.quickDelete) |
| 1089 | + .click(function () { // deselect the project and refresh the search |
| 1090 | + $changedItem |
| 1091 | + .prop('checked', false) |
| 1092 | + .trigger('change'); |
| 1093 | + /* |
| 1094 | + * Modified for OpenGrok in 2017. |
| 1095 | + */ |
| 1096 | + if (isOnSearchPage()) { |
| 1097 | + $('#sbox').submit(); |
| 1098 | + } |
| 1099 | + }) |
| 1100 | + .prependTo($existingDisplayItem); |
1099 | 1101 | }
|
| 1102 | + |
| 1103 | + solOptionItem.displaySelectionItem = $existingDisplayItem; |
1100 | 1104 | },
|
1101 | 1105 |
|
1102 | 1106 | _removeSelectionDisplayItem: function ($changedItem) {
|
1103 | 1107 | var solOptionItem = $changedItem.data('sol-item'),
|
1104 | 1108 | $myDisplayItem = solOptionItem.displaySelectionItem;
|
1105 | 1109 |
|
| 1110 | + var wasExceeding = this.config.maxShow !== 0 && this.numSelected > this.config.maxShow; |
1106 | 1111 | this.numSelected = this.numSelected - 1;
|
1107 | 1112 |
|
1108 | 1113 | if ($myDisplayItem) {
|
1109 | 1114 | $myDisplayItem.remove();
|
1110 | 1115 | solOptionItem.displaySelectionItem = undefined;
|
| 1116 | + |
| 1117 | + /* |
| 1118 | + * N.b. for bulk mode, wasExceeding handling is off since only |
| 1119 | + * Clear or Invert-Selection would cause this function to be |
| 1120 | + * called. For Clear, there won't be any selected items at the |
| 1121 | + * end, so wasExceeding is irrelevant. For Invert-Selection, |
| 1122 | + * checked options are unchecked first -- i.e. we go to zero |
| 1123 | + * this.numSelected first -- so normal _addSelectionDisplayItem |
| 1124 | + * takes care of things. |
| 1125 | + */ |
| 1126 | + |
| 1127 | + if (wasExceeding && this.valMap == null) { |
| 1128 | + var self = this; |
| 1129 | + this.$selectionContainer |
| 1130 | + .find('.sol-option input[type="checkbox"]:not([disabled]):checked') |
| 1131 | + .each(function (index, item) { |
| 1132 | + var $currentOptionItem = $(item); |
| 1133 | + if ($currentOptionItem.data('sol-item').displaySelectionItem == null) { |
| 1134 | + self._buildSelectionDisplayItem($currentOptionItem); |
| 1135 | + return false; |
| 1136 | + } |
| 1137 | + }); |
| 1138 | + } |
1111 | 1139 | }
|
1112 | 1140 | if (this.valMap == null) {
|
1113 | 1141 | this._setXItemsSelected();
|
|
0 commit comments