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

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

Issue 7399015: Sync Promo: Add a way to collapse the sync promo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync Promo: Add a way to collapse the sync promo Created 9 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_tab_sync_promo.css ('k') | chrome/browser/resources/sync_promo_minimize.png » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/new_tab_sync_promo.js
===================================================================
--- chrome/browser/resources/new_tab_sync_promo.js (revision 93571)
+++ chrome/browser/resources/new_tab_sync_promo.js (working copy)
@@ -3,7 +3,6 @@
// found in the LICENSE file.
cr.define('new_tab', function() {
-
/**
* NewTabSyncPromo class
* Subclass of options.SyncSetupOverlay that customizes the sync setup
@@ -21,18 +20,67 @@
NewTabSyncPromo.prototype = {
__proto__: options.SyncSetupOverlay.prototype,
+ // Variable to track if the promo is expanded or collapsed.
+ isSyncPromoExpanded_: false,
+
showOverlay_: function() {
- $('sync-setup-overlay').hidden = false;
+ this.expandSyncPromo_(true);
},
+ // Initializes the page.
initializePage: function() {
options.SyncSetupOverlay.prototype.initializePage.call(this);
- chrome.send('SyncSetupAttachHandler');
+ var self = this;
+ $('sync-promo-toggle-button').onclick = function() {
+ self.onTogglePromo();
+ }
+ chrome.send('InitializeSyncPromo');
},
- showOverlay_: function() {
- $('sync-setup-overlay').hidden = false;
+ // Handler for the toggle button to show or hide the sync promo.
+ onTogglePromo: function() {
+ if (this.isSyncPromoExpanded_) {
+ this.expandSyncPromo_(false);
+ chrome.send('CollapseSyncPromo');
+ } else {
+ chrome.send('ExpandSyncPromo');
+ }
},
+
+ // Shows or hides the sync promo.
+ expandSyncPromo_: function(shouldExpand) {
+ this.isSyncPromoExpanded_ = shouldExpand;
+ if (shouldExpand) {
+ $('sync-promo-login-status').hidden = true;
+ $('sync-setup-overlay').hidden = false;
+ $('sync-promo').classList.remove('collapsed');
+ } else {
+ $('sync-promo-login-status').hidden = false;
+ $('sync-setup-overlay').hidden = true;
+ $('sync-promo').classList.add('collapsed');
+ }
+ layoutSections();
+ },
+
+ // Sets the sync login name. If there's no login name then makes the
+ // 'not connected' UI visible and shows the sync promo toggle button.
+ updateLogin_: function(user_name) {
+ if (user_name) {
+ $('sync-promo-toggle').hidden = true;
+ $('sync-promo-user-name').textContent = user_name;
+ $('sync-promo-not-connected').hidden = true;
+ } else {
+ $('sync-promo-toggle').hidden = false;
+ $('sync-promo-user-name').hidden = true;
+ $('sync-promo-not-connected').hidden = false;
+ }
+ layoutSections();
+ },
+
+ // Shows the sync promo.
+ showSyncPromo_: function() {
+ $('sync-promo').hidden = false;
+ },
};
NewTabSyncPromo.showErrorUI = function() {
@@ -63,6 +111,14 @@
NewTabSyncPromo.getInstance().initializePage();
}
+ NewTabSyncPromo.showSyncPromo = function() {
+ NewTabSyncPromo.getInstance().showSyncPromo_();
+ }
+
+ NewTabSyncPromo.updateLogin = function(user_name) {
+ NewTabSyncPromo.getInstance().updateLogin_(user_name);
+ }
+
// Export
return {
NewTabSyncPromo : NewTabSyncPromo
« no previous file with comments | « chrome/browser/resources/new_tab_sync_promo.css ('k') | chrome/browser/resources/sync_promo_minimize.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698