Skip to content

Commit 7550159

Browse files
committed
Merge branch 'master' of https://github.com/davidstutz/bootstrap-multiselect, fixed select all.
Conflicts: js/bootstrap-multiselect.js
2 parents 49e25eb + a50ba90 commit 7550159

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

index-2-3.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ <h1><a id="examples"></a>Examples</h1>
241241
</select>
242242
</td>
243243
<td>
244-
Multiselect with a 'Select all' option
244+
Multiselect with a 'Select all' option.
245245
</td>
246246
</tr>
247247
<tr>

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ <h1><a id="examples"></a>Examples</h1>
251251
</select>
252252
</td>
253253
<td>
254-
Multiselect with a 'Select all' option
254+
Multiselect with a 'Select all' option.
255255
</td>
256256
</tr>
257257
<tr>

js/bootstrap-multiselect.js

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -346,13 +346,14 @@
346346
if (this.$select[0][0].value === this.options.selectAllValue) {
347347

348348
var values = [];
349-
350-
// Check for visibility of options.
351-
var options = $('option[value!="' + this.options.selectAllValue + '"][data-role!="divider"]', this.$select)
352-
.filter(':visible');
349+
var options = $('option[value!="' + this.options.selectAllValue + '"][data-role!="divider"]', this.$select);
353350

354351
for (var i = 0; i < options.length; i++) {
355-
values.push(options[i].value);
352+
353+
// Check whether this option is actually visible.
354+
if (this.getInputByValue(options[i].value) && this.getInputByValue(options[i].value).is(':visible')) {
355+
values.push(options[i].value);
356+
}
356357
}
357358

358359
if (checked) {
@@ -618,19 +619,22 @@
618619
var value = $('input', element).val();
619620
var text = $('label', element).text();
620621

622+
var filterCandidate = '';
623+
if ((this.options.filterBehavior === 'text')) {
624+
filterCandidate = text;
625+
}
626+
else if ((this.options.filterBehavior === 'value')) {
627+
filterCandidate = value;
628+
}
629+
else if (this.options.filterBehavior === 'both') {
630+
filterCandidate = text + '\n' + value;
631+
}
632+
621633
if (value !== this.options.selectAllValue && text) {
622634
// by default lets assume that element is not
623635
// interesting for this search
624636
var showElement = false;
625637

626-
var filterCandidate = '';
627-
if ((this.options.filterBehavior === 'text' || this.options.filterBehavior === 'both')) {
628-
filterCandidate = text;
629-
}
630-
if ((this.options.filterBehavior === 'value' || this.options.filterBehavior === 'both')) {
631-
filterCandidate = value;
632-
}
633-
634638
if (this.options.enableCaseInsensitiveFiltering && filterCandidate.toLowerCase().indexOf(this.query.toLowerCase()) > -1) {
635639
showElement = true;
636640
}
@@ -920,7 +924,7 @@
920924

921925
for (var i = 0; i < options.length; i = i + 1) {
922926
var option = options[i];
923-
if (option.value == valueToCompare) {
927+
if (option.value === valueToCompare) {
924928
return $(option);
925929
}
926930
}
@@ -939,7 +943,7 @@
939943

940944
for (var i = 0; i < checkboxes.length; i = i + 1) {
941945
var checkbox = checkboxes[i];
942-
if (checkbox.value == valueToCompare) {
946+
if (checkbox.value === valueToCompare) {
943947
return $(checkbox);
944948
}
945949
}

0 commit comments

Comments
 (0)