Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(linear-progress): add basic aria support
Browse files Browse the repository at this point in the history
This fix adds support for aria-valuemin, aria-valuemax and
aria-valuenow. The valuemin and valuemax attributes are static and thus
added during the compile phase. The valuenow attribute is updated as
the progress bar’s value attribute changes.

This commit relates to issue #297
  • Loading branch information
EisenbergEffect committed Sep 29, 2014
1 parent fd7697d commit 1619976
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions src/components/linearProgress/linearProgress.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,29 @@ function MaterialLinearProgressDirective($timeout) {
'<div class="bar bar1"></div>' +
'<div class="bar bar2"></div>' +
'</div>',
link: function(scope, element, attr) {
var bar1 = angular.element(element[0].querySelector('.bar1')),
bar2 = angular.element(element[0].querySelector('.bar2')),
container = angular.element(element[0].querySelector('.container'));
compile: function compile(tElement, tAttrs, transclude) {
tElement.attr('aria-valuemin', 0);
tElement.attr('aria-valuemax', 100);

attr.$observe('value', function(value) {
bar2.css('width', clamp(value).toString() + '%');
});
return function(scope, element, attr) {
var bar1 = angular.element(element[0].querySelector('.bar1')),
bar2 = angular.element(element[0].querySelector('.bar2')),
container = angular.element(element[0].querySelector('.container'));

attr.$observe('secondaryvalue', function(value) {
bar1.css('width', clamp(value).toString() + '%');
});
attr.$observe('value', function(value) {
var clamped = clamp(value);
element.attr('aria-valuenow', clamped)
bar2.css('width', clamped.toString() + '%');
});

$timeout(function() {
container.addClass('ready');
});
attr.$observe('secondaryvalue', function(value) {
bar1.css('width', clamp(value).toString() + '%');
});

$timeout(function() {
container.addClass('ready');
});
}
}
};
}
Expand Down

0 comments on commit 1619976

Please sign in to comment.