| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 * @private | 155 * @private |
| 156 */ | 156 */ |
| 157 cardTitle_: function(numberOfItems, historyDate, search) { | 157 cardTitle_: function(numberOfItems, historyDate, search) { |
| 158 if (!search) | 158 if (!search) |
| 159 return this.item.dateRelativeDay; | 159 return this.item.dateRelativeDay; |
| 160 | 160 |
| 161 var resultId = numberOfItems == 1 ? 'searchResult' : 'searchResults'; | 161 var resultId = numberOfItems == 1 ? 'searchResult' : 'searchResults'; |
| 162 return loadTimeData.getStringF('foundSearchResults', numberOfItems, | 162 return loadTimeData.getStringF('foundSearchResults', numberOfItems, |
| 163 loadTimeData.getString(resultId), search); | 163 loadTimeData.getString(resultId), search); |
| 164 }, | 164 }, |
| 165 | |
| 166 /** | |
| 167 * Crop long item titles to reduce their effect on layout performance. See | |
| 168 * crbug.com/621347. | |
| 169 * @param {string} title | |
| 170 * @return {string} | |
| 171 */ | |
| 172 cropItemTitle_: function(title) { | |
| 173 return (title.length > TITLE_MAX_LENGTH) ? | |
| 174 title.substr(0, TITLE_MAX_LENGTH) : | |
| 175 title; | |
| 176 } | |
| 177 }); | 165 }); |
| 178 | 166 |
| 179 /** | 167 /** |
| 180 * Check whether the time difference between the given history item and the | 168 * Check whether the time difference between the given history item and the |
| 181 * next one is large enough for a spacer to be required. | 169 * next one is large enough for a spacer to be required. |
| 182 * @param {Array<HistoryEntry>} visits | 170 * @param {Array<HistoryEntry>} visits |
| 183 * @param {number} currentIndex | 171 * @param {number} currentIndex |
| 184 * @param {string} searchedTerm | 172 * @param {string} searchedTerm |
| 185 * @return {boolean} Whether or not time gap separator is required. | 173 * @return {boolean} Whether or not time gap separator is required. |
| 186 * @private | 174 * @private |
| 187 */ | 175 */ |
| 188 HistoryItem.needsTimeGap = function(visits, currentIndex, searchedTerm) { | 176 HistoryItem.needsTimeGap = function(visits, currentIndex, searchedTerm) { |
| 189 if (currentIndex >= visits.length - 1 || visits.length == 0) | 177 if (currentIndex >= visits.length - 1 || visits.length == 0) |
| 190 return false; | 178 return false; |
| 191 | 179 |
| 192 var currentItem = visits[currentIndex]; | 180 var currentItem = visits[currentIndex]; |
| 193 var nextItem = visits[currentIndex + 1]; | 181 var nextItem = visits[currentIndex + 1]; |
| 194 | 182 |
| 195 if (searchedTerm) | 183 if (searchedTerm) |
| 196 return currentItem.dateShort != nextItem.dateShort; | 184 return currentItem.dateShort != nextItem.dateShort; |
| 197 | 185 |
| 198 return currentItem.time - nextItem.time > BROWSING_GAP_TIME && | 186 return currentItem.time - nextItem.time > BROWSING_GAP_TIME && |
| 199 currentItem.dateRelativeDay == nextItem.dateRelativeDay; | 187 currentItem.dateRelativeDay == nextItem.dateRelativeDay; |
| 200 }; | 188 }; |
| 201 | 189 |
| 202 return { HistoryItem: HistoryItem }; | 190 return { HistoryItem: HistoryItem }; |
| 203 }); | 191 }); |
| OLD | NEW |