| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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('ntp', function() { | 5 cr.define('ntp', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 var TilePage = ntp.TilePage; | 8 var TilePage = ntp.TilePage; |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 this.innerHTML = | 53 this.innerHTML = |
| 54 '<span class="thumbnail-wrapper fills-parent">' + | 54 '<span class="thumbnail-wrapper fills-parent">' + |
| 55 '<div class="close-button"></div>' + | 55 '<div class="close-button"></div>' + |
| 56 '<span class="thumbnail fills-parent">' + | 56 '<span class="thumbnail fills-parent">' + |
| 57 // thumbnail-shield provides a gradient fade effect. | 57 // thumbnail-shield provides a gradient fade effect. |
| 58 '<div class="thumbnail-shield fills-parent"></div>' + | 58 '<div class="thumbnail-shield fills-parent"></div>' + |
| 59 '</span>' + | 59 '</span>' + |
| 60 '<span class="favicon"></span>' + | 60 '<span class="favicon"></span>' + |
| 61 '</span>' + | 61 '</span>' + |
| 62 '<div class="color-stripe"></div>' + | 62 '<div class="color-stripe"></div>' + |
| 63 '<span class="title"></span>'; | 63 '<span class="title"></span>' + |
| 64 '<span class="score"></span>'; |
| 64 | 65 |
| 65 this.querySelector('.close-button').title = | 66 this.querySelector('.close-button').title = |
| 66 loadTimeData.getString('removethumbnailtooltip'); | 67 loadTimeData.getString('removethumbnailtooltip'); |
| 67 | 68 |
| 68 this.tabIndex = -1; | 69 this.tabIndex = -1; |
| 69 this.data_ = null; | 70 this.data_ = null; |
| 70 this.removeAttribute('id'); | 71 this.removeAttribute('id'); |
| 71 this.title = ''; | 72 this.title = ''; |
| 72 }, | 73 }, |
| 73 | 74 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 95 | 96 |
| 96 var faviconDiv = this.querySelector('.favicon'); | 97 var faviconDiv = this.querySelector('.favicon'); |
| 97 var faviconUrl = 'chrome://favicon/size/16/' + data.url; | 98 var faviconUrl = 'chrome://favicon/size/16/' + data.url; |
| 98 faviconDiv.style.backgroundImage = url(faviconUrl); | 99 faviconDiv.style.backgroundImage = url(faviconUrl); |
| 99 chrome.send('getFaviconDominantColor', [faviconUrl, this.id]); | 100 chrome.send('getFaviconDominantColor', [faviconUrl, this.id]); |
| 100 | 101 |
| 101 var title = this.querySelector('.title'); | 102 var title = this.querySelector('.title'); |
| 102 title.textContent = data.title; | 103 title.textContent = data.title; |
| 103 title.dir = data.direction; | 104 title.dir = data.direction; |
| 104 | 105 |
| 106 var score = this.querySelector('.score'); |
| 107 score.textContent = data.score; |
| 108 |
| 105 // Sets the tooltip. | 109 // Sets the tooltip. |
| 106 this.title = data.title; | 110 this.title = data.title; |
| 107 | 111 |
| 108 var thumbnailUrl = 'chrome://thumb/' + data.url; | 112 var thumbnailUrl = 'chrome://thumb/' + data.url; |
| 109 this.querySelector('.thumbnail').style.backgroundImage = | 113 this.querySelector('.thumbnail').style.backgroundImage = |
| 110 url(thumbnailUrl); | 114 url(thumbnailUrl); |
| 111 | 115 |
| 112 this.href = data.url; | 116 this.href = data.url; |
| 113 | 117 |
| 114 this.classList.remove('filler'); | 118 this.classList.remove('filler'); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 tileSpacingFraction: 1 / 8, | 260 tileSpacingFraction: 1 / 8, |
| 257 }; | 261 }; |
| 258 TilePage.initGridValues(suggestionsPageGridValues); | 262 TilePage.initGridValues(suggestionsPageGridValues); |
| 259 | 263 |
| 260 /** | 264 /** |
| 261 * Calculates the height for a Suggestion tile for a given width. The size | 265 * Calculates the height for a Suggestion tile for a given width. The size |
| 262 * is based on the thumbnail, which should have a 212:132 ratio. | 266 * is based on the thumbnail, which should have a 212:132 ratio. |
| 263 * @return {number} The height. | 267 * @return {number} The height. |
| 264 */ | 268 */ |
| 265 function heightForWidth(width) { | 269 function heightForWidth(width) { |
| 266 // The 2s are for borders, the 31 is for the title. | 270 // The 2s are for borders, the 36 is for the title and score. |
| 267 return (width - 2) * 132 / 212 + 2 + 31; | 271 return (width - 2) * 132 / 212 + 2 + 36; |
| 268 } | 272 } |
| 269 | 273 |
| 270 var THUMBNAIL_COUNT = 8; | 274 var THUMBNAIL_COUNT = 8; |
| 271 | 275 |
| 272 /** | 276 /** |
| 273 * Creates a new SuggestionsPage object. | 277 * Creates a new SuggestionsPage object. |
| 274 * @constructor | 278 * @constructor |
| 275 * @extends {TilePage} | 279 * @extends {TilePage} |
| 276 */ | 280 */ |
| 277 function SuggestionsPage() { | 281 function SuggestionsPage() { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 return oldData; | 462 return oldData; |
| 459 } | 463 } |
| 460 | 464 |
| 461 return { | 465 return { |
| 462 SuggestionsPage: SuggestionsPage, | 466 SuggestionsPage: SuggestionsPage, |
| 463 refreshData: refreshData, | 467 refreshData: refreshData, |
| 464 }; | 468 }; |
| 465 }); | 469 }); |
| 466 | 470 |
| 467 document.addEventListener('ntpLoaded', ntp.SuggestionsPage.onLoaded); | 471 document.addEventListener('ntpLoaded', ntp.SuggestionsPage.onLoaded); |
| OLD | NEW |