OLD | NEW |
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 cr.define('md_history', function() { | 5 cr.define('md_history', function() { |
6 var HistoryItem = Polymer({ | 6 var HistoryItem = Polymer({ |
7 is: 'history-item', | 7 is: 'history-item', |
8 | 8 |
9 properties: { | 9 properties: { |
10 // Underlying HistoryEntry data for this item. Contains read-only fields | 10 // Underlying HistoryEntry data for this item. Contains read-only fields |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 * @param {string} search The search term associated with these results. | 74 * @param {string} search The search term associated with these results. |
75 * @private | 75 * @private |
76 */ | 76 */ |
77 cardTitle_: function(numberOfItems, historyDate, search) { | 77 cardTitle_: function(numberOfItems, historyDate, search) { |
78 if (!search) | 78 if (!search) |
79 return this.item.dateRelativeDay; | 79 return this.item.dateRelativeDay; |
80 | 80 |
81 var resultId = numberOfItems == 1 ? 'searchResult' : 'searchResults'; | 81 var resultId = numberOfItems == 1 ? 'searchResult' : 'searchResults'; |
82 return loadTimeData.getStringF('foundSearchResults', numberOfItems, | 82 return loadTimeData.getStringF('foundSearchResults', numberOfItems, |
83 loadTimeData.getString(resultId), search); | 83 loadTimeData.getString(resultId), search); |
| 84 }, |
| 85 |
| 86 /** |
| 87 * Crop long item titles to reduce their effect on layout performance. See |
| 88 * crbug.com/621347. |
| 89 * @param {string} title |
| 90 * @return {string} |
| 91 */ |
| 92 cropItemTitle_: function(title) { |
| 93 return (title.length > TITLE_MAX_LENGTH) ? |
| 94 title.substr(0, TITLE_MAX_LENGTH) : |
| 95 title; |
84 } | 96 } |
85 }); | 97 }); |
86 | 98 |
87 /** | 99 /** |
88 * Check whether the time difference between the given history item and the | 100 * Check whether the time difference between the given history item and the |
89 * next one is large enough for a spacer to be required. | 101 * next one is large enough for a spacer to be required. |
90 * @param {Array<HistoryEntry>} visits | 102 * @param {Array<HistoryEntry>} visits |
91 * @param {number} currentIndex | 103 * @param {number} currentIndex |
92 * @param {string} searchedTerm | 104 * @param {string} searchedTerm |
93 * @return {boolean} Whether or not time gap separator is required. | 105 * @return {boolean} Whether or not time gap separator is required. |
94 * @private | 106 * @private |
95 */ | 107 */ |
96 HistoryItem.needsTimeGap = function(visits, currentIndex, searchedTerm) { | 108 HistoryItem.needsTimeGap = function(visits, currentIndex, searchedTerm) { |
97 if (currentIndex >= visits.length - 1 || visits.length == 0) | 109 if (currentIndex >= visits.length - 1 || visits.length == 0) |
98 return false; | 110 return false; |
99 | 111 |
100 var currentItem = visits[currentIndex]; | 112 var currentItem = visits[currentIndex]; |
101 var nextItem = visits[currentIndex + 1]; | 113 var nextItem = visits[currentIndex + 1]; |
102 | 114 |
103 if (searchedTerm) | 115 if (searchedTerm) |
104 return currentItem.dateShort != nextItem.dateShort; | 116 return currentItem.dateShort != nextItem.dateShort; |
105 | 117 |
106 return currentItem.time - nextItem.time > BROWSING_GAP_TIME && | 118 return currentItem.time - nextItem.time > BROWSING_GAP_TIME && |
107 currentItem.dateRelativeDay == nextItem.dateRelativeDay; | 119 currentItem.dateRelativeDay == nextItem.dateRelativeDay; |
108 }; | 120 }; |
109 | 121 |
110 return { HistoryItem: HistoryItem }; | 122 return { HistoryItem: HistoryItem }; |
111 }); | 123 }); |
OLD | NEW |