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 'use strict'; | 6 'use strict'; |
7 | 7 |
8 /** | 8 /** |
9 * Creates a PrintHeader object. This object encapsulates all the elements | 9 * Creates a PrintHeader object. This object encapsulates all the elements |
10 * and logic related to the top part of the left pane in print_preview.html. | 10 * and logic related to the top part of the left pane in print_preview.html. |
(...skipping 26 matching lines...) Expand all Loading... |
37 * Adding event listeners where necessary. Listeners take care of changing | 37 * Adding event listeners where necessary. Listeners take care of changing |
38 * their behavior depending on the current state, no need to remove them. | 38 * their behavior depending on the current state, no need to remove them. |
39 * @private | 39 * @private |
40 */ | 40 */ |
41 addEventListeners_: function() { | 41 addEventListeners_: function() { |
42 this.cancelButton_.onclick = function() { | 42 this.cancelButton_.onclick = function() { |
43 this.disableCancelButton(); | 43 this.disableCancelButton(); |
44 closePrintPreviewTab(); | 44 closePrintPreviewTab(); |
45 }.bind(this); | 45 }.bind(this); |
46 this.printButton_.onclick = this.onPrintButtonClicked_.bind(this); | 46 this.printButton_.onclick = this.onPrintButtonClicked_.bind(this); |
47 document.addEventListener('updateSummary', | 47 document.addEventListener(customEvents.UPDATE_SUMMARY, |
48 this.updateSummary_.bind(this)); | 48 this.updateSummary_.bind(this)); |
49 document.addEventListener('updatePrintButton', | 49 document.addEventListener(customEvents.UPDATE_PRINT_BUTTON, |
50 this.updatePrintButton_.bind(this)); | 50 this.updatePrintButton_.bind(this)); |
51 document.addEventListener('disableCancelButton', | 51 document.addEventListener(customEvents.PDF_GENERATION_ERROR, |
52 this.disableCancelButton.bind(this)); | |
53 document.addEventListener('PDFGenerationError', | |
54 this.onPDFGenerationError_.bind(this)); | 52 this.onPDFGenerationError_.bind(this)); |
55 }, | 53 }, |
56 | 54 |
57 /** | 55 /** |
58 * Executes when an |PDFGenerationError| event is occurs. | 56 * Executes when a |customEvents.PDF_GENERATION_ERROR| event occurs. |
59 * @private | 57 * @private |
60 */ | 58 */ |
61 onPDFGenerationError_: function() { | 59 onPDFGenerationError_: function() { |
62 this.printButton_.disabled = true; | 60 this.printButton_.disabled = true; |
63 }, | 61 }, |
64 | 62 |
65 /** | 63 /** |
66 * Disables the cancel button and removes its keydown event listener. | 64 * Disables the cancel button and removes its keydown event listener. |
67 */ | 65 */ |
68 disableCancelButton: function() { | 66 disableCancelButton: function() { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 // Removing extra spaces from within the string. | 153 // Removing extra spaces from within the string. |
156 html = html.replace(/\s{2,}/g, ' '); | 154 html = html.replace(/\s{2,}/g, ' '); |
157 this.summary_.innerHTML = html; | 155 this.summary_.innerHTML = html; |
158 }, | 156 }, |
159 }; | 157 }; |
160 | 158 |
161 return { | 159 return { |
162 PrintHeader: PrintHeader, | 160 PrintHeader: PrintHeader, |
163 }; | 161 }; |
164 }); | 162 }); |
OLD | NEW |