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 cr.define('options', function() { | 5 cr.define('options', function() { |
6 /** @const */ var OptionsPage = options.OptionsPage; | 6 /** @const */ var OptionsPage = options.OptionsPage; |
7 | 7 |
8 // Variable to track if a captcha challenge was issued. If this gets set to | 8 // Variable to track if a captcha challenge was issued. If this gets set to |
9 // true, it stays that way until we are told about successful login from | 9 // true, it stays that way until we are told about successful login from |
10 // the browser. This means subsequent errors (like invalid password) are | 10 // the browser. This means subsequent errors (like invalid password) are |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 'passphrase': customPassphrase | 236 'passphrase': customPassphrase |
237 }); | 237 }); |
238 chrome.send('SyncSetupConfigure', [result]); | 238 chrome.send('SyncSetupConfigure', [result]); |
239 }, | 239 }, |
240 | 240 |
241 /** | 241 /** |
242 * Sets the disabled property of all input elements within the 'Customize | 242 * Sets the disabled property of all input elements within the 'Customize |
243 * Sync Preferences' screen. This is used to prohibit the user from changing | 243 * Sync Preferences' screen. This is used to prohibit the user from changing |
244 * the inputs after confirming the customized sync preferences, or resetting | 244 * the inputs after confirming the customized sync preferences, or resetting |
245 * the state when re-showing the dialog. | 245 * the state when re-showing the dialog. |
246 * @param disabled True if controls should be set to disabled. | 246 * @param {boolean} disabled True if controls should be set to disabled. |
247 * @private | 247 * @private |
248 */ | 248 */ |
249 setInputElementsDisabledState_: function(disabled) { | 249 setInputElementsDisabledState_: function(disabled) { |
250 var configureElements = | 250 var configureElements = |
251 $('customize-sync-preferences').querySelectorAll('input'); | 251 $('customize-sync-preferences').querySelectorAll('input'); |
252 for (var i = 0; i < configureElements.length; i++) | 252 for (var i = 0; i < configureElements.length; i++) |
253 configureElements[i].disabled = disabled; | 253 configureElements[i].disabled = disabled; |
254 $('sync-select-datatypes').disabled = disabled; | 254 $('sync-select-datatypes').disabled = disabled; |
255 | 255 |
256 var self = this; | 256 var self = this; |
257 this.animateDisableLink_($('customize-link'), disabled, function() { | 257 this.animateDisableLink_($('customize-link'), disabled, function() { |
258 self.showCustomizePage_(null, true); | 258 self.showCustomizePage_(null, true); |
259 }); | 259 }); |
260 }, | 260 }, |
261 | 261 |
262 /** | 262 /** |
263 * Animate a link being enabled/disabled. The link is hidden by animating | 263 * Animate a link being enabled/disabled. The link is hidden by animating |
264 * its opacity, but to ensure the user doesn't click it during that time, | 264 * its opacity, but to ensure the user doesn't click it during that time, |
265 * its onclick handler is changed to null as well. | 265 * its onclick handler is changed to null as well. |
266 * @param elt The anchor element to enable/disable. | 266 * @param {HTMLElement} elt The anchor element to enable/disable. |
267 * @param disabled True if the link should be disabled. | 267 * @param {boolean} disabled True if the link should be disabled. |
268 * @param enabledFunction The onclick handler when the link is enabled. | 268 * @param {function} enabledFunction The onclick handler when the link is |
| 269 * enabled. |
269 * @private | 270 * @private |
270 */ | 271 */ |
271 animateDisableLink_: function(elt, disabled, enabledFunction) { | 272 animateDisableLink_: function(elt, disabled, enabledFunction) { |
272 if (disabled) { | 273 if (disabled) { |
273 elt.classList.add('transparent'); | 274 elt.classList.add('transparent'); |
274 elt.onclick = null; | 275 elt.onclick = null; |
275 elt.addEventListener('webkitTransitionEnd', function f(e) { | 276 elt.addEventListener('webkitTransitionEnd', function f(e) { |
276 if (e.propertyName != 'opacity') | 277 if (e.propertyName != 'opacity') |
277 return; | 278 return; |
278 elt.removeEventListener('webkitTransitionEnd', f); | 279 elt.removeEventListener('webkitTransitionEnd', f); |
279 elt.classList.remove('transparent'); | 280 elt.classList.remove('transparent'); |
280 elt.hidden = true; | 281 elt.hidden = true; |
281 }); | 282 }); |
282 } else { | 283 } else { |
283 elt.hidden = false; | 284 elt.hidden = false; |
284 elt.onclick = enabledFunction; | 285 elt.onclick = enabledFunction; |
285 } | 286 } |
286 }, | 287 }, |
287 | 288 |
288 setChooseDataTypesCheckboxes_: function(args) { | 289 setChooseDataTypesCheckboxes_: function(args) { |
289 var datatypeSelect = document.getElementById('sync-select-datatypes'); | 290 var datatypeSelect = $('sync-select-datatypes'); |
290 datatypeSelect.selectedIndex = args.syncAllDataTypes ? 0 : 1; | 291 datatypeSelect.selectedIndex = args.syncAllDataTypes ? 0 : 1; |
291 | 292 |
292 $('bookmarks-checkbox').checked = args.sync_bookmarks; | 293 $('bookmarks-checkbox').checked = args.sync_bookmarks; |
293 $('preferences-checkbox').checked = args.sync_preferences; | 294 $('preferences-checkbox').checked = args.sync_preferences; |
294 $('themes-checkbox').checked = args.sync_themes; | 295 $('themes-checkbox').checked = args.sync_themes; |
295 | 296 |
296 if (args.passwords_registered) { | 297 if (args.passwords_registered) { |
297 $('passwords-checkbox').checked = args.sync_passwords; | 298 $('passwords-checkbox').checked = args.sync_passwords; |
298 $('passwords-item').hidden = false; | 299 $('passwords-item').hidden = false; |
299 } else { | 300 } else { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 } | 356 } |
356 }, | 357 }, |
357 | 358 |
358 setCheckboxesAndErrors_: function(args) { | 359 setCheckboxesAndErrors_: function(args) { |
359 this.setChooseDataTypesCheckboxes_(args); | 360 this.setChooseDataTypesCheckboxes_(args); |
360 this.setEncryptionRadios_(args); | 361 this.setEncryptionRadios_(args); |
361 this.setPassphraseRadios_(args); | 362 this.setPassphraseRadios_(args); |
362 }, | 363 }, |
363 | 364 |
364 showConfigure_: function(args) { | 365 showConfigure_: function(args) { |
365 var datatypeSelect = document.getElementById('sync-select-datatypes'); | 366 var datatypeSelect = $('sync-select-datatypes'); |
366 var self = this; | 367 var self = this; |
367 datatypeSelect.onchange = function() { | 368 datatypeSelect.onchange = function() { |
368 var syncAll = this.selectedIndex == 0; | 369 var syncAll = this.selectedIndex == 0; |
369 self.setCheckboxesToKeepEverythingSynced_(syncAll); | 370 self.setCheckboxesToKeepEverythingSynced_(syncAll); |
370 }; | 371 }; |
371 | 372 |
372 this.resetPage_('sync-setup-configure'); | 373 this.resetPage_('sync-setup-configure'); |
373 $('sync-setup-configure').hidden = false; | 374 $('sync-setup-configure').hidden = false; |
374 | 375 |
375 // onsubmit is changed when submitting a passphrase. Reset it to its | 376 // onsubmit is changed when submitting a passphrase. Reset it to its |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 $('confirm-sync-preferences').hidden = true; | 469 $('confirm-sync-preferences').hidden = true; |
469 $('customize-sync-preferences').hidden = false; | 470 $('customize-sync-preferences').hidden = false; |
470 | 471 |
471 $('sync-custom-passphrase-container').hidden = false; | 472 $('sync-custom-passphrase-container').hidden = false; |
472 $('sync-existing-passphrase-container').hidden = true; | 473 $('sync-existing-passphrase-container').hidden = true; |
473 | 474 |
474 // If the user has selected the 'Customize' page on initial set up, it's | 475 // If the user has selected the 'Customize' page on initial set up, it's |
475 // likely he intends to change the data types. Select the | 476 // likely he intends to change the data types. Select the |
476 // 'Choose data types' option in this case. | 477 // 'Choose data types' option in this case. |
477 var index = syncEverything ? 0 : 1; | 478 var index = syncEverything ? 0 : 1; |
478 document.getElementById('sync-select-datatypes').selectedIndex = index; | 479 $('sync-select-datatypes').selectedIndex = index; |
479 this.setDataTypeCheckboxesEnabled_(!syncEverything); | 480 this.setDataTypeCheckboxesEnabled_(!syncEverything); |
480 | 481 |
481 // The passphrase input may need to take over focus from the OK button, so | 482 // The passphrase input may need to take over focus from the OK button, so |
482 // set focus before that logic. | 483 // set focus before that logic. |
483 $('choose-datatypes-ok').focus(); | 484 $('choose-datatypes-ok').focus(); |
484 | 485 |
485 if (args && args['show_passphrase']) { | 486 if (args && args['show_passphrase']) { |
486 this.showPassphraseContainer_(args); | 487 this.showPassphraseContainer_(args); |
487 } else { | 488 } else { |
488 // We only show the 'Use Default' link if we're not prompting for an | 489 // We only show the 'Use Default' link if we're not prompting for an |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 $('gaia-passwd').disabled = false; | 608 $('gaia-passwd').disabled = false; |
608 $('captcha-value').disabled = false; | 609 $('captcha-value').disabled = false; |
609 $('captcha-wrapper').style.backgroundImage = url(args.captchaUrl); | 610 $('captcha-wrapper').style.backgroundImage = url(args.captchaUrl); |
610 }, | 611 }, |
611 | 612 |
612 /** | 613 /** |
613 * Reset the state of all descendant elements of a root element to their | 614 * Reset the state of all descendant elements of a root element to their |
614 * initial state. | 615 * initial state. |
615 * The initial state is specified by adding a class to the descendant | 616 * The initial state is specified by adding a class to the descendant |
616 * element in sync_setup_overlay.html. | 617 * element in sync_setup_overlay.html. |
617 * @param pageElementId The root page element id. | 618 * @param {HTMLElement} pageElementId The root page element id. |
618 * @private | 619 * @private |
619 */ | 620 */ |
620 resetPage_: function(pageElementId) { | 621 resetPage_: function(pageElementId) { |
621 var page = $(pageElementId); | 622 var page = $(pageElementId); |
622 var forEach = function(arr, fn) { | 623 var forEach = function(arr, fn) { |
623 var length = arr.length; | 624 var length = arr.length; |
624 for (var i = 0; i < length; i++) { | 625 for (var i = 0; i < length; i++) { |
625 fn(arr[i]); | 626 fn(arr[i]); |
626 } | 627 } |
627 }; | 628 }; |
(...skipping 20 matching lines...) Expand all Loading... |
648 var email = $('gaia-email'); | 649 var email = $('gaia-email'); |
649 var passwd = $('gaia-passwd'); | 650 var passwd = $('gaia-passwd'); |
650 if (f) { | 651 if (f) { |
651 if (args.user != undefined) { | 652 if (args.user != undefined) { |
652 if (email.value != args.user) | 653 if (email.value != args.user) |
653 passwd.value = ''; // Reset the password field | 654 passwd.value = ''; // Reset the password field |
654 email.value = args.user; | 655 email.value = args.user; |
655 } | 656 } |
656 | 657 |
657 if (!args.editable_user) { | 658 if (!args.editable_user) { |
658 email.hidden = true; | 659 $('email-row').hidden = true; |
659 var span = $('email-readonly'); | 660 var span = $('email-readonly'); |
660 span.textContent = email.value; | 661 span.textContent = email.value; |
661 span.hidden = false; | 662 $('email-readonly-row').hidden = false; |
662 $('create-account-div').hidden = true; | 663 $('create-account-div').hidden = true; |
663 } | 664 } |
664 | 665 |
665 f.accessCode.disabled = true; | 666 f.accessCode.disabled = true; |
666 } | 667 } |
667 | 668 |
668 if (1 == args.error) { | 669 if (1 == args.error) { |
669 var access_code = document.getElementById('access-code'); | 670 var access_code = $('access-code'); |
670 if (access_code.value) { | 671 if (access_code.value) { |
671 $('errormsg-0-access-code').hidden = false; | 672 $('errormsg-0-access-code').hidden = false; |
672 this.showAccessCodeRequired_(); | 673 this.showAccessCodeRequired_(); |
673 } else { | 674 } else { |
674 $('errormsg-1-password').hidden = false; | 675 $('errormsg-1-password').hidden = false; |
675 } | 676 } |
676 this.setBlurbError_(args.error_message); | 677 this.setBlurbError_(args.error_message); |
677 } else if (3 == args.error) { | 678 } else if (3 == args.error) { |
678 $('errormsg-0-connection').hidden = false; | 679 $('errormsg-0-connection').hidden = false; |
679 this.setBlurbError_(args.error_message); | 680 this.setBlurbError_(args.error_message); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
879 | 880 |
880 SyncSetupOverlay.showStopSyncingUI = function() { | 881 SyncSetupOverlay.showStopSyncingUI = function() { |
881 SyncSetupOverlay.getInstance().showStopSyncingUI_(); | 882 SyncSetupOverlay.getInstance().showStopSyncingUI_(); |
882 }; | 883 }; |
883 | 884 |
884 // Export | 885 // Export |
885 return { | 886 return { |
886 SyncSetupOverlay: SyncSetupOverlay | 887 SyncSetupOverlay: SyncSetupOverlay |
887 }; | 888 }; |
888 }); | 889 }); |
OLD | NEW |