Skip to content
This repository was archived by the owner on Dec 16, 2019. It is now read-only.

Fix infinite loop bug and add feature event. #302

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/angularjs-dropdown-multiselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ directiveModule.directive('ngDropdownMultiselect', ['$filter', '$document', '$co
onDeselectAll: angular.noop,
onInitDone: angular.noop,
onMaxSelectionReached: angular.noop,
onSearchNotFound: angular.noop,
onSelectionChanged: angular.noop,
onClose: angular.noop
};
Expand Down Expand Up @@ -260,9 +261,8 @@ directiveModule.directive('ngDropdownMultiselect', ['$filter', '$document', '$co
if ($scope.settings.smartButtonMaxItems > 0) {

var paddingWidth = 12 * 2,
borderWidth = 1 * 2,
dropdownIconWidth = 8;
var ellipsisWidth = textWidth("...");
borderWidth = 1 * 2,
dropdownIconWidth = 8;
var widthLimit = $element[0].offsetWidth - paddingWidth - borderWidth - dropdownIconWidth;

var itemsText = [];
Expand All @@ -283,9 +283,12 @@ directiveModule.directive('ngDropdownMultiselect', ['$filter', '$document', '$co

var result = itemsText.join(', ');
var index = result.length - 4;
var countLimit = 100;

if ($element[0].offsetWidth === 0)
return result;

while (textWidth(result) > widthLimit) {
if (itemsText[itemsText.length - 1] !== "...") {
if (itemsText[itemsText.length - 1] !== '...') {
itemsText.push('...');
result = result + "...";
}
Expand Down Expand Up @@ -505,6 +508,7 @@ directiveModule.directive('ngDropdownMultiselect', ['$filter', '$document', '$co
} else if ($scope.settings.enableSearch) {
$scope.selectAll();
}
$scope.externalEvents.onSearchNotFound($scope.input.searchFilter, $scope);
}
};

Expand Down