| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 for (var header in this.streamDetails_.responseHeaders) { | 105 for (var header in this.streamDetails_.responseHeaders) { |
| 106 headers += header + ': ' + | 106 headers += header + ': ' + |
| 107 this.streamDetails_.responseHeaders[header] + '\n'; | 107 this.streamDetails_.responseHeaders[header] + '\n'; |
| 108 } | 108 } |
| 109 this.plugin_.setAttribute('headers', headers); | 109 this.plugin_.setAttribute('headers', headers); |
| 110 | 110 |
| 111 if (!this.streamDetails_.embedded) | 111 if (!this.streamDetails_.embedded) |
| 112 this.plugin_.setAttribute('full-frame', ''); | 112 this.plugin_.setAttribute('full-frame', ''); |
| 113 document.body.appendChild(this.plugin_); | 113 document.body.appendChild(this.plugin_); |
| 114 | 114 |
| 115 this.pageIndicator_.addEventListener('changePage', function(e) { |
| 116 this.viewport_.goToPage(e.detail.page); |
| 117 }.bind(this)); |
| 118 |
| 115 // Setup the button event listeners. | 119 // Setup the button event listeners. |
| 116 $('fit-to-width-button').addEventListener('click', | 120 $('fit-to-width-button').addEventListener('click', |
| 117 this.viewport_.fitToWidth.bind(this.viewport_)); | 121 this.viewport_.fitToWidth.bind(this.viewport_)); |
| 118 $('fit-to-page-button').addEventListener('click', | 122 $('fit-to-page-button').addEventListener('click', |
| 119 this.viewport_.fitToPage.bind(this.viewport_)); | 123 this.viewport_.fitToPage.bind(this.viewport_)); |
| 120 $('zoom-in-button').addEventListener('click', | 124 $('zoom-in-button').addEventListener('click', |
| 121 this.viewport_.zoomIn.bind(this.viewport_)); | 125 this.viewport_.zoomIn.bind(this.viewport_)); |
| 122 $('zoom-out-button').addEventListener('click', | 126 $('zoom-out-button').addEventListener('click', |
| 123 this.viewport_.zoomOut.bind(this.viewport_)); | 127 this.viewport_.zoomOut.bind(this.viewport_)); |
| 124 $('save-button').addEventListener('click', this.save_.bind(this)); | 128 $('save-button').addEventListener('click', this.save_.bind(this)); |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 this.sizer_.style.display = 'none'; | 335 this.sizer_.style.display = 'none'; |
| 332 this.toolbar_.style.visibility = 'hidden'; | 336 this.toolbar_.style.visibility = 'hidden'; |
| 333 if (this.passwordScreen_.active) { | 337 if (this.passwordScreen_.active) { |
| 334 this.passwordScreen_.deny(); | 338 this.passwordScreen_.deny(); |
| 335 this.passwordScreen_.active = false; | 339 this.passwordScreen_.active = false; |
| 336 } | 340 } |
| 337 } else if (progress == 100) { | 341 } else if (progress == 100) { |
| 338 // Document load complete. | 342 // Document load complete. |
| 339 if (this.lastViewportPosition_) | 343 if (this.lastViewportPosition_) |
| 340 this.viewport_.position = this.lastViewportPosition_; | 344 this.viewport_.position = this.lastViewportPosition_; |
| 345 if (this.isMaterial_) |
| 346 this.pageIndicator_.style.visibility = 'visible'; |
| 341 this.handleURLParams_(); | 347 this.handleURLParams_(); |
| 342 this.loaded_ = true; | 348 this.loaded_ = true; |
| 343 this.sendScriptingMessage_({ | 349 this.sendScriptingMessage_({ |
| 344 type: 'documentLoaded' | 350 type: 'documentLoaded' |
| 345 }); | 351 }); |
| 346 } | 352 } |
| 347 }, | 353 }, |
| 348 | 354 |
| 349 /** | 355 /** |
| 350 * @private | 356 * @private |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 handlePluginMessage_: function(message) { | 435 handlePluginMessage_: function(message) { |
| 430 switch (message.data.type.toString()) { | 436 switch (message.data.type.toString()) { |
| 431 case 'documentDimensions': | 437 case 'documentDimensions': |
| 432 this.documentDimensions_ = message.data; | 438 this.documentDimensions_ = message.data; |
| 433 this.viewport_.setDocumentDimensions(this.documentDimensions_); | 439 this.viewport_.setDocumentDimensions(this.documentDimensions_); |
| 434 // If we received the document dimensions, the password was good so we | 440 // If we received the document dimensions, the password was good so we |
| 435 // can dismiss the password screen. | 441 // can dismiss the password screen. |
| 436 if (this.passwordScreen_.active) | 442 if (this.passwordScreen_.active) |
| 437 this.passwordScreen_.accept(); | 443 this.passwordScreen_.accept(); |
| 438 | 444 |
| 439 this.pageIndicator_.initialFadeIn(); | 445 if (this.isMaterial_) { |
| 446 this.pageIndicator_.docLength = |
| 447 this.documentDimensions_.pageDimensions.length; |
| 448 } else { |
| 449 this.pageIndicator_.initialFadeIn(); |
| 450 } |
| 451 |
| 440 this.toolbar_.initialFadeIn(); | 452 this.toolbar_.initialFadeIn(); |
| 441 break; | 453 break; |
| 442 case 'email': | 454 case 'email': |
| 443 var href = 'mailto:' + message.data.to + '?cc=' + message.data.cc + | 455 var href = 'mailto:' + message.data.to + '?cc=' + message.data.cc + |
| 444 '&bcc=' + message.data.bcc + '&subject=' + message.data.subject + | 456 '&bcc=' + message.data.bcc + '&subject=' + message.data.subject + |
| 445 '&body=' + message.data.body; | 457 '&body=' + message.data.body; |
| 446 window.location.href = href; | 458 window.location.href = href; |
| 447 break; | 459 break; |
| 448 case 'getAccessibilityJSONReply': | 460 case 'getAccessibilityJSONReply': |
| 449 this.sendScriptingMessage_(message.data); | 461 this.sendScriptingMessage_(message.data); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 this.toolbar_.style.bottom = toolbarBottom + 'px'; | 598 this.toolbar_.style.bottom = toolbarBottom + 'px'; |
| 587 // Hide the toolbar if it doesn't fit in the viewport. | 599 // Hide the toolbar if it doesn't fit in the viewport. |
| 588 if (this.toolbar_.offsetLeft < 0 || this.toolbar_.offsetTop < 0) | 600 if (this.toolbar_.offsetLeft < 0 || this.toolbar_.offsetTop < 0) |
| 589 this.toolbar_.style.visibility = 'hidden'; | 601 this.toolbar_.style.visibility = 'hidden'; |
| 590 else | 602 else |
| 591 this.toolbar_.style.visibility = 'visible'; | 603 this.toolbar_.style.visibility = 'visible'; |
| 592 | 604 |
| 593 // Update the page indicator. | 605 // Update the page indicator. |
| 594 var visiblePage = this.viewport_.getMostVisiblePage(); | 606 var visiblePage = this.viewport_.getMostVisiblePage(); |
| 595 this.pageIndicator_.index = visiblePage; | 607 this.pageIndicator_.index = visiblePage; |
| 596 if (this.documentDimensions_.pageDimensions.length > 1 && | 608 if (!this.isMaterial_) { |
| 597 hasScrollbars.vertical) { | 609 if (this.documentDimensions_.pageDimensions.length > 1 && |
| 598 this.pageIndicator_.style.visibility = 'visible'; | 610 hasScrollbars.vertical) { |
| 599 } else { | 611 this.pageIndicator_.style.visibility = 'visible'; |
| 600 this.pageIndicator_.style.visibility = 'hidden'; | 612 } else { |
| 613 this.pageIndicator_.style.visibility = 'hidden'; |
| 614 } |
| 601 } | 615 } |
| 602 | 616 |
| 603 var visiblePageDimensions = this.viewport_.getPageScreenRect(visiblePage); | 617 var visiblePageDimensions = this.viewport_.getPageScreenRect(visiblePage); |
| 604 var size = this.viewport_.size; | 618 var size = this.viewport_.size; |
| 605 this.sendScriptingMessage_({ | 619 this.sendScriptingMessage_({ |
| 606 type: 'viewport', | 620 type: 'viewport', |
| 607 pageX: visiblePageDimensions.x, | 621 pageX: visiblePageDimensions.x, |
| 608 pageY: visiblePageDimensions.y, | 622 pageY: visiblePageDimensions.y, |
| 609 pageWidth: visiblePageDimensions.width, | 623 pageWidth: visiblePageDimensions.width, |
| 610 viewportWidth: size.width, | 624 viewportWidth: size.width, |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 this.streamDetails_.tabId != -1); | 718 this.streamDetails_.tabId != -1); |
| 705 }, | 719 }, |
| 706 | 720 |
| 707 /** | 721 /** |
| 708 * @type {Viewport} the viewport of the PDF viewer. | 722 * @type {Viewport} the viewport of the PDF viewer. |
| 709 */ | 723 */ |
| 710 get viewport() { | 724 get viewport() { |
| 711 return this.viewport_; | 725 return this.viewport_; |
| 712 } | 726 } |
| 713 }; | 727 }; |
| OLD | NEW |