Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <polymer-element name="viewer-button" attributes="src latchable"> | |
| 2 <template> | |
| 3 <link rel="stylesheet" href="viewer-button.css"> | |
| 4 <div id="icon"></div> | |
| 5 </template> | |
| 6 <script> | |
| 7 (function() { | |
| 8 var dpi = ''; | |
| 9 | |
| 10 Polymer('viewer-button', { | |
| 11 src: '', | |
| 12 latchable: false, | |
| 13 srcChanged: function() { | |
| 14 if (this.src) { | |
| 15 if (!dpi) { | |
| 16 var mql = window.matchMedia('(-webkit-min-device-pixel-ratio: 1.3'); | |
| 17 dpi = mql.matches ? 'hi' : 'low'; | |
| 18 } | |
|
ganetsky1
2014/01/03 18:14:39
You may want to consider moving this out to ready:
raymes
2014/01/06 00:22:45
Done.
| |
| 19 this.$.icon.style.backgroundImage = | |
| 20 'url(elements/viewer-button/img/' + dpi + 'DPI/' + this.src + ')'; | |
| 21 } else { | |
| 22 this.$.icon.style.backgroundImage = ''; | |
| 23 } | |
| 24 }, | |
| 25 latchableChanged: function() { | |
| 26 if (this.latchable) | |
| 27 this.classList.add('latchable') | |
| 28 else | |
| 29 this.classList.remove('latchable') | |
|
ganetsky1
2014/01/03 18:14:39
Semicolon?
Also, maybe you want to use { } around
raymes
2014/01/06 00:22:45
Added the semicolons. The braces aren't required f
| |
| 30 }, | |
| 31 }); | |
| 32 })(); | |
| 33 </script> | |
| 34 </polymer-element> | |
| OLD | NEW |