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

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
« no previous file with comments | « chrome/browser/resources/pdf/index.html ('k') | chrome/browser/resources/pdf/index.in.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/pdf/index.js
diff --git a/chrome/browser/resources/pdf/index.js b/chrome/browser/resources/pdf/index.js
index 17c794e64ea9231a8b1c9a19d098687106fed765..d46391ccdf0ae27bb355df4efe9e4dd443ed5f51 100644
--- a/chrome/browser/resources/pdf/index.js
+++ b/chrome/browser/resources/pdf/index.js
@@ -448,3 +448,71 @@ Polymer={},"function"==typeof window.Polymer&&(Polymer={}),function(a){function
},
});
})();
+;
+
+ Polymer('viewer-page-indicator', {
+ text: '1',
+ timerId: undefined,
+ ready: function() {
+ var scrollCallback = function() {
+ 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,
+ text: 'Loading',
+ numSegments: 8,
+ segments: [],
+ ready: function() {
+ this.numSegmentsChanged();
+ },
+ progressChanged: function() {
+ var numVisible = this.progress * this.segments.length / 100.0;
+ for (var i = 0; i < this.segments.length; i++) {
+ this.segments[i].style.visibility =
+ i < numVisible ? 'visible' : 'hidden';
+ }
+
+ if (this.progress >= 100 || this.progress < 0)
+ this.style.opacity = 0;
+ },
+ numSegmentsChanged: function() {
+ // Clear the existing segments.
+ this.segments = [];
+ var segmentsElement = this.$.segments;
+ segmentsElement.innerHTML = '';
+
+ // 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();
+ }
+ });
« no previous file with comments | « chrome/browser/resources/pdf/index.html ('k') | chrome/browser/resources/pdf/index.in.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698