summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoristeven <ignatius.steven@gmail.com>2014-03-30 14:52:41 +0800
committeristeven <ignatius.steven@gmail.com>2014-03-30 14:52:41 +0800
commit2359b0f927c4a75f60031818602913a85c7d0c4a (patch)
treee006de4e862d32462d80c1a37df5749bbb100e1f
parentc4d841575715ddff4d766be35b47e092977f82ed (diff)
downloadangular-multi-select-2359b0f927c4a75f60031818602913a85c7d0c4a.zip
angular-multi-select-2359b0f927c4a75f60031818602913a85c7d0c4a.tar.gz
angular-multi-select-2359b0f927c4a75f60031818602913a85c7d0c4a.tar.bz2
Bug fix, brought back the 'None selected' label
-rw-r--r--.angular-multi-select.js.swpbin0 -> 32768 bytes
-rw-r--r--angular-multi-select.js47
2 files changed, 26 insertions, 21 deletions
diff --git a/.angular-multi-select.js.swp b/.angular-multi-select.js.swp
new file mode 100644
index 0000000..210349e
--- /dev/null
+++ b/.angular-multi-select.js.swp
Binary files differ
diff --git a/angular-multi-select.js b/angular-multi-select.js
index 72dae75..f96d0f4 100644
--- a/angular-multi-select.js
+++ b/angular-multi-select.js
@@ -103,37 +103,42 @@ angular.module( 'multi-select', ['ng'] ).directive( 'multiSelect' , [ '$timeout'
}
}
});
-
+
// Push into output model
if ( typeof attrs.outputModel !== 'undefined' ) {
$scope.outputModel = angular.copy( $scope.selectedItems );
}
- var tempMaxLabels = $scope.selectedItems.length;
- if ( typeof $scope.maxLabels !== 'undefined' && $scope.maxLabels !== '' && $scope.maxLabels !== "0" ) {
- tempMaxLabels = $scope.maxLabels;
+ // Write label...
+ if ( $scope.selectedItems.length === 0 ) {
+ $scope.buttonLabel = 'None selected';
}
+ else {
+ var tempMaxLabels = $scope.selectedItems.length;
+ if ( typeof $scope.maxLabels !== 'undefined' && $scope.maxLabels !== '' && $scope.maxLabels !== "0" ) {
+ tempMaxLabels = $scope.maxLabels;
+ }
- // If max amount of labels displayed..
- if ( $scope.selectedItems.length > tempMaxLabels ) {
- $scope.more = true;
- }
- else {
- $scope.more = false;
- }
+ // If max amount of labels displayed..
+ if ( $scope.selectedItems.length > tempMaxLabels ) {
+ $scope.more = true;
+ }
+ else {
+ $scope.more = false;
+ }
- // Write label...
- angular.forEach( $scope.selectedItems, function( value, key ) {
- if ( typeof value !== 'undefined' ) {
- if ( ctr < tempMaxLabels ) {
- $scope.buttonLabel += ( $scope.buttonLabel.length > 0 ? ', ' : '') + $scope.writeLabel( value );
+ angular.forEach( $scope.selectedItems, function( value, key ) {
+ if ( typeof value !== 'undefined' ) {
+ if ( ctr < tempMaxLabels ) {
+ $scope.buttonLabel += ( $scope.buttonLabel.length > 0 ? ', ' : '') + $scope.writeLabel( value );
+ }
+ ctr++;
}
- ctr++;
- }
- });
+ });
- if ( $scope.more === true ) {
- $scope.buttonLabel += ', ... (Total: ' + $scope.selectedItems.length + ')';
+ if ( $scope.more === true ) {
+ $scope.buttonLabel += ', ... (Total: ' + $scope.selectedItems.length + ')';
+ }
}
}