Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: chrome/browser/resources/print_preview/print_header.js

Issue 8223009: Print Preview: Keep the cancel button enabled whenever possible. Hook up the escape key to cancel. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/resources/print_preview/print_preview.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 20 matching lines...) Expand all
31 get summary() { 31 get summary() {
32 return this.summary_; 32 return this.summary_;
33 }, 33 },
34 34
35 /** 35 /**
36 * Adding event listeners where necessary. Listeners take care of changing 36 * Adding event listeners where necessary. Listeners take care of changing
37 * their behavior depending on the current state, no need to remove them. 37 * their behavior depending on the current state, no need to remove them.
38 */ 38 */
39 addEventListeners: function() { 39 addEventListeners: function() {
40 this.cancelButton_.onclick = function() { 40 this.cancelButton_.onclick = function() {
41 chrome.send('closePrintPreviewTab'); 41 this.disableCancelButton();
42 }; 42 closePrintPreviewTab();
43 }.bind(this);
43 this.printButton_.onclick = this.onPrintButtonClicked_.bind(this); 44 this.printButton_.onclick = this.onPrintButtonClicked_.bind(this);
44 document.addEventListener('updateSummary', 45 document.addEventListener('updateSummary',
45 this.updateSummary_.bind(this)); 46 this.updateSummary_.bind(this));
46 document.addEventListener('updatePrintButton', 47 document.addEventListener('updatePrintButton',
47 this.updatePrintButton_.bind(this)); 48 this.updatePrintButton_.bind(this));
49 document.addEventListener('disableCancelButton',
50 this.disableCancelButton.bind(this));
51 },
52
53 /**
54 * Disables the cancel button and removes its keydown event listener.
55 */
56 disableCancelButton: function() {
57 window.onkeydown = null;
58 this.cancelButton_.disabled = true;
48 }, 59 },
49 60
50 /** 61 /**
51 * Listener executing whenever |this.printButton_| is clicked. 62 * Listener executing whenever |this.printButton_| is clicked.
52 * @private 63 * @private
53 */ 64 */
54 onPrintButtonClicked_: function() { 65 onPrintButtonClicked_: function() {
55 var printToPDF = getSelectedPrinterName() == PRINT_TO_PDF; 66 var printToPDF = getSelectedPrinterName() == PRINT_TO_PDF;
56 if (!printToPDF) { 67 if (!printToPDF) {
57 this.printButton_.classList.add('loading'); 68 this.printButton_.classList.add('loading');
58 this.cancelButton_.classList.add('loading'); 69 this.cancelButton_.classList.add('loading');
59 this.summary_.innerHTML = localStrings.getString('printing'); 70 this.summary_.innerHTML = localStrings.getString('printing');
60 } 71 }
72 this.disableCancelButton();
61 requestToPrintDocument(); 73 requestToPrintDocument();
62 }, 74 },
63 75
64 /** 76 /**
65 * Updates the state of |this.printButton_| depending on the user selection. 77 * Updates the state of |this.printButton_| depending on the user selection.
66 * The button is enabled only when the following conditions are true. 78 * The button is enabled only when the following conditions are true.
67 * 1) The selected page ranges are valid. 79 * 1) The selected page ranges are valid.
68 * 2) The number of copies is valid (if applicable). 80 * 2) The number of copies is valid (if applicable).
69 * @private 81 * @private
70 */ 82 */
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // Removing extra spaces from within the string. 135 // Removing extra spaces from within the string.
124 html = html.replace(/\s{2,}/g, ' '); 136 html = html.replace(/\s{2,}/g, ' ');
125 this.summary_.innerHTML = html; 137 this.summary_.innerHTML = html;
126 }, 138 },
127 }; 139 };
128 140
129 return { 141 return {
130 PrintHeader: PrintHeader, 142 PrintHeader: PrintHeader,
131 }; 143 };
132 }); 144 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/print_preview/print_preview.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698