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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/print_preview/print_header.js
===================================================================
--- chrome/browser/resources/print_preview/print_header.js (revision 104750)
+++ chrome/browser/resources/print_preview/print_header.js (working copy)
@@ -38,13 +38,16 @@
*/
addEventListeners: function() {
this.cancelButton_.onclick = function() {
- chrome.send('closePrintPreviewTab');
+ cr.dispatchSimpleEvent(document, 'disableCancelButton');
arv (Not doing code reviews) 2011/10/10 19:44:26 It is a bit unclear why you are dispatching an eve
Lei Zhang 2011/10/10 20:03:14 Done.
+ closePrintPreviewTab();
};
this.printButton_.onclick = this.onPrintButtonClicked_.bind(this);
document.addEventListener('updateSummary',
this.updateSummary_.bind(this));
document.addEventListener('updatePrintButton',
this.updatePrintButton_.bind(this));
+ document.addEventListener('disableCancelButton',
+ this.disableCancelButton_.bind(this));
},
/**
@@ -58,10 +61,20 @@
this.cancelButton_.classList.add('loading');
this.summary_.innerHTML = localStrings.getString('printing');
}
+ cr.dispatchSimpleEvent(document, 'disableCancelButton');
requestToPrintDocument();
},
/**
+ * Disables the cancel button and removes its keydown event listener.
+ * @private
+ */
+ disableCancelButton_: function() {
+ window.removeEventListener('keydown');
arv (Not doing code reviews) 2011/10/10 19:44:26 This will not work. You need to pass in the functi
dpapad 2011/10/10 19:53:24 Or you could add it as window.onkeydown = ....; an
Lei Zhang 2011/10/10 20:03:14 Done.
+ this.cancelButton_.disabled = true;
+ },
+
+ /**
* Updates the state of |this.printButton_| depending on the user selection.
* The button is enabled only when the following conditions are true.
* 1) The selected page ranges are valid.

Powered by Google App Engine
This is Rietveld 408576698