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 localStrings = new LocalStrings; | 8 var localStrings = new LocalStrings; |
9 | 9 |
10 /** | 10 /** |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 }, | 82 }, |
83 | 83 |
84 /** | 84 /** |
85 * Set the size and position of the bookmark tile. | 85 * Set the size and position of the bookmark tile. |
86 * @param {number} size The total size of |this|. | 86 * @param {number} size The total size of |this|. |
87 * @param {number} x The x-position. | 87 * @param {number} x The x-position. |
88 * @param {number} y The y-position. | 88 * @param {number} y The y-position. |
89 * animate. | 89 * animate. |
90 */ | 90 */ |
91 setBounds: function(size, x, y) { | 91 setBounds: function(size, x, y) { |
92 this.style.width = this.style.height = size + 'px'; | 92 this.style.width = size + 'px'; |
93 this.style.height = bookmarksHeightForWidth(size) + 'px'; | |
94 | |
93 this.style.left = x + 'px'; | 95 this.style.left = x + 'px'; |
96 this.style.right = x + 'px'; | |
94 this.style.top = y + 'px'; | 97 this.style.top = y + 'px'; |
95 }, | 98 }, |
96 | 99 |
97 /** | 100 /** |
98 * Invoked when a bookmark is clicked | 101 * Invoked when a bookmark is clicked |
99 * @param {Event} e The click event. | 102 * @param {Event} e The click event. |
100 * @private | 103 * @private |
101 */ | 104 */ |
102 handleClick_: function(e) { | 105 handleClick_: function(e) { |
103 if (e.target.classList.contains('close-button')) { | 106 if (e.target.classList.contains('close-button')) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 maxColCount: 6, | 169 maxColCount: 6, |
167 | 170 |
168 // The smallest a tile can be. | 171 // The smallest a tile can be. |
169 minTileWidth: 150, | 172 minTileWidth: 150, |
170 // The biggest a tile can be. | 173 // The biggest a tile can be. |
171 maxTileWidth: 150, | 174 maxTileWidth: 150, |
172 }; | 175 }; |
173 TilePage.initGridValues(bookmarksPageGridValues); | 176 TilePage.initGridValues(bookmarksPageGridValues); |
174 | 177 |
175 /** | 178 /** |
179 * Calculates the height for a Most Visited tile for a given width. The size | |
180 * is based on a desired size of 96x72 ratio. | |
181 * @return {number} The height. | |
182 */ | |
183 function bookmarksHeightForWidth(width) { | |
184 // The 2s are for borders, the 31 is for the title. | |
185 return (width - 2) * 72 / 96 + 2 + 31; | |
186 } | |
187 | |
188 /** | |
176 * Creates a new BookmarksPage object. | 189 * Creates a new BookmarksPage object. |
177 * @constructor | 190 * @constructor |
178 * @extends {TilePage} | 191 * @extends {TilePage} |
179 */ | 192 */ |
180 function BookmarksPage() { | 193 function BookmarksPage() { |
181 var el = new TilePage(bookmarksPageGridValues); | 194 var el = new TilePage(bookmarksPageGridValues); |
182 el.__proto__ = BookmarksPage.prototype; | 195 el.__proto__ = BookmarksPage.prototype; |
183 el.initialize(); | 196 el.initialize(); |
184 | 197 |
185 return el; | 198 return el; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
268 } | 281 } |
269 } | 282 } |
270 return false; | 283 return false; |
271 }, | 284 }, |
272 | 285 |
273 /** @inheritDoc */ | 286 /** @inheritDoc */ |
274 shouldAcceptDrag: function(dataTransfer) { | 287 shouldAcceptDrag: function(dataTransfer) { |
275 return false; | 288 return false; |
276 }, | 289 }, |
277 | 290 |
291 /** @inheritDoc */ | |
292 bookmarksHeightForWidth: bookmarksHeightForWidth, | |
Evan Stade
2011/08/29 23:06:46
huh? shouldn't this be heightForWidth?
csilv
2011/08/30 00:45:29
Done.
| |
293 | |
278 /** | 294 /** |
279 * Invoked before a batch import begins. We will ignore added/changed | 295 * Invoked before a batch import begins. We will ignore added/changed |
280 * notifications while the operation is in progress. | 296 * notifications while the operation is in progress. |
281 */ | 297 */ |
282 bookmarkImportBegan: function() { | 298 bookmarkImportBegan: function() { |
283 this.importing = true; | 299 this.importing = true; |
284 }, | 300 }, |
285 | 301 |
286 /** | 302 /** |
287 * Invoked after a batch import finishes. We will reload the bookmarks | 303 * Invoked after a batch import finishes. We will reload the bookmarks |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
442 }; | 458 }; |
443 | 459 |
444 return { | 460 return { |
445 BookmarksPage: BookmarksPage, | 461 BookmarksPage: BookmarksPage, |
446 initBookmarkChevron: initBookmarkChevron, | 462 initBookmarkChevron: initBookmarkChevron, |
447 setBookmarksFaviconDominantColor: setBookmarksFaviconDominantColor | 463 setBookmarksFaviconDominantColor: setBookmarksFaviconDominantColor |
448 }; | 464 }; |
449 }); | 465 }); |
450 | 466 |
451 window.addEventListener('load', ntp4.initBookmarkChevron); | 467 window.addEventListener('load', ntp4.initBookmarkChevron); |
OLD | NEW |