Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * @return {number} Width of a scrollbar in pixels | 8 * @return {number} Width of a scrollbar in pixels |
| 9 */ | 9 */ |
| 10 function getScrollbarWidth() { | 10 function getScrollbarWidth() { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 */ | 88 */ |
| 89 PDFViewer.MIN_TOOLBAR_OFFSET = 15; | 89 PDFViewer.MIN_TOOLBAR_OFFSET = 15; |
| 90 | 90 |
| 91 /** | 91 /** |
| 92 * The height of the toolbar along the top of the page. The document will be | 92 * The height of the toolbar along the top of the page. The document will be |
| 93 * shifted down by this much in the viewport. | 93 * shifted down by this much in the viewport. |
| 94 */ | 94 */ |
| 95 PDFViewer.MATERIAL_TOOLBAR_HEIGHT = 56; | 95 PDFViewer.MATERIAL_TOOLBAR_HEIGHT = 56; |
| 96 | 96 |
| 97 /** | 97 /** |
| 98 * The light-gray background color used for print preview. | |
| 99 */ | |
| 100 PDFViewer.LIGHT_BACKGROUND_COLOR = '0xFFCCCCCC'; | |
| 101 | |
| 102 /** | |
| 103 * The dark-gray background color used for the regular viewer. | |
| 104 */ | |
| 105 PDFViewer.DARK_BACKGROUND_COLOR = '0xFF525659'; | |
| 106 | |
| 107 /** | |
| 98 * Creates a new PDFViewer. There should only be one of these objects per | 108 * Creates a new PDFViewer. There should only be one of these objects per |
| 99 * document. | 109 * document. |
| 100 * @constructor | 110 * @constructor |
| 101 * @param {!BrowserApi} browserApi An object providing an API to the browser. | 111 * @param {!BrowserApi} browserApi An object providing an API to the browser. |
| 102 */ | 112 */ |
| 103 function PDFViewer(browserApi) { | 113 function PDFViewer(browserApi) { |
| 104 this.browserApi_ = browserApi; | 114 this.browserApi_ = browserApi; |
| 105 this.loadState_ = LoadState.LOADING; | 115 this.loadState_ = LoadState.LOADING; |
| 106 this.parentWindow_ = null; | 116 this.parentWindow_ = null; |
| 107 this.parentOrigin_ = null; | 117 this.parentOrigin_ = null; |
| 108 | 118 |
| 109 this.delayedScriptingMessages_ = []; | 119 this.delayedScriptingMessages_ = []; |
| 110 | 120 |
| 111 this.isPrintPreview_ = this.browserApi_.getStreamInfo().originalUrl.indexOf( | 121 this.isPrintPreview_ = this.browserApi_.getStreamInfo().originalUrl.indexOf( |
| 112 'chrome://print') == 0; | 122 'chrome://print') == 0; |
| 113 this.isMaterial_ = location.pathname.substring(1) === 'index-material.html'; | 123 this.isMaterial_ = location.pathname.substring(1) === 'index-material.html'; |
| 114 | 124 |
| 115 // The sizer element is placed behind the plugin element to cause scrollbars | 125 // The sizer element is placed behind the plugin element to cause scrollbars |
| 116 // to be displayed in the window. It is sized according to the document size | 126 // to be displayed in the window. It is sized according to the document size |
| 117 // of the pdf and zoom level. | 127 // of the pdf and zoom level. |
| 118 this.sizer_ = $('sizer'); | 128 this.sizer_ = $('sizer'); |
| 119 this.toolbar_ = $('toolbar'); | 129 this.toolbar_ = $('toolbar'); |
| 120 this.pageIndicator_ = $('page-indicator'); | 130 if (!this.isMaterial_ || this.isPrintPreview_) |
| 131 this.pageIndicator_ = $('page-indicator'); | |
| 121 this.progressBar_ = $('progress-bar'); | 132 this.progressBar_ = $('progress-bar'); |
| 122 this.passwordScreen_ = $('password-screen'); | 133 this.passwordScreen_ = $('password-screen'); |
| 123 this.passwordScreen_.addEventListener('password-submitted', | 134 this.passwordScreen_.addEventListener('password-submitted', |
| 124 this.onPasswordSubmitted_.bind(this)); | 135 this.onPasswordSubmitted_.bind(this)); |
| 125 this.errorScreen_ = $('error-screen'); | 136 this.errorScreen_ = $('error-screen'); |
| 126 if (chrome.tabs) | 137 if (chrome.tabs) |
| 127 this.errorScreen_.reloadFn = chrome.tabs.reload; | 138 this.errorScreen_.reloadFn = chrome.tabs.reload; |
| 128 | 139 |
| 129 // Create the viewport. | 140 // Create the viewport. |
| 130 var topToolbarHeight = | 141 this.topToolbarHeight = |
|
Sam McNally
2015/09/16 06:29:38
this.topToolbarHeight_
raymes
2015/09/16 06:57:17
Hmm I'm not sure why I changed this to be an insta
| |
| 131 this.isMaterial_ ? PDFViewer.MATERIAL_TOOLBAR_HEIGHT : 0; | 142 (this.isMaterial_ && !this.isPrintPreview_) ? |
| 143 PDFViewer.MATERIAL_TOOLBAR_HEIGHT : 0; | |
| 132 this.viewport_ = new Viewport(window, | 144 this.viewport_ = new Viewport(window, |
| 133 this.sizer_, | 145 this.sizer_, |
| 134 this.viewportChanged_.bind(this), | 146 this.viewportChanged_.bind(this), |
| 135 this.beforeZoom_.bind(this), | 147 this.beforeZoom_.bind(this), |
| 136 this.afterZoom_.bind(this), | 148 this.afterZoom_.bind(this), |
| 137 getScrollbarWidth(), | 149 getScrollbarWidth(), |
| 138 this.browserApi_.getDefaultZoom(), | 150 this.browserApi_.getDefaultZoom(), |
| 139 topToolbarHeight); | 151 this.topToolbarHeight); |
| 140 | 152 |
| 141 // Create the plugin object dynamically so we can set its src. The plugin | 153 // Create the plugin object dynamically so we can set its src. The plugin |
| 142 // element is sized to fill the entire window and is set to be fixed | 154 // element is sized to fill the entire window and is set to be fixed |
| 143 // positioning, acting as a viewport. The plugin renders into this viewport | 155 // positioning, acting as a viewport. The plugin renders into this viewport |
| 144 // according to the scroll position of the window. | 156 // according to the scroll position of the window. |
| 145 this.plugin_ = document.createElement('embed'); | 157 this.plugin_ = document.createElement('embed'); |
| 146 // NOTE: The plugin's 'id' field must be set to 'plugin' since | 158 // NOTE: The plugin's 'id' field must be set to 'plugin' since |
| 147 // chrome/renderer/printing/print_web_view_helper.cc actually references it. | 159 // chrome/renderer/printing/print_web_view_helper.cc actually references it. |
| 148 this.plugin_.id = 'plugin'; | 160 this.plugin_.id = 'plugin'; |
| 149 this.plugin_.type = 'application/x-google-chrome-pdf'; | 161 this.plugin_.type = 'application/x-google-chrome-pdf'; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 160 this.browserApi_.getStreamInfo().originalUrl); | 172 this.browserApi_.getStreamInfo().originalUrl); |
| 161 this.plugin_.setAttribute('stream-url', | 173 this.plugin_.setAttribute('stream-url', |
| 162 this.browserApi_.getStreamInfo().streamUrl); | 174 this.browserApi_.getStreamInfo().streamUrl); |
| 163 var headers = ''; | 175 var headers = ''; |
| 164 for (var header in this.browserApi_.getStreamInfo().responseHeaders) { | 176 for (var header in this.browserApi_.getStreamInfo().responseHeaders) { |
| 165 headers += header + ': ' + | 177 headers += header + ': ' + |
| 166 this.browserApi_.getStreamInfo().responseHeaders[header] + '\n'; | 178 this.browserApi_.getStreamInfo().responseHeaders[header] + '\n'; |
| 167 } | 179 } |
| 168 this.plugin_.setAttribute('headers', headers); | 180 this.plugin_.setAttribute('headers', headers); |
| 169 | 181 |
| 170 if (this.isMaterial_) { | 182 var backgroundColor = PDFViewer.DARK_BACKGROUND_COLOR; |
| 171 this.plugin_.setAttribute('is-material', ''); | 183 if (!this.isMaterial_ || this.isPrintPreview_) |
| 172 this.plugin_.setAttribute('top-toolbar-height', | 184 backgroundColor = PDFViewer.LIGHT_BACKGROUND_COLOR; |
| 173 PDFViewer.MATERIAL_TOOLBAR_HEIGHT); | 185 this.plugin_.setAttribute('background-color', backgroundColor); |
| 174 } | 186 this.plugin_.setAttribute('top-toolbar-height', this.topToolbarHeight); |
| 175 | 187 |
| 176 if (!this.browserApi_.getStreamInfo().embedded) | 188 if (!this.browserApi_.getStreamInfo().embedded) |
| 177 this.plugin_.setAttribute('full-frame', ''); | 189 this.plugin_.setAttribute('full-frame', ''); |
| 178 document.body.appendChild(this.plugin_); | 190 document.body.appendChild(this.plugin_); |
| 179 | 191 |
| 180 // Setup the button event listeners. | 192 // Setup the button event listeners. |
| 181 if (!this.isMaterial_) { | 193 if (!this.isMaterial_) { |
| 182 $('fit-to-width-button').addEventListener('click', | 194 $('fit-to-width-button').addEventListener('click', |
| 183 this.viewport_.fitToWidth.bind(this.viewport_)); | 195 this.viewport_.fitToWidth.bind(this.viewport_)); |
| 184 $('fit-to-page-button').addEventListener('click', | 196 $('fit-to-page-button').addEventListener('click', |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 195 this.zoomToolbar_ = $('zoom-toolbar'); | 207 this.zoomToolbar_ = $('zoom-toolbar'); |
| 196 this.zoomToolbar_.addEventListener('fit-to-width', | 208 this.zoomToolbar_.addEventListener('fit-to-width', |
| 197 this.viewport_.fitToWidth.bind(this.viewport_)); | 209 this.viewport_.fitToWidth.bind(this.viewport_)); |
| 198 this.zoomToolbar_.addEventListener('fit-to-page', | 210 this.zoomToolbar_.addEventListener('fit-to-page', |
| 199 this.fitToPage_.bind(this)); | 211 this.fitToPage_.bind(this)); |
| 200 this.zoomToolbar_.addEventListener('zoom-in', | 212 this.zoomToolbar_.addEventListener('zoom-in', |
| 201 this.viewport_.zoomIn.bind(this.viewport_)); | 213 this.viewport_.zoomIn.bind(this.viewport_)); |
| 202 this.zoomToolbar_.addEventListener('zoom-out', | 214 this.zoomToolbar_.addEventListener('zoom-out', |
| 203 this.viewport_.zoomOut.bind(this.viewport_)); | 215 this.viewport_.zoomOut.bind(this.viewport_)); |
| 204 | 216 |
| 205 this.materialToolbar_ = $('material-toolbar'); | 217 if (!this.isPrintPreview_) { |
| 206 this.materialToolbar_.addEventListener('save', this.save_.bind(this)); | 218 this.materialToolbar_ = $('material-toolbar'); |
| 207 this.materialToolbar_.addEventListener('print', this.print_.bind(this)); | 219 this.materialToolbar_.addEventListener('save', this.save_.bind(this)); |
| 208 this.materialToolbar_.addEventListener('rotate-right', | 220 this.materialToolbar_.addEventListener('print', this.print_.bind(this)); |
| 209 this.rotateClockwise_.bind(this)); | 221 this.materialToolbar_.addEventListener('rotate-right', |
| 210 this.materialToolbar_.addEventListener('rotate-left', | 222 this.rotateClockwise_.bind(this)); |
| 211 this.rotateCounterClockwise_.bind(this)); | 223 this.materialToolbar_.addEventListener('rotate-left', |
| 224 this.rotateCounterClockwise_.bind(this)); | |
| 225 // Must attach to mouseup on the plugin element, since it eats mousedown | |
| 226 // and click events. | |
| 227 this.plugin_.addEventListener('mouseup', | |
| 228 this.materialToolbar_.hideDropdowns.bind(this.materialToolbar_)); | |
| 229 } | |
| 212 | 230 |
| 213 document.body.addEventListener('change-page', function(e) { | 231 document.body.addEventListener('change-page', function(e) { |
| 214 this.viewport_.goToPage(e.detail.page); | 232 this.viewport_.goToPage(e.detail.page); |
| 215 }.bind(this)); | 233 }.bind(this)); |
| 216 | 234 |
| 217 this.toolbarManager_ = | 235 this.toolbarManager_ = |
| 218 new ToolbarManager(window, this.materialToolbar_, this.zoomToolbar_); | 236 new ToolbarManager(window, this.materialToolbar_, this.zoomToolbar_); |
| 219 | |
| 220 // Must attach to mouseup on the plugin element, since it eats mousedown and | |
| 221 // click events. | |
| 222 this.plugin_.addEventListener( | |
| 223 'mouseup', | |
| 224 this.materialToolbar_.hideDropdowns.bind(this.materialToolbar_)); | |
| 225 } | 237 } |
| 226 | 238 |
| 227 // Set up the ZoomManager. | 239 // Set up the ZoomManager. |
| 228 this.zoomManager_ = new ZoomManager( | 240 this.zoomManager_ = new ZoomManager( |
| 229 this.viewport_, this.browserApi_.setZoom.bind(this.browserApi_), | 241 this.viewport_, this.browserApi_.setZoom.bind(this.browserApi_), |
| 230 this.browserApi_.getInitialZoom()); | 242 this.browserApi_.getInitialZoom()); |
| 231 this.browserApi_.addZoomEventListener( | 243 this.browserApi_.addZoomEventListener( |
| 232 this.zoomManager_.onBrowserZoomChange.bind(this.zoomManager_)); | 244 this.zoomManager_.onBrowserZoomChange.bind(this.zoomManager_)); |
| 233 | 245 |
| 234 // Setup the keyboard event listener. | 246 // Setup the keyboard event listener. |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 346 case 65: // a key. | 358 case 65: // a key. |
| 347 if (e.ctrlKey || e.metaKey) { | 359 if (e.ctrlKey || e.metaKey) { |
| 348 this.plugin_.postMessage({ | 360 this.plugin_.postMessage({ |
| 349 type: 'selectAll' | 361 type: 'selectAll' |
| 350 }); | 362 }); |
| 351 // Since we do selection ourselves. | 363 // Since we do selection ourselves. |
| 352 e.preventDefault(); | 364 e.preventDefault(); |
| 353 } | 365 } |
| 354 return; | 366 return; |
| 355 case 71: // g key. | 367 case 71: // g key. |
| 356 if (this.isMaterial_ && (e.ctrlKey || e.metaKey)) { | 368 if (this.isMaterial_ && this.materialToolbar_ && |
| 369 (e.ctrlKey || e.metaKey)) { | |
| 357 this.toolbarManager_.showToolbars(); | 370 this.toolbarManager_.showToolbars(); |
| 358 this.materialToolbar_.selectPageNumber(); | 371 this.materialToolbar_.selectPageNumber(); |
| 359 // To prevent the default "find text" behaviour in Chrome. | 372 // To prevent the default "find text" behaviour in Chrome. |
| 360 e.preventDefault(); | 373 e.preventDefault(); |
| 361 } | 374 } |
| 362 return; | 375 return; |
| 363 case 219: // left bracket. | 376 case 219: // left bracket. |
| 364 if (e.ctrlKey) | 377 if (e.ctrlKey) |
| 365 this.rotateCounterClockwise_(); | 378 this.rotateCounterClockwise_(); |
| 366 return; | 379 return; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 481 this.viewport_.setZoom(viewportPosition.zoom); | 494 this.viewport_.setZoom(viewportPosition.zoom); |
| 482 }, | 495 }, |
| 483 | 496 |
| 484 /** | 497 /** |
| 485 * @private | 498 * @private |
| 486 * Update the loading progress of the document in response to a progress | 499 * Update the loading progress of the document in response to a progress |
| 487 * message being received from the plugin. | 500 * message being received from the plugin. |
| 488 * @param {number} progress the progress as a percentage. | 501 * @param {number} progress the progress as a percentage. |
| 489 */ | 502 */ |
| 490 updateProgress_: function(progress) { | 503 updateProgress_: function(progress) { |
| 491 if (this.isMaterial_) | 504 if (this.isMaterial_) { |
| 492 this.materialToolbar_.loadProgress = progress; | 505 if (this.materialToolbar_) |
| 493 else | 506 this.materialToolbar_.loadProgress = progress; |
| 507 } else { | |
| 494 this.progressBar_.progress = progress; | 508 this.progressBar_.progress = progress; |
| 509 } | |
| 495 | 510 |
| 496 if (progress == -1) { | 511 if (progress == -1) { |
| 497 // Document load failed. | 512 // Document load failed. |
| 498 this.errorScreen_.show(); | 513 this.errorScreen_.show(); |
| 499 this.sizer_.style.display = 'none'; | 514 this.sizer_.style.display = 'none'; |
| 500 if (!this.isMaterial_) | 515 if (!this.isMaterial_) |
| 501 this.toolbar_.style.visibility = 'hidden'; | 516 this.toolbar_.style.visibility = 'hidden'; |
| 502 if (this.passwordScreen_.active) { | 517 if (this.passwordScreen_.active) { |
| 503 this.passwordScreen_.deny(); | 518 this.passwordScreen_.deny(); |
| 504 this.passwordScreen_.active = false; | 519 this.passwordScreen_.active = false; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 543 handlePluginMessage_: function(message) { | 558 handlePluginMessage_: function(message) { |
| 544 switch (message.data.type.toString()) { | 559 switch (message.data.type.toString()) { |
| 545 case 'documentDimensions': | 560 case 'documentDimensions': |
| 546 this.documentDimensions_ = message.data; | 561 this.documentDimensions_ = message.data; |
| 547 this.viewport_.setDocumentDimensions(this.documentDimensions_); | 562 this.viewport_.setDocumentDimensions(this.documentDimensions_); |
| 548 // If we received the document dimensions, the password was good so we | 563 // If we received the document dimensions, the password was good so we |
| 549 // can dismiss the password screen. | 564 // can dismiss the password screen. |
| 550 if (this.passwordScreen_.active) | 565 if (this.passwordScreen_.active) |
| 551 this.passwordScreen_.accept(); | 566 this.passwordScreen_.accept(); |
| 552 | 567 |
| 568 if (this.pageIndicator_) | |
| 569 this.pageIndicator_.initialFadeIn(); | |
| 570 | |
| 553 if (this.isMaterial_) { | 571 if (this.isMaterial_) { |
| 554 this.materialToolbar_.docLength = | 572 if (this.materialToolbar_) { |
| 555 this.documentDimensions_.pageDimensions.length; | 573 this.materialToolbar_.docLength = |
| 574 this.documentDimensions_.pageDimensions.length; | |
| 575 } | |
| 556 this.toolbarManager_.enableToolbars(); | 576 this.toolbarManager_.enableToolbars(); |
| 557 } else { | 577 } else { |
| 558 this.pageIndicator_.initialFadeIn(); | |
| 559 this.toolbar_.initialFadeIn(); | 578 this.toolbar_.initialFadeIn(); |
| 560 } | 579 } |
| 561 break; | 580 break; |
| 562 case 'email': | 581 case 'email': |
| 563 var href = 'mailto:' + message.data.to + '?cc=' + message.data.cc + | 582 var href = 'mailto:' + message.data.to + '?cc=' + message.data.cc + |
| 564 '&bcc=' + message.data.bcc + '&subject=' + message.data.subject + | 583 '&bcc=' + message.data.bcc + '&subject=' + message.data.subject + |
| 565 '&body=' + message.data.body; | 584 '&body=' + message.data.body; |
| 566 window.location.href = href; | 585 window.location.href = href; |
| 567 break; | 586 break; |
| 568 case 'getAccessibilityJSONReply': | 587 case 'getAccessibilityJSONReply': |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 613 chrome.mimeHandlerPrivate.abortStream(); | 632 chrome.mimeHandlerPrivate.abortStream(); |
| 614 break; | 633 break; |
| 615 case 'metadata': | 634 case 'metadata': |
| 616 if (message.data.title) { | 635 if (message.data.title) { |
| 617 document.title = message.data.title; | 636 document.title = message.data.title; |
| 618 } else { | 637 } else { |
| 619 document.title = | 638 document.title = |
| 620 getFilenameFromURL(this.browserApi_.getStreamInfo().originalUrl); | 639 getFilenameFromURL(this.browserApi_.getStreamInfo().originalUrl); |
| 621 } | 640 } |
| 622 this.bookmarks_ = message.data.bookmarks; | 641 this.bookmarks_ = message.data.bookmarks; |
| 623 if (this.isMaterial_) { | 642 if (this.isMaterial_ && this.materialToolbar_) { |
| 624 this.materialToolbar_.docTitle = document.title; | 643 this.materialToolbar_.docTitle = document.title; |
| 625 this.materialToolbar_.bookmarks = this.bookmarks; | 644 this.materialToolbar_.bookmarks = this.bookmarks; |
| 626 } | 645 } |
| 627 break; | 646 break; |
| 628 case 'setIsSelecting': | 647 case 'setIsSelecting': |
| 629 this.viewportScroller_.setEnableScrolling(message.data.isSelecting); | 648 this.viewportScroller_.setEnableScrolling(message.data.isSelecting); |
| 630 break; | 649 break; |
| 631 case 'getNamedDestinationReply': | 650 case 'getNamedDestinationReply': |
| 632 this.paramsParser_.onNamedDestinationReceived( | 651 this.paramsParser_.onNamedDestinationReceived( |
| 633 message.data.pageNumber); | 652 message.data.pageNumber); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 698 this.toolbar_.style.bottom = toolbarBottom + 'px'; | 717 this.toolbar_.style.bottom = toolbarBottom + 'px'; |
| 699 // Hide the toolbar if it doesn't fit in the viewport. | 718 // Hide the toolbar if it doesn't fit in the viewport. |
| 700 if (this.toolbar_.offsetLeft < 0 || this.toolbar_.offsetTop < 0) | 719 if (this.toolbar_.offsetLeft < 0 || this.toolbar_.offsetTop < 0) |
| 701 this.toolbar_.style.visibility = 'hidden'; | 720 this.toolbar_.style.visibility = 'hidden'; |
| 702 else | 721 else |
| 703 this.toolbar_.style.visibility = 'visible'; | 722 this.toolbar_.style.visibility = 'visible'; |
| 704 } | 723 } |
| 705 | 724 |
| 706 // Update the page indicator. | 725 // Update the page indicator. |
| 707 var visiblePage = this.viewport_.getMostVisiblePage(); | 726 var visiblePage = this.viewport_.getMostVisiblePage(); |
| 708 if (this.isMaterial_) { | 727 |
| 728 if (this.materialToolbar_) | |
| 709 this.materialToolbar_.pageNo = visiblePage + 1; | 729 this.materialToolbar_.pageNo = visiblePage + 1; |
| 710 } else { | 730 |
| 731 // TODO(raymes): Give pageIndicator_ the same API as materialToolbar_. | |
| 732 if (this.pageIndicator_) { | |
| 711 this.pageIndicator_.index = visiblePage; | 733 this.pageIndicator_.index = visiblePage; |
| 712 if (this.documentDimensions_.pageDimensions.length > 1 && | 734 if (this.documentDimensions_.pageDimensions.length > 1 && |
| 713 hasScrollbars.vertical) { | 735 hasScrollbars.vertical) { |
| 714 this.pageIndicator_.style.visibility = 'visible'; | 736 this.pageIndicator_.style.visibility = 'visible'; |
| 715 } else { | 737 } else { |
| 716 this.pageIndicator_.style.visibility = 'hidden'; | 738 this.pageIndicator_.style.visibility = 'hidden'; |
| 717 } | 739 } |
| 718 } | 740 } |
| 719 | 741 |
| 720 var visiblePageDimensions = this.viewport_.getPageScreenRect(visiblePage); | 742 var visiblePageDimensions = this.viewport_.getPageScreenRect(visiblePage); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 790 this.lastViewportPosition_ = this.viewport_.position; | 812 this.lastViewportPosition_ = this.viewport_.position; |
| 791 | 813 |
| 792 // TODO(raymes): Disable these properly in the plugin. | 814 // TODO(raymes): Disable these properly in the plugin. |
| 793 var printButton = $('print-button'); | 815 var printButton = $('print-button'); |
| 794 if (printButton) | 816 if (printButton) |
| 795 printButton.parentNode.removeChild(printButton); | 817 printButton.parentNode.removeChild(printButton); |
| 796 var saveButton = $('save-button'); | 818 var saveButton = $('save-button'); |
| 797 if (saveButton) | 819 if (saveButton) |
| 798 saveButton.parentNode.removeChild(saveButton); | 820 saveButton.parentNode.removeChild(saveButton); |
| 799 | 821 |
| 800 if (!this.isMaterial_) | 822 this.pageIndicator_.pageLabels = message.data.pageNumbers; |
| 801 this.pageIndicator_.pageLabels = message.data.pageNumbers; | |
| 802 | 823 |
| 803 this.plugin_.postMessage({ | 824 this.plugin_.postMessage({ |
| 804 type: 'resetPrintPreviewMode', | 825 type: 'resetPrintPreviewMode', |
| 805 url: message.data.url, | 826 url: message.data.url, |
| 806 grayscale: message.data.grayscale, | 827 grayscale: message.data.grayscale, |
| 807 // If the PDF isn't modifiable we send 0 as the page count so that no | 828 // If the PDF isn't modifiable we send 0 as the page count so that no |
| 808 // blank placeholder pages get appended to the PDF. | 829 // blank placeholder pages get appended to the PDF. |
| 809 pageCount: (message.data.modifiable ? | 830 pageCount: (message.data.modifiable ? |
| 810 message.data.pageNumbers.length : 0) | 831 message.data.pageNumbers.length : 0) |
| 811 }); | 832 }); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 852 * Each bookmark is an Object containing a: | 873 * Each bookmark is an Object containing a: |
| 853 * - title | 874 * - title |
| 854 * - page (optional) | 875 * - page (optional) |
| 855 * - array of children (themselves bookmarks) | 876 * - array of children (themselves bookmarks) |
| 856 * @type {Array} the top-level bookmarks of the PDF. | 877 * @type {Array} the top-level bookmarks of the PDF. |
| 857 */ | 878 */ |
| 858 get bookmarks() { | 879 get bookmarks() { |
| 859 return this.bookmarks_; | 880 return this.bookmarks_; |
| 860 } | 881 } |
| 861 }; | 882 }; |
| OLD | NEW |