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 Polymer({ | 5 Polymer({ |
6 is: 'history-list-container', | 6 is: 'history-list-container', |
7 | 7 |
8 properties: { | 8 properties: { |
9 // The path of the currently selected page. | 9 // The path of the currently selected page. |
10 selectedPage_: String, | 10 selectedPage_: String, |
11 | 11 |
12 // Whether domain-grouped history is enabled. | 12 // Whether domain-grouped history is enabled. |
13 grouped: Boolean, | 13 grouped: Boolean, |
14 | 14 |
15 /** @type {!QueryState} */ | 15 /** @type {!QueryState} */ |
16 queryState: Object, | 16 queryState: Object, |
17 | 17 |
18 /** @type {!QueryResult} */ | 18 /** @type {!QueryResult} */ |
19 queryResult: Object, | 19 queryResult: Object, |
20 }, | 20 }, |
21 | 21 |
22 observers: [ | 22 observers: [ |
23 'groupedRangeChanged_(queryState.range)', | 23 'groupedRangeChanged_(queryState.range)', |
24 ], | 24 ], |
25 | 25 |
26 listeners: { | 26 listeners: { |
| 27 'history-list-scrolled': 'closeMenu_', |
27 'load-more-history': 'loadMoreHistory_', | 28 'load-more-history': 'loadMoreHistory_', |
| 29 'tap': 'closeMenu_', |
| 30 'toggle-menu': 'toggleMenu_', |
28 }, | 31 }, |
29 | 32 |
30 /** | 33 /** |
31 * @param {HistoryQuery} info An object containing information about the | 34 * @param {HistoryQuery} info An object containing information about the |
32 * query. | 35 * query. |
33 * @param {!Array<HistoryEntry>} results A list of results. | 36 * @param {!Array<HistoryEntry>} results A list of results. |
34 */ | 37 */ |
35 historyResult: function(info, results) { | 38 historyResult: function(info, results) { |
36 this.initializeResults_(info, results); | 39 this.initializeResults_(info, results); |
37 | 40 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 139 |
137 /** @private */ | 140 /** @private */ |
138 onDialogConfirmTap_: function() { | 141 onDialogConfirmTap_: function() { |
139 this.$['infinite-list'].deleteSelected(); | 142 this.$['infinite-list'].deleteSelected(); |
140 this.$.dialog.close(); | 143 this.$.dialog.close(); |
141 }, | 144 }, |
142 | 145 |
143 /** @private */ | 146 /** @private */ |
144 onDialogCancelTap_: function() { | 147 onDialogCancelTap_: function() { |
145 this.$.dialog.close(); | 148 this.$.dialog.close(); |
146 } | 149 }, |
| 150 |
| 151 /** |
| 152 * Closes the overflow menu. |
| 153 * @private |
| 154 */ |
| 155 closeMenu_: function() { |
| 156 /** @type {CrSharedMenuElement} */(this.$.sharedMenu).closeMenu(); |
| 157 }, |
| 158 |
| 159 /** |
| 160 * Opens the overflow menu unless the menu is already open and the same button |
| 161 * is pressed. |
| 162 * @param {{detail: {item: !HistoryEntry, target: !HTMLElement}}} e |
| 163 * @private |
| 164 */ |
| 165 toggleMenu_: function(e) { |
| 166 var target = e.detail.target; |
| 167 /** @type {CrSharedMenuElement} */(this.$.sharedMenu).toggleMenu( |
| 168 target, e.detail.item); |
| 169 }, |
| 170 |
| 171 /** @private */ |
| 172 onMoreFromSiteTap_: function() { |
| 173 var menu = /** @type {CrSharedMenuElement} */(this.$.sharedMenu); |
| 174 this.fire('search-domain', {domain: menu.itemData.domain}); |
| 175 menu.closeMenu(); |
| 176 }, |
| 177 |
| 178 /** @private */ |
| 179 onRemoveFromHistoryTap_: function() { |
| 180 var menu = /** @type {CrSharedMenuElement} */(this.$.sharedMenu); |
| 181 md_history.BrowserService.getInstance() |
| 182 .deleteItems([menu.itemData]) |
| 183 .then(function(items) { |
| 184 this.$['infinite-list'].removeDeletedHistory_(items); |
| 185 // This unselect-all is to reset the toolbar when deleting a selected |
| 186 // item. TODO(tsergeant): Make this automatic based on observing list |
| 187 // modifications. |
| 188 this.fire('unselect-all'); |
| 189 }.bind(this)); |
| 190 menu.closeMenu(); |
| 191 }, |
147 }); | 192 }); |
OLD | NEW |