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

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

Issue 2366783002: MD Settings: Search engine dialog, tweak logic to show "input invalid". (Closed)
Patch Set: Undo Created 4 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 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 this.$.dialog.close(); 91 this.$.dialog.close();
92 }, 92 },
93 93
94 /** 94 /**
95 * @param {!Event} event 95 * @param {!Event} event
96 * @private 96 * @private
97 */ 97 */
98 validate_: function(event) { 98 validate_: function(event) {
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
102 // invalid message.
103 if (inputElement.value == '') {
104 inputElement.invalid = false;
105 this.updateActionButtonState_();
106 return;
107 }
108
101 this.browserProxy_.validateSearchEngineInput( 109 this.browserProxy_.validateSearchEngineInput(
102 inputElement.id, inputElement.value).then(function(isValid) { 110 inputElement.id, inputElement.value).then(function(isValid) {
103 inputElement.invalid = !isValid; 111 inputElement.invalid = !isValid;
104 this.updateActionButtonState_(); 112 this.updateActionButtonState_();
105 }.bind(this)); 113 }.bind(this));
106 }, 114 },
107 115
108 /** @private */ 116 /** @private */
109 updateActionButtonState_: function() { 117 updateActionButtonState_: function() {
110 var allValid = [ 118 var allValid = [
111 this.$.searchEngine, this.$.keyword, this.$.queryUrl 119 this.$.searchEngine, this.$.keyword, this.$.queryUrl
112 ].every(function(inputElement) { 120 ].every(function(inputElement) {
113 return !inputElement.invalid && inputElement.value.length != 0; 121 return !inputElement.invalid && inputElement.value.length > 0;
114 }); 122 });
115 this.$.actionButton.disabled = !allValid; 123 this.$.actionButton.disabled = !allValid;
116 }, 124 },
117 }); 125 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698