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

Side by Side Diff: chrome/browser/resources/settings/search_engines_page/search_engine_dialog.js

Issue 2795353002: WebUI: For cr-dialog, handle Enter keys in paper-inputs. (Closed)
Patch Set: update tests Created 3 years, 8 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 /** 5 /**
6 * @fileoverview 'settings-search-engine-dialog' is a component for adding 6 * @fileoverview 'settings-search-engine-dialog' is a component for adding
7 * or editing a search engine entry. 7 * or editing a search engine entry.
8 */ 8 */
9 Polymer({ 9 Polymer({
10 is: 'settings-search-engine-dialog', 10 is: 'settings-search-engine-dialog',
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 }, 85 },
86 86
87 /** @private */ 87 /** @private */
88 onActionButtonTap_: function() { 88 onActionButtonTap_: function() {
89 this.browserProxy_.searchEngineEditCompleted( 89 this.browserProxy_.searchEngineEditCompleted(
90 this.searchEngine_, this.keyword_, this.queryUrl_); 90 this.searchEngine_, this.keyword_, this.queryUrl_);
91 this.$.dialog.close(); 91 this.$.dialog.close();
92 }, 92 },
93 93
94 /** 94 /**
95 * @param {!KeyboardEvent} e
96 * @private
97 */
98 onKeypress_: function(e) {
99 if (e.key == 'Enter' && !this.$.actionButton.disabled)
100 this.onActionButtonTap_();
101 },
102
103 /**
104 * @param {!Event} event 95 * @param {!Event} event
105 * @private 96 * @private
106 */ 97 */
107 validate_: function(event) { 98 validate_: function(event) {
108 var inputElement = Polymer.dom(event).localTarget; 99 var inputElement = Polymer.dom(event).localTarget;
109 100
110 // If element is empty, disable the action button, but don't show the red 101 // If element is empty, disable the action button, but don't show the red
111 // invalid message. 102 // invalid message.
112 if (inputElement.value == '') { 103 if (inputElement.value == '') {
113 inputElement.invalid = false; 104 inputElement.invalid = false;
(...skipping 11 matching lines...) Expand all
125 /** @private */ 116 /** @private */
126 updateActionButtonState_: function() { 117 updateActionButtonState_: function() {
127 var allValid = [ 118 var allValid = [
128 this.$.searchEngine, this.$.keyword, this.$.queryUrl 119 this.$.searchEngine, this.$.keyword, this.$.queryUrl
129 ].every(function(inputElement) { 120 ].every(function(inputElement) {
130 return !inputElement.invalid && inputElement.value.length > 0; 121 return !inputElement.invalid && inputElement.value.length > 0;
131 }); 122 });
132 this.$.actionButton.disabled = !allValid; 123 this.$.actionButton.disabled = !allValid;
133 }, 124 },
134 }); 125 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698