| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 cr.define('print_preview', function() { | 5 cr.define('print_preview', function() { |
| 6 'strict'; | 6 'strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Creates a PreviewArea object. It represents the area where the preview | 9 * Creates a PreviewArea object. It represents the area where the preview |
| 10 * document is displayed. | 10 * document is displayed. |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 }; | 127 }; |
| 128 } | 128 } |
| 129 this.pdfLoaded_ = false; | 129 this.pdfLoaded_ = false; |
| 130 }, | 130 }, |
| 131 | 131 |
| 132 /** | 132 /** |
| 133 * Adds event listeners for various events. | 133 * Adds event listeners for various events. |
| 134 * @private | 134 * @private |
| 135 */ | 135 */ |
| 136 addEventListeners_: function() { | 136 addEventListeners_: function() { |
| 137 document.addEventListener('PDFLoaded', | 137 document.addEventListener(customEvents.PDF_LOADED, |
| 138 this.onPDFLoaded_.bind(this)); | 138 this.onPDFLoaded_.bind(this)); |
| 139 }, | 139 }, |
| 140 | 140 |
| 141 /** | 141 /** |
| 142 * Listener executing when a PDFLoaded event occurs. | 142 * Listener executing when a |customEvents.PDF_LOADED| event occurs. |
| 143 * @private | 143 * @private |
| 144 */ | 144 */ |
| 145 onPDFLoaded_: function() { | 145 onPDFLoaded_: function() { |
| 146 this.pdfPlugin_ = $('pdf-viewer'); | 146 this.pdfPlugin_ = $('pdf-viewer'); |
| 147 this.pdfLoaded_ = true; | 147 this.pdfLoaded_ = true; |
| 148 if (this.zoomLevel_ != null && this.pageOffset_ != null) { | 148 if (this.zoomLevel_ != null && this.pageOffset_ != null) { |
| 149 this.pdfPlugin_.setZoomLevel(this.zoomLevel_); | 149 this.pdfPlugin_.setZoomLevel(this.zoomLevel_); |
| 150 this.pdfPlugin_.setPageXOffset(this.pageOffset_.x); | 150 this.pdfPlugin_.setPageXOffset(this.pageOffset_.x); |
| 151 this.pdfPlugin_.setPageYOffset(this.pageOffset_.y); | 151 this.pdfPlugin_.setPageYOffset(this.pageOffset_.y); |
| 152 } else { | 152 } else { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 displayErrorMessageAndNotify: function(errorMessage) { | 201 displayErrorMessageAndNotify: function(errorMessage) { |
| 202 this.overlayLayer.classList.remove('invisible'); | 202 this.overlayLayer.classList.remove('invisible'); |
| 203 this.customMessage_.textContent = errorMessage; | 203 this.customMessage_.textContent = errorMessage; |
| 204 this.customMessage_.hidden = false; | 204 this.customMessage_.hidden = false; |
| 205 this.customMessageWithDots_.innerHTML = ''; | 205 this.customMessageWithDots_.innerHTML = ''; |
| 206 this.customMessageWithDots_.hidden = true; | 206 this.customMessageWithDots_.hidden = true; |
| 207 if (this.pdfPlugin_) { | 207 if (this.pdfPlugin_) { |
| 208 $('mainview').removeChild(this.pdfPlugin_); | 208 $('mainview').removeChild(this.pdfPlugin_); |
| 209 this.pdfPlugin_ = null; | 209 this.pdfPlugin_ = null; |
| 210 } | 210 } |
| 211 cr.dispatchSimpleEvent(document, 'PDFGenerationError'); | 211 cr.dispatchSimpleEvent(document, customEvents.PDF_GENERATION_ERROR); |
| 212 }, | 212 }, |
| 213 | 213 |
| 214 /** | 214 /** |
| 215 * Display an error message in the center of the preview area followed by a | 215 * Display an error message in the center of the preview area followed by a |
| 216 * button. | 216 * button. |
| 217 * @param {string} errorMessage The error message to be displayed. | 217 * @param {string} errorMessage The error message to be displayed. |
| 218 * @param {string} buttonText The text to be displayed within the button. | 218 * @param {string} buttonText The text to be displayed within the button. |
| 219 * @param {string} buttonListener The listener to be executed when the | 219 * @param {string} buttonListener The listener to be executed when the |
| 220 * button is clicked. | 220 * button is clicked. |
| 221 */ | 221 */ |
| 222 displayErrorMessageWithButtonAndNotify: function( | 222 displayErrorMessageWithButtonAndNotify: function( |
| 223 errorMessage, buttonText, buttonListener) { | 223 errorMessage, buttonText, buttonListener) { |
| 224 this.errorButton.disabled = false; | 224 this.errorButton.disabled = false; |
| 225 this.errorButton.textContent = buttonText; | 225 this.errorButton.textContent = buttonText; |
| 226 this.errorButton.onclick = buttonListener; | 226 this.errorButton.onclick = buttonListener; |
| 227 this.errorButton.hidden = false; | 227 this.errorButton.hidden = false; |
| 228 $('system-dialog-throbber').hidden = true; | 228 $('system-dialog-throbber').hidden = true; |
| 229 $('native-print-dialog-throbber').hidden = true; | 229 $('native-print-dialog-throbber').hidden = true; |
| 230 this.displayErrorMessageAndNotify(errorMessage); | 230 this.displayErrorMessageAndNotify(errorMessage); |
| 231 } | 231 } |
| 232 }; | 232 }; |
| 233 | 233 |
| 234 return { | 234 return { |
| 235 PreviewArea: PreviewArea, | 235 PreviewArea: PreviewArea, |
| 236 }; | 236 }; |
| 237 }); | 237 }); |
| OLD | NEW |