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

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

Issue 2207323002: [MD History] Factor out a common HistoryListBehavior. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 /** 5 /**
6 * @typedef {{domain: string, 6 * @typedef {{domain: string,
7 * visits: !Array<HistoryEntry>, 7 * visits: !Array<HistoryEntry>,
8 * rendered: boolean, 8 * rendered: boolean,
9 * expanded: boolean}} 9 * expanded: boolean}}
10 */ 10 */
11 var HistoryDomain; 11 var HistoryDomain;
12 12
13 /** 13 /**
14 * @typedef {{title: string, 14 * @typedef {{title: string,
15 * domains: !Array<HistoryDomain>}} 15 * domains: !Array<HistoryDomain>}}
16 */ 16 */
17 var HistoryGroup; 17 var HistoryGroup;
18 18
19 // TODO(calamity): Support selection by refactoring selection out of 19 // TODO(calamity): Support selection by refactoring selection out of
20 // history-list and into history-app. 20 // history-list and into history-app.
tsergeant 2016/08/05 01:39:09 This can be deleted now 🙌
calamity 2016/08/09 02:56:00 Done.
21 Polymer({ 21 Polymer({
22 is: 'history-grouped-list', 22 is: 'history-grouped-list',
23 23
24 behaviors: [HistoryListBehavior],
25
24 properties: { 26 properties: {
25 // An array of history entries in reverse chronological order. 27 // An array of history entries in reverse chronological order.
26 historyData: { 28 historyData: {
27 type: Array, 29 type: Array,
28 }, 30 },
29 31
30 /** 32 /**
31 * @type {Array<HistoryGroup>} 33 * @type {Array<HistoryGroup>}
32 */ 34 */
33 groupedHistoryData_: { 35 groupedHistoryData_: {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 * @private 151 * @private
150 */ 152 */
151 needsTimeGap_: function(groupIndex, domainIndex, itemIndex) { 153 needsTimeGap_: function(groupIndex, domainIndex, itemIndex) {
152 var visits = 154 var visits =
153 this.groupedHistoryData_[groupIndex].domains[domainIndex].visits; 155 this.groupedHistoryData_[groupIndex].domains[domainIndex].visits;
154 156
155 return md_history.HistoryItem.needsTimeGap( 157 return md_history.HistoryItem.needsTimeGap(
156 visits, itemIndex, this.searchedTerm); 158 visits, itemIndex, this.searchedTerm);
157 }, 159 },
158 160
159 hasResults_: function(historyDataLength) { 161 /**
160 return historyDataLength > 0; 162 * @param {number} groupIndex
163 * @param {number} domainIndex
164 * @param {number} itemIndex
165 * @return {string}
166 * @private
167 */
168 pathForItem_: function(groupIndex, domainIndex, itemIndex) {
169 return [
170 'groupedHistoryData_', groupIndex, 'domains', domainIndex, 'visits',
171 itemIndex
172 ].join('.');
161 }, 173 },
162 174
175 /**
176 * @param {HistoryDomain} domain
177 * @return {string}
178 * @private
179 */
163 getWebsiteIconStyle_: function(domain) { 180 getWebsiteIconStyle_: function(domain) {
164 return 'background-image: ' + 181 return 'background-image: ' +
165 cr.icon.getFaviconImageSet(domain.visits[0].url); 182 cr.icon.getFaviconImageSet(domain.visits[0].url);
166 }, 183 },
167 184
185 /**
186 * @param {boolean} expanded
187 * @return {string}
188 * @private
189 */
168 getDropdownIcon_: function(expanded) { 190 getDropdownIcon_: function(expanded) {
169 return expanded ? 'cr:expand-less' : 'cr:expand-more'; 191 return expanded ? 'cr:expand-less' : 'cr:expand-more';
170 }, 192 },
171
172 noResultsMessage_: function(searchedTerm) {
173 var messageId = searchedTerm !== '' ? 'noSearchResults' : 'noResults';
174 return loadTimeData.getString(messageId);
175 },
176 }); 193 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698