| 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 * @group Chrome Settings Elements | 9 * @group Chrome Settings Elements |
| 10 * @element settings-search-engine-dialog | 10 * @element settings-search-engine-dialog |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 * The |modelIndex| to use when a new search engine is added. Must match with | 43 * The |modelIndex| to use when a new search engine is added. Must match with |
| 44 * kNewSearchEngineIndex constant specified at | 44 * kNewSearchEngineIndex constant specified at |
| 45 * chrome/browser/ui/webui/settings/search_engines_handler.cc | 45 * chrome/browser/ui/webui/settings/search_engines_handler.cc |
| 46 * @const {number} | 46 * @const {number} |
| 47 */ | 47 */ |
| 48 DEFAULT_MODEL_INDEX: -1, | 48 DEFAULT_MODEL_INDEX: -1, |
| 49 | 49 |
| 50 /** @override */ | 50 /** @override */ |
| 51 ready: function() { | 51 ready: function() { |
| 52 if (this.model) { | 52 if (this.model) { |
| 53 // TODO(dpapad): Localize strings. | 53 this.dialogTitle_ = |
| 54 this.dialogTitle_ = 'Edit search engine'; | 54 loadTimeData.getString('searchEnginesEditSearchEngine'); |
| 55 this.actionButtonText_ = 'Edit'; | 55 this.actionButtonText_ = loadTimeData.getString('save'); |
| 56 | 56 |
| 57 // If editing an existing search engine, pre-populate the input fields. | 57 // If editing an existing search engine, pre-populate the input fields. |
| 58 this.searchEngine_ = this.model.displayName; | 58 this.searchEngine_ = this.model.displayName; |
| 59 this.keyword_ = this.model.keyword; | 59 this.keyword_ = this.model.keyword; |
| 60 this.queryUrl_ = this.model.url; | 60 this.queryUrl_ = this.model.url; |
| 61 } else { | 61 } else { |
| 62 // TODO(dpapad): Localize string. | 62 this.dialogTitle_ = |
| 63 this.dialogTitle_ = 'Add search engine'; | 63 loadTimeData.getString('searchEnginesAddSearchEngine'); |
| 64 this.actionButtonText_ = loadTimeData.getString('searchEnginesAdd'); | 64 this.actionButtonText_ = loadTimeData.getString('add'); |
| 65 } | 65 } |
| 66 }, | 66 }, |
| 67 | 67 |
| 68 /** @override */ | 68 /** @override */ |
| 69 attached: function() { | 69 attached: function() { |
| 70 this.browserProxy_ = settings.SearchEnginesBrowserProxy.getInstance(); | 70 this.browserProxy_ = settings.SearchEnginesBrowserProxy.getInstance(); |
| 71 this.updateActionButtonState_(); | 71 this.updateActionButtonState_(); |
| 72 this.browserProxy_.searchEngineEditStarted( | 72 this.browserProxy_.searchEngineEditStarted( |
| 73 this.model ? this.model.modelIndex : this.DEFAULT_MODEL_INDEX); | 73 this.model ? this.model.modelIndex : this.DEFAULT_MODEL_INDEX); |
| 74 this.$.dialog.open(); | 74 this.$.dialog.open(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 /** @private */ | 107 /** @private */ |
| 108 updateActionButtonState_: function() { | 108 updateActionButtonState_: function() { |
| 109 var allValid = [ | 109 var allValid = [ |
| 110 this.$.searchEngine, this.$.keyword, this.$.queryUrl | 110 this.$.searchEngine, this.$.keyword, this.$.queryUrl |
| 111 ].every(function(inputElement) { | 111 ].every(function(inputElement) { |
| 112 return !inputElement.invalid && inputElement.value.length != 0; | 112 return !inputElement.invalid && inputElement.value.length != 0; |
| 113 }); | 113 }); |
| 114 this.$.actionButton.disabled = !allValid; | 114 this.$.actionButton.disabled = !allValid; |
| 115 }, | 115 }, |
| 116 }); | 116 }); |
| OLD | NEW |