| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 var inputElement = Polymer.dom(event).localTarget; | 99 var inputElement = Polymer.dom(event).localTarget; |
| 100 | 100 |
| 101 // 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 |
| 102 // invalid message. | 102 // invalid message. |
| 103 if (inputElement.value == '') { | 103 if (inputElement.value == '') { |
| 104 inputElement.invalid = false; | 104 inputElement.invalid = false; |
| 105 this.updateActionButtonState_(); | 105 this.updateActionButtonState_(); |
| 106 return; | 106 return; |
| 107 } | 107 } |
| 108 | 108 |
| 109 this.browserProxy_.validateSearchEngineInput( | 109 this.browserProxy_ |
| 110 inputElement.id, inputElement.value).then(function(isValid) { | 110 .validateSearchEngineInput(inputElement.id, inputElement.value) |
| 111 inputElement.invalid = !isValid; | 111 .then(function(isValid) { |
| 112 this.updateActionButtonState_(); | 112 inputElement.invalid = !isValid; |
| 113 }.bind(this)); | 113 this.updateActionButtonState_(); |
| 114 }.bind(this)); |
| 114 }, | 115 }, |
| 115 | 116 |
| 116 /** @private */ | 117 /** @private */ |
| 117 updateActionButtonState_: function() { | 118 updateActionButtonState_: function() { |
| 118 var allValid = [ | 119 var allValid = [ |
| 119 this.$.searchEngine, this.$.keyword, this.$.queryUrl | 120 this.$.searchEngine, this.$.keyword, this.$.queryUrl |
| 120 ].every(function(inputElement) { | 121 ].every(function(inputElement) { |
| 121 return !inputElement.invalid && inputElement.value.length > 0; | 122 return !inputElement.invalid && inputElement.value.length > 0; |
| 122 }); | 123 }); |
| 123 this.$.actionButton.disabled = !allValid; | 124 this.$.actionButton.disabled = !allValid; |
| 124 }, | 125 }, |
| 125 }); | 126 }); |
| OLD | NEW |