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