OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Handle the bookmark bar and theme change requests from the C++ side. | |
6 var ntp = { | |
7 /** @param {string} attached */ | |
8 setBookmarkBarAttached: function(attached) { | |
9 document.documentElement.setAttribute('bookmarkbarattached', attached); | |
10 }, | |
11 | |
12 /** @param {!{hasCustomBackground: boolean}} themeData */ | |
13 themeChanged: function(themeData) { | |
14 document.documentElement.setAttribute('hascustombackground', | |
15 themeData.hasCustomBackground); | |
16 $('incognitothemecss').href = | |
17 'chrome://theme/css/incognito_new_tab_theme.css?' + Date.now(); | |
18 }, | |
19 }; | |
20 | |
21 // Let the width of two lists of bulletpoints in a horizontal alignment | |
22 // determine the maximum content width. | |
23 window.addEventListener('load', function() { | |
24 var b1 = $('firstBulletpoints'); | |
Dan Beam
2017/04/20 18:27:51
nit: why not just
var bullets = querySelectorAll(
msramek
2017/04/21 12:20:36
Done. I'm actually using '.bulletpoints + .bulletp
| |
25 var b2 = $('secondBulletpoints'); | |
26 var c = document.querySelector('.content'); | |
27 | |
28 var maxWidth = (b1.offsetWidth + b2.offsetWidth + | |
29 40 /* margin */ + 2 /* offsetWidths may be rounded down */); | |
30 | |
31 // Limit the maximum width to 600px. That might force the two lists | |
32 // of bulletpoints under each other, in which case we must swap the left | |
33 // and right margin. | |
34 if (maxWidth > 600) { | |
35 maxWidth = 600; | |
36 | |
37 b2.className += " tooWide"; | |
Dan Beam
2017/04/20 18:27:51
b2.classList.add('tooWide');
msramek
2017/04/21 12:20:36
Done. (Thanks, my JS-fu seems to have degraded ove
| |
38 } | |
39 | |
40 c.style.maxWidth = maxWidth + "px"; | |
41 }); | |
OLD | NEW |