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

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

Issue 337011: NTP: Allow hiding tips and bookmark sync.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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') | chrome/chrome.gyp » ('j') | 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 30053)
+++ chrome/browser/resources/new_new_tab.js (working copy)
@@ -8,7 +8,10 @@
}
function addClass(el, name) {
- el.className += ' ' + name;
+ var names = el.className.split(/\s+/);
+ if (names.indexOf(name) == -1) {
+ el.className += ' ' + name;
+ }
}
function removeClass(el, name) {
@@ -297,17 +300,27 @@
if (section == Section.THUMB) {
// hide LIST
shownSections &= ~Section.LIST;
- mostVisited.invalidate();
} else if (section == Section.LIST) {
// hide THUMB
shownSections &= ~Section.THUMB;
- mostVisited.invalidate();
- } else {
- renderRecentlyClosed();
}
-
- mostVisited.updateDisplayMode();
- mostVisited.layout();
+ switch (section) {
+ case Section.THUMB:
+ case Section.LIST:
+ mostVisited.invalidate();
+ mostVisited.updateDisplayMode();
+ mostVisited.layout();
+ break;
+ case Section.RECENT:
+ renderRecentlyClosed();
+ break;
+ case Section.TIPS:
+ $('tip-line').style.display = '';
+ break;
+ case Section.SYNC:
+ $('sync-status').style.display = '';
+ break;
+ }
}
}
@@ -315,16 +328,23 @@
if (section & shownSections) {
shownSections &= ~section;
- if (section & Section.THUMB || section & Section.LIST) {
- mostVisited.invalidate();
+ switch (section) {
+ case Section.THUMB:
+ case Section.LIST:
+ mostVisited.invalidate();
+ mostVisited.updateDisplayMode();
+ mostVisited.layout();
+ break;
+ case Section.RECENT:
+ renderRecentlyClosed();
+ break;
+ case Section.TIPS:
+ $('tip-line').style.display = 'none';
+ break;
+ case Section.SYNC:
+ $('sync-status').style.display = 'none';
+ break;
}
-
- if (section & Section.RECENT) {
- renderRecentlyClosed();
- }
-
- mostVisited.updateDisplayMode();
- mostVisited.layout();
}
}
@@ -545,15 +565,12 @@
// Recently closed
function layoutRecentlyClosed() {
- var recentElement = $('recently-closed');
var recentShown = shownSections & Section.RECENT;
- var style = recentElement.style;
+ updateSimpleSection('recently-closed', Section.RECENT);
- if (!recentShown) {
- addClass(recentElement, 'collapsed');
- } else {
- removeClass(recentElement, 'collapsed');
-
+ if (recentShown) {
+ var recentElement = $('recently-closed');
+ var style = recentElement.style;
// We cannot use clientWidth here since the width has a transition.
var spacing = 20;
var headerEl = recentElement.firstElementChild;
@@ -602,9 +619,10 @@
function syncMessageChanged(newMessage) {
var syncStatusElement = $('sync-status');
var style = syncStatusElement.style;
+ $('sync-menu-item').style.display = 'block';
// Hide the section if the message is emtpy.
- if (!newMessage.syncsectionisvisible) {
+ if (!newMessage['syncsectionisvisible'] || !(shownSections & Section.SYNC)) {
style.display = 'none';
return;
}
« no previous file with comments | « chrome/browser/resources/new_new_tab.html ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698