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

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: 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 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 3df08cf81ea9b20f05a867ce4c35df020b12893a..c8c4c96548454956c3f80de3cc779eb5aa2c7cd1 100644
--- a/chrome/browser/resources/md_history/history_card.js
+++ b/chrome/browser/resources/md_history/history_card.js
@@ -6,7 +6,7 @@ Polymer({
is: 'history-card',
properties: {
- // The date of these history items.
+ // The date associated with the history-card.
historyDate: {
type: String,
value: ''
@@ -17,6 +17,11 @@ Polymer({
historyItems: {
type: Array,
value: function() { return []; }
+ },
+
+ searchTerm: {
+ type: String,
+ value: ''
}
},
@@ -26,12 +31,35 @@ Polymer({
* @param {number} index The index number of the first item being compared.
* @param {number} itemsLength The number of items on the card. Used to force
* needsTimeGap_ to run for every item if an item is deleted from the card.
+ * @param {string} search The search term associated with this item.
* @return {boolean} Whether or not time gap separator is required.
* @private
*/
- needsTimeGap_: function(index, itemsLength) {
+ needsTimeGap_: function(index, itemsLength, 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].visibleTimestamp != items[index + 1].visibleTimestamp;
+ }
+ },
+
+ /**
+ * 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.
+ * @private
+ */
+ cardTitle_: function(numberOfItems, search, historyDate) {
+ var resultId = numberOfItems == 1 ? 'searchResult' : 'searchResults';
+
+ 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.
+ return historyDate;
+ } else
+ return loadTimeData.getStringF('foundSearchResults', numberOfItems,
+ loadTimeData.getString(resultId), search);
}
});

Powered by Google App Engine
This is Rietveld 408576698