Skip to content

Commit b093555

Browse files
committed
Have a fixed caption for button
1 parent 28f9622 commit b093555

File tree

2 files changed

+17
-56
lines changed

2 files changed

+17
-56
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name" : "meanhub-angular-multiselect",
3-
"version" : "v4.1.0",
3+
"version" : "v4.2.0",
44
"main" : [
55
"isteven-multi-select.js",
66
"isteven-multi-select.css"

isteven-multi-select.js

Lines changed: 16 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Project started on: Tue, 14 Jan 2014 - 5:18:02 PM
66
* Current version: 4.0.0
7-
*
7+
*
88
* Released under the MIT License
99
* --------------------------------------------------------------------------------
1010
* The MIT License (MIT)
@@ -58,7 +58,10 @@ angular.module( 'isteven-multi-select', ['ng'] ).directive( 'istevenMultiSelect'
5858
onSelectNone : '&',
5959

6060
// i18n
61-
translation : '='
61+
translation : '=',
62+
63+
// caption
64+
caption : '@'
6265
},
6366

6467
/*
@@ -73,7 +76,7 @@ angular.module( 'isteven-multi-select', ['ng'] ).directive( 'istevenMultiSelect'
7376
link: function ( $scope, element, attrs ) {
7477

7578
$scope.backUp = [];
76-
$scope.varButtonLabel = '';
79+
$scope.varButtonLabel = '';
7780
$scope.spacingProperty = '';
7881
$scope.indexProperty = '';
7982
$scope.orientationH = false;
@@ -447,7 +450,7 @@ angular.module( 'isteven-multi-select', ['ng'] ).directive( 'istevenMultiSelect'
447450
}
448451

449452
$scope.refreshOutputModel();
450-
$scope.refreshButton();
453+
$scope.refreshButton();
451454

452455
// We update the index here
453456
prevTabIndex = $scope.tabIndex;
@@ -513,47 +516,7 @@ angular.module( 'isteven-multi-select', ['ng'] ).directive( 'istevenMultiSelect'
513516

514517
// refresh button label
515518
$scope.refreshButton = function() {
516-
517-
$scope.varButtonLabel = '';
518-
var ctr = 0;
519-
520-
// refresh button label...
521-
if ( $scope.outputModel.length === 0 ) {
522-
// https://github.com/isteven/angular-multi-select/pull/19
523-
$scope.varButtonLabel = $scope.lang.nothingSelected;
524-
}
525-
else {
526-
var tempMaxLabels = $scope.outputModel.length;
527-
if ( typeof attrs.maxLabels !== 'undefined' && attrs.maxLabels !== '' ) {
528-
tempMaxLabels = attrs.maxLabels;
529-
}
530-
531-
// if max amount of labels displayed..
532-
if ( $scope.outputModel.length > tempMaxLabels ) {
533-
$scope.more = true;
534-
}
535-
else {
536-
$scope.more = false;
537-
}
538-
539-
angular.forEach( $scope.inputModel, function( value, key ) {
540-
if ( typeof value !== 'undefined' && value[ attrs.tickProperty ] === true ) {
541-
if ( ctr < tempMaxLabels ) {
542-
$scope.varButtonLabel += ( $scope.varButtonLabel.length > 0 ? '</div>, <div class="buttonLabel">' : '<div class="buttonLabel">') + $scope.writeLabel( value, 'buttonLabel' );
543-
}
544-
ctr++;
545-
}
546-
});
547-
548-
if ( $scope.more === true ) {
549-
// https://github.com/isteven/angular-multi-select/pull/16
550-
if (tempMaxLabels > 0) {
551-
$scope.varButtonLabel += ', ... ';
552-
}
553-
$scope.varButtonLabel += '(' + $scope.outputModel.length + ')';
554-
}
555-
}
556-
$scope.varButtonLabel = $sce.trustAsHtml( $scope.varButtonLabel + '<span class="caret"></span>' );
519+
$scope.varButtonLabel = $sce.trustAsHtml(($scope.caption || '' ) + '<span class="caret"></span>' );
557520
}
558521

559522
// Check if a checkbox is disabled or enabled. It will check the granular control (disableProperty) and global control (isDisabled)
@@ -725,8 +688,8 @@ angular.module( 'isteven-multi-select', ['ng'] ).directive( 'istevenMultiSelect'
725688
}
726689
});
727690
$scope.refreshOutputModel();
728-
$scope.refreshButton();
729-
$scope.onSelectAll();
691+
$scope.refreshButton();
692+
$scope.onSelectAll();
730693
break;
731694
case 'NONE':
732695
angular.forEach( $scope.filteredModel, function( value, key ) {
@@ -737,8 +700,8 @@ angular.module( 'isteven-multi-select', ['ng'] ).directive( 'istevenMultiSelect'
737700
}
738701
});
739702
$scope.refreshOutputModel();
740-
$scope.refreshButton();
741-
$scope.onSelectNone();
703+
$scope.refreshButton();
704+
$scope.onSelectNone();
742705
break;
743706
case 'RESET':
744707
angular.forEach( $scope.filteredModel, function( value, key ) {
@@ -748,8 +711,8 @@ angular.module( 'isteven-multi-select', ['ng'] ).directive( 'istevenMultiSelect'
748711
}
749712
});
750713
$scope.refreshOutputModel();
751-
$scope.refreshButton();
752-
$scope.onReset();
714+
$scope.refreshButton();
715+
$scope.onReset();
753716
break;
754717
case 'CLEAR':
755718
$scope.tabIndex = $scope.tabIndex + 1;
@@ -954,14 +917,12 @@ angular.module( 'isteven-multi-select', ['ng'] ).directive( 'istevenMultiSelect'
954917
$scope.lang.selectNone = $sce.trustAsHtml( $scope.icon.selectNone + '&nbsp;&nbsp;' + $scope.translation.selectNone );
955918
$scope.lang.reset = $sce.trustAsHtml( $scope.icon.reset + '&nbsp;&nbsp;' + $scope.translation.reset );
956919
$scope.lang.search = $scope.translation.search;
957-
$scope.lang.nothingSelected = $sce.trustAsHtml( $scope.translation.nothingSelected );
958920
}
959921
else {
960922
$scope.lang.selectAll = $sce.trustAsHtml( $scope.icon.selectAll + '&nbsp;&nbsp;Select All' );
961923
$scope.lang.selectNone = $sce.trustAsHtml( $scope.icon.selectNone + '&nbsp;&nbsp;Select None' );
962924
$scope.lang.reset = $sce.trustAsHtml( $scope.icon.reset + '&nbsp;&nbsp;Reset' );
963925
$scope.lang.search = 'Search...';
964-
$scope.lang.nothingSelected = 'None Selected';
965926
}
966927
$scope.icon.tickMark = $sce.trustAsHtml( $scope.icon.tickMark );
967928

@@ -984,7 +945,7 @@ angular.module( 'isteven-multi-select', ['ng'] ).directive( 'istevenMultiSelect'
984945
$scope.$watch( 'inputModel' , function( newVal ) {
985946
if ( newVal ) {
986947
$scope.refreshOutputModel();
987-
$scope.refreshButton();
948+
$scope.refreshButton();
988949
}
989950
}, true );
990951

@@ -997,7 +958,7 @@ angular.module( 'isteven-multi-select', ['ng'] ).directive( 'istevenMultiSelect'
997958
$scope.prepareGrouping();
998959
$scope.prepareIndex();
999960
$scope.refreshOutputModel();
1000-
$scope.refreshButton();
961+
$scope.refreshButton();
1001962
}
1002963
});
1003964

0 commit comments

Comments
 (0)