Chromium Code Reviews

Side by Side 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.
Jump to:
View unified diff |
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // To avoid creating tons of unnecessary nodes. We assume we cannot fit more 5 // To avoid creating tons of unnecessary nodes. We assume we cannot fit more
6 // than this many items in the miniview. 6 // than this many items in the miniview.
7 var MAX_MINIVIEW_ITEMS = 15; 7 var MAX_MINIVIEW_ITEMS = 15;
8 8
9 // Extra spacing at the top of the layout. 9 // Extra spacing at the top of the layout.
10 var LAYOUT_SPACING_TOP = 25; 10 var LAYOUT_SPACING_TOP = 25;
11 11
12 var loading = true;
13
14 function updateSimpleSection(id, section) { 12 function updateSimpleSection(id, section) {
15 var elm = $(id); 13 var elm = $(id);
16 var maxiview = getSectionMaxiview(elm); 14 var maxiview = getSectionMaxiview(elm);
17 if (shownSections & section) { 15 if (shownSections & section) {
18 $(id).classList.remove('hidden'); 16 $(id).classList.remove('hidden');
19 if (maxiview) 17 if (maxiview)
20 maxiview.classList.remove('hidden'); 18 maxiview.classList.remove('hidden');
21 } else { 19 } else {
22 $(id).classList.add('hidden'); 20 $(id).classList.add('hidden');
23 if (maxiview) 21 if (maxiview)
(...skipping 554 matching lines...)
578 // onload. 576 // onload.
579 577
580 handleWindowResize(); 578 handleWindowResize();
581 579
582 var localStrings = new LocalStrings(); 580 var localStrings = new LocalStrings();
583 581
584 /////////////////////////////////////////////////////////////////////////////// 582 ///////////////////////////////////////////////////////////////////////////////
585 // Things we know are not needed at startup go below here 583 // Things we know are not needed at startup go below here
586 584
587 function afterTransition(f) { 585 function afterTransition(f) {
588 if (loading) { 586 if (!isDoneLoading()) {
589 // Make sure we do not use a timer during load since it slows down the UI. 587 // Make sure we do not use a timer during load since it slows down the UI.
590 f(); 588 f();
591 } else { 589 } else {
592 // The duration of all transitions are .15s 590 // The duration of all transitions are .15s
593 window.setTimeout(f, 150); 591 window.setTimeout(f, 150);
594 } 592 }
595 } 593 }
596 594
597 // Notification 595 // Notification
598 596
(...skipping 348 matching lines...)
947 shownSections & Section.THUMB); 945 shownSections & Section.THUMB);
948 946
949 function mostVisitedPages(data, firstRun, hasBlacklistedUrls) { 947 function mostVisitedPages(data, firstRun, hasBlacklistedUrls) {
950 logEvent('received most visited pages'); 948 logEvent('received most visited pages');
951 949
952 mostVisited.updateSettingsLink(hasBlacklistedUrls); 950 mostVisited.updateSettingsLink(hasBlacklistedUrls);
953 mostVisited.data = data; 951 mostVisited.data = data;
954 mostVisited.layout(); 952 mostVisited.layout();
955 layoutSections(); 953 layoutSections();
956 954
957 loading = false;
958
959 // Remove class name in a timeout so that changes done in this JS thread are 955 // Remove class name in a timeout so that changes done in this JS thread are
960 // not animated. 956 // not animated.
961 window.setTimeout(function() { 957 window.setTimeout(function() {
962 mostVisited.ensureSmallGridCorrect(); 958 mostVisited.ensureSmallGridCorrect();
963 document.body.classList.remove('loading'); 959 maybeDoneLoading();
964 }, 1); 960 }, 1);
965 961
966 // Only show the first run notification if first run. 962 // Only show the first run notification if first run.
967 if (firstRun) { 963 if (firstRun) {
968 showFirstRunNotification(); 964 showFirstRunNotification();
969 } 965 }
970 } 966 }
967
968 function maybeDoneLoading() {
969 if (mostVisited.data && apps.loaded)
970 document.body.classList.remove('loading');
971 }
972
973 function isDoneLoading() {
974 return !document.body.classList.contains('loading');
975 }
OLDNEW
« 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