|
142 | 142 | maxHeight: undefined,
|
143 | 143 | converter: undefined,
|
144 | 144 | asyncBatchSize: 300,
|
| 145 | + searchTimeout: 300, |
145 | 146 | maxShow: 0
|
146 | 147 | },
|
147 | 148 |
|
|
454 | 455 | valueChanged = e.originalEvent.propertyName.toLowerCase()=='value';
|
455 | 456 | }
|
456 | 457 | if (valueChanged) {
|
457 |
| - self._applySearchTermFilter(); |
| 458 | + if ($(this).data('timeout')) { |
| 459 | + clearTimeout($(this).data('timeout')); |
| 460 | + } |
| 461 | + $(this).data('timeout', setTimeout(function () { |
| 462 | + self._applySearchTermFilter(); |
| 463 | + }, self.config.searchTimeout)) |
| 464 | + |
458 | 465 | }
|
459 | 466 | });
|
460 | 467 |
|
|
586 | 593 | return;
|
587 | 594 | }
|
588 | 595 |
|
589 |
| - var self = this; |
| 596 | + var self = this, |
| 597 | + amountOfUnfilteredItems = dataArray.length |
590 | 598 |
|
591 | 599 | // reset keyboard navigation mode when applying new filter
|
592 | 600 | this._setKeyBoardNavigationMode(false);
|
593 | 601 |
|
594 |
| - $.each(dataArray, function (index, item) { |
| 602 | + /* |
| 603 | + * Modified 2016 |
| 604 | + * recursion was very slow (however good lookin') |
| 605 | + */ |
| 606 | + for (var itemIndex = 0; itemIndex < dataArray.length; itemIndex++) { |
| 607 | + var item = dataArray[itemIndex]; |
595 | 608 | if (item.type === 'option') {
|
596 | 609 | var $element = item.displayElement,
|
597 |
| - elementSearchableTerms = (item.label + ' ' + item.tooltip).trim().toLowerCase(); |
| 610 | + elementSearchableTerms = (item.label + ' ' + item.tooltip).trim().toLowerCase(); |
598 | 611 |
|
599 | 612 | if (elementSearchableTerms.indexOf(searchTerm) === -1) {
|
600 | 613 | $element.addClass('sol-filtered-search');
|
| 614 | + amountOfUnfilteredItems--; |
601 | 615 | }
|
602 | 616 | } else {
|
603 |
| - self._findTerms(item.children, searchTerm); |
604 |
| - var amountOfUnfilteredChildren = item.displayElement.find('.sol-option:not(.sol-filtered-search)'); |
| 617 | + var amountOfUnfilteredChildren = item.children.length |
| 618 | + for (var childrenIndex = 0; childrenIndex < item.children.length; childrenIndex++) { |
| 619 | + var child = item.children[childrenIndex]; |
| 620 | + if (child.type === 'option') { |
| 621 | + var $element = child.displayElement, |
| 622 | + elementSearchableTerms = (child.label + ' ' + child.tooltip).trim().toLowerCase(); |
| 623 | + |
| 624 | + if (elementSearchableTerms.indexOf(searchTerm) === -1) { |
| 625 | + $element.addClass('sol-filtered-search'); |
| 626 | + amountOfUnfilteredChildren--; |
| 627 | + } |
| 628 | + } |
| 629 | + } |
605 | 630 |
|
606 |
| - if (amountOfUnfilteredChildren.length === 0) { |
| 631 | + if (amountOfUnfilteredChildren === 0) { |
607 | 632 | item.displayElement.addClass('sol-filtered-search');
|
| 633 | + amountOfUnfilteredItems--; |
608 | 634 | }
|
609 | 635 | }
|
610 |
| - }); |
| 636 | + } |
611 | 637 |
|
612 |
| - this._setNoResultsItemVisible(this.$selectionContainer.find('.sol-option:not(.sol-filtered-search)').length === 0); |
| 638 | + this._setNoResultsItemVisible(amountOfUnfilteredItems === 0); |
613 | 639 | },
|
614 | 640 |
|
615 | 641 | _initializeData: function () {
|
|
1146 | 1172 | .prop('checked', true)
|
1147 | 1173 | .trigger('change', true);
|
1148 | 1174 |
|
1149 |
| - this.options.closeOnClick && this.close(); |
| 1175 | + this.config.closeOnClick && this.close(); |
1150 | 1176 |
|
1151 | 1177 | if ($.isFunction(this.config.events.onChange)) {
|
1152 | 1178 | this.config.events.onChange.call(this, this, $changedInputs);
|
|
1168 | 1194 | $closedInputs.prop('checked', true)
|
1169 | 1195 | .trigger('change', true)
|
1170 | 1196 |
|
1171 |
| - this.options.closeOnClick && this.close(); |
| 1197 | + this.config.closeOnClick && this.close(); |
1172 | 1198 |
|
1173 | 1199 | if ($.isFunction(this.config.events.onChange)) {
|
1174 | 1200 | this.config.events.onChange.call(this, this, $openedInputs.add($closedInputs));
|
|
0 commit comments