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

Side by Side Diff: chrome/browser/resources/signin/signin_error/signin_error.js

Issue 2298503002: [Signin Error Dialog] (1/3) Adds necessary web components (Closed)
Patch Set: Address feedback. Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 /* Copyright 2015 The Chromium Authors. All rights reserved. 1 /* Copyright 2016 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('sync.confirmation', function() { 5 cr.define('signin.error', function() {
6 'use strict'; 6 'use strict';
7 7
8 function onConfirm(e) {
9 chrome.send('confirm');
10 }
11
12 function onUndo(e) {
13 chrome.send('undo');
14 }
15
16 function onGoToSettings(e) {
17 chrome.send('goToSettings');
18 }
19
20 function initialize() { 8 function initialize() {
21 document.addEventListener('keydown', onKeyDown); 9 document.addEventListener('keydown', onKeyDown);
22 $('confirmButton').addEventListener('click', onConfirm); 10 $('confirmButton').addEventListener('click', onConfirm);
23 $('undoButton').addEventListener('click', onUndo); 11 $('closeButton').addEventListener('click', onConfirm);
24 $('settingsLink').addEventListener('click', onGoToSettings); 12 $('switchButton').addEventListener('click', onSwitchToExistingProfile);
25 $('profile-picture').addEventListener('load', onPictureLoaded); 13 $('learnMoreLink').addEventListener('click', onLearnMore);
26 chrome.send('initializedWithSize', [document.body.scrollHeight]); 14 chrome.send('initializedWithSize', [document.body.scrollHeight]);
27 } 15 }
28 16
29 function clearFocus() {
30 document.activeElement.blur();
31 }
32
33 function setUserImageURL(url) {
34 $('profile-picture').src = url;
35 }
36
37 function onPictureLoaded(e) {
38 $('picture-container').classList.add('loaded');
39 }
40
41 function onKeyDown(e) { 17 function onKeyDown(e) {
42 // If the currently focused element isn't something that performs an action 18 // If the currently focused element isn't something that performs an action
43 // on "enter" being pressed and the user hits "enter", perform the default 19 // on "enter" being pressed and the user hits "enter", perform the default
44 // action of the dialog, which is "OK, Got It". 20 // action of the dialog, which is "OK".
45 if (e.key == 'Enter' && 21 if (e.key == 'Enter' &&
46 !/^(A|PAPER-BUTTON)$/.test(document.activeElement.tagName)) { 22 !/^(A|PAPER-BUTTON)$/.test(document.activeElement.tagName)) {
47 $('confirmButton').click(); 23 $('confirmButton').click();
48 e.preventDefault(); 24 e.preventDefault();
49 } 25 }
50 } 26 }
51 27
28 function onConfirm(e) {
29 chrome.send('confirm');
30 }
31
32 function onSwitchToExistingProfile(e) {
33 chrome.send('switchToExistingProfile');
34 }
35
36 function onLearnMore(e) {
37 chrome.send('learnMore');
38 }
39
40 function clearFocus() {
41 document.activeElement.blur();
42 }
43
44 function removeSwitchButton() {
45 $('switchButton').hidden = true;
46 $('closeButton').hidden = true;
47 $('confirmButton').hidden = false;
48 }
49
52 return { 50 return {
51 initialize: initialize,
53 clearFocus: clearFocus, 52 clearFocus: clearFocus,
54 initialize: initialize, 53 removeSwitchButton: removeSwitchButton
55 setUserImageURL: setUserImageURL
56 }; 54 };
57 }); 55 });
58 56
59 document.addEventListener('DOMContentLoaded', sync.confirmation.initialize); 57 document.addEventListener('DOMContentLoaded', signin.error.initialize);
OLDNEW
« no previous file with comments | « chrome/browser/resources/signin/signin_error/signin_error.html ('k') | chrome/browser/resources/signin/signin_shared_css.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698