| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // TODO(sail): Refactor options_page and remove this include. | 5 // TODO(sail): Refactor options_page and remove this include. |
| 6 <include src="../options/options_page.js"/> | 6 <include src="../options/options_page.js"/> |
| 7 <include src="../sync_setup_overlay.js"/> | 7 <include src="../sync_setup_overlay.js"/> |
| 8 | 8 |
| 9 cr.define('sync_promo', function() { | 9 cr.define('sync_promo', function() { |
| 10 /** | 10 /** |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 chrome.send('SyncPromo:Initialize'); | 67 chrome.send('SyncPromo:Initialize'); |
| 68 | 68 |
| 69 var self = this; | 69 var self = this; |
| 70 | 70 |
| 71 $('promo-skip-button').addEventListener('click', function() { | 71 $('promo-skip-button').addEventListener('click', function() { |
| 72 chrome.send('SyncPromo:UserSkipped'); | 72 chrome.send('SyncPromo:UserSkipped'); |
| 73 self.closeOverlay_(); | 73 self.closeOverlay_(); |
| 74 }); | 74 }); |
| 75 | 75 |
| 76 var learnMoreClickedAlready = false; | 76 var learnMoreClickedAlready = false; |
| 77 $('promo-learn-more-show').addEventListener('click', function() { | 77 $('promo-learn-more').addEventListener('click', function() { |
| 78 self.showLearnMore_(true); | |
| 79 if (!learnMoreClickedAlready) | 78 if (!learnMoreClickedAlready) |
| 80 chrome.send('SyncPromo:UserFlowAction', [actions.LEARN_MORE_CLICKED]); | 79 chrome.send('SyncPromo:UserFlowAction', [actions.LEARN_MORE_CLICKED]); |
| 81 learnMoreClickedAlready = true; | 80 learnMoreClickedAlready = true; |
| 82 }); | 81 }); |
| 83 | 82 |
| 84 $('promo-learn-more-hide').addEventListener('click', function() { | |
| 85 self.showLearnMore_(false); | |
| 86 }); | |
| 87 | |
| 88 $('promo-advanced').addEventListener('click', function() { | 83 $('promo-advanced').addEventListener('click', function() { |
| 89 chrome.send('SyncPromo:ShowAdvancedSettings'); | 84 chrome.send('SyncPromo:ShowAdvancedSettings'); |
| 90 }); | 85 }); |
| 91 | 86 |
| 92 var accountHelpClickedAlready = false; | 87 var accountHelpClickedAlready = false; |
| 93 $('cannot-access-account-link').addEventListener('click', function() { | 88 $('cannot-access-account-link').addEventListener('click', function() { |
| 94 if (!accountHelpClickedAlready) | 89 if (!accountHelpClickedAlready) |
| 95 chrome.send('SyncPromo:UserFlowAction', | 90 chrome.send('SyncPromo:UserFlowAction', |
| 96 [actions.ACCOUNT_HELP_CLICKED]); | 91 [actions.ACCOUNT_HELP_CLICKED]); |
| 97 accountHelpClickedAlready = true; | 92 accountHelpClickedAlready = true; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 advancedOptionsClickedAlready = true; | 125 advancedOptionsClickedAlready = true; |
| 131 }); | 126 }); |
| 132 | 127 |
| 133 // Re-used across both cancel buttons after a successful sign in. | 128 // Re-used across both cancel buttons after a successful sign in. |
| 134 var cancelFunc = function() { | 129 var cancelFunc = function() { |
| 135 chrome.send('SyncPromo:UserFlowAction', | 130 chrome.send('SyncPromo:UserFlowAction', |
| 136 [actions.CANCELLED_AFTER_SIGN_IN]); | 131 [actions.CANCELLED_AFTER_SIGN_IN]); |
| 137 }; | 132 }; |
| 138 $('confirm-everything-cancel').addEventListener('click', cancelFunc); | 133 $('confirm-everything-cancel').addEventListener('click', cancelFunc); |
| 139 $('choose-datatypes-cancel').addEventListener('click', cancelFunc); | 134 $('choose-datatypes-cancel').addEventListener('click', cancelFunc); |
| 140 | |
| 141 this.infographic_ = $('promo-infographic'); | |
| 142 this.learnMore_ = $('promo-information'); | |
| 143 | |
| 144 this.infographic_.addEventListener('webkitTransitionEnd', | |
| 145 this.toggleHidden_.bind(this)); | |
| 146 this.learnMore_.addEventListener('webkitTransitionEnd', | |
| 147 this.toggleHidden_.bind(this)); | |
| 148 }, | 135 }, |
| 149 | 136 |
| 150 /** | 137 /** |
| 151 * Called when the page is unloading to record number of times a user tried | 138 * Called when the page is unloading to record number of times a user tried |
| 152 * to sign in and if they left while a throbber was running. | 139 * to sign in and if they left while a throbber was running. |
| 153 * @private | 140 * @private |
| 154 */ | 141 */ |
| 155 recordPageViewActions_: function() { | 142 recordPageViewActions_: function() { |
| 156 chrome.send('SyncPromo:RecordSignInAttempts', [this.signInAttempts_]); | 143 chrome.send('SyncPromo:RecordSignInAttempts', [this.signInAttempts_]); |
| 157 if (this.throbberStart_) | 144 if (this.throbberStart_) |
| 158 chrome.send('SyncPromo:UserFlowAction', [actions.LEFT_DURING_THROBBER]); | 145 chrome.send('SyncPromo:UserFlowAction', [actions.LEFT_DURING_THROBBER]); |
| 159 }, | 146 }, |
| 160 | 147 |
| 161 /** | |
| 162 * Remove the [hidden] attribute from the node that was not previously | |
| 163 * transitioning. | |
| 164 * @param {Event} e A -webkit-transition end event. | |
| 165 * @private | |
| 166 */ | |
| 167 toggleHidden_: function(e) { | |
| 168 // Only show the other element if the target of this event was hidden | |
| 169 // (showing also triggers a transition end). | |
| 170 if (e.target.hidden) { | |
| 171 if (e.target === this.infographic_) | |
| 172 this.learnMore_.hidden = false; | |
| 173 else | |
| 174 this.infographic_.hidden = false; | |
| 175 } | |
| 176 }, | |
| 177 | |
| 178 /** | |
| 179 * Shows or hides the sync information. | |
| 180 * @param {Boolean} show True if sync information should be shown, false | |
| 181 * otherwise. | |
| 182 * @private | |
| 183 */ | |
| 184 showLearnMore_: function(show) { | |
| 185 $('promo-learn-more-show').hidden = show; | |
| 186 $('promo-learn-more-hide').hidden = !show; | |
| 187 // Setting [hidden] triggers a transition, which (when ended) will trigger | |
| 188 // this.toggleHidden_. | |
| 189 (show ? this.infographic_ : this.learnMore_).hidden = true; | |
| 190 }, | |
| 191 | |
| 192 /** @inheritDoc */ | 148 /** @inheritDoc */ |
| 193 sendConfiguration_: function() { | 149 sendConfiguration_: function() { |
| 194 chrome.send('SyncPromo:UserFlowAction', | 150 chrome.send('SyncPromo:UserFlowAction', |
| 195 [actions.CONFIRMED_AFTER_SIGN_IN]); | 151 [actions.CONFIRMED_AFTER_SIGN_IN]); |
| 196 options.SyncSetupOverlay.prototype.sendConfiguration_.apply(this, | 152 options.SyncSetupOverlay.prototype.sendConfiguration_.apply(this, |
| 197 arguments); | 153 arguments); |
| 198 }, | 154 }, |
| 199 | 155 |
| 200 /** @inheritDoc */ | 156 /** @inheritDoc */ |
| 201 setThrobbersVisible_: function(visible) { | 157 setThrobbersVisible_: function(visible) { |
| 202 if (visible) { | 158 if (visible) { |
| 203 this.throbberStart_ = Date.now(); | 159 this.throbberStart_ = Date.now(); |
| 204 } else { | 160 } else { |
| 205 if (this.throbberStart_) { | 161 if (this.throbberStart_) { |
| 206 chrome.send('SyncPromo:RecordThrobberTime', | 162 chrome.send('SyncPromo:RecordThrobberTime', |
| 207 [Date.now() - this.throbberStart_]); | 163 [Date.now() - this.throbberStart_]); |
| 208 } | 164 } |
| 209 this.throbberStart_ = 0; | 165 this.throbberStart_ = 0; |
| 210 } | 166 } |
| 211 // Pass through to SyncSetupOverlay to handle display logic. | 167 // Pass through to SyncSetupOverlay to handle display logic. |
| 212 options.SyncSetupOverlay.prototype.setThrobbersVisible_.apply( | 168 options.SyncSetupOverlay.prototype.setThrobbersVisible_.apply( |
| 213 this, arguments); | 169 this, arguments); |
| 214 }, | 170 }, |
| 215 | 171 |
| 216 /** | 172 /** |
| 217 * Shows the given promo version. Each version changes the UI slightly | |
| 218 * (for example, replacing text with an infographic). | |
| 219 * @param {Integer} the version of the promo. | |
| 220 * @private | |
| 221 */ | |
| 222 showPromoVersion_: function(version) { | |
| 223 document.documentElement.setAttribute('promo-version', version); | |
| 224 }, | |
| 225 | |
| 226 /** | |
| 227 * Number of times a user attempted to sign in to GAIA during this page | 173 * Number of times a user attempted to sign in to GAIA during this page |
| 228 * view. | 174 * view. |
| 229 * @private | 175 * @private |
| 230 */ | 176 */ |
| 231 signInAttempts_: 0, | 177 signInAttempts_: 0, |
| 232 | 178 |
| 233 /** | 179 /** |
| 234 * The start time of a throbber on the page. | 180 * The start time of a throbber on the page. |
| 235 * @private | 181 * @private |
| 236 */ | 182 */ |
| (...skipping 30 matching lines...) Expand all Loading... |
| 267 }; | 213 }; |
| 268 | 214 |
| 269 SyncPromo.recordPageViewActions = function() { | 215 SyncPromo.recordPageViewActions = function() { |
| 270 SyncPromo.getInstance().recordPageViewActions_(); | 216 SyncPromo.getInstance().recordPageViewActions_(); |
| 271 }; | 217 }; |
| 272 | 218 |
| 273 SyncPromo.populatePromoMessage = function(resName) { | 219 SyncPromo.populatePromoMessage = function(resName) { |
| 274 SyncPromo.getInstance().populatePromoMessage_(resName); | 220 SyncPromo.getInstance().populatePromoMessage_(resName); |
| 275 }; | 221 }; |
| 276 | 222 |
| 277 SyncPromo.showPromoVersion = function(version) { | |
| 278 SyncPromo.getInstance().showPromoVersion_(version); | |
| 279 }; | |
| 280 | |
| 281 // Export | 223 // Export |
| 282 return { | 224 return { |
| 283 SyncPromo: SyncPromo | 225 SyncPromo: SyncPromo |
| 284 }; | 226 }; |
| 285 }); | 227 }); |
| 286 | 228 |
| 287 var OptionsPage = options.OptionsPage; | 229 var OptionsPage = options.OptionsPage; |
| 288 var SyncSetupOverlay = sync_promo.SyncPromo; | 230 var SyncSetupOverlay = sync_promo.SyncPromo; |
| 289 window.addEventListener('DOMContentLoaded', sync_promo.SyncPromo.initialize); | 231 window.addEventListener('DOMContentLoaded', sync_promo.SyncPromo.initialize); |
| 290 window.addEventListener('beforeunload', | 232 window.addEventListener('beforeunload', |
| 291 sync_promo.SyncPromo.recordPageViewActions.bind(sync_promo.SyncPromo)); | 233 sync_promo.SyncPromo.recordPageViewActions.bind(sync_promo.SyncPromo)); |
| OLD | NEW |