Index: chrome/browser/resources/new_new_tab.js |
=================================================================== |
--- chrome/browser/resources/new_new_tab.js (revision 19722) |
+++ chrome/browser/resources/new_new_tab.js (working copy) |
@@ -65,6 +65,7 @@ |
} |
} |
+var loading = true; |
var mostVisitedData = []; |
var gotMostVisited = false; |
var gotShownSections = false; |
@@ -101,9 +102,17 @@ |
processData('#tab-items', data); |
} |
-function onShownSections(m) { |
+function onShownSections(mask) { |
logEvent('received shown sections'); |
- setShownSections(m); |
+ if (mask != shownSections) { |
+ shownSections = mask; |
+ // No need to relayout these unless changed. |
+ mostVisited.updateDisplayMode(); |
+ layoutMostVisited(); |
+ layoutLowerSections(); |
+ updateOptionMenu(); |
+ } |
+ |
gotShownSections = true; |
onDataLoaded(); |
} |
@@ -327,7 +336,7 @@ |
TIPS: 8 |
}; |
-var shownSections = Section.RECENT | Section.TIPS; |
+var shownSections = Section.THUMB | Section.RECENT | Section.TIPS; |
function showSection(section) { |
if (!(section & shownSections)) { |
@@ -373,19 +382,6 @@ |
} |
} |
-/** |
- * This is called when we get the shown sections pref from the backend. |
- */ |
-function setShownSections(mask) { |
- if (mask != shownSections) { |
- shownSections = mask; |
- mostVisited.updateDisplayMode(); |
- layoutMostVisited(); |
- layoutLowerSections(); |
- updateOptionMenu(); |
- } |
-} |
- |
var mostVisited = { |
getItem: function(el) { |
return findAncestorByClass(el, 'thumbnail-container'); |
@@ -596,6 +592,7 @@ |
*/ |
function onDataLoaded() { |
if (gotMostVisited && gotShownSections) { |
+ loading = false; |
// Remove class name in a timeout so that changes done in this JS thread are |
// not animated. |
window.setTimeout(function() { |
@@ -659,13 +656,18 @@ |
/////////////////////////////////////////////////////////////////////////////// |
// Things we know are not needed at startup go below here |
-// Notification |
- |
function afterTransition(f) { |
- // The duration of all transitions are 500ms |
- window.setTimeout(f, 500); |
+ if (loading) { |
+ // Make sure we do not use a timer during load since it slows down the UI. |
+ f(); |
+ } else { |
+ // The duration of all transitions are 500ms |
+ window.setTimeout(f, 500); |
+ } |
} |
+// Notification |
+ |
function showNotification(text, actionText, f) { |
var notificationElement = $('notification'); |
var actionLink = notificationElement.querySelector('.link'); |
@@ -755,7 +757,6 @@ |
handleMouseOver: function(e) { |
var el = e.target; |
var index = Array.prototype.indexOf.call(this.menu.children, el); |
- console.log(el, index); |
this.setSelectedIndex(index); |
}, |