diff --git a/src/angularjs-dropdown-multiselect.js b/src/angularjs-dropdown-multiselect.js index 1594e442..a87a1d28 100644 --- a/src/angularjs-dropdown-multiselect.js +++ b/src/angularjs-dropdown-multiselect.js @@ -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 }; @@ -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 = []; @@ -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 + "..."; } @@ -505,6 +508,7 @@ directiveModule.directive('ngDropdownMultiselect', ['$filter', '$document', '$co } else if ($scope.settings.enableSearch) { $scope.selectAll(); } + $scope.externalEvents.onSearchNotFound($scope.input.searchFilter, $scope); } };