| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 this.innerHTML = | 63 this.innerHTML = |
| 64 '<span class="thumbnail-wrapper fills-parent">' + | 64 '<span class="thumbnail-wrapper fills-parent">' + |
| 65 '<div class="close-button"></div>' + | 65 '<div class="close-button"></div>' + |
| 66 '<span class="thumbnail fills-parent">' + | 66 '<span class="thumbnail fills-parent">' + |
| 67 // thumbnail-shield provides a gradient fade effect. | 67 // thumbnail-shield provides a gradient fade effect. |
| 68 '<div class="thumbnail-shield fills-parent"></div>' + | 68 '<div class="thumbnail-shield fills-parent"></div>' + |
| 69 '</span>' + | 69 '</span>' + |
| 70 '<span class="favicon"></span>' + | 70 '<span class="favicon"></span>' + |
| 71 '</span>' + | 71 '</span>' + |
| 72 '<div class="color-stripe"></div>' + | 72 '<div class="color-stripe"></div>' + |
| 73 '<span class="title"></span>'; | 73 '<span class="title"></span>' + |
| 74 '<span class="score"></span>'; |
| 74 | 75 |
| 75 this.querySelector('.close-button').title = | 76 this.querySelector('.close-button').title = |
| 76 templateData.removethumbnailtooltip; | 77 templateData.removethumbnailtooltip; |
| 77 | 78 |
| 78 this.tabIndex = -1; | 79 this.tabIndex = -1; |
| 79 this.data_ = null; | 80 this.data_ = null; |
| 80 this.removeAttribute('id'); | 81 this.removeAttribute('id'); |
| 81 this.title = ''; | 82 this.title = ''; |
| 82 }, | 83 }, |
| 83 | 84 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 105 | 106 |
| 106 var faviconDiv = this.querySelector('.favicon'); | 107 var faviconDiv = this.querySelector('.favicon'); |
| 107 var faviconUrl = 'chrome://favicon/size/16/' + data.url; | 108 var faviconUrl = 'chrome://favicon/size/16/' + data.url; |
| 108 faviconDiv.style.backgroundImage = url(faviconUrl); | 109 faviconDiv.style.backgroundImage = url(faviconUrl); |
| 109 chrome.send('getFaviconDominantColor', [faviconUrl, this.id]); | 110 chrome.send('getFaviconDominantColor', [faviconUrl, this.id]); |
| 110 | 111 |
| 111 var title = this.querySelector('.title'); | 112 var title = this.querySelector('.title'); |
| 112 title.textContent = data.title; | 113 title.textContent = data.title; |
| 113 title.dir = data.direction; | 114 title.dir = data.direction; |
| 114 | 115 |
| 116 var score = this.querySelector('.score'); |
| 117 score.textContent = data.score; |
| 118 |
| 115 // Sets the tooltip. | 119 // Sets the tooltip. |
| 116 this.title = data.title; | 120 this.title = data.title; |
| 117 | 121 |
| 118 var thumbnailUrl = 'chrome://thumb/' + data.url; | 122 var thumbnailUrl = 'chrome://thumb/' + data.url; |
| 119 this.querySelector('.thumbnail').style.backgroundImage = | 123 this.querySelector('.thumbnail').style.backgroundImage = |
| 120 url(thumbnailUrl); | 124 url(thumbnailUrl); |
| 121 | 125 |
| 122 this.href = data.url; | 126 this.href = data.url; |
| 123 | 127 |
| 124 this.classList.remove('filler'); | 128 this.classList.remove('filler'); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 tileSpacingFraction: 1 / 8, | 269 tileSpacingFraction: 1 / 8, |
| 266 }; | 270 }; |
| 267 TilePage.initGridValues(suggestionsPageGridValues); | 271 TilePage.initGridValues(suggestionsPageGridValues); |
| 268 | 272 |
| 269 /** | 273 /** |
| 270 * Calculates the height for a Suggestion tile for a given width. The size | 274 * Calculates the height for a Suggestion tile for a given width. The size |
| 271 * is based on the thumbnail, which should have a 212:132 ratio. | 275 * is based on the thumbnail, which should have a 212:132 ratio. |
| 272 * @return {number} The height. | 276 * @return {number} The height. |
| 273 */ | 277 */ |
| 274 function heightForWidth(width) { | 278 function heightForWidth(width) { |
| 275 // The 2s are for borders, the 31 is for the title. | 279 // The 2s are for borders, the 36 is for the title and score. |
| 276 return (width - 2) * 132 / 212 + 2 + 31; | 280 return (width - 2) * 132 / 212 + 2 + 36; |
| 277 } | 281 } |
| 278 | 282 |
| 279 var THUMBNAIL_COUNT = 8; | 283 var THUMBNAIL_COUNT = 8; |
| 280 | 284 |
| 281 /** | 285 /** |
| 282 * Creates a new SuggestionsPage object. | 286 * Creates a new SuggestionsPage object. |
| 283 * @constructor | 287 * @constructor |
| 284 * @extends {TilePage} | 288 * @extends {TilePage} |
| 285 */ | 289 */ |
| 286 function SuggestionsPage() { | 290 function SuggestionsPage() { |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 } | 452 } |
| 449 | 453 |
| 450 return oldData; | 454 return oldData; |
| 451 } | 455 } |
| 452 | 456 |
| 453 return { | 457 return { |
| 454 SuggestionsPage: SuggestionsPage, | 458 SuggestionsPage: SuggestionsPage, |
| 455 refreshData: refreshData, | 459 refreshData: refreshData, |
| 456 }; | 460 }; |
| 457 }); | 461 }); |
| OLD | NEW |