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

Unified 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: Update comments. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/md_history/history_card.js
diff --git a/chrome/browser/resources/md_history/history_card.js b/chrome/browser/resources/md_history/history_card.js
index 06332cb1961d6b636fdcf677e6a4d3ded4e2f8ea..834b7ea20e83acb43336ad9e74089eaa859f3c6f 100644
--- a/chrome/browser/resources/md_history/history_card.js
+++ b/chrome/browser/resources/md_history/history_card.js
@@ -6,8 +6,8 @@ Polymer({
is: 'history-card',
properties: {
- // The date of these history items.
- historyDate: {
+ // The title of the history-card.
+ historyTitle: {
type: String,
value: ''
},
@@ -17,6 +17,11 @@ Polymer({
historyItems: {
type: Array,
value: function() { return []; }
+ },
+
+ searchTerm: {
+ type: String,
+ value: ''
}
},
@@ -24,12 +29,37 @@ Polymer({
* Check whether the time difference between the given historyItem and the
* next one is large enough for a spacer to be required.
* @param {number} index The index number of the first item being compared.
+ * @param {!HistoryEntry} historyItem The first item being compared.
+ * @param {string} search The search term associated with this item.
* @return {boolean} Whether or not time gap separator is required.
* @private
*/
- needsTimeGap_: function(index) {
+ needsTimeGap_: function(index, historyItem, search) {
var items = this.historyItems;
- return index + 1 < items.length &&
+
+ if (search == '' || search == undefined) {
+ return index + 1 < items.length &&
items[index].time - items[index + 1].time > BROWSING_GAP_TIME;
+ } else {
+ return index + 1 < items.length &&
+ items[index].dateTimeOfDay != items[index + 1].dateTimeOfDay;
+ }
+ },
+
+ /**
+ * Generates the title for this history card.
+ * @param {number} numberOfItems The number of items in the card.
+ * @param {string} search The search term associated with these results.
+ * @param {string} historyTitle The title of this card.
+ * @private
+ */
+ cardTitle_: function(numberOfItems, search, historyTitle) {
+ var resultId = numberOfItems == 1 ? 'searchResult' : 'searchResults';
+
+ if (search == '' || search == undefined)
+ return historyTitle;
+ else
+ return loadTimeData.getStringF('foundSearchResults', numberOfItems,
+ loadTimeData.getString(resultId), search);
}
});

Powered by Google App Engine
This is Rietveld 408576698