From 1a13224309d6d1d94a2cd1b1d492cd2f78f20e94 Mon Sep 17 00:00:00 2001 From: "aa@chromium.org" Date: Wed, 1 Sep 2010 05:59:47 +0000 Subject: De-suck the NTP a bit more: * When there are no apps, don't show the apps section. * Expand the MV section by default, like it was in M6. * Fix bug where recently closed is incorrectly toggleable. * Stop showing miniview items for MV section when there is no more room. * Don't show filler MV items in miniview. * MV section is 5px too high because we were only apply extra padding to the first section, even if that section was disabled. TEST=Visual inspection. Review URL: http://codereview.chromium.org/3292003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58139 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/resources/new_new_tab.css | 7 ------- chrome/browser/resources/new_new_tab.html | 3 ++- chrome/browser/resources/new_new_tab.js | 9 ++++++--- chrome/browser/resources/ntp/apps.js | 6 ++++++ chrome/browser/resources/ntp/most_visited.js | 9 +++++++++ 5 files changed, 23 insertions(+), 11 deletions(-) (limited to 'chrome/browser/resources') diff --git a/chrome/browser/resources/new_new_tab.css b/chrome/browser/resources/new_new_tab.css index ef82016..8987445 100644 --- a/chrome/browser/resources/new_new_tab.css +++ b/chrome/browser/resources/new_new_tab.css @@ -338,13 +338,6 @@ html[dir=rtl] #option-menu > [command=hide]:before { cursor: pointer; } -/* The first one is special because we want a little extra space at the top of -the layout. */ -.section:first-child > h2 { - padding-top: 20px; - background-size: 100% 44px, 100% 10px; -} - .section > h2 > .disclosure { margin-left: -13px; padding-right: 4px; diff --git a/chrome/browser/resources/new_new_tab.html b/chrome/browser/resources/new_new_tab.html index f14d019..ae85056 100644 --- a/chrome/browser/resources/new_new_tab.html +++ b/chrome/browser/resources/new_new_tab.html @@ -130,7 +130,8 @@ if ('mode' in hashParams) {
-
+ +

diff --git a/chrome/browser/resources/new_new_tab.js b/chrome/browser/resources/new_new_tab.js index f780837..89297c5c 100644 --- a/chrome/browser/resources/new_new_tab.js +++ b/chrome/browser/resources/new_new_tab.js @@ -6,6 +6,9 @@ // than this many items in the miniview. var MAX_MINIVIEW_ITEMS = 15; +// Extra spacing at the top of the layout. +var LAYOUT_SPACING_TOP = 5; + var loading = true; function updateSimpleSection(id, section) { @@ -152,7 +155,7 @@ SectionLayoutInfo.getAll = function() { function layoutSections() { var sections = SectionLayoutInfo.getAll(); var expandedSection = null; - var headerHeight = 0; + var headerHeight = LAYOUT_SPACING_TOP; var footerHeight = 0; // Calculate the height of the fixed elements above the expanded section. Also @@ -204,7 +207,7 @@ function layoutSections() { } // Now position all the elements. - var y = 0; + var y = LAYOUT_SPACING_TOP; for (i = 0, section; section = sections[i]; i++) { section.header.style.top = y + 'px'; y += section.header.offsetHeight; @@ -737,7 +740,7 @@ $('main').addEventListener('click', function(e) { } p = p.parentNode; - if (p.noexpand) { + if (p.hasAttribute('noexpand')) { return; } diff --git a/chrome/browser/resources/ntp/apps.js b/chrome/browser/resources/ntp/apps.js index 5735b61..5bf1d1a 100644 --- a/chrome/browser/resources/ntp/apps.js +++ b/chrome/browser/resources/ntp/apps.js @@ -10,6 +10,11 @@ function getAppsCallback(data) { appsSectionContent.textContent = ''; appsMiniview.textContent = ''; + if (data.apps.length == 0) { + appsSection.classList.add('disabled'); + return; + } + data.apps.forEach(function(app) { appsSectionContent.appendChild(apps.createElement(app)); }); @@ -20,6 +25,7 @@ function getAppsCallback(data) { appsMiniview.appendChild(apps.createMiniviewElement(app)); }); + appsSection.classList.remove('disabled'); layoutSections(); } diff --git a/chrome/browser/resources/ntp/most_visited.js b/chrome/browser/resources/ntp/most_visited.js index acb0200..ca01c1e 100644 --- a/chrome/browser/resources/ntp/most_visited.js +++ b/chrome/browser/resources/ntp/most_visited.js @@ -561,6 +561,10 @@ var MostVisited = (function() { this.miniview.textContent = ''; var data = this.data.slice(0, MAX_MINIVIEW_ITEMS); for (var i = 0, item; item = data[i]; i++) { + if (item.filler) { + continue; + } + var span = document.createElement('span'); var a = span.appendChild(document.createElement('a')); a.href = item.url; @@ -568,6 +572,11 @@ var MostVisited = (function() { a.style.backgroundImage = url('chrome://favicon/' + item.url); a.className = 'item'; this.miniview.appendChild(span); + + if ((a.offsetLeft + a.offsetWidth) > this.miniview.offsetWidth) { + this.miniview.removeChild(span); + return; + } } }, -- cgit v1.1