| 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 | |
| 40 // The sizer element is placed behind the plugin element to cause scrollbars | 38 // The sizer element is placed behind the plugin element to cause scrollbars |
| 41 // to be displayed in the window. It is sized according to the document size | 39 // to be displayed in the window. It is sized according to the document size |
| 42 // of the pdf and zoom level. | 40 // of the pdf and zoom level. |
| 43 this.sizer_ = $('sizer'); | 41 this.sizer_ = $('sizer'); |
| 44 this.toolbar_ = $('toolbar'); | 42 this.toolbar_ = $('toolbar'); |
| 45 this.pageIndicator_ = $('page-indicator'); | 43 this.pageIndicator_ = $('page-indicator'); |
| 46 this.progressBar_ = $('progress-bar'); | 44 this.progressBar_ = $('progress-bar'); |
| 47 this.passwordScreen_ = $('password-screen'); | 45 this.passwordScreen_ = $('password-screen'); |
| 48 this.passwordScreen_.addEventListener('password-submitted', | 46 this.passwordScreen_.addEventListener('password-submitted', |
| 49 this.onPasswordSubmitted_.bind(this)); | 47 this.onPasswordSubmitted_.bind(this)); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 // Document load failed. | 249 // Document load failed. |
| 252 this.errorScreen_.style.visibility = 'visible'; | 250 this.errorScreen_.style.visibility = 'visible'; |
| 253 this.sizer_.style.display = 'none'; | 251 this.sizer_.style.display = 'none'; |
| 254 this.toolbar_.style.visibility = 'hidden'; | 252 this.toolbar_.style.visibility = 'hidden'; |
| 255 if (this.passwordScreen_.active) { | 253 if (this.passwordScreen_.active) { |
| 256 this.passwordScreen_.deny(); | 254 this.passwordScreen_.deny(); |
| 257 this.passwordScreen_.active = false; | 255 this.passwordScreen_.active = false; |
| 258 } | 256 } |
| 259 } else if (progress == 100) { | 257 } else if (progress == 100) { |
| 260 // Document load complete. | 258 // Document load complete. |
| 261 this.loaded = true; | |
| 262 var loadEvent = new Event('pdfload'); | 259 var loadEvent = new Event('pdfload'); |
| 263 window.dispatchEvent(loadEvent); | 260 window.dispatchEvent(loadEvent); |
| 264 this.sendScriptingMessage_({ | 261 this.sendScriptingMessage_({ |
| 265 type: 'documentLoaded' | 262 type: 'documentLoaded' |
| 266 }); | 263 }); |
| 267 if (this.lastViewportPosition_) | 264 if (this.lastViewportPosition_) |
| 268 this.viewport_.position = this.lastViewportPosition_; | 265 this.viewport_.position = this.lastViewportPosition_; |
| 269 } | 266 } |
| 270 }, | 267 }, |
| 271 | 268 |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 | 475 |
| 479 /** | 476 /** |
| 480 * @type {Viewport} the viewport of the PDF viewer. | 477 * @type {Viewport} the viewport of the PDF viewer. |
| 481 */ | 478 */ |
| 482 get viewport() { | 479 get viewport() { |
| 483 return this.viewport_; | 480 return this.viewport_; |
| 484 } | 481 } |
| 485 }; | 482 }; |
| 486 | 483 |
| 487 var viewer = new PDFViewer(); | 484 var viewer = new PDFViewer(); |
| OLD | NEW |