Commit 3757ccd6 authored by Tyf0x's avatar Tyf0x

** Bugfix **

-> The deselectall function was deselecting all options regardless of their visibility. It now takes it into account.
parent e733c262
...@@ -773,7 +773,7 @@ ...@@ -773,7 +773,7 @@
* Selects all enabled & visible options. * Selects all enabled & visible options.
* *
*/ */
selectall: function () { selectall: function () {
var allCheckboxes = $("li input[type='checkbox']:enabled", this.$ul), var allCheckboxes = $("li input[type='checkbox']:enabled", this.$ul),
visibleCheckboxes = allCheckboxes.filter(":visible"), visibleCheckboxes = allCheckboxes.filter(":visible"),
allCheckboxesCount = allCheckboxes.length, allCheckboxesCount = allCheckboxes.length,
...@@ -798,11 +798,26 @@ ...@@ -798,11 +798,26 @@
* @param {Boolean} justVisible * @param {Boolean} justVisible
*/ */
deselectall: function (justVisible) { deselectall: function (justVisible) {
justVisible = typeof justVisible === 'undefined' ? true : justVisible; var allCheckboxes = $("li input[type='checkbox']:enabled", this.$ul),
var filter = justVisible ? ":visible" : "*"; justVisible = typeof justVisible === 'undefined' ? true : justVisible,
$("li input", this.$ul).filter(filter).prop('checked', false); visibleCheckboxes = void(0);
$("li:not(.divider)", this.$ul).filter(filter).removeClass(this.options.selectedClass);
$("option:not([data-role='divider'])", this.$select).prop('selected', false); if(justVisible) {
var values = void(0);
visibleCheckboxes = allCheckboxes.filter(":visible");
visibleCheckboxes.prop('checked', false);
values = visibleCheckboxes.map(function() { return $(this).val() }).get();
$("option:enabled:not([data-role='divider'])", this.$select).filter(function(index){ return $.inArray($(this).val(), values) !== -1; }).prop('selected', false);
$("li:not(.divider):not(.disabled)", this.$ul).filter(":visible").removeClass(this.options.selectedClass);
}else {
allCheckboxes.prop('checked', false);
$("option:enabled:not([data-role='divider'])", this.$select).prop('selected', false);
$("li:not(.divider):not(.disabled)", this.$ul).removeClass(this.options.selectedClass);
}
}, },
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment