OLD | NEW |
---|---|
(Empty) | |
1 <polymer-element name="viewer-progress-bar" attributes="progress text"> | |
2 <template> | |
3 <link rel="stylesheet" href="viewer-progress-bar.css"> | |
4 <div class="scaler"> | |
5 <ul id="segments"> | |
6 <li class="segment"></li> | |
7 <li class="segment"></li> | |
8 <li class="segment"></li> | |
9 <li class="segment"></li> | |
10 <li class="segment"></li> | |
11 <li class="segment"></li> | |
12 <li class="segment"></li> | |
13 <li class="segment"></li> | |
ganetsky1
2014/02/04 17:27:29
I would try to avoid this repitition and just have
raymes
2014/02/05 05:04:37
Because it's so simple, I don't know if it's worth
| |
14 </ul> | |
15 <div class="center-circle"></div> | |
16 </div> | |
17 <div id="text">Loading</div> | |
18 </template> | |
19 <script> | |
20 Polymer('viewer-progress-bar', { | |
21 progress: 0, | |
22 text: 'Loading', | |
23 segments: [], | |
24 ready: function() { | |
25 var children = this.$.segments.childNodes; | |
26 for (var i = 0; i < children.length; i++) { | |
27 if (children[i].classList && | |
28 children[i].classList.contains('segment')) { | |
29 this.segments.push(children[i]); | |
30 } | |
31 } | |
32 this.progressChanged(); | |
33 }, | |
34 progressChanged: function() { | |
35 var numVisible = this.progress * this.segments.length / 100.0; | |
36 for (var i = 0; i < this.segments.length; i++) { | |
37 if (i < numVisible) | |
38 this.segments[i].style.visibility = 'visible'; | |
39 else | |
40 this.segments[i].style.visibility = 'hidden'; | |
ganetsky1
2014/02/04 17:27:29
Ternary operator?
this.segments[i].style.visibili
raymes
2014/02/05 05:04:37
Done.
| |
41 } | |
42 if (this.progress == 100) | |
43 this.style.opacity = 0; | |
44 }, | |
45 textChanged: function() { | |
46 this.$.text.innerHTML = this.text; | |
47 }, | |
48 }); | |
49 </script> | |
50 </polymer-element> | |
OLD | NEW |