Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: chrome/browser/resources/ntp4/bookmarks_page.js

Issue 7810007: [ntp4] More UI refinements (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 title.textContent = this.data.title; 52 title.textContent = this.data.title;
53 53
54 if (this.data.url) { 54 if (this.data.url) {
55 var button = this.querySelector('.button'); 55 var button = this.querySelector('.button');
56 button.href = title.href = this.data.url; 56 button.href = title.href = this.data.url;
57 } 57 }
58 58
59 var faviconDiv = this.querySelector('.favicon'); 59 var faviconDiv = this.querySelector('.favicon');
60 var faviconUrl; 60 var faviconUrl;
61 if (this.data.url) { 61 if (this.data.url) {
62 faviconUrl = 'chrome://favicon/size/32/' + this.data.url; 62 faviconUrl = 'chrome://favicon/size/16/' + this.data.url;
63 chrome.send('getFaviconDominantColor', 63 chrome.send('getFaviconDominantColor',
64 [faviconUrl, id, 'ntp4.setBookmarksFaviconDominantColor']); 64 [faviconUrl, id, 'ntp4.setBookmarksFaviconDominantColor']);
65 } else { 65 } else {
66 // TODO(csilv): We need a large (32px) icon for this URL.
67 faviconUrl = 'chrome://theme/IDR_BOOKMARK_BAR_FOLDER'; 66 faviconUrl = 'chrome://theme/IDR_BOOKMARK_BAR_FOLDER';
68 // TODO(csilv): Should we vary this color by platform? 67 // TODO(csilv): Should we vary this color by platform?
69 this.stripeColor = '#919191'; 68 this.stripeColor = '#919191';
70 } 69 }
71 faviconDiv.style.backgroundImage = url(faviconUrl); 70 faviconDiv.style.backgroundImage = url(faviconUrl);
72 71
73 this.addEventListener('click', this.handleClick_.bind(this)); 72 this.addEventListener('click', this.handleClick_.bind(this));
74 }, 73 },
75 74
76 /** 75 /**
77 * Sets the color of the favicon dominant color bar. 76 * Sets the color of the favicon dominant color bar.
78 * @param {string} color The css-parsable value for the color. 77 * @param {string} color The css-parsable value for the color.
79 */ 78 */
80 set stripeColor(color) { 79 set stripeColor(color) {
81 this.querySelector('.color-stripe').style.backgroundColor = color; 80 this.querySelector('.color-stripe').style.backgroundColor = color;
82 }, 81 },
83 82
84 /** 83 /**
85 * Set the size and position of the bookmark tile. 84 * Set the size and position of the bookmark tile.
86 * @param {number} size The total size of |this|. 85 * @param {number} size The total size of |this|.
87 * @param {number} x The x-position. 86 * @param {number} x The x-position.
88 * @param {number} y The y-position. 87 * @param {number} y The y-position.
89 * animate. 88 * animate.
90 */ 89 */
91 setBounds: function(size, x, y) { 90 setBounds: function(size, x, y) {
92 this.style.width = this.style.height = size + 'px'; 91 this.style.width = size + 'px';
92 this.style.height = heightForWidth(size) + 'px';
93
93 this.style.left = x + 'px'; 94 this.style.left = x + 'px';
95 this.style.right = x + 'px';
94 this.style.top = y + 'px'; 96 this.style.top = y + 'px';
95 }, 97 },
96 98
97 /** 99 /**
98 * Invoked when a bookmark is clicked 100 * Invoked when a bookmark is clicked
99 * @param {Event} e The click event. 101 * @param {Event} e The click event.
100 * @private 102 * @private
101 */ 103 */
102 handleClick_: function(e) { 104 handleClick_: function(e) {
103 if (e.target.classList.contains('close-button')) { 105 if (e.target.classList.contains('close-button')) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 maxColCount: 6, 168 maxColCount: 6,
167 169
168 // The smallest a tile can be. 170 // The smallest a tile can be.
169 minTileWidth: 150, 171 minTileWidth: 150,
170 // The biggest a tile can be. 172 // The biggest a tile can be.
171 maxTileWidth: 150, 173 maxTileWidth: 150,
172 }; 174 };
173 TilePage.initGridValues(bookmarksPageGridValues); 175 TilePage.initGridValues(bookmarksPageGridValues);
174 176
175 /** 177 /**
178 * Calculates the height for a bookmarks tile for a given width. The size
179 * is based on a desired size of 96x72 ratio.
180 * @return {number} The height.
181 */
182 function heightForWidth(width) {
183 // The 2s are for borders, the 31 is for the title.
184 return (width - 2) * 72 / 96 + 2 + 31;
185 }
186
187 /**
176 * Creates a new BookmarksPage object. 188 * Creates a new BookmarksPage object.
177 * @constructor 189 * @constructor
178 * @extends {TilePage} 190 * @extends {TilePage}
179 */ 191 */
180 function BookmarksPage() { 192 function BookmarksPage() {
181 var el = new TilePage(bookmarksPageGridValues); 193 var el = new TilePage(bookmarksPageGridValues);
182 el.__proto__ = BookmarksPage.prototype; 194 el.__proto__ = BookmarksPage.prototype;
183 el.initialize(); 195 el.initialize();
184 196
185 return el; 197 return el;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 } 280 }
269 } 281 }
270 return false; 282 return false;
271 }, 283 },
272 284
273 /** @inheritDoc */ 285 /** @inheritDoc */
274 shouldAcceptDrag: function(dataTransfer) { 286 shouldAcceptDrag: function(dataTransfer) {
275 return false; 287 return false;
276 }, 288 },
277 289
290 /** @inheritDoc */
291 heightForWidth: heightForWidth,
292
278 /** 293 /**
279 * Invoked before a batch import begins. We will ignore added/changed 294 * Invoked before a batch import begins. We will ignore added/changed
280 * notifications while the operation is in progress. 295 * notifications while the operation is in progress.
281 */ 296 */
282 bookmarkImportBegan: function() { 297 bookmarkImportBegan: function() {
283 this.importing = true; 298 this.importing = true;
284 }, 299 },
285 300
286 /** 301 /**
287 * Invoked after a batch import finishes. We will reload the bookmarks 302 * Invoked after a batch import finishes. We will reload the bookmarks
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 }; 457 };
443 458
444 return { 459 return {
445 BookmarksPage: BookmarksPage, 460 BookmarksPage: BookmarksPage,
446 initBookmarkChevron: initBookmarkChevron, 461 initBookmarkChevron: initBookmarkChevron,
447 setBookmarksFaviconDominantColor: setBookmarksFaviconDominantColor 462 setBookmarksFaviconDominantColor: setBookmarksFaviconDominantColor
448 }; 463 };
449 }); 464 });
450 465
451 window.addEventListener('load', ntp4.initBookmarkChevron); 466 window.addEventListener('load', ntp4.initBookmarkChevron);
OLDNEW
« no previous file with comments | « chrome/browser/resources/ntp4/bookmarks_page.css ('k') | chrome/browser/resources/ntp4/most_visited_page.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698