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

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

Issue 155116: Change to use CSS media queries instead of using the "small" class name... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 5 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.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/new_new_tab.js
===================================================================
--- chrome/browser/resources/new_new_tab.js (revision 19979)
+++ chrome/browser/resources/new_new_tab.js (working copy)
@@ -106,8 +106,8 @@
if (mask != shownSections) {
// Only invalidate most visited if needed.
- if (mask & Section.THUMB != shownSections & Section.THUMB ||
- mask & Section.LIST != shownSections & Section.LIST) {
+ if ((mask & Section.THUMB) != (shownSections & Section.THUMB) ||
+ (mask & Section.LIST) != (shownSections & Section.LIST)) {
mostVisited.invalidate();
}
@@ -213,31 +213,29 @@
}
function useSmallGrid() {
- return document.body.clientWidth <= 940;
+ return window.innerWidth <= 940;
}
-function handleWindowResize(e, opt_noUpdate) {
- var body = document.body;
- if (!body || body.clientWidth < 10) {
+var LayoutMode = {
+ SMALL: 1,
+ NORMAL: 2
+};
+
+var layoutMode = useSmallGrid() ? LayoutMode.SMALL : LayoutMode.NORMAL;
+
+function handleWindowResize() {
+ if (window.innerWidth < 10) {
// We're probably a background tab, so don't do anything.
return;
}
- var hasSmallClass = hasClass(body, 'small');
- if (hasSmallClass && !useSmallGrid()) {
- removeClass(body, 'small');
+ var oldLayoutMode = layoutMode;
+ layoutMode = useSmallGrid() ? LayoutMode.SMALL : LayoutMode.NORMAL
+
+ if (layoutMode != oldLayoutMode){
mostVisited.invalidate();
- if (!opt_noUpdate) {
- mostVisited.layout();
- layoutLowerSections();
- }
- } else if (!hasSmallClass && useSmallGrid()) {
- addClass(body, 'small');
- mostVisited.invalidate();
- if (!opt_noUpdate) {
- mostVisited.layout();
- layoutLowerSections();
- }
+ mostVisited.layout();
+ layoutLowerSections();
}
}
@@ -513,6 +511,9 @@
for (var i = 0; i < thumbnails.length; i++) {
var t = thumbnails[i];
+ // Remove temporary ID that was used during startup layout.
+ t.id = '';
+
var row, col;
if (shownSections & Section.THUMB) {
row = Math.floor(i / cols);
@@ -680,7 +681,7 @@
// We apply the size class here so that we don't trigger layout animations
// onload.
-handleWindowResize(null, true);
+handleWindowResize();
var localStrings = new LocalStrings();
« no previous file with comments | « chrome/browser/resources/new_new_tab.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698