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

Unified Diff: chrome/browser/resources/new_new_tab.js

Issue 3474006: NTP: Don't show any sections or layout until we receive mv and apps. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: Created 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/new_new_tab.css ('k') | chrome/browser/resources/ntp/apps.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/new_new_tab.js
diff --git a/chrome/browser/resources/new_new_tab.js b/chrome/browser/resources/new_new_tab.js
index e4720725b61b81502b720f210cf053627008af0d..99cb712c4e4616555d12a52617f772b87973c9d9 100644
--- a/chrome/browser/resources/new_new_tab.js
+++ b/chrome/browser/resources/new_new_tab.js
@@ -9,8 +9,6 @@ var MAX_MINIVIEW_ITEMS = 15;
// Extra spacing at the top of the layout.
var LAYOUT_SPACING_TOP = 25;
-var loading = true;
-
function updateSimpleSection(id, section) {
var elm = $(id);
var maxiview = getSectionMaxiview(elm);
@@ -585,7 +583,7 @@ var localStrings = new LocalStrings();
// Things we know are not needed at startup go below here
function afterTransition(f) {
- if (loading) {
+ if (!isDoneLoading()) {
// Make sure we do not use a timer during load since it slows down the UI.
f();
} else {
@@ -954,13 +952,11 @@ function mostVisitedPages(data, firstRun, hasBlacklistedUrls) {
mostVisited.layout();
layoutSections();
- loading = false;
-
// Remove class name in a timeout so that changes done in this JS thread are
// not animated.
window.setTimeout(function() {
mostVisited.ensureSmallGridCorrect();
- document.body.classList.remove('loading');
+ maybeDoneLoading();
}, 1);
// Only show the first run notification if first run.
@@ -968,3 +964,12 @@ function mostVisitedPages(data, firstRun, hasBlacklistedUrls) {
showFirstRunNotification();
}
}
+
+function maybeDoneLoading() {
+ if (mostVisited.data && apps.loaded)
+ document.body.classList.remove('loading');
+}
+
+function isDoneLoading() {
+ return !document.body.classList.contains('loading');
+}
« no previous file with comments | « chrome/browser/resources/new_new_tab.css ('k') | chrome/browser/resources/ntp/apps.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698