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

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 commenting. 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 of these history items.
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.
32 * @param {!HistoryEntry} historyItem The first item being compared.
33 * @param {string} search The search term associated with this item.
27 * @return {boolean} Whether or not time gap separator is required. 34 * @return {boolean} Whether or not time gap separator is required.
28 * @private 35 * @private
29 */ 36 */
30 needsTimeGap_: function(index) { 37 needsTimeGap_: function(index, historyItem, search) {
31 var items = this.historyItems; 38 var items = this.historyItems;
32 return index + 1 < items.length && 39
40 if ((search == '') || (search == undefined)) {
calamity 2016/02/05 02:30:10 (((Too) (many) parens))!
hsampson 2016/02/08 04:40:23 Done.
41 return index + 1 < items.length &&
33 items[index].time - items[index + 1].time > BROWSING_GAP_TIME; 42 items[index].time - items[index + 1].time > BROWSING_GAP_TIME;
43 } else {
44 return index + 1 < items.length &&
45 items[index].dateTimeOfDay != items[index + 1].dateTimeOfDay;
46 }
47 },
48
49 /**
50 * Create the title for the history-card holding all the results.
51 * @param {number} numberOfItems The number of items in the card.
52 * @param {string} search The search term associated with these results.
53 * @param {string} historyDate The day this card corresponds to if these
54 * results are part of a normal history search.
55 * @private
56 */
57 searchResultTitle_: function(numberOfItems, search, historyDate) {
calamity 2016/02/05 02:30:10 This should be called something like 'cardTitle_'
hsampson 2016/02/08 04:40:23 Done.
58 var resultId = numberOfItems == 1 ? 'searchResult' : 'searchResults';
59
60 if (search == '') {
tsergeant 2016/02/04 02:28:49 Nit: Remove {} Also use a ternary expression if y
hsampson 2016/02/08 04:40:23 Done.
61 return historyDate;
62 } else {
63 return loadTimeData.getStringF('foundSearchResults', numberOfItems,
64 loadTimeData.getString(resultId), search);
65 }
34 } 66 }
35 }); 67 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698