2 * Angular Material Design
3 * https://github.com/angular/material
7 (function( window, angular, undefined ){
12 * @name material.components.progressLinear
13 * @description Linear Progress module!
15 angular.module('material.components.progressLinear', [
18 .directive('mdProgressLinear', MdProgressLinearDirective);
22 * @name mdProgressLinear
23 * @module material.components.progressLinear
27 * The linear progress directive is used to make loading content in your app as delightful and painless as possible by minimizing the amount of visual change a user sees before they can view and interact with content. Each operation should only be represented by one activity indicator—for example, one refresh operation should not display both a refresh bar and an activity circle.
29 * For operations where the percentage of the operation completed can be determined, use a determinate indicator. They give users a quick sense of how long an operation will take.
31 * For operations where the user is asked to wait a moment while something finishes up, and it’s not necessary to expose what's happening behind the scenes and how long it will take, use an indeterminate indicator.
33 * @param {string} md-mode Select from one of four modes: determinate, indeterminate, buffer or query.
34 * @param {number=} value In determinate and buffer modes, this number represents the percentage of the primary progress bar. Default: 0
35 * @param {number=} md-buffer-value In the buffer mode, this number represents the precentage of the secondary progress bar. Default: 0
39 * <md-progress-linear md-mode="determinate" value="..."></md-progress-linear>
41 * <md-progress-linear md-mode="determinate" ng-value="..."></md-progress-linear>
43 * <md-progress-linear md-mode="indeterminate"></md-progress-linear>
45 * <md-progress-linear md-mode="buffer" value="..." md-buffer-value="..."></md-progress-linear>
47 * <md-progress-linear md-mode="query"></md-progress-linear>
50 function MdProgressLinearDirective($$rAF, $mdConstant, $mdTheming) {
54 template: '<div class="md-container">' +
55 '<div class="md-dashed"></div>' +
56 '<div class="md-bar md-bar1"></div>' +
57 '<div class="md-bar md-bar2"></div>' +
62 function compile(tElement, tAttrs, transclude) {
63 tElement.attr('aria-valuemin', 0);
64 tElement.attr('aria-valuemax', 100);
65 tElement.attr('role', 'progressbar');
69 function postLink(scope, element, attr) {
71 var bar1Style = element[0].querySelector('.md-bar1').style,
72 bar2Style = element[0].querySelector('.md-bar2').style,
73 container = angular.element(element[0].querySelector('.md-container'));
75 attr.$observe('value', function(value) {
76 if (attr.mdMode == 'query') {
80 var clamped = clamp(value);
81 element.attr('aria-valuenow', clamped);
82 bar2Style[$mdConstant.CSS.TRANSFORM] = transforms[clamped];
85 attr.$observe('mdBufferValue', function(value) {
86 bar1Style[$mdConstant.CSS.TRANSFORM] = transforms[clamp(value)];
90 container.addClass('md-ready');
94 function clamp(value) {
103 return Math.ceil(value || 0);
106 MdProgressLinearDirective.$inject = ["$$rAF", "$mdConstant", "$mdTheming"];
109 // **********************************************************
111 // **********************************************************
112 var transforms = (function() {
113 var values = new Array(101);
114 for(var i = 0; i < 101; i++){
115 values[i] = makeTransform(i);
120 function makeTransform(value){
121 var scale = value/100;
122 var translateX = (value-100)/2;
123 return 'translateX(' + translateX.toString() + '%) scale(' + scale.toString() + ', 1)';
127 })(window, window.angular);