OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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('ntp4', function() { | 5 cr.define('ntp4', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 var TilePage = ntp4.TilePage; | 8 var TilePage = ntp4.TilePage; |
9 | 9 |
10 /** | 10 /** |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 84 } |
85 | 85 |
86 var id = tileID++; | 86 var id = tileID++; |
87 this.id = 'most-visited-tile-' + id; | 87 this.id = 'most-visited-tile-' + id; |
88 this.data_ = data; | 88 this.data_ = data; |
89 // TODO(estade): this shouldn't be focusable if the page isn't showing. | 89 // TODO(estade): this shouldn't be focusable if the page isn't showing. |
90 this.tabIndex = 0; | 90 this.tabIndex = 0; |
91 | 91 |
92 var faviconDiv = this.querySelector('.favicon'); | 92 var faviconDiv = this.querySelector('.favicon'); |
93 var faviconUrl = data.faviconUrl || | 93 var faviconUrl = data.faviconUrl || |
94 'chrome://favicon/size/32/' + data.url; | 94 'chrome://favicon/size/16/' + data.url; |
95 faviconDiv.style.backgroundImage = url(faviconUrl); | 95 faviconDiv.style.backgroundImage = url(faviconUrl); |
96 faviconDiv.dir = data.direction; | 96 faviconDiv.dir = data.direction; |
97 if (data.faviconDominantColor) { | 97 if (data.faviconDominantColor) { |
98 this.setStripeColor(data.faviconDominantColor); | 98 this.setStripeColor(data.faviconDominantColor); |
99 } else { | 99 } else { |
100 chrome.send('getFaviconDominantColor', | 100 chrome.send('getFaviconDominantColor', |
101 [faviconUrl, id, 'ntp4.setMostVisitedFaviconDominantColor']); | 101 [faviconUrl, id, 'ntp4.setMostVisitedFaviconDominantColor']); |
102 } | 102 } |
103 | 103 |
104 var title = this.querySelector('.title'); | 104 var title = this.querySelector('.title'); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 maxTileWidth: 214, | 252 maxTileWidth: 214, |
253 }; | 253 }; |
254 TilePage.initGridValues(mostVisitedPageGridValues); | 254 TilePage.initGridValues(mostVisitedPageGridValues); |
255 | 255 |
256 /** | 256 /** |
257 * Calculates the height for a Most Visited tile for a given width. The size | 257 * Calculates the height for a Most Visited tile for a given width. The size |
258 * is based on the thumbnail, which should have a 212:132 ratio. | 258 * is based on the thumbnail, which should have a 212:132 ratio. |
259 * @return {number} The height. | 259 * @return {number} The height. |
260 */ | 260 */ |
261 function heightForWidth(width) { | 261 function heightForWidth(width) { |
262 // The 2s are for borders, the 23 is for the title. | 262 // The 2s are for borders, the 31 is for the title. |
263 return (width - 2) * 132 / 212 + 2 + 23; | 263 return (width - 2) * 132 / 212 + 2 + 31; |
264 } | 264 } |
265 | 265 |
266 var THUMBNAIL_COUNT = 8; | 266 var THUMBNAIL_COUNT = 8; |
267 | 267 |
268 /** | 268 /** |
269 * Creates a new MostVisitedPage object. | 269 * Creates a new MostVisitedPage object. |
270 * @constructor | 270 * @constructor |
271 * @extends {TilePage} | 271 * @extends {TilePage} |
272 */ | 272 */ |
273 function MostVisitedPage() { | 273 function MostVisitedPage() { |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 if (tile) | 442 if (tile) |
443 tile.setStripeColor(color); | 443 tile.setStripeColor(color); |
444 }; | 444 }; |
445 | 445 |
446 return { | 446 return { |
447 MostVisitedPage: MostVisitedPage, | 447 MostVisitedPage: MostVisitedPage, |
448 refreshData: refreshData, | 448 refreshData: refreshData, |
449 setMostVisitedFaviconDominantColor: setMostVisitedFaviconDominantColor, | 449 setMostVisitedFaviconDominantColor: setMostVisitedFaviconDominantColor, |
450 }; | 450 }; |
451 }); | 451 }); |
OLD | NEW |