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

Unified Diff: chrome/browser/resources/pdf/pdf.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.in.html ('k') | chrome/browser/resources/pdf/viewport.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/pdf/pdf.js
diff --git a/chrome/browser/resources/pdf/pdf.js b/chrome/browser/resources/pdf/pdf.js
index bf37990457c9f6b3e8abd423690962e054d232bc..604a13f2c43bc61c84f2fe103de153ebabe82466 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -21,29 +21,67 @@ var sizer;
// The toolbar element.
var viewerToolbar;
+// The page indicator element.
+var viewerPageIndicator;
+
+// The progress bar element.
+var viewerProgressBar;
+
// The viewport object.
var viewport;
+// The document dimensions.
+var documentDimensions;
+
// Returns true if the fit-to-page button is enabled.
function isFitToPageEnabled() {
return $('fit-to-page-button').classList.contains('polymer-selected');
}
+function updateProgress(progress) {
+ viewerProgressBar.progress = progress;
+ if (progress == -1) {
+ // Document load failed.
+ sizer.style.display = 'none';
+ viewerToolbar.style.visibility = 'hidden';
+ }
+}
+
// Called when a message is received from the plugin.
function handleMessage(message) {
if (message.data.type == 'documentDimensions') {
- viewport.setDocumentDimensions(message.data);
+ documentDimensions = message.data;
+ viewport.setDocumentDimensions(documentDimensions);
+ viewerToolbar.style.visibility = 'visible';
+ viewerPageIndicator.initialFadeIn();
+ viewerToolbar.initialFadeIn();
+ } else if (message.data.type == 'loadProgress') {
+ updateProgress(message.data['progress']);
}
}
// Callback that's called when the viewport changes.
-function viewportChangedCallback(zoom, x, y, scrollbarWidth, hasScrollbars) {
+function viewportChangedCallback(zoom,
+ x,
+ y,
+ scrollbarWidth,
+ hasScrollbars,
+ page) {
// Offset the toolbar position so that it doesn't move if scrollbars appear.
var toolbarRight = hasScrollbars.y ? 0 : scrollbarWidth;
var toolbarBottom = hasScrollbars.x ? 0 : scrollbarWidth;
viewerToolbar.style.right = toolbarRight + 'px';
viewerToolbar.style.bottom = toolbarBottom + 'px';
+ // Show or hide the page indicator.
+ if (documentDimensions.pageDimensions.length > 1 && hasScrollbars.y)
+ viewerPageIndicator.style.visibility = 'visible';
+ else
+ viewerPageIndicator.style.visibility = 'hidden';
+
+ // Update the most visible page.
+ viewerPageIndicator.text = page + 1;
+
// Notify the plugin of the viewport change.
plugin.postMessage({
type: 'viewport',
@@ -56,6 +94,8 @@ function viewportChangedCallback(zoom, x, y, scrollbarWidth, hasScrollbars) {
function load() {
sizer = $('sizer');
viewerToolbar = $('toolbar');
+ viewerPageIndicator = $('page-indicator');
+ viewerProgressBar = $('progress-bar');
// Create the viewport.
viewport = new Viewport(window,
« no previous file with comments | « chrome/browser/resources/pdf/index.in.html ('k') | chrome/browser/resources/pdf/viewport.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698