| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 (function() { | |
| 6 var dpi = ''; | |
| 7 | |
| 8 Polymer({ | |
| 9 is: 'viewer-button', | |
| 10 | |
| 11 properties: { | |
| 12 img: { | |
| 13 type: String, | |
| 14 observer: 'imgChanged' | |
| 15 }, | |
| 16 | |
| 17 latchable: { | |
| 18 type: Boolean, | |
| 19 observer: 'latchableChanged' | |
| 20 } | |
| 21 }, | |
| 22 | |
| 23 created: function() { | |
| 24 if (!dpi) { | |
| 25 var mql = window.matchMedia('(-webkit-min-device-pixel-ratio: 1.3'); | |
| 26 dpi = mql.matches ? 'hi' : 'low'; | |
| 27 } | |
| 28 }, | |
| 29 | |
| 30 imgChanged: function() { | |
| 31 if (this.img) { | |
| 32 this.$.icon.style.backgroundImage = | |
| 33 'url(' + this.getAttribute('assetpath') + 'img/' + dpi + | |
| 34 'DPI/' + this.img + ')'; | |
| 35 } else { | |
| 36 this.$.icon.style.backgroundImage = ''; | |
| 37 } | |
| 38 }, | |
| 39 | |
| 40 latchableChanged: function() { | |
| 41 if (this.latchable) | |
| 42 this.classList.add('latchable'); | |
| 43 else | |
| 44 this.classList.remove('latchable'); | |
| 45 }, | |
| 46 }); | |
| 47 })(); | |
| OLD | NEW |