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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/pdf/index.js
diff --git a/chrome/browser/resources/pdf/index.js b/chrome/browser/resources/pdf/index.js
index 4be5675b5c6ebdbf1f9ad1a1b36a24c8a8c30896..e475a66b1935865ef5df7cef812ad48dd3044cfa 100644
--- a/chrome/browser/resources/pdf/index.js
+++ b/chrome/browser/resources/pdf/index.js
@@ -448,4 +448,74 @@ Polymer={},"function"==typeof window.Polymer&&(Polymer={}),function(a){function
},
});
})();
-
+ ;
+
+ Polymer('viewer-page-indicator', {
+ text: '1',
+ timerId: undefined,
+ ready: function() {
+ var scrollCallback = function() {
+ this.style.visibility = document.documentElement.clientWidth ==
+ window.innerWidth ? 'hidden' : 'visible';
+ var percent = window.scrollY /
+ (document.body.scrollHeight -
+ document.documentElement.clientHeight);
+ this.style.top = percent *
+ (document.documentElement.clientHeight - this.offsetHeight) + 'px';
+ this.style.opacity = 1;
+ clearTimeout(this.timerId);
+
+ this.timerId = setTimeout(function() {
+ this.style.opacity = 0;
+ this.timerId = undefined;
+ }.bind(this), 2000);
+ }.bind(this);
+ window.addEventListener('scroll', function() {
+ requestAnimationFrame(scrollCallback);
+ });
+
+ scrollCallback();
+ },
+ });
+;
+
+ Polymer('viewer-progress-bar', {
+ 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.
+ text: 'Loading',
+ numSegments: 8,
+ segments: [],
+ ready: function() {
+ this.numSegmentsChanged();
+ },
+ progressChanged: function() {
+ 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
+ for (var i = 0; i < this.segments.length; i++) {
+ this.segments[i].style.visibility =
+ i < numVisible ? 'visible' : 'hidden';
+ }
+
+ if (this.progress == 100)
+ this.style.opacity = 0;
+ },
+ numSegmentsChanged: function() {
+ // Clear the existing segments.
+ this.segments = [];
+ var segmentsElement = this.$.segments;
+ while (segmentsElement.hasChildNodes())
+ segmentsElement.removeChild(segmentsElement.lastChild);
+
+ // Create the new segments.
+ var segment = document.createElement('li');
+ segment.classList.add('segment');
+ var angle = 360 / this.numSegments;
+ for (var i = 0; i < this.numSegments; ++i) {
+ var segmentCopy = segment.cloneNode(true);
+ segmentCopy.style.webkitTransform =
+ 'rotate(' + (i * angle) + 'deg) skewY(' +
+ -1 * (90 - angle) + 'deg)';
+ segmentsElement.appendChild(segmentCopy);
+ this.segments.push(segmentCopy);
+ }
+ this.progressChanged();
+ }
+ });

Powered by Google App Engine
This is Rietveld 408576698