| OLD | NEW |
| 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 Loading... |
| 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 /** |
| 95 * @param {!Event} event | 104 * @param {!Event} event |
| 96 * @private | 105 * @private |
| 97 */ | 106 */ |
| 98 validate_: function(event) { | 107 validate_: function(event) { |
| 99 var inputElement = Polymer.dom(event).localTarget; | 108 var inputElement = Polymer.dom(event).localTarget; |
| 100 | 109 |
| 101 // If element is empty, disable the action button, but don't show the red | 110 // If element is empty, disable the action button, but don't show the red |
| 102 // invalid message. | 111 // invalid message. |
| 103 if (inputElement.value == '') { | 112 if (inputElement.value == '') { |
| 104 inputElement.invalid = false; | 113 inputElement.invalid = false; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 116 /** @private */ | 125 /** @private */ |
| 117 updateActionButtonState_: function() { | 126 updateActionButtonState_: function() { |
| 118 var allValid = [ | 127 var allValid = [ |
| 119 this.$.searchEngine, this.$.keyword, this.$.queryUrl | 128 this.$.searchEngine, this.$.keyword, this.$.queryUrl |
| 120 ].every(function(inputElement) { | 129 ].every(function(inputElement) { |
| 121 return !inputElement.invalid && inputElement.value.length > 0; | 130 return !inputElement.invalid && inputElement.value.length > 0; |
| 122 }); | 131 }); |
| 123 this.$.actionButton.disabled = !allValid; | 132 this.$.actionButton.disabled = !allValid; |
| 124 }, | 133 }, |
| 125 }); | 134 }); |
| OLD | NEW |