Commit 3a66b6a3 authored by Tyf0x's avatar Tyf0x

** Further performance improvement **

-> Now only filters the options to select if not all them have to be selected. This means to select all should be faster when there is no filter used.
parent ceac8764
......@@ -773,13 +773,22 @@
* Selects all visible options.
*
*/
selectall: function () {
var selectedInputs = $("li input", this.$ul).filter(":visible");
var values = selectedInputs.map(function() { return $(this).val() }).get();
selectedInputs.prop('checked', true);
selectall: function () {
var allCheckboxes = $("li input[type='checkbox']", this.$ul),
visibleCheckboxes = allCheckboxes.filter(":visible"),
allCheckboxesCount = allCheckboxes.length,
visibleCheckboxesCount = visibleCheckboxes.length;
visibleCheckboxes.prop('checked', true);
$("li", this.$ul).not(".divider").filter(":visible").addClass(this.options.selectedClass);
$("option", this.$select).not("[data-role='divider']").filter(function(index){ return $.inArray($(this).val(), values) !== -1; }).prop('selected', true);
if (allCheckboxesCount === visibleCheckboxesCount) {
$("option", this.$select).not("[data-role='divider']").prop('selected', true);
}
else {
var values = visibleCheckboxes.map(function() { return $(this).val() }).get();
$("option", this.$select).not("[data-role='divider']").filter(function(index){ return $.inArray($(this).val(), values) !== -1; }).prop('selected', true);
}
},
/**
......
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