2 * Angular Material Design
3 * https://github.com/angular/material
7 (function( window, angular, undefined ){
12 * @name material.components.progressCircular
13 * @description Circular Progress module!
15 angular.module('material.components.progressCircular', [
18 .directive('mdProgressCircular', MdProgressCircularDirective);
22 * @name mdProgressCircular
23 * @module material.components.progressCircular
27 * The circular progress directive is used to make loading content in your app as delightful and
28 * painless as possible by minimizing the amount of visual change a user sees before they can view
29 * and interact with content.
31 * For operations where the percentage of the operation completed can be determined, use a
32 * determinate indicator. They give users a quick sense of how long an operation will take.
34 * For operations where the user is asked to wait a moment while something finishes up, and it’s
35 * not necessary to expose what's happening behind the scenes and how long it will take, use an
36 * indeterminate indicator.
38 * @param {string} md-mode Select from one of two modes: determinate and indeterminate.
39 * @param {number=} value In determinate mode, this number represents the percentage of the
40 * circular progress. Default: 0
41 * @param {number=} md-diameter This specifies the diamter of the circular progress. Default: 48
45 * <md-progress-circular md-mode="determinate" value="..."></md-progress-circular>
47 * <md-progress-circular md-mode="determinate" ng-value="..."></md-progress-circular>
49 * <md-progress-circular md-mode="determinate" value="..." md-diameter="100"></md-progress-circular>
51 * <md-progress-circular md-mode="indeterminate"></md-progress-circular>
54 function MdProgressCircularDirective($mdConstant, $mdTheming) {
58 // The progress 'circle' is composed of two half-circles: the left side and the right
59 // side. Each side has CSS applied to 'fill-in' the half-circle to the appropriate progress.
60 '<div class="md-spinner-wrapper">' +
61 '<div class="md-inner">' +
62 '<div class="md-gap"></div>' +
63 '<div class="md-left">' +
64 '<div class="md-half-circle"></div>' +
66 '<div class="md-right">' +
67 '<div class="md-half-circle"></div>' +
74 function compile(tElement) {
75 // The javascript in this file is mainly responsible for setting the correct aria attributes.
76 // The animation of the progress spinner is done entirely with just CSS.
77 tElement.attr('aria-valuemin', 0);
78 tElement.attr('aria-valuemax', 100);
79 tElement.attr('role', 'progressbar');
84 function postLink(scope, element, attr) {
86 var circle = element[0];
88 // Scale the progress circle based on the default diameter.
89 var diameter = attr.mdDiameter || 48;
90 var scale = diameter / 48;
91 circle.style[$mdConstant.CSS.TRANSFORM] = 'scale(' + scale + ')';
93 attr.$observe('value', function(value) {
94 var percentValue = clamp(value);
95 element.attr('aria-valuenow', percentValue);
100 * Clamps the value to be between 0 and 100.
101 * @param {number} value The value to clamp.
104 function clamp(value) {
105 return Math.max(0, Math.min(value || 0, 100));
108 MdProgressCircularDirective.$inject = ["$mdConstant", "$mdTheming"];
110 })(window, window.angular);