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 /** | 5 /** |
6 * @param {!Element} root | 6 * @param {!Element} root |
7 * @param {?Element} boundary | 7 * @param {?Element} boundary |
8 * @param {cr.ui.FocusRow.Delegate} delegate | 8 * @param {cr.ui.FocusRow.Delegate} delegate |
9 * @constructor | 9 * @constructor |
10 * @extends {cr.ui.FocusRow} | 10 * @extends {cr.ui.FocusRow} |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 */ | 282 */ |
283 showIcon_: function() { | 283 showIcon_: function() { |
284 this.$.icon.style.backgroundImage = cr.icon.getFavicon(this.item.url); | 284 this.$.icon.style.backgroundImage = cr.icon.getFavicon(this.item.url); |
285 }, | 285 }, |
286 | 286 |
287 selectionNotAllowed_: function() { | 287 selectionNotAllowed_: function() { |
288 return !loadTimeData.getBoolean('allowDeletingHistory'); | 288 return !loadTimeData.getBoolean('allowDeletingHistory'); |
289 }, | 289 }, |
290 | 290 |
291 /** | 291 /** |
292 * Generates the title for this history card. | |
293 * @param {number} numberOfItems The number of items in the card. | 292 * @param {number} numberOfItems The number of items in the card. |
| 293 * @param {string} historyDate Date of the current result. |
294 * @param {string} search The search term associated with these results. | 294 * @param {string} search The search term associated with these results. |
| 295 * @return {string} The title for this history card. |
295 * @private | 296 * @private |
296 */ | 297 */ |
297 cardTitle_: function(numberOfItems, historyDate, search) { | 298 cardTitle_: function(numberOfItems, historyDate, search) { |
298 if (!search) | 299 if (!search) |
299 return this.item.dateRelativeDay; | 300 return this.item.dateRelativeDay; |
300 | 301 return HistoryItem.searchResultsTitle(numberOfItems, search); |
301 var resultId = numberOfItems == 1 ? 'searchResult' : 'searchResults'; | |
302 return loadTimeData.getStringF('foundSearchResults', numberOfItems, | |
303 loadTimeData.getString(resultId), search); | |
304 }, | 302 }, |
305 }); | 303 }); |
306 | 304 |
307 /** | 305 /** |
308 * Check whether the time difference between the given history item and the | 306 * Check whether the time difference between the given history item and the |
309 * next one is large enough for a spacer to be required. | 307 * next one is large enough for a spacer to be required. |
310 * @param {Array<HistoryEntry>} visits | 308 * @param {Array<HistoryEntry>} visits |
311 * @param {number} currentIndex | 309 * @param {number} currentIndex |
312 * @param {string} searchedTerm | 310 * @param {string} searchedTerm |
313 * @return {boolean} Whether or not time gap separator is required. | 311 * @return {boolean} Whether or not time gap separator is required. |
314 * @private | |
315 */ | 312 */ |
316 HistoryItem.needsTimeGap = function(visits, currentIndex, searchedTerm) { | 313 HistoryItem.needsTimeGap = function(visits, currentIndex, searchedTerm) { |
317 if (currentIndex >= visits.length - 1 || visits.length == 0) | 314 if (currentIndex >= visits.length - 1 || visits.length == 0) |
318 return false; | 315 return false; |
319 | 316 |
320 var currentItem = visits[currentIndex]; | 317 var currentItem = visits[currentIndex]; |
321 var nextItem = visits[currentIndex + 1]; | 318 var nextItem = visits[currentIndex + 1]; |
322 | 319 |
323 if (searchedTerm) | 320 if (searchedTerm) |
324 return currentItem.dateShort != nextItem.dateShort; | 321 return currentItem.dateShort != nextItem.dateShort; |
325 | 322 |
326 return currentItem.time - nextItem.time > BROWSING_GAP_TIME && | 323 return currentItem.time - nextItem.time > BROWSING_GAP_TIME && |
327 currentItem.dateRelativeDay == nextItem.dateRelativeDay; | 324 currentItem.dateRelativeDay == nextItem.dateRelativeDay; |
328 }; | 325 }; |
329 | 326 |
| 327 /** |
| 328 * @param {number} numberOfResults |
| 329 * @param {string} searchTerm |
| 330 * @return {string} The title for a page of search results. |
| 331 */ |
| 332 HistoryItem.searchResultsTitle = function(numberOfResults, searchTerm) { |
| 333 var resultId = numberOfResults == 1 ? 'searchResult' : 'searchResults'; |
| 334 return loadTimeData.getStringF('foundSearchResults', numberOfResults, |
| 335 loadTimeData.getString(resultId), searchTerm); |
| 336 }; |
| 337 |
330 return { HistoryItem: HistoryItem }; | 338 return { HistoryItem: HistoryItem }; |
331 }); | 339 }); |
OLD | NEW |