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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // If editing an existing search engine, pre-populate the input fields. | 59 // If editing an existing search engine, pre-populate the input fields. |
60 this.searchEngine_ = this.model.name; | 60 this.searchEngine_ = this.model.name; |
61 this.keyword_ = this.model.keyword; | 61 this.keyword_ = this.model.keyword; |
62 this.queryUrl_ = this.model.url; | 62 this.queryUrl_ = this.model.url; |
63 } else { | 63 } else { |
64 this.dialogTitle_ = | 64 this.dialogTitle_ = |
65 loadTimeData.getString('searchEnginesAddSearchEngine'); | 65 loadTimeData.getString('searchEnginesAddSearchEngine'); |
66 this.actionButtonText_ = loadTimeData.getString('add'); | 66 this.actionButtonText_ = loadTimeData.getString('add'); |
67 } | 67 } |
68 | 68 |
69 this.addEventListener('cancel', function() { | 69 this.addEventListener('cancel', () => { |
70 this.browserProxy_.searchEngineEditCancelled(); | 70 this.browserProxy_.searchEngineEditCancelled(); |
71 }.bind(this)); | 71 }); |
72 }, | 72 }, |
73 | 73 |
74 /** @override */ | 74 /** @override */ |
75 attached: function() { | 75 attached: function() { |
76 this.updateActionButtonState_(); | 76 this.updateActionButtonState_(); |
77 this.browserProxy_.searchEngineEditStarted( | 77 this.browserProxy_.searchEngineEditStarted( |
78 this.model ? this.model.modelIndex : this.DEFAULT_MODEL_INDEX); | 78 this.model ? this.model.modelIndex : this.DEFAULT_MODEL_INDEX); |
79 this.$.dialog.showModal(); | 79 this.$.dialog.showModal(); |
80 }, | 80 }, |
81 | 81 |
(...skipping 19 matching lines...) Expand all Loading... |
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_ | 109 this.browserProxy_ |
110 .validateSearchEngineInput(inputElement.id, inputElement.value) | 110 .validateSearchEngineInput(inputElement.id, inputElement.value) |
111 .then(function(isValid) { | 111 .then(isValid => { |
112 inputElement.invalid = !isValid; | 112 inputElement.invalid = !isValid; |
113 this.updateActionButtonState_(); | 113 this.updateActionButtonState_(); |
114 }.bind(this)); | 114 }); |
115 }, | 115 }, |
116 | 116 |
117 /** @private */ | 117 /** @private */ |
118 updateActionButtonState_: function() { | 118 updateActionButtonState_: function() { |
119 var allValid = [ | 119 var allValid = [ |
120 this.$.searchEngine, this.$.keyword, this.$.queryUrl | 120 this.$.searchEngine, this.$.keyword, this.$.queryUrl |
121 ].every(function(inputElement) { | 121 ].every(function(inputElement) { |
122 return !inputElement.invalid && inputElement.value.length > 0; | 122 return !inputElement.invalid && inputElement.value.length > 0; |
123 }); | 123 }); |
124 this.$.actionButton.disabled = !allValid; | 124 this.$.actionButton.disabled = !allValid; |
125 }, | 125 }, |
126 }); | 126 }); |
OLD | NEW |