diff options
author | Filipe La Ruina <filaruina@gmail.com> | 2014-06-03 11:21:30 -0300 |
---|---|---|
committer | Filipe La Ruina <filaruina@gmail.com> | 2014-06-04 16:27:21 -0300 |
commit | bc683e6cca341532da0cc47beae693e69c7d7ffb (patch) | |
tree | 84fcc00aa91aab1cc5860c5794c33c7cf7bb15b7 /angular-multi-select.js | |
parent | 3550dfe977a924183643e7a03b401096ae34f26d (diff) | |
download | angular-multi-select-bc683e6cca341532da0cc47beae693e69c7d7ffb.zip angular-multi-select-bc683e6cca341532da0cc47beae693e69c7d7ffb.tar.gz angular-multi-select-bc683e6cca341532da0cc47beae693e69c7d7ffb.tar.bz2 |
Adding the possibility to always have a total counter
If maxLabels="0" it will always display the number of selected itens
Diffstat (limited to 'angular-multi-select.js')
-rw-r--r-- | angular-multi-select.js | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/angular-multi-select.js b/angular-multi-select.js index 33d5c60..dd610f4 100644 --- a/angular-multi-select.js +++ b/angular-multi-select.js @@ -181,9 +181,9 @@ angular.module( 'multi-select', ['ng'] ).directive( 'multiSelect' , [ '$sce', '$ if ( $scope.selectedItems.length === 0 ) { $scope.varButtonLabel = 'None selected'; } - else { + else { var tempMaxLabels = $scope.selectedItems.length; - if ( typeof $scope.maxLabels !== 'undefined' && $scope.maxLabels !== '' && $scope.maxLabels !== "0" ) { + if ( typeof $scope.maxLabels !== 'undefined' && $scope.maxLabels !== '' ) { tempMaxLabels = $scope.maxLabels; } @@ -202,11 +202,15 @@ angular.module( 'multi-select', ['ng'] ).directive( 'multiSelect' , [ '$sce', '$ } ctr++; } - }); + }); if ( $scope.more === true ) { - $scope.varButtonLabel += ', ... (Total: ' + $scope.selectedItems.length + ')'; - }$scope + if (tempMaxLabels > 0) { + $scope.varButtonLabel += ', ... '; + } + + $scope.varButtonLabel += '(Total: ' + $scope.selectedItems.length + ')'; + } } $scope.varButtonLabel = $sce.trustAsHtml( $scope.varButtonLabel + '<span class="multiSelect caret"></span>' ); } |