Skip to content

Commit 4d1faad

Browse files
author
isteven
committed
v2.0.0
1 parent 8f87cf3 commit 4d1faad

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

angular-multi-select.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ angular.module( 'multi-select', ['ng'] ).directive( 'multiSelect' , [ '$sce', '$
6060
tickProperty : '@',
6161
disableProperty : '@',
6262
groupProperty : '@',
63+
maxHeight : '@',
6364

6465
// callbacks
6566
onClose : '&',
@@ -84,13 +85,11 @@ angular.module( 'multi-select', ['ng'] ).directive( 'multiSelect' , [ '$sce', '$
8485
'<button type="button" class="clearButton" ng-click="inputLabel.labelFilter=\'\';updateFilter();prepareGrouping();prepareIndex();select( \'clear\', $event )">&#10799;</button> ' +
8586
'</div>' +
8687
'</div>' +
87-
'<div class="checkBoxContainer">' +
88-
88+
'<div class="checkBoxContainer" style="{{setHeight();}}">' +
8989
'<div ng-repeat="item in filteredModel | filter:removeGroupEndMarker" class="multiSelectItem"' +
9090
'ng-class="{selected: item[ tickProperty ], horizontal: orientationH, vertical: orientationV, multiSelectGroup:item[ groupProperty ], disabled:itemIsDisabled( item )}"' +
9191
'ng-click="syncItems( item, $event, $index );"' +
9292
'ng-mouseleave="removeFocusStyle( tabIndex );">' +
93-
9493
'<div class="acol" ng-if="item[ spacingProperty ] > 0" ng-repeat="i in numberToArray( item[ spacingProperty ] ) track by $index">&nbsp;</div>' +
9594
'<div class="acol">' +
9695
'<label>' +
@@ -99,9 +98,7 @@ angular.module( 'multi-select', ['ng'] ).directive( 'multiSelect' , [ '$sce', '$
9998
'</label>' +
10099
'</div>' +
101100
'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' +
102-
103101
'<span class="tickMark" ng-if="item[ groupProperty ] !== true && item[ tickProperty ] === true">&#10004;</span>' +
104-
105102
'</div>' +
106103
'</div>' +
107104
'<form>' +
@@ -127,6 +124,13 @@ angular.module( 'multi-select', ['ng'] ).directive( 'multiSelect' , [ '$sce', '$
127124
helperItems = [];
128125
helperItemsLength = 0;
129126

127+
// If user specify a height, call this function
128+
$scope.setHeight = function() {
129+
if ( typeof $scope.maxHeight !== 'undefined' ) {
130+
return 'max-height: ' + $scope.maxHeight + '; overflow-y:scroll';
131+
}
132+
}
133+
130134
// A little hack so that AngularJS ng-repeat can loop using start and end index like a normal loop
131135
// http://stackoverflow.com/questions/16824853/way-to-ng-repeat-defined-number-of-times-instead-of-repeating-over-array
132136
$scope.numberToArray = function( num ) {
@@ -242,7 +246,8 @@ angular.module( 'multi-select', ['ng'] ).directive( 'multiSelect' , [ '$sce', '$
242246
return true;
243247
}
244248
break;
245-
default:
249+
default:
250+
return false;
246251
break;
247252
}
248253
}

0 commit comments

Comments
 (0)