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

Unified Diff: chrome/browser/resources/ntp4/md_incognito_tab.js

Issue 2905433002: Refresh the Incognito NTP layout on default font size change (Closed)
Patch Set: s/tooWide/too-wide/ Created 3 years, 7 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/ntp4/md_incognito_tab.css ('k') | chrome/browser/ui/webui/ntp/new_tab_ui.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/ntp4/md_incognito_tab.js
diff --git a/chrome/browser/resources/ntp4/md_incognito_tab.js b/chrome/browser/resources/ntp4/md_incognito_tab.js
index a48c9a0d3ba991e267c72305f3272989c1ade41a..4a36703026a43362714c02f437053043b1ef655a 100644
--- a/chrome/browser/resources/ntp4/md_incognito_tab.js
+++ b/chrome/browser/resources/ntp4/md_incognito_tab.js
@@ -2,25 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Handle the bookmark bar and theme change requests from the C++ side.
-var ntp = {
- /** @param {string} attached */
- setBookmarkBarAttached: function(attached) {
- document.documentElement.setAttribute('bookmarkbarattached', attached);
- },
-
- /** @param {!{hasCustomBackground: boolean}} themeData */
- themeChanged: function(themeData) {
- document.documentElement.setAttribute('hascustombackground',
- themeData.hasCustomBackground);
- $('incognitothemecss').href =
- 'chrome://theme/css/incognito_new_tab_theme.css?' + Date.now();
- },
-};
-
// Let the width of two lists of bulletpoints in a horizontal alignment
// determine the maximum content width.
-window.addEventListener('load', function() {
+function recomputeLayoutWidth() {
var bulletpoints = document.querySelectorAll('.bulletpoints');
var content = document.querySelector('.content');
@@ -39,11 +23,34 @@ window.addEventListener('load', function() {
// Limit the maximum width to 600px. That might force the two lists
// of bulletpoints under each other, in which case we must swap the left
// and right margin.
- if (maxWidth > 600) {
- maxWidth = 600;
-
- bulletpoints[1].classList.add('tooWide');
- }
+ var MAX_ALLOWED_WIDTH = 600;
+ var tooWide = maxWidth > MAX_ALLOWED_WIDTH;
+ bulletpoints[1].classList.toggle('too-wide', tooWide);
+ if (tooWide)
+ maxWidth = MAX_ALLOWED_WIDTH;
content.style.maxWidth = maxWidth + "px";
-});
+}
+
+window.addEventListener('load', recomputeLayoutWidth);
+
+// Handle the bookmark bar, theme, and font size change requests
+// from the C++ side.
+var ntp = {
+ /** @param {string} attached */
+ setBookmarkBarAttached: function(attached) {
+ document.documentElement.setAttribute('bookmarkbarattached', attached);
+ },
+
+ /** @param {!{hasCustomBackground: boolean}} themeData */
+ themeChanged: function(themeData) {
+ document.documentElement.setAttribute('hascustombackground',
+ themeData.hasCustomBackground);
+ $('incognitothemecss').href =
+ 'chrome://theme/css/incognito_new_tab_theme.css?' + Date.now();
+ },
+
+ defaultFontSizeChanged: function() {
+ setTimeout(recomputeLayoutWidth, 100);
+ }
+};
« no previous file with comments | « chrome/browser/resources/ntp4/md_incognito_tab.css ('k') | chrome/browser/ui/webui/ntp/new_tab_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698