| 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 <include src="../../../../ui/webui/resources/js/util.js"> | 7 <include src="../../../../ui/webui/resources/js/util.js"> |
| 8 <include src="pdf_scripting_api.js"> | 8 <include src="pdf_scripting_api.js"> |
| 9 <include src="viewport.js"> | 9 <include src="viewport.js"> |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 * The minimum number of pixels to offset the toolbar by from the bottom and | 28 * The minimum number of pixels to offset the toolbar by from the bottom and |
| 29 * right side of the screen. | 29 * right side of the screen. |
| 30 */ | 30 */ |
| 31 PDFViewer.MIN_TOOLBAR_OFFSET = 15; | 31 PDFViewer.MIN_TOOLBAR_OFFSET = 15; |
| 32 | 32 |
| 33 /** | 33 /** |
| 34 * Creates a new PDFViewer. There should only be one of these objects per | 34 * Creates a new PDFViewer. There should only be one of these objects per |
| 35 * document. | 35 * document. |
| 36 */ | 36 */ |
| 37 function PDFViewer() { | 37 function PDFViewer() { |
| 38 this.loaded = false; |
| 39 |
| 38 // The sizer element is placed behind the plugin element to cause scrollbars | 40 // The sizer element is placed behind the plugin element to cause scrollbars |
| 39 // to be displayed in the window. It is sized according to the document size | 41 // to be displayed in the window. It is sized according to the document size |
| 40 // of the pdf and zoom level. | 42 // of the pdf and zoom level. |
| 41 this.sizer_ = $('sizer'); | 43 this.sizer_ = $('sizer'); |
| 42 this.toolbar_ = $('toolbar'); | 44 this.toolbar_ = $('toolbar'); |
| 43 this.pageIndicator_ = $('page-indicator'); | 45 this.pageIndicator_ = $('page-indicator'); |
| 44 this.progressBar_ = $('progress-bar'); | 46 this.progressBar_ = $('progress-bar'); |
| 45 this.passwordScreen_ = $('password-screen'); | 47 this.passwordScreen_ = $('password-screen'); |
| 46 this.passwordScreen_.addEventListener('password-submitted', | 48 this.passwordScreen_.addEventListener('password-submitted', |
| 47 this.onPasswordSubmitted_.bind(this)); | 49 this.onPasswordSubmitted_.bind(this)); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 // Document load failed. | 251 // Document load failed. |
| 250 this.errorScreen_.style.visibility = 'visible'; | 252 this.errorScreen_.style.visibility = 'visible'; |
| 251 this.sizer_.style.display = 'none'; | 253 this.sizer_.style.display = 'none'; |
| 252 this.toolbar_.style.visibility = 'hidden'; | 254 this.toolbar_.style.visibility = 'hidden'; |
| 253 if (this.passwordScreen_.active) { | 255 if (this.passwordScreen_.active) { |
| 254 this.passwordScreen_.deny(); | 256 this.passwordScreen_.deny(); |
| 255 this.passwordScreen_.active = false; | 257 this.passwordScreen_.active = false; |
| 256 } | 258 } |
| 257 } else if (progress == 100) { | 259 } else if (progress == 100) { |
| 258 // Document load complete. | 260 // Document load complete. |
| 261 this.loaded = true; |
| 259 var loadEvent = new Event('pdfload'); | 262 var loadEvent = new Event('pdfload'); |
| 260 window.dispatchEvent(loadEvent); | 263 window.dispatchEvent(loadEvent); |
| 261 this.sendScriptingMessage_({ | 264 this.sendScriptingMessage_({ |
| 262 type: 'documentLoaded' | 265 type: 'documentLoaded' |
| 263 }); | 266 }); |
| 264 if (this.lastViewportPosition_) | 267 if (this.lastViewportPosition_) |
| 265 this.viewport_.position = this.lastViewportPosition_; | 268 this.viewport_.position = this.lastViewportPosition_; |
| 266 } | 269 } |
| 267 }, | 270 }, |
| 268 | 271 |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 | 478 |
| 476 /** | 479 /** |
| 477 * @type {Viewport} the viewport of the PDF viewer. | 480 * @type {Viewport} the viewport of the PDF viewer. |
| 478 */ | 481 */ |
| 479 get viewport() { | 482 get viewport() { |
| 480 return this.viewport_; | 483 return this.viewport_; |
| 481 } | 484 } |
| 482 }; | 485 }; |
| 483 | 486 |
| 484 var viewer = new PDFViewer(); | 487 var viewer = new PDFViewer(); |
| OLD | NEW |