Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Side by Side Diff: chrome/browser/resources/md_history/list_container.js

Issue 2656443004: MD History: Add routing for grouped history mode. (Closed)
Patch Set: Tweak Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_: { 10 selectedPage_: {
(...skipping 14 matching lines...) Expand all
25 * @private {?{ 25 * @private {?{
26 * index: number, 26 * index: number,
27 * item: !HistoryEntry, 27 * item: !HistoryEntry,
28 * path: string, 28 * path: string,
29 * target: !HTMLElement 29 * target: !HTMLElement
30 * }} 30 * }}
31 */ 31 */
32 actionMenuModel_: Object, 32 actionMenuModel_: Object,
33 }, 33 },
34 34
35 observers: [
36 'groupedRangeChanged_(queryState.range)',
37 ],
38
39 listeners: { 35 listeners: {
40 'open-menu': 'openMenu_', 36 'open-menu': 'openMenu_',
41 }, 37 },
42 38
43 /** 39 /**
44 * @param {HistoryQuery} info An object containing information about the 40 * @param {HistoryQuery} info An object containing information about the
45 * query. 41 * query.
46 * @param {!Array<!HistoryEntry>} results A list of results. 42 * @param {!Array<!HistoryEntry>} results A list of results.
47 */ 43 */
48 historyResult: function(info, results) { 44 historyResult: function(info, results) {
49 this.initializeResults_(info, results); 45 this.initializeResults_(info, results);
50 this.closeMenu_(); 46 this.closeMenu_();
51 47
52 if (info.term && !this.queryState.incremental) { 48 if (info.term && !this.queryState.incremental) {
53 Polymer.IronA11yAnnouncer.requestAvailability(); 49 Polymer.IronA11yAnnouncer.requestAvailability();
54 this.fire('iron-announce', { 50 this.fire('iron-announce', {
55 text: 51 text:
56 md_history.HistoryItem.searchResultsTitle(results.length, info.term) 52 md_history.HistoryItem.searchResultsTitle(results.length, info.term)
57 }); 53 });
58 } 54 }
59 55
60 var list = /** @type {HistoryListBehavior} */ this.getSelectedList_(); 56 var list = /** @type {HistoryListBehavior} */ this.getSelectedList_();
61 list.addNewResults(results, this.queryState.incremental, info.finished); 57 if (Polymer.isInstance(list))
58 list.addNewResults(results, this.queryState.incremental, info.finished);
59 else
60 list.initialData = results;
calamity 2017/01/27 03:47:34 Explain the lazy load problem here.
tsergeant 2017/01/30 02:13:14 Done.
62 }, 61 },
63 62
64 historyDeleted: function() { 63 historyDeleted: function() {
65 // Do not reload the list when there are items checked. 64 // Do not reload the list when there are items checked.
66 if (this.getSelectedItemCount() > 0) 65 if (this.getSelectedItemCount() > 0)
67 return; 66 return;
68 67
69 // Reload the list with current search state. 68 // Reload the list with current search state.
70 this.fire('query-history', false); 69 this.fire('query-history', false);
71 }, 70 },
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 /** 106 /**
108 * @param {HistoryRange} range 107 * @param {HistoryRange} range
109 * @return {string} 108 * @return {string}
110 * @private 109 * @private
111 */ 110 */
112 computeSelectedPage_: function(range) { 111 computeSelectedPage_: function(range) {
113 return range == HistoryRange.ALL_TIME ? 'infinite-list' : 'grouped-list'; 112 return range == HistoryRange.ALL_TIME ? 'infinite-list' : 'grouped-list';
114 }, 113 },
115 114
116 /** 115 /**
117 * @param {HistoryRange} range
118 * @private
119 */
120 groupedRangeChanged_: function(range) {
121 // Reset the results on range change to prevent stale results from being
122 // processed into the incoming range's UI.
123 if (range != HistoryRange.ALL_TIME && this.queryResult.info) {
124 this.set('queryResult.results', []);
125 this.historyResult(this.queryResult.info, []);
126 }
127 },
128
129 /**
130 * @param {HistoryQuery} info 116 * @param {HistoryQuery} info
131 * @param {!Array<HistoryEntry>} results 117 * @param {!Array<HistoryEntry>} results
132 * @private 118 * @private
133 */ 119 */
134 initializeResults_: function(info, results) { 120 initializeResults_: function(info, results) {
135 if (results.length == 0) 121 if (results.length == 0)
136 return; 122 return;
137 123
138 var currentDate = results[0].dateRelativeDay; 124 var currentDate = results[0].dateRelativeDay;
139 125
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 */ 230 */
245 getSelectedList_: function() { 231 getSelectedList_: function() {
246 return this.$$('#' + this.selectedPage_); 232 return this.$$('#' + this.selectedPage_);
247 }, 233 },
248 234
249 /** @private */ 235 /** @private */
250 canDeleteHistory_: function() { 236 canDeleteHistory_: function() {
251 return loadTimeData.getBoolean('allowDeletingHistory'); 237 return loadTimeData.getBoolean('allowDeletingHistory');
252 } 238 }
253 }); 239 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698