| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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-entry' is a component for showing a | 6 * @fileoverview 'settings-search-engine-entry' is a component for showing a |
| 7 * search engine with its name, domain and query URL. | 7 * search engine with its name, domain and query URL. |
| 8 */ | 8 */ |
| 9 Polymer({ | 9 Polymer({ |
| 10 is: 'settings-search-engine-entry', | 10 is: 'settings-search-engine-entry', |
| 11 | 11 |
| 12 properties: { | 12 properties: { |
| 13 /** @type {!SearchEngine} */ | 13 /** @type {!SearchEngine} */ |
| 14 engine: Object, | 14 engine: Object, |
| 15 | 15 |
| 16 /** @type {boolean} */ | 16 /** @type {boolean} */ |
| 17 isDefault: { | 17 isDefault: { |
| 18 reflectToAttribute: true, | 18 reflectToAttribute: true, |
| 19 type: Boolean, | 19 type: Boolean, |
| 20 computed: 'computeIsDefault_(engine)' | 20 computed: 'computeIsDefault_(engine)' |
| 21 }, | 21 }, |
| 22 | 22 |
| 23 /** @private {boolean} */ | 23 /** @private {boolean} */ |
| 24 showDots_: { | 24 showDots_: { |
| 25 reflectToAttribute: true, | 25 reflectToAttribute: true, |
| 26 type: Boolean, | 26 type: Boolean, |
| 27 computed: 'computeShowDots_(engine.canBeDefault,' + | 27 computed: 'computeShowDots_(engine.canBeDefault,' + |
| 28 'engine.canBeEdited,' + | 28 'engine.canBeEdited,' + |
| 29 'engine.canBeRemoved)', | 29 'engine.canBeRemoved)', |
| 30 }, | 30 }, |
| 31 | 31 |
| 32 /** @private {boolean} */ | 32 /** @private {boolean} */ |
| 33 showEditSearchEngineDialog_: Boolean, | 33 showEditSearchEngineDialog_: Boolean, |
| 34 }, | 34 }, |
| 35 | 35 |
| 36 /** @private {settings.SearchEnginesBrowserProxy} */ | 36 /** @private {settings.SearchEnginesBrowserProxy} */ |
| 37 browserProxy_: null, | 37 browserProxy_: null, |
| 38 | 38 |
| 39 /** @override */ | 39 /** @override */ |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 }, | 76 }, |
| 77 | 77 |
| 78 /** @private */ | 78 /** @private */ |
| 79 onDeleteTap_: function() { | 79 onDeleteTap_: function() { |
| 80 this.browserProxy_.removeSearchEngine(this.engine.modelIndex); | 80 this.browserProxy_.removeSearchEngine(this.engine.modelIndex); |
| 81 this.closePopupMenu_(); | 81 this.closePopupMenu_(); |
| 82 }, | 82 }, |
| 83 | 83 |
| 84 /** @private */ | 84 /** @private */ |
| 85 onDotsTap_: function() { | 85 onDotsTap_: function() { |
| 86 /** @type {!CrActionMenuElement} */ ( | 86 /** @type {!CrActionMenuElement} */ (this.$$('dialog[is=cr-action-menu]')) |
| 87 this.$$('dialog[is=cr-action-menu]')).showAt( | 87 .showAt(assert(this.$$('paper-icon-button'))); |
| 88 assert(this.$$('paper-icon-button'))); | |
| 89 }, | 88 }, |
| 90 | 89 |
| 91 /** | 90 /** |
| 92 * @param {!Event} e | 91 * @param {!Event} e |
| 93 * @private | 92 * @private |
| 94 */ | 93 */ |
| 95 onEditTap_: function(e) { | 94 onEditTap_: function(e) { |
| 96 e.preventDefault(); | 95 e.preventDefault(); |
| 97 this.closePopupMenu_(); | 96 this.closePopupMenu_(); |
| 98 | 97 |
| 99 this.showEditSearchEngineDialog_ = true; | 98 this.showEditSearchEngineDialog_ = true; |
| 100 this.async(function() { | 99 this.async(function() { |
| 101 var dialog = this.$$('settings-search-engine-dialog'); | 100 var dialog = this.$$('settings-search-engine-dialog'); |
| 102 // Register listener to detect when the dialog is closed. Flip the boolean | 101 // Register listener to detect when the dialog is closed. Flip the boolean |
| 103 // once closed to force a restamp next time it is shown such that the | 102 // once closed to force a restamp next time it is shown such that the |
| 104 // previous dialog's contents are cleared. | 103 // previous dialog's contents are cleared. |
| 105 dialog.addEventListener('close', function() { | 104 dialog.addEventListener('close', function() { |
| 106 this.showEditSearchEngineDialog_ = false; | 105 this.showEditSearchEngineDialog_ = false; |
| 107 }.bind(this)); | 106 }.bind(this)); |
| 108 }.bind(this)); | 107 }.bind(this)); |
| 109 }, | 108 }, |
| 110 | 109 |
| 111 /** @private */ | 110 /** @private */ |
| 112 onMakeDefaultTap_: function() { | 111 onMakeDefaultTap_: function() { |
| 113 this.closePopupMenu_(); | 112 this.closePopupMenu_(); |
| 114 this.browserProxy_.setDefaultSearchEngine(this.engine.modelIndex); | 113 this.browserProxy_.setDefaultSearchEngine(this.engine.modelIndex); |
| 115 }, | 114 }, |
| 116 }); | 115 }); |
| OLD | NEW |