| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 /** | 5 /** |
| 6 * @typedef {{accessibility: Function, | 6 * @typedef {{accessibility: Function, |
| 7 * documentLoadComplete: Function, | 7 * documentLoadComplete: Function, |
| 8 * getHeight: Function, | 8 * getHeight: Function, |
| 9 * getHorizontalScrollbarThickness: Function, | 9 * getHorizontalScrollbarThickness: Function, |
| 10 * getPageLocationNormalized: Function, | 10 * getPageLocationNormalized: Function, |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 PreviewArea.Classes_ = { | 192 PreviewArea.Classes_ = { |
| 193 COMPATIBILITY_OBJECT: 'preview-area-compatibility-object', | 193 COMPATIBILITY_OBJECT: 'preview-area-compatibility-object', |
| 194 OUT_OF_PROCESS_COMPATIBILITY_OBJECT: | 194 OUT_OF_PROCESS_COMPATIBILITY_OBJECT: |
| 195 'preview-area-compatibility-object-out-of-process', | 195 'preview-area-compatibility-object-out-of-process', |
| 196 CUSTOM_MESSAGE_TEXT: 'preview-area-custom-message-text', | 196 CUSTOM_MESSAGE_TEXT: 'preview-area-custom-message-text', |
| 197 MESSAGE: 'preview-area-message', | 197 MESSAGE: 'preview-area-message', |
| 198 INVISIBLE: 'invisible', | 198 INVISIBLE: 'invisible', |
| 199 OPEN_SYSTEM_DIALOG_BUTTON: 'preview-area-open-system-dialog-button', | 199 OPEN_SYSTEM_DIALOG_BUTTON: 'preview-area-open-system-dialog-button', |
| 200 OPEN_SYSTEM_DIALOG_BUTTON_THROBBER: | 200 OPEN_SYSTEM_DIALOG_BUTTON_THROBBER: |
| 201 'preview-area-open-system-dialog-button-throbber', | 201 'preview-area-open-system-dialog-button-throbber', |
| 202 OVERLAY: 'preview-area-overlay-layer' | 202 OVERLAY: 'preview-area-overlay-layer', |
| 203 OVERLAYED: 'preview-area-overlayed', |
| 204 MARGIN_CONTROL: 'margin-control', |
| 205 PREVIEW_AREA: 'preview-area-plugin-wrapper' |
| 203 }; | 206 }; |
| 204 | 207 |
| 205 /** | 208 /** |
| 206 * Enumeration of IDs shown in the preview area. | 209 * Enumeration of IDs shown in the preview area. |
| 207 * @enum {string} | 210 * @enum {string} |
| 208 * @private | 211 * @private |
| 209 */ | 212 */ |
| 210 PreviewArea.MessageId_ = { | 213 PreviewArea.MessageId_ = { |
| 211 CUSTOM: 'custom', | 214 CUSTOM: 'custom', |
| 212 LOADING: 'loading', | 215 LOADING: 'loading', |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 var customMessageTextEl = this.getElement().getElementsByClassName( | 500 var customMessageTextEl = this.getElement().getElementsByClassName( |
| 498 PreviewArea.Classes_.CUSTOM_MESSAGE_TEXT)[0]; | 501 PreviewArea.Classes_.CUSTOM_MESSAGE_TEXT)[0]; |
| 499 customMessageTextEl.textContent = opt_message; | 502 customMessageTextEl.textContent = opt_message; |
| 500 } else if (messageId == PreviewArea.MessageId_.LOADING) { | 503 } else if (messageId == PreviewArea.MessageId_.LOADING) { |
| 501 jumpingDotsEl.classList.add('jumping-dots'); | 504 jumpingDotsEl.classList.add('jumping-dots'); |
| 502 } | 505 } |
| 503 var messageEl = this.getElement().getElementsByClassName( | 506 var messageEl = this.getElement().getElementsByClassName( |
| 504 PreviewArea.MessageIdClassMap_[messageId])[0]; | 507 PreviewArea.MessageIdClassMap_[messageId])[0]; |
| 505 setIsVisible(messageEl, true); | 508 setIsVisible(messageEl, true); |
| 506 | 509 |
| 507 // Show overlay. | 510 this.setOverlayVisible_(true); |
| 508 this.overlayEl_.classList.remove(PreviewArea.Classes_.INVISIBLE); | |
| 509 }, | 511 }, |
| 510 | 512 |
| 511 /** | 513 /** |
| 512 * Hides the message overlay. | 514 * Set the visibility of the message overlay. |
| 515 * @param {boolean} visible Whether to make the overlay visible or not |
| 513 * @private | 516 * @private |
| 514 */ | 517 */ |
| 515 hideOverlay_: function() { | 518 setOverlayVisible_: function(visible) { |
| 516 this.overlayEl_.classList.add(PreviewArea.Classes_.INVISIBLE); | 519 this.overlayEl_.classList.toggle( |
| 517 // Disable jumping animation to conserve cycles. | 520 PreviewArea.Classes_.INVISIBLE, |
| 518 var jumpingDotsEl = this.getElement().querySelector( | 521 !visible); |
| 519 '.preview-area-loading-message-jumping-dots'); | 522 |
| 520 jumpingDotsEl.classList.remove('jumping-dots'); | 523 // Hide/show all controls that will overlap when the overlay is visible. |
| 524 var marginControls = this.getElement().getElementsByClassName( |
| 525 PreviewArea.Classes_.MARGIN_CONTROL); |
| 526 for (var i = 0; i < marginControls.length; ++i) { |
| 527 marginControls[i].classList.toggle(PreviewArea.Classes_.OVERLAYED, |
| 528 visible); |
| 529 } |
| 530 var previewAreaControls = this.getElement().getElementsByClassName( |
| 531 PreviewArea.Classes_.PREVIEW_AREA); |
| 532 for (var i = 0; i < previewAreaControls.length; ++i) { |
| 533 previewAreaControls[i].classList.toggle(PreviewArea.Classes_.OVERLAYED, |
| 534 visible); |
| 535 } |
| 536 |
| 537 if (!visible) { |
| 538 // Disable jumping animation to conserve cycles. |
| 539 var jumpingDotsEl = this.getElement().querySelector( |
| 540 '.preview-area-loading-message-jumping-dots'); |
| 541 jumpingDotsEl.classList.remove('jumping-dots'); |
| 542 } |
| 521 }, | 543 }, |
| 522 | 544 |
| 523 /** | 545 /** |
| 524 * Creates a preview plugin and adds it to the DOM. | 546 * Creates a preview plugin and adds it to the DOM. |
| 525 * @param {string} srcUrl Initial URL of the plugin. | 547 * @param {string} srcUrl Initial URL of the plugin. |
| 526 * @private | 548 * @private |
| 527 */ | 549 */ |
| 528 createPlugin_: function(srcUrl) { | 550 createPlugin_: function(srcUrl) { |
| 529 if (this.plugin_) { | 551 if (this.plugin_) { |
| 530 console.warn('Pdf preview plugin already created'); | 552 console.warn('Pdf preview plugin already created'); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 this.plugin_.setPageNumbers(JSON.stringify( | 729 this.plugin_.setPageNumbers(JSON.stringify( |
| 708 this.printTicketStore_.pageRange.getPageNumberSet().asArray())); | 730 this.printTicketStore_.pageRange.getPageNumberSet().asArray())); |
| 709 if (this.zoomLevel_ != null && this.pageOffset_ != null) { | 731 if (this.zoomLevel_ != null && this.pageOffset_ != null) { |
| 710 this.plugin_.setZoomLevel(this.zoomLevel_); | 732 this.plugin_.setZoomLevel(this.zoomLevel_); |
| 711 this.plugin_.setPageXOffset(this.pageOffset_.x); | 733 this.plugin_.setPageXOffset(this.pageOffset_.x); |
| 712 this.plugin_.setPageYOffset(this.pageOffset_.y); | 734 this.plugin_.setPageYOffset(this.pageOffset_.y); |
| 713 } else { | 735 } else { |
| 714 this.plugin_.fitToHeight(); | 736 this.plugin_.fitToHeight(); |
| 715 } | 737 } |
| 716 } | 738 } |
| 717 this.hideOverlay_(); | 739 this.setOverlayVisible_(false); |
| 718 this.isPluginReloaded_ = true; | 740 this.isPluginReloaded_ = true; |
| 719 this.dispatchPreviewGenerationDoneIfReady_(); | 741 this.dispatchPreviewGenerationDoneIfReady_(); |
| 720 }, | 742 }, |
| 721 | 743 |
| 722 /** | 744 /** |
| 723 * Called when the preview plugin's visual state has changed. This is a | 745 * Called when the preview plugin's visual state has changed. This is a |
| 724 * consequence of scrolling or zooming the plugin. Updates the custom | 746 * consequence of scrolling or zooming the plugin. Updates the custom |
| 725 * margins component if shown. | 747 * margins component if shown. |
| 726 * @private | 748 * @private |
| 727 */ | 749 */ |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 new print_preview.Size(viewportWidth, viewportHeight)); | 793 new print_preview.Size(viewportWidth, viewportHeight)); |
| 772 } | 794 } |
| 773 } | 795 } |
| 774 }; | 796 }; |
| 775 | 797 |
| 776 // Export | 798 // Export |
| 777 return { | 799 return { |
| 778 PreviewArea: PreviewArea | 800 PreviewArea: PreviewArea |
| 779 }; | 801 }; |
| 780 }); | 802 }); |
| OLD | NEW |