Chromium Code Reviews| Index: chrome/browser/resources/ntp_search/tile_page.js |
| diff --git a/chrome/browser/resources/ntp_search/tile_page.js b/chrome/browser/resources/ntp_search/tile_page.js |
| index 7499dc22747055c40115976377474c501bb31793..4abf4f0eb0c8e24a9675b6cdc4e56e75bd12f801 100644 |
| --- a/chrome/browser/resources/ntp_search/tile_page.js |
| +++ b/chrome/browser/resources/ntp_search/tile_page.js |
| @@ -6,6 +6,62 @@ cr.define('ntp', function() { |
| 'use strict'; |
| //---------------------------------------------------------------------------- |
| + // Constants |
| + //---------------------------------------------------------------------------- |
| + |
| + /** |
| + * The maximum window height required to show 2 rows of Tiles in the Bottom |
|
jeremycho_google
2012/08/23 01:09:28
minimum
pedrosimonetti2
2012/08/24 00:22:15
Done.
|
| + * Section. If the height is bigger than this value, 2 rows will be displayed. |
| + * @type {Number} |
| + * @const |
| + */ |
| + var MAX_WINDOW_HEIGHT = 275; |
|
jeremycho_google
2012/08/23 01:09:28
To me, this sounds like the window can't be larger
pedrosimonetti2
2012/08/24 00:22:15
Done.
|
| + |
| + /** |
| + * The minimum window height required to show the Bottom Section. If the |
| + * height is smaller than this value, the Bottom Section will be hidden. |
| + * @type {Number} |
| + * @const |
| + */ |
| + var MIN_WINDOW_HEIGHT = 170; |
|
jeremycho_google
2012/08/23 01:09:28
See above comment, maybe BOTTOM_SECTION_WINDOW_HEI
pedrosimonetti2
2012/08/24 00:22:15
Done.
|
| + |
| + /** |
| + * The maximum window width required to show 5 cols of Tiles in the Bottom |
|
jeremycho_google
2012/08/23 01:09:28
minimum
pedrosimonetti2
2012/08/24 00:22:15
Done.
|
| + * Section. If the width is bigger than this value, 5 cols will be displayed. |
|
jeremycho_google
2012/08/23 01:09:28
Shouldn't this be used in getColCountForWidth_ the
pedrosimonetti2
2012/08/24 00:22:15
I don't think so because getColCountForWidth_ will
|
| + * @type {Number} |
| + * @const |
| + */ |
| + var MAX_WINDOW_WIDTH = 948; |
|
jeremycho_google
2012/08/23 01:09:28
Maybe LARGE_WINDOW_WIDTH?
jeremycho_google
2012/08/23 01:09:28
This value is also used in the bottom section widt
pedrosimonetti2
2012/08/24 00:22:15
Done.
pedrosimonetti2
2012/08/24 00:22:15
I'm not sure if I understand what you mean by "thi
jeremycho_google
2012/08/24 00:54:42
Not done?
On 2012/08/24 00:22:15, pedrosimonetti w
jeremycho_google
2012/08/24 00:54:42
Sorry, what I meant was - can you give a comment e
|
| + |
| + /** |
| + * The medium window width. If the window width is greater than or equal to |
| + * this value, then the Bottom Section width will be the window width minus |
|
jeremycho_google
2012/08/23 01:09:28
Stick with either Bottom Section or Bottom Panel e
pedrosimonetti2
2012/08/24 00:22:15
Done.
|
| + * the Bottom Panel's side margin, which we'll call the default width. If the |
| + * window is smaller than this value, then the Bottom Section's width will |
| + * be an interpolation between the default width, and the minimum width |
| + * defined by the constant MIN_BOTTOM_SECTION_WIDTH. |
| + * @type {Number} |
| + * @const |
| + */ |
| + var MED_WINDOW_WIDTH = 500; |
| + |
| + /** |
| + * The minimum window width. If the window is smaller than this value, then |
| + * the Bottom Section width will be fixed to MIN_BOTTOM_SECTION_WIDTH. |
| + * @type {Number} |
| + * @const |
| + */ |
| + var MIN_WINDOW_WIDTH = 300; |
|
jeremycho_google
2012/08/23 01:09:28
Maybe SMALL_WINDOW_WIDTH?
pedrosimonetti2
2012/08/24 00:22:15
Done.
jeremycho_google
2012/08/24 00:54:42
Not done?
On 2012/08/24 00:22:15, pedrosimonetti w
|
| + |
| + /** |
| + * The minimum Bottom Section width, which will be used when the window width |
| + * is smaller than MIN_WINDOW_WIDTH. |
| + * @type {Number} |
| + * @const |
| + */ |
| + var MIN_BOTTOM_SECTION_WIDTH = 200; |
| + |
| + //---------------------------------------------------------------------------- |
| // Tile |
| //---------------------------------------------------------------------------- |
| @@ -512,17 +568,20 @@ cr.define('ntp', function() { |
| */ |
| getBottomPanelWidth_: function() { |
| var windowWidth = cr.doc.documentElement.clientWidth; |
| + var margin = this.config_.bottomPanelHorizontalMargin; |
| var width; |
| - // TODO(pedrosimonetti): Add constants? |
| - if (windowWidth >= 948) |
| - width = 748; |
| - else if (windowWidth >= 500) |
| - width = windowWidth - 2 * this.config_.bottomPanelHorizontalMargin; |
| - else if (windowWidth >= 300) |
| - // TODO(pedrosimonetti): Check specification. |
| - width = Math.floor(((windowWidth - 300) / 200) * 100 + 200); |
| + if (windowWidth >= MAX_WINDOW_WIDTH) |
| + width = MAX_WINDOW_WIDTH - 2 * margin; |
| + else if (windowWidth >= MED_WINDOW_WIDTH) |
| + width = windowWidth - 2 * margin; |
| + else if (windowWidth >= MIN_WINDOW_WIDTH) |
|
jeremycho_google
2012/08/23 01:09:28
Add curlies, since this is multi-line?
pedrosimonetti2
2012/08/24 00:22:15
Done.
|
| + // Interpolation between the previous and next states. |
| + width = Math.floor((windowWidth - MIN_WINDOW_WIDTH) / |
| + (MED_WINDOW_WIDTH - MIN_WINDOW_WIDTH) * |
| + (MED_WINDOW_WIDTH - 2 * margin - MIN_BOTTOM_SECTION_WIDTH) + |
| + MIN_BOTTOM_SECTION_WIDTH); |
| else |
| - width = 200; |
| + width = MIN_BOTTOM_SECTION_WIDTH; |
| return width; |
| }, |
| @@ -645,9 +704,9 @@ cr.define('ntp', function() { |
| this.tileGridContent_.classList.add('animate-tile'); |
| - // TODO(pedrosimonetti): Better handling of height state. |
| - // TODO(pedrosimonetti): Add constants? |
| - var numOfVisibleRows = windowHeight > 500 ? 2 : 1; |
| + this.showBottomSection_(windowHeight < MIN_WINDOW_HEIGHT); |
| + |
| + var numOfVisibleRows = windowHeight > MAX_WINDOW_HEIGHT ? 2 : 1; |
|
jeremycho_google
2012/08/23 01:09:28
When windowHeight < MIN_WINDOW_HEIGHT, should numO
pedrosimonetti2
2012/08/24 00:22:15
I thought about this too. Even though zero rows ar
jeremycho_google
2012/08/24 00:54:42
Ok, makes sense.
On 2012/08/24 00:22:15, pedrosimo
|
| if (numOfVisibleRows != this.numOfVisibleRows_) { |
| this.numOfVisibleRows_ = numOfVisibleRows; |
| this.paginate_(null, true); |
| @@ -706,6 +765,15 @@ cr.define('ntp', function() { |
| // ------------------------------------------------------------------------- |
| /** |
| + * Animates the display the Bottom Section. |
| + * @param {boolean} show Whether or not to show the Bottom Section. |
| + */ |
| + showBottomSection_: function(show) { |
|
jeremycho_google
2012/08/23 01:09:28
Shouldn't the parameter be 'hide'? Maybe make thi
pedrosimonetti2
2012/08/24 00:22:15
I changed the implementation so it uses a show par
|
| + $('card-slider-frame'). |
|
jeremycho_google
2012/08/23 01:09:28
nit: I think it's more typical to line-break on a
pedrosimonetti2
2012/08/24 00:22:15
Done.
|
| + classList[show ? 'add' : 'remove']('hide-card-slider'); |
| + }, |
| + |
| + /** |
| * Animates the display of a row. TODO(pedrosimonetti): Make it local? |
| * @param {HTMLElement} row The row element. |
| * @param {boolean} show Whether or not to show the row. |