Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: chrome/browser/resources/pdf/index.js

Issue 138703009: Hookup the page-indicator and progress-bar elements in the PDF extension. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 451 ;
452
453 Polymer('viewer-page-indicator', {
454 text: '1',
455 timerId: undefined,
456 ready: function() {
457 var scrollCallback = function() {
458 this.style.visibility = document.documentElement.clientWidth ==
459 window.innerWidth ? 'hidden' : 'visible';
460 var percent = window.scrollY /
461 (document.body.scrollHeight -
462 document.documentElement.clientHeight);
463 this.style.top = percent *
464 (document.documentElement.clientHeight - this.offsetHeight) + 'px';
465 this.style.opacity = 1;
466 clearTimeout(this.timerId);
467
468 this.timerId = setTimeout(function() {
469 this.style.opacity = 0;
470 this.timerId = undefined;
471 }.bind(this), 2000);
472 }.bind(this);
473 window.addEventListener('scroll', function() {
474 requestAnimationFrame(scrollCallback);
475 });
476
477 scrollCallback();
478 },
479 });
480 ;
481
482 Polymer('viewer-progress-bar', {
483 progress: 0,
koz (OOO until 15th September) 2014/02/10 22:38:02 Add a comment indicating this is a value from 0 to
raymes 2014/02/10 23:58:37 This comes from inside of the polymer element.
484 text: 'Loading',
485 numSegments: 8,
486 segments: [],
487 ready: function() {
488 this.numSegmentsChanged();
489 },
490 progressChanged: function() {
491 var numVisible = this.progress * this.segments.length / 100.0;
koz (OOO until 15th September) 2014/02/10 22:38:02 nit: Might be slightly clearer to have (this.progr
raymes 2014/02/10 23:58:37 It would be a bit clearer, but the floating point
492 for (var i = 0; i < this.segments.length; i++) {
493 this.segments[i].style.visibility =
494 i < numVisible ? 'visible' : 'hidden';
495 }
496
497 if (this.progress == 100)
498 this.style.opacity = 0;
499 },
500 numSegmentsChanged: function() {
501 // Clear the existing segments.
502 this.segments = [];
503 var segmentsElement = this.$.segments;
504 while (segmentsElement.hasChildNodes())
505 segmentsElement.removeChild(segmentsElement.lastChild);
506
507 // Create the new segments.
508 var segment = document.createElement('li');
509 segment.classList.add('segment');
510 var angle = 360 / this.numSegments;
511 for (var i = 0; i < this.numSegments; ++i) {
512 var segmentCopy = segment.cloneNode(true);
513 segmentCopy.style.webkitTransform =
514 'rotate(' + (i * angle) + 'deg) skewY(' +
515 -1 * (90 - angle) + 'deg)';
516 segmentsElement.appendChild(segmentCopy);
517 this.segments.push(segmentCopy);
518 }
519 this.progressChanged();
520 }
521 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698