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

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

Issue 1643693003: MD History: Implement search functionality. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@patch_to_be_uploaded
Patch Set: Fix time-gap-separator insertion. Created 4 years, 10 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 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 Polymer({ 5 Polymer({
6 is: 'history-card', 6 is: 'history-card',
7 7
8 properties: { 8 properties: {
9 // The date of these history items. 9 // The date associated with the history-card.
10 historyDate: { 10 historyDate: {
11 type: String, 11 type: String,
12 value: '' 12 value: ''
13 }, 13 },
14 14
15 // The list of history results that were accessed for a particular day in 15 // The list of history results that were accessed for a particular day in
16 // reverse chronological order. 16 // reverse chronological order.
17 historyItems: { 17 historyItems: {
18 type: Array, 18 type: Array,
19 value: function() { return []; } 19 value: function() { return []; }
20 },
21
22 searchTerm: {
23 type: String,
24 value: ''
20 } 25 }
21 }, 26 },
22 27
23 /** 28 /**
24 * Check whether the time difference between the given historyItem and the 29 * Check whether the time difference between the given historyItem and the
25 * next one is large enough for a spacer to be required. 30 * next one is large enough for a spacer to be required.
26 * @param {number} index The index number of the first item being compared. 31 * @param {number} index The index number of the first item being compared.
27 * @param {number} itemsLength The number of items on the card. Used to force 32 * @param {number} itemsLength The number of items on the card. Used to force
28 * needsTimeGap_ to run for every item if an item is deleted from the card. 33 * needsTimeGap_ to run for every item if an item is deleted from the card.
34 * @param {string} search The search term associated with this item.
29 * @return {boolean} Whether or not time gap separator is required. 35 * @return {boolean} Whether or not time gap separator is required.
30 * @private 36 * @private
31 */ 37 */
32 needsTimeGap_: function(index, itemsLength) { 38 needsTimeGap_: function(index, itemsLength, search) {
33 var items = this.historyItems; 39 var items = this.historyItems;
34 return index + 1 < items.length && 40
41 if (search == '' || search == undefined) {
42 return index + 1 < items.length &&
35 items[index].time - items[index + 1].time > BROWSING_GAP_TIME; 43 items[index].time - items[index + 1].time > BROWSING_GAP_TIME;
44 } else {
45 return index + 1 < items.length &&
46 items[index].visibleTimestamp != items[index + 1].visibleTimestamp;
47 }
48 },
49
50 /**
51 * Generates the title for this history card.
52 * @param {number} numberOfItems The number of items in the card.
53 * @param {string} search The search term associated with these results.
54 * @private
55 */
56 cardTitle_: function(numberOfItems, search, historyDate) {
57 var resultId = numberOfItems == 1 ? 'searchResult' : 'searchResults';
58
59 if (search == '' || search == undefined) {
tsergeant 2016/02/12 00:03:52 Can search actually ever be undefined? Can you do
hsampson 2016/02/12 06:45:43 No I don't think it can.
60 return historyDate;
61 } else
62 return loadTimeData.getStringF('foundSearchResults', numberOfItems,
63 loadTimeData.getString(resultId), search);
36 } 64 }
37 }); 65 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698