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

Unified Diff: chrome/browser/resources/pdf/pdf.js

Issue 806633003: Implement basic toolbar with Material Design and loading progress. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re-insert Sam's print preview workaround Created 5 years, 11 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/pdf.js
diff --git a/chrome/browser/resources/pdf/pdf.js b/chrome/browser/resources/pdf/pdf.js
index a8ec3081fc0f46a7015d7ede91659ce26a14140e..3fd10212f4c4ab734ec6b05c2fc4469b28d20250 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -47,6 +47,7 @@ function PDFViewer(streamDetails) {
this.loaded_ = false;
this.parentWindow_ = null;
+ this.isMaterial_ = location.pathname.substring(1) == 'index-material.html';
// The sizer element is placed behind the plugin element to cause scrollbars
// to be displayed in the window. It is sized according to the document size
// of the pdf and zoom level.
@@ -58,6 +59,7 @@ function PDFViewer(streamDetails) {
this.passwordScreen_.addEventListener('password-submitted',
this.onPasswordSubmitted_.bind(this));
this.errorScreen_ = $('error-screen');
+ this.toolbarHeight_ = (this.isMaterial_) ? $('pdf-toolbar').clientHeight : 0;
raymes 2015/01/13 06:24:50 nit: don't need the () around this.isMaterial_
// Create the viewport.
this.viewport_ = new Viewport(window,
@@ -65,7 +67,8 @@ function PDFViewer(streamDetails) {
this.viewportChanged_.bind(this),
this.beforeZoom_.bind(this),
this.afterZoom_.bind(this),
- getScrollbarWidth());
+ getScrollbarWidth(),
+ this.toolbarHeight_);
// Create the plugin object dynamically so we can set its src. The plugin
// element is sized to fill the entire window and is set to be fixed
// positioning, acting as a viewport. The plugin renders into this viewport
@@ -77,6 +80,13 @@ function PDFViewer(streamDetails) {
this.plugin_.type = 'application/x-google-chrome-pdf';
this.plugin_.addEventListener('message', this.handlePluginMessage_.bind(this),
false);
+ if (this.isMaterial_) {
+ this.plugin_.style.top = this.toolbarHeight_ + 'px';
Sam McNally 2015/01/13 07:03:56 top and width can be set in the css file.
Alexandre Carlton 2015/01/14 22:42:50 Done for top; does width need to be set at all?
+ this.plugin_.style.height =
+ (window.innerHeight - this.toolbarHeight_) + 'px';
+ this.plugin_.style.width = window.innerWidth + 'px';
+ }
+
// Handle scripting messages from outside the extension that wish to interact
// with it. We also send a message indicating that extension has loaded and
@@ -85,6 +95,8 @@ function PDFViewer(streamDetails) {
false);
document.title = getFilenameFromURL(this.streamDetails_.originalUrl);
+ if (this.isMaterial_)
+ $('title').innerHTML = document.title;
Sam McNally 2015/01/13 07:03:56 $('title').textContent
this.plugin_.setAttribute('src', this.streamDetails_.originalUrl);
this.plugin_.setAttribute('stream-url', this.streamDetails_.streamUrl);
var headers = '';
@@ -304,7 +316,11 @@ PDFViewer.prototype = {
* @param {number} progress the progress as a percentage.
*/
updateProgress_: function(progress) {
- this.progressBar_.progress = progress;
+ if (this.isMaterial_)
+ this.progressBar_.value = progress;
+ else
+ this.progressBar_.progress = progress;
+
if (progress == -1) {
// Document load failed.
this.errorScreen_.style.visibility = 'visible';
@@ -398,7 +414,8 @@ PDFViewer.prototype = {
break;
case 'setTranslatedStrings':
this.passwordScreen_.text = message.data.getPasswordString;
- this.progressBar_.text = message.data.loadingString;
+ if (!this.isMaterial_)
+ this.progressBar_.text = message.data.loadingString;
this.progressBar_.style.visibility = 'visible';
this.errorScreen_.text = message.data.loadFailedString;
break;
@@ -466,6 +483,12 @@ PDFViewer.prototype = {
if (!this.documentDimensions_)
return;
+ if (this.isMaterial_) {
+ this.plugin_.style.height =
+ (window.innerHeight - this.toolbarHeight_) + 'px';
+ this.plugin_.style.height = window.innerWidth;
Sam McNally 2015/01/13 07:03:56 this.plugin_.style.width. I think it's worth skipp
+ }
+
// Update the buttons selected.
$('fit-to-page-button').classList.remove('polymer-selected');
$('fit-to-width-button').classList.remove('polymer-selected');

Powered by Google App Engine
This is Rietveld 408576698