This repository has been archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding the indeterminate state to md-checkbox.
- Loading branch information
Derek Louie
committed
Mar 21, 2016
1 parent
9b1a4e3
commit 6c36b21
Showing
11 changed files
with
285 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
|
||
|
||
md-checkbox.md-THEME_NAME-theme { | ||
.md-ripple { | ||
color: '{{accent-600}}'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<div ng-controller="AppCtrl" class="md-padding"> | ||
<div layout="row" layout-wrap> | ||
|
||
<div flex="100" layout="column"> | ||
<div> | ||
<!-- | ||
In IE, we cannot apply flex directly to <fieldset> | ||
@see https://github.com/philipwalton/flexbugs#9-some-html-elements-cant-be-flex-containers | ||
--> | ||
<fieldset class="standard" > | ||
<legend>Using <md-checkbox> with the 'indeterminate' attribute </legend> | ||
<div layout="row" layout-wrap flex> | ||
<div flex-xs flex="50"> | ||
<md-checkbox aria-label="Select All" | ||
indeterminate="isIndeterminate()" | ||
indeterminate-checked-when="isChecked()" | ||
indeterminate-click="toggleAll()"> | ||
<span ng-if="isChecked()">Un-</span>Select All | ||
</md-checkbox> | ||
</div> | ||
<div class="select-all-checkboxes" flex="100" ng-repeat="item in items"> | ||
<md-checkbox ng-checked="exists(item, selected)" ng-click="toggle(item, selected)"> | ||
{{ item }} | ||
</md-checkbox> | ||
</div> | ||
</div> | ||
</fieldset> | ||
</div> | ||
</div> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
angular.module('checkboxDemo3', ['ngMaterial']) | ||
|
||
.controller('AppCtrl', function($scope) { | ||
$scope.items = [1,2,3,4,5]; | ||
$scope.selected = [1]; | ||
$scope.toggle = function (item, list) { | ||
var idx = list.indexOf(item); | ||
if (idx > -1) { | ||
list.splice(idx, 1); | ||
} | ||
else { | ||
list.push(item); | ||
} | ||
}; | ||
|
||
$scope.exists = function (item, list) { | ||
return list.indexOf(item) > -1; | ||
}; | ||
|
||
$scope.isIndeterminate = function() { | ||
return ($scope.selected.length !== 0 && | ||
$scope.selected.length !== $scope.items.length); | ||
}; | ||
|
||
$scope.isChecked = function() { | ||
return $scope.selected.length === $scope.items.length; | ||
}; | ||
|
||
$scope.toggleAll = function() { | ||
if ($scope.selected.length === $scope.items.length) { | ||
$scope.selected = []; | ||
} else if ($scope.selected.length === 0 || $scope.selected.length > 0) { | ||
$scope.selected = $scope.items.slice(0); | ||
} | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
legend { | ||
color: #3F51B5; | ||
} | ||
|
||
fieldset.standard { | ||
border-style: solid; | ||
border-width: 1px; | ||
height: 100%; | ||
} | ||
|
||
.select-all-checkboxes { | ||
padding-left: 30px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters