summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authordpapad@chromium.org <dpapad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-19 03:14:28 +0000
committerdpapad@chromium.org <dpapad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-19 03:14:28 +0000
commit0d84c61ad7d0c0245d6d9bd9eb2638c2d50ef2d4 (patch)
treec91e9a8065fbf94d93a4c6ba7882e2e521d1a553 /chrome
parentac13ef1965ce96760719c62f0ced449cdcc738a0 (diff)
downloadchromium_src-0d84c61ad7d0c0245d6d9bd9eb2638c2d50ef2d4.zip
chromium_src-0d84c61ad7d0c0245d6d9bd9eb2638c2d50ef2d4.tar.gz
chromium_src-0d84c61ad7d0c0245d6d9bd9eb2638c2d50ef2d4.tar.bz2
Print Preview: Making ENTER keystroke print when pages textfield is focused.
BUG=107583 TEST=Focus the page field. Hit enter, printing should start. Review URL: http://codereview.chromium.org/9254015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118220 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/resources/print_preview/margin_textbox.js6
-rw-r--r--chrome/browser/resources/print_preview/page_settings.js13
-rw-r--r--chrome/browser/resources/print_preview/print_header.js10
3 files changed, 19 insertions, 10 deletions
diff --git a/chrome/browser/resources/print_preview/margin_textbox.js b/chrome/browser/resources/print_preview/margin_textbox.js
index 8e8948d9..6d1798a 100644
--- a/chrome/browser/resources/print_preview/margin_textbox.js
+++ b/chrome/browser/resources/print_preview/margin_textbox.js
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -31,8 +31,6 @@ cr.define('print_preview', function() {
MarginTextbox.CSS_CLASS_MARGIN_TEXTBOX = 'margin-box';
// Keycode for the "Escape" key.
MarginTextbox.ESCAPE_KEYCODE = 27;
- // Keycode for the "Enter" key.
- MarginTextbox.ENTER_KEYCODE = 13;
MarginTextbox.prototype = {
__proto__: HTMLInputElement.prototype,
@@ -165,7 +163,7 @@ cr.define('print_preview', function() {
* @private
*/
onKeyPressed_: function(e) {
- if (e.keyCode == MarginTextbox.ENTER_KEYCODE)
+ if (e.keyIdentifier == 'Enter')
this.blur();
},
diff --git a/chrome/browser/resources/print_preview/page_settings.js b/chrome/browser/resources/print_preview/page_settings.js
index a87be15..d69f6e7 100644
--- a/chrome/browser/resources/print_preview/page_settings.js
+++ b/chrome/browser/resources/print_preview/page_settings.js
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -342,6 +342,16 @@ cr.define('print_preview', function() {
},
/**
+ * Listener executing whenever a keyup events occurs in the pages textfield.
+ * @param {!KeyboardEvent} e The event that triggered this listener.
+ * @private
+ */
+ onKeyUp_: function(e) {
+ if (e.keyIdentifier == 'Enter')
+ printHeader.onPrintRequested();
+ },
+
+ /**
* Adding listeners to all pages related controls. The listeners take care
* of altering their behavior depending on |hasPendingPreviewRequest|.
* @private
@@ -357,6 +367,7 @@ cr.define('print_preview', function() {
this.addTimerToSelectedPagesTextfield_.bind(this);
this.selectedPagesTextfield.onblur =
this.onSelectedPagesTextfieldBlur_.bind(this);
+ this.selectedPagesTextfield.onkeyup = this.onKeyUp_.bind(this);
}
};
diff --git a/chrome/browser/resources/print_preview/print_header.js b/chrome/browser/resources/print_preview/print_header.js
index 977a649..1c17c83 100644
--- a/chrome/browser/resources/print_preview/print_header.js
+++ b/chrome/browser/resources/print_preview/print_header.js
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -43,7 +43,7 @@ cr.define('print_preview', function() {
this.disableCancelButton();
closePrintPreviewTab();
}.bind(this);
- this.printButton_.onclick = this.onPrintButtonClicked_.bind(this);
+ this.printButton_.onclick = this.onPrintRequested.bind(this);
document.addEventListener(customEvents.UPDATE_SUMMARY,
this.updateSummary_.bind(this));
document.addEventListener(customEvents.UPDATE_PRINT_BUTTON,
@@ -77,10 +77,10 @@ cr.define('print_preview', function() {
},
/**
- * Listener executing whenever |this.printButton_| is clicked.
- * @private
+ * Listener executing whenever the print button is clicked or user presses
+ * the enter button while focus is in the pages field.
*/
- onPrintButtonClicked_: function() {
+ onPrintRequested: function() {
var printToPDF = getSelectedPrinterName() == PRINT_TO_PDF;
if (!printToPDF) {
this.printButton_.classList.add('loading');