| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 DEFAULT_MODEL_INDEX: -1, | 48 DEFAULT_MODEL_INDEX: -1, |
| 49 | 49 |
| 50 /** @override */ | 50 /** @override */ |
| 51 created: function() { | 51 created: function() { |
| 52 this.browserProxy_ = settings.SearchEnginesBrowserProxyImpl.getInstance(); | 52 this.browserProxy_ = settings.SearchEnginesBrowserProxyImpl.getInstance(); |
| 53 }, | 53 }, |
| 54 | 54 |
| 55 /** @override */ | 55 /** @override */ |
| 56 ready: function() { | 56 ready: function() { |
| 57 if (this.model) { | 57 if (this.model) { |
| 58 // TODO(dpapad): Localize strings. | 58 this.dialogTitle_ = |
| 59 this.dialogTitle_ = 'Edit search engine'; | 59 loadTimeData.getString('searchEnginesEditSearchEngine'); |
| 60 this.actionButtonText_ = 'Edit'; | 60 this.actionButtonText_ = loadTimeData.getString('save'); |
| 61 | 61 |
| 62 // If editing an existing search engine, pre-populate the input fields. | 62 // If editing an existing search engine, pre-populate the input fields. |
| 63 this.searchEngine_ = this.model.displayName; | 63 this.searchEngine_ = this.model.displayName; |
| 64 this.keyword_ = this.model.keyword; | 64 this.keyword_ = this.model.keyword; |
| 65 this.queryUrl_ = this.model.url; | 65 this.queryUrl_ = this.model.url; |
| 66 } else { | 66 } else { |
| 67 // TODO(dpapad): Localize string. | 67 this.dialogTitle_ = |
| 68 this.dialogTitle_ = 'Add search engine'; | 68 loadTimeData.getString('searchEnginesAddSearchEngine'); |
| 69 this.actionButtonText_ = loadTimeData.getString('searchEnginesAdd'); | 69 this.actionButtonText_ = loadTimeData.getString('add'); |
| 70 } | 70 } |
| 71 }, | 71 }, |
| 72 | 72 |
| 73 /** @override */ | 73 /** @override */ |
| 74 attached: function() { | 74 attached: function() { |
| 75 this.updateActionButtonState_(); | 75 this.updateActionButtonState_(); |
| 76 this.browserProxy_.searchEngineEditStarted( | 76 this.browserProxy_.searchEngineEditStarted( |
| 77 this.model ? this.model.modelIndex : this.DEFAULT_MODEL_INDEX); | 77 this.model ? this.model.modelIndex : this.DEFAULT_MODEL_INDEX); |
| 78 this.$.dialog.open(); | 78 this.$.dialog.open(); |
| 79 }, | 79 }, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 108 /** @private */ | 108 /** @private */ |
| 109 updateActionButtonState_: function() { | 109 updateActionButtonState_: function() { |
| 110 var allValid = [ | 110 var allValid = [ |
| 111 this.$.searchEngine, this.$.keyword, this.$.queryUrl | 111 this.$.searchEngine, this.$.keyword, this.$.queryUrl |
| 112 ].every(function(inputElement) { | 112 ].every(function(inputElement) { |
| 113 return !inputElement.invalid && inputElement.value.length != 0; | 113 return !inputElement.invalid && inputElement.value.length != 0; |
| 114 }); | 114 }); |
| 115 this.$.actionButton.disabled = !allValid; | 115 this.$.actionButton.disabled = !allValid; |
| 116 }, | 116 }, |
| 117 }); | 117 }); |
| OLD | NEW |