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.
feat(checkbox): add indeterminate checkbox support
Closes #7643
- Loading branch information
1 parent
9a8eab0
commit 2776ad2
Showing
12 changed files
with
220 additions
and
15 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,29 @@ | ||
<div ng-controller="AppCtrl" class="md-padding demo"> | ||
<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="demo-fieldset" > | ||
<legend class="demo-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" | ||
ng-checked="isChecked()" | ||
md-indeterminate="isIndeterminate()" | ||
ng-click="toggleAll()"> | ||
<span ng-if="isChecked()">Un-</span>Select All | ||
</md-checkbox> | ||
</div> | ||
<div class="demo-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,15 @@ | ||
.demo { | ||
&-legend { | ||
color: #3F51B5; | ||
} | ||
|
||
&-fieldset { | ||
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
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