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 ready: function() { |
| 14 if (!dpi) { |
| 15 var mql = window.matchMedia('(-webkit-min-device-pixel-ratio: 1.3'); |
| 16 dpi = mql.matches ? 'hi' : 'low'; |
| 17 } |
| 18 }, |
| 19 srcChanged: function() { |
| 20 if (this.src) { |
| 21 this.$.icon.style.backgroundImage = |
| 22 'url(elements/viewer-button/img/' + dpi + 'DPI/' + this.src + ')'; |
| 23 } else { |
| 24 this.$.icon.style.backgroundImage = ''; |
| 25 } |
| 26 }, |
| 27 latchableChanged: function() { |
| 28 if (this.latchable) |
| 29 this.classList.add('latchable'); |
| 30 else |
| 31 this.classList.remove('latchable'); |
| 32 }, |
| 33 }); |
| 34 })(); |
| 35 </script> |
| 36 </polymer-element> |
OLD | NEW |