Update Polymer and pull in iron-list
[chromium-blink-merge.git] / third_party / polymer / v1_0 / components-chromium / paper-progress / paper-progress-extracted.js
blob8ea57108d31ee698685bb00d8f52ccd10f4d4ac9
2   Polymer({
4     is: 'paper-progress',
6     behaviors: [
7       Polymer.IronRangeBehavior
8     ],
10     properties: {
12       /**
13        * The number that represents the current secondary progress.
14        */
15       secondaryProgress: {
16         type: Number,
17         value: 0
18       },
20       /**
21        * The secondary ratio
22        */
23       secondaryRatio: {
24         type: Number,
25         value: 0,
26         readOnly: true
27       },
29       /**
30        * Use an indeterminate progress indicator.
31        */
32       indeterminate: {
33         type: Boolean,
34         value: false,
35         observer: '_toggleIndeterminate'
36       },
38       /**
39        * True if the progress is disabled.
40        */
41       disabled: {
42         type: Boolean,
43         value: false,
44         reflectToAttribute: true,
45         observer: '_disabledChanged'
46       }
47     },
49     observers: [
50       '_progressChanged(secondaryProgress, value, min, max)'
51     ],
53     hostAttributes: {
54       role: 'progressbar'
55     },
57     _toggleIndeterminate: function(indeterminate) {
58       // If we use attribute/class binding, the animation sometimes doesn't translate properly
59       // on Safari 7.1. So instead, we toggle the class here in the update method.
60       this.toggleClass('indeterminate', indeterminate, this.$.primaryProgress);
61     },
63     _transformProgress: function(progress, ratio) {
64       var transform = 'scaleX(' + (ratio / 100) + ')';
65       progress.style.transform = progress.style.webkitTransform = transform;
66     },
68     _mainRatioChanged: function(ratio) {
69       this._transformProgress(this.$.primaryProgress, ratio);
70     },
72     _progressChanged: function(secondaryProgress, value, min, max) {
73       secondaryProgress = this._clampValue(secondaryProgress);
74       value = this._clampValue(value);
76       var secondaryRatio = this._calcRatio(secondaryProgress) * 100;
77       var mainRatio = this._calcRatio(value) * 100;
79       this._setSecondaryRatio(secondaryRatio);
80       this._transformProgress(this.$.secondaryProgress, secondaryRatio);
81       this._transformProgress(this.$.primaryProgress, mainRatio);
83       this.secondaryProgress = secondaryProgress;
85       this.setAttribute('aria-valuenow', value);
86       this.setAttribute('aria-valuemin', min);
87       this.setAttribute('aria-valuemax', max);
88     },
90     _disabledChanged: function(disabled) {
91       this.$.progressContainer.setAttribute('aria-disabled', disabled ? 'true' : 'false');
92     },
94     _hideSecondaryProgress: function(secondaryRatio) {
95       return secondaryRatio === 0;
96     }
98   });