OLD | NEW |
1 // Copyright (c) 2012 The Polymer Authors. All rights reserved. | 1 // Copyright (c) 2012 The Polymer Authors. All rights reserved. |
2 // | 2 // |
3 // Redistribution and use in source and binary forms, with or without | 3 // Redistribution and use in source and binary forms, with or without |
4 // modification, are permitted provided that the following conditions are | 4 // modification, are permitted provided that the following conditions are |
5 // met: | 5 // met: |
6 // | 6 // |
7 // * Redistributions of source code must retain the above copyright | 7 // * Redistributions of source code must retain the above copyright |
8 // notice, this list of conditions and the following disclaimer. | 8 // notice, this list of conditions and the following disclaimer. |
9 // * Redistributions in binary form must reproduce the above | 9 // * Redistributions in binary form must reproduce the above |
10 // copyright notice, this list of conditions and the following disclaimer | 10 // copyright notice, this list of conditions and the following disclaimer |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 var i = Array.prototype.indexOf.call(nodes, target); | 380 var i = Array.prototype.indexOf.call(nodes, target); |
381 if (i >= 0) { | 381 if (i >= 0) { |
382 return i; | 382 return i; |
383 } | 383 } |
384 target = target.parentNode; | 384 target = target.parentNode; |
385 } | 385 } |
386 } | 386 } |
387 }); | 387 }); |
388 ; | 388 ; |
389 | 389 |
390 Polymer('viewer-toolbar', { | 390 Polymer('viewer-toolbar', { |
391 fadingIn: false, | 391 fadingIn: false, |
392 timerId: undefined, | 392 timerId: undefined, |
393 ready: function() { | 393 ready: function() { |
394 this.fadingInChanged(); | 394 this.fadingInChanged(); |
395 }, | 395 }, |
396 fadeIn: function() { | 396 fadeIn: function() { |
397 this.fadingIn = true; | 397 this.fadingIn = true; |
398 }, | 398 }, |
399 fadeOut: function() { | 399 fadeOut: function() { |
400 this.fadingIn = false; | 400 this.fadingIn = false; |
401 }, | 401 }, |
402 fadingInChanged: function() { | 402 fadingInChanged: function() { |
403 if (this.fadingIn) { | 403 if (this.fadingIn) { |
404 this.style.opacity = 1; | 404 this.style.opacity = 1; |
405 if (this.timerId !== undefined) { | 405 if (this.timerId !== undefined) { |
406 clearTimeout(this.timerId); | 406 clearTimeout(this.timerId); |
407 this.timerId = undefined; | 407 this.timerId = undefined; |
408 } | 408 } |
409 } else { | 409 } else { |
410 if (this.timerId === undefined) { | 410 if (this.timerId === undefined) { |
411 this.timerId = setTimeout( | 411 this.timerId = setTimeout( |
412 function() { | 412 function() { |
413 this.style.opacity = 0; | 413 this.style.opacity = 0; |
414 this.timerId = undefined; | 414 this.timerId = undefined; |
415 }.bind(this), 3000); | 415 }.bind(this), 3000); |
416 } | |
417 } | 416 } |
418 } | 417 } |
419 }); | 418 } |
420 ; | 419 }); |
| 420 ; |
421 | 421 |
422 (function() { | 422 (function() { |
423 var dpi = ''; | 423 var dpi = ''; |
424 | 424 |
425 Polymer('viewer-button', { | 425 Polymer('viewer-button', { |
426 src: '', | 426 src: '', |
427 latchable: false, | 427 latchable: false, |
428 ready: function() { | 428 ready: function() { |
429 if (!dpi) { | 429 if (!dpi) { |
430 var mql = window.matchMedia('(-webkit-min-device-pixel-ratio: 1.3'); | 430 var mql = window.matchMedia('(-webkit-min-device-pixel-ratio: 1.3'); |
431 dpi = mql.matches ? 'hi' : 'low'; | 431 dpi = mql.matches ? 'hi' : 'low'; |
432 } | 432 } |
433 }, | 433 }, |
434 srcChanged: function() { | 434 srcChanged: function() { |
435 if (this.src) { | 435 if (this.src) { |
436 this.$.icon.style.backgroundImage = | 436 this.$.icon.style.backgroundImage = |
437 'url(' + this.getAttribute('assetpath') + 'img/' + dpi + | 437 'url(' + this.getAttribute('assetpath') + 'img/' + dpi + |
438 'DPI/' + this.src + ')'; | 438 'DPI/' + this.src + ')'; |
439 } else { | 439 } else { |
440 this.$.icon.style.backgroundImage = ''; | 440 this.$.icon.style.backgroundImage = ''; |
441 } | 441 } |
442 }, | 442 }, |
443 latchableChanged: function() { | 443 latchableChanged: function() { |
444 if (this.latchable) | 444 if (this.latchable) |
445 this.classList.add('latchable'); | 445 this.classList.add('latchable'); |
446 else | 446 else |
447 this.classList.remove('latchable'); | 447 this.classList.remove('latchable'); |
448 }, | 448 }, |
449 }); | 449 }); |
450 })(); | 450 })(); |
451 | |
OLD | NEW |