Chromium Code Reviews| Index: chrome/browser/resources/ntp/apps.js |
| diff --git a/chrome/browser/resources/ntp/apps.js b/chrome/browser/resources/ntp/apps.js |
| index da91af7e8ce2737f6c9b517c09ee58864288a1f9..f925b85dfbfc152311d45e6e933b73b423706d8d 100644 |
| --- a/chrome/browser/resources/ntp/apps.js |
| +++ b/chrome/browser/resources/ntp/apps.js |
| @@ -2,16 +2,21 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +var MAX_APPS_PER_ROW = []; |
| +MAX_APPS_PER_ROW[LayoutMode.SMALL] = 4; |
| +MAX_APPS_PER_ROW[LayoutMode.NORMAL] = 6; |
| + |
| function getAppsCallback(data) { |
| logEvent('received apps'); |
| var appsSection = $('apps'); |
| - var appsSectionContent = $('apps-maxiview'); |
| + var appsSectionContent = $('apps-content'); |
| var appsMiniview = appsSection.getElementsByClassName('miniview')[0]; |
| var appsPromo = $('apps-promo'); |
| + var webStoreEntry = null; |
|
arv (Not doing code reviews)
2010/10/15 22:33:36
do you really need to assign null here?
|
| appsMiniview.textContent = ''; |
| - while (appsSectionContent.lastChild != appsPromo) { |
| - appsSectionContent.removeChild(appsSectionContent.lastChild); |
| + while (appsSectionContent.firstChild) { |
|
arv (Not doing code reviews)
2010/10/15 22:33:36
Since you are now removing all of them you can jus
|
| + appsSectionContent.removeChild(appsSectionContent.firstChild); |
| } |
| data.apps.sort(function(a,b) { |
| @@ -24,10 +29,11 @@ function getAppsCallback(data) { |
| layoutSections(); |
| } else { |
| data.apps.forEach(function(app) { |
| - appsSectionContent.appendChild(apps.createElement(app)); |
| + appsSectionContent.appendChild(apps.createElement(app)); |
| }); |
| - appsSectionContent.appendChild(apps.createWebStoreElement()); |
| + webStoreEntry = apps.createWebStoreElement(); |
| + appsSectionContent.appendChild(webStoreEntry); |
| data.apps.slice(0, MAX_MINIVIEW_ITEMS).forEach(function(app) { |
| appsMiniview.appendChild(apps.createMiniviewElement(app)); |
| @@ -48,6 +54,11 @@ function getAppsCallback(data) { |
| maybeDoneLoading(); |
| if (data.apps.length > 0 && isDoneLoading()) { |
| + if (!data.showPromo && data.apps.length >= MAX_APPS_PER_ROW[layoutMode]) |
| + webStoreEntry.classList.add('loner'); |
| + else |
| + webStoreEntry.classList.remove('loner'); |
| + |
| updateMiniviewClipping(appsMiniview); |
| layoutSections(); |
| } |