Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / resources / pdf / elements / viewer-button / viewer-button.js
blob063a26e106d7336366d94b2342450c039444892c
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.
5 (function() {
6 var dpi = '';
8 Polymer({
9 is: 'viewer-button',
11 properties: {
12 img: {
13 type: String,
14 observer: 'imgChanged'
17 latchable: {
18 type: Boolean,
19 observer: 'latchableChanged'
23 created: function() {
24 if (!dpi) {
25 var mql = window.matchMedia('(-webkit-min-device-pixel-ratio: 1.3');
26 dpi = mql.matches ? 'hi' : 'low';
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 = '';
40 latchableChanged: function() {
41 if (this.latchable)
42 this.classList.add('latchable');
43 else
44 this.classList.remove('latchable');
46 });
47 })();