| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 activeElement.tagName == 'TEXTAREA'); | 68 activeElement.tagName == 'TEXTAREA'); |
| 69 } | 69 } |
| 70 | 70 |
| 71 /** | 71 /** |
| 72 * The minimum number of pixels to offset the toolbar by from the bottom and | 72 * The minimum number of pixels to offset the toolbar by from the bottom and |
| 73 * right side of the screen. | 73 * right side of the screen. |
| 74 */ | 74 */ |
| 75 PDFViewer.MIN_TOOLBAR_OFFSET = 15; | 75 PDFViewer.MIN_TOOLBAR_OFFSET = 15; |
| 76 | 76 |
| 77 /** | 77 /** |
| 78 * The height of the toolbar along the top of the page. The document will be |
| 79 * shifted down by this much in the viewport. |
| 80 */ |
| 81 PDFViewer.MATERIAL_TOOLBAR_HEIGHT = 64; |
| 82 |
| 83 /** |
| 78 * Creates a new PDFViewer. There should only be one of these objects per | 84 * Creates a new PDFViewer. There should only be one of these objects per |
| 79 * document. | 85 * document. |
| 80 * @constructor | 86 * @constructor |
| 81 * @param {!BrowserApi} browserApi An object providing an API to the browser. | 87 * @param {!BrowserApi} browserApi An object providing an API to the browser. |
| 82 */ | 88 */ |
| 83 function PDFViewer(browserApi) { | 89 function PDFViewer(browserApi) { |
| 84 this.browserApi_ = browserApi; | 90 this.browserApi_ = browserApi; |
| 85 this.loadState_ = LoadState.LOADING; | 91 this.loadState_ = LoadState.LOADING; |
| 86 this.parentWindow_ = null; | 92 this.parentWindow_ = null; |
| 87 | 93 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 this.browserApi_.getStreamInfo().originalUrl); | 142 this.browserApi_.getStreamInfo().originalUrl); |
| 137 this.plugin_.setAttribute('stream-url', | 143 this.plugin_.setAttribute('stream-url', |
| 138 this.browserApi_.getStreamInfo().streamUrl); | 144 this.browserApi_.getStreamInfo().streamUrl); |
| 139 var headers = ''; | 145 var headers = ''; |
| 140 for (var header in this.browserApi_.getStreamInfo().responseHeaders) { | 146 for (var header in this.browserApi_.getStreamInfo().responseHeaders) { |
| 141 headers += header + ': ' + | 147 headers += header + ': ' + |
| 142 this.browserApi_.getStreamInfo().responseHeaders[header] + '\n'; | 148 this.browserApi_.getStreamInfo().responseHeaders[header] + '\n'; |
| 143 } | 149 } |
| 144 this.plugin_.setAttribute('headers', headers); | 150 this.plugin_.setAttribute('headers', headers); |
| 145 | 151 |
| 146 if (this.isMaterial_) | 152 if (this.isMaterial_) { |
| 147 this.plugin_.setAttribute('is-material', ''); | 153 this.plugin_.setAttribute('is-material', ''); |
| 154 this.plugin_.setAttribute('top-toolbar-height', |
| 155 PDFViewer.MATERIAL_TOOLBAR_HEIGHT); |
| 156 this.viewport_.topToolbarHeight = PDFViewer.MATERIAL_TOOLBAR_HEIGHT; |
| 157 } |
| 148 | 158 |
| 149 if (!this.browserApi_.getStreamInfo().embedded) | 159 if (!this.browserApi_.getStreamInfo().embedded) |
| 150 this.plugin_.setAttribute('full-frame', ''); | 160 this.plugin_.setAttribute('full-frame', ''); |
| 151 document.body.appendChild(this.plugin_); | 161 document.body.appendChild(this.plugin_); |
| 152 | 162 |
| 153 // Setup the button event listeners. | 163 // Setup the button event listeners. |
| 154 if (!this.isMaterial_) { | 164 if (!this.isMaterial_) { |
| 155 $('fit-to-width-button').addEventListener('click', | 165 $('fit-to-width-button').addEventListener('click', |
| 156 this.viewport_.fitToWidth.bind(this.viewport_)); | 166 this.viewport_.fitToWidth.bind(this.viewport_)); |
| 157 $('fit-to-page-button').addEventListener('click', | 167 $('fit-to-page-button').addEventListener('click', |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 * Each bookmark is an Object containing a: | 815 * Each bookmark is an Object containing a: |
| 806 * - title | 816 * - title |
| 807 * - page (optional) | 817 * - page (optional) |
| 808 * - array of children (themselves bookmarks) | 818 * - array of children (themselves bookmarks) |
| 809 * @type {Array} the top-level bookmarks of the PDF. | 819 * @type {Array} the top-level bookmarks of the PDF. |
| 810 */ | 820 */ |
| 811 get bookmarks() { | 821 get bookmarks() { |
| 812 return this.bookmarks_; | 822 return this.bookmarks_; |
| 813 } | 823 } |
| 814 }; | 824 }; |
| OLD | NEW |