@@ -49,6 +49,7 @@ angular.module( 'multi-select', ['ng'] ).directive( 'multiSelect' , [ '$sce', '$
4949 tickProperty : '@' ,
5050 disableProperty : '@' ,
5151 orientation : '@' ,
52+ defaultLabel : '@' ,
5253 maxLabels : '@' ,
5354 isDisabled : '=' ,
5455 directiveId : '@' ,
@@ -179,11 +180,11 @@ angular.module( 'multi-select', ['ng'] ).directive( 'multiSelect' , [ '$sce', '$
179180
180181 // Write label...
181182 if ( $scope . selectedItems . length === 0 ) {
182- $scope . varButtonLabel = 'None selected' ;
183+ $scope . varButtonLabel = ( $scope . defaultLabel ) ? $scope . defaultLabel : 'None selected' ;
183184 }
184- else {
185+ else {
185186 var tempMaxLabels = $scope . selectedItems . length ;
186- if ( typeof $scope . maxLabels !== 'undefined' && $scope . maxLabels !== '' && $scope . maxLabels !== "0" ) {
187+ if ( typeof $scope . maxLabels !== 'undefined' && $scope . maxLabels !== '' ) {
187188 tempMaxLabels = $scope . maxLabels ;
188189 }
189190
@@ -202,11 +203,15 @@ angular.module( 'multi-select', ['ng'] ).directive( 'multiSelect' , [ '$sce', '$
202203 }
203204 ctr ++ ;
204205 }
205- } ) ;
206+ } ) ;
206207
207208 if ( $scope . more === true ) {
208- $scope . varButtonLabel += ', ... (Total: ' + $scope . selectedItems . length + ')' ;
209- } $scope
209+ if ( tempMaxLabels > 0 ) {
210+ $scope . varButtonLabel += ', ... ' ;
211+ }
212+
213+ $scope . varButtonLabel += '(Total: ' + $scope . selectedItems . length + ')' ;
214+ }
210215 }
211216 $scope . varButtonLabel = $sce . trustAsHtml ( $scope . varButtonLabel + '<span class="multiSelect caret"></span>' ) ;
212217 }
@@ -444,7 +449,7 @@ angular.module( 'multi-select', ['ng'] ).directive( 'multiSelect' , [ '$sce', '$
444449
445450 if ( e . type === 'click' || e . type === 'touchend' && $scope . scrolled === false ) {
446451 var checkboxes = document . querySelectorAll ( '.checkboxLayer' ) ;
447- if ( e . target . className . indexOf ( 'multiSelect' ) === - 1 ) {
452+ if ( e . target . className . indexOf === undefined || e . target . className . indexOf ( 'multiSelect' ) ) {
448453 for ( i = 0 ; i < checkboxes . length ; i ++ ) {
449454 checkboxes [ i ] . className = 'multiSelect checkboxLayer hide' ;
450455 }
0 commit comments