nexus site path corrected
[portal.git] / ecomp-portal-FE / client / bower_components / angular-material / modules / js / progressCircular / progressCircular.js
1 /*!
2  * Angular Material Design
3  * https://github.com/angular/material
4  * @license MIT
5  * v0.9.8
6  */
7 (function( window, angular, undefined ){
8 "use strict";
9
10 /**
11  * @ngdoc module
12  * @name material.components.progressCircular
13  * @description Circular Progress module!
14  */
15 angular.module('material.components.progressCircular', [
16   'material.core'
17 ])
18   .directive('mdProgressCircular', MdProgressCircularDirective);
19
20 /**
21  * @ngdoc directive
22  * @name mdProgressCircular
23  * @module material.components.progressCircular
24  * @restrict E
25  *
26 * @description
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.
30  *
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.
33  *
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.
37  *
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
42  *
43  * @usage
44  * <hljs lang="html">
45  * <md-progress-circular md-mode="determinate" value="..."></md-progress-circular>
46  *
47  * <md-progress-circular md-mode="determinate" ng-value="..."></md-progress-circular>
48  *
49  * <md-progress-circular md-mode="determinate" value="..." md-diameter="100"></md-progress-circular>
50  *
51  * <md-progress-circular md-mode="indeterminate"></md-progress-circular>
52  * </hljs>
53  */
54 function MdProgressCircularDirective($mdConstant, $mdTheming) {
55   return {
56     restrict: 'E',
57     template:
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>' +
65             '</div>' +
66             '<div class="md-right">' +
67               '<div class="md-half-circle"></div>' +
68             '</div>' +
69           '</div>' +
70         '</div>',
71     compile: compile
72   };
73
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');
80
81     return postLink;
82   }
83
84   function postLink(scope, element, attr) {
85     $mdTheming(element);
86     var circle = element[0];
87
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 + ')';
92
93     attr.$observe('value', function(value) {
94       var percentValue = clamp(value);
95       element.attr('aria-valuenow', percentValue);
96     });
97   }
98
99   /**
100    * Clamps the value to be between 0 and 100.
101    * @param {number} value The value to clamp.
102    * @returns {number}
103    */
104   function clamp(value) {
105     return Math.max(0, Math.min(value || 0, 100));
106   }
107 }
108 MdProgressCircularDirective.$inject = ["$mdConstant", "$mdTheming"];
109
110 })(window, window.angular);