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

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: Hide cards that haven't been rerendered from previous chrome.send(). 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 // 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
15 // reverse chronological order. 16 // reverse chronological order.
16 historyItems: { 17 historyItems: {
17 type: Array, 18 type: Array,
18 value: function() { return []; } 19 value: function() { return []; }
20 },
21
22 searchTerm: {
23 type: String,
24 value: ''
19 } 25 }
20 }, 26 },
21 27
22 /** 28 /**
23 * Check whether the time difference between the given historyItem and the 29 * Check whether the time difference between the given historyItem and the
24 * next one is large enough for a spacer to be required. 30 * next one is large enough for a spacer to be required.
25 * @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.
26 * @return {boolean} Whether or not time gap separator is required. 32 * @return {boolean} Whether or not time gap separator is required.
27 * @private 33 * @private
28 */ 34 */
29 needsTimeGap_: function(index) { 35 needsTimeGap_: function(index) {
30 var items = this.historyItems; 36 var items = this.historyItems;
31 return index + 1 < items.length && 37 return index + 1 < items.length &&
32 items[index].time - items[index + 1].time > BROWSING_GAP_TIME; 38 items[index].time - items[index + 1].time > BROWSING_GAP_TIME;
39 },
40
41 /**
42 * Checks whether the results returned are part of a search.
43 * @private
44 */
45 isNotSearchResult_: function(search) {
46 return search == '';
47 },
48
49 /**
50 * Create the title for the history-card holding all the search results.
51 * Found <numberOfItems> search result(s) for '<search>'.
52 * @private
53 */
54 searchResultTitle_: function(numberOfItems, search) {
55 var resultId = numberOfItems == 1 ? 'searchResult' : 'searchResults';
56 return loadTimeData.getStringF('foundSearchResults', numberOfItems,
57 loadTimeData.getString(resultId), search);
33 } 58 }
34 }); 59 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698