| 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.showOverlay_(); |
| 508 this.overlayEl_.classList.remove(PreviewArea.Classes_.INVISIBLE); | |
| 509 }, | 511 }, |
| 510 | 512 |
| 511 /** | 513 /** |
| 514 * Shows the message overlay. |
| 515 * @private |
| 516 */ |
| 517 showOverlay_: function() { |
| 518 this.overlayEl_.classList.remove(PreviewArea.Classes_.INVISIBLE); |
| 519 |
| 520 // Hide all controls that will be hidden when the overlay is visible. |
| 521 var marginControls = this.getElement().getElementsByClassName( |
| 522 PreviewArea.Classes_.MARGIN_CONTROL); |
| 523 for (var i = 0; i < marginControls.length; ++i) { |
| 524 marginControls[i].classList.add(PreviewArea.Classes_.OVERLAYED); |
| 525 } |
| 526 var previewAreaControls = this.getElement().getElementsByClassName( |
| 527 PreviewArea.Classes_.PREVIEW_AREA); |
| 528 for (var i = 0; i < previewAreaControls.length; ++i) { |
| 529 previewAreaControls[i].classList.add(PreviewArea.Classes_.OVERLAYED); |
| 530 } |
| 531 }, |
| 532 |
| 533 /** |
| 512 * Hides the message overlay. | 534 * Hides the message overlay. |
| 513 * @private | 535 * @private |
| 514 */ | 536 */ |
| 515 hideOverlay_: function() { | 537 hideOverlay_: function() { |
| 516 this.overlayEl_.classList.add(PreviewArea.Classes_.INVISIBLE); | 538 this.overlayEl_.classList.add(PreviewArea.Classes_.INVISIBLE); |
| 539 |
| 540 // Display all controls that will be visible when the overlay is no longer |
| 541 // visible. |
| 542 var marginControls = this.getElement().getElementsByClassName( |
| 543 PreviewArea.Classes_.MARGIN_CONTROL); |
| 544 for (var i = 0; i < marginControls.length; ++i) { |
| 545 marginControls[i].classList.remove(PreviewArea.Classes_.OVERLAYED); |
| 546 } |
| 547 var previewAreaControls = this.getElement().getElementsByClassName( |
| 548 PreviewArea.Classes_.PREVIEW_AREA); |
| 549 for (var i = 0; i < previewAreaControls.length; ++i) { |
| 550 previewAreaControls[i].classList.remove(PreviewArea.Classes_.OVERLAYED); |
| 551 } |
| 552 |
| 517 // Disable jumping animation to conserve cycles. | 553 // Disable jumping animation to conserve cycles. |
| 518 var jumpingDotsEl = this.getElement().querySelector( | 554 var jumpingDotsEl = this.getElement().querySelector( |
| 519 '.preview-area-loading-message-jumping-dots'); | 555 '.preview-area-loading-message-jumping-dots'); |
| 520 jumpingDotsEl.classList.remove('jumping-dots'); | 556 jumpingDotsEl.classList.remove('jumping-dots'); |
| 521 }, | 557 }, |
| 522 | 558 |
| 523 /** | 559 /** |
| 524 * Creates a preview plugin and adds it to the DOM. | 560 * Creates a preview plugin and adds it to the DOM. |
| 525 * @param {string} srcUrl Initial URL of the plugin. | 561 * @param {string} srcUrl Initial URL of the plugin. |
| 526 * @private | 562 * @private |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 new print_preview.Size(viewportWidth, viewportHeight)); | 807 new print_preview.Size(viewportWidth, viewportHeight)); |
| 772 } | 808 } |
| 773 } | 809 } |
| 774 }; | 810 }; |
| 775 | 811 |
| 776 // Export | 812 // Export |
| 777 return { | 813 return { |
| 778 PreviewArea: PreviewArea | 814 PreviewArea: PreviewArea |
| 779 }; | 815 }; |
| 780 }); | 816 }); |
| OLD | NEW |