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

Side by Side Diff: chrome/browser/resources/sync_confirmation/sync_confirmation.js

Issue 1949613003: Clear initial focus in Sync Confirmation dialog. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit tests Created 4 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/ui/webui/signin/sync_confirmation_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright 2015 The Chromium Authors. All rights reserved. 1 /* Copyright 2015 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('sync.confirmation', function() {
6 'use strict'; 6 'use strict';
7 7
8 function onConfirm(e) { 8 function onConfirm(e) {
9 chrome.send('confirm'); 9 chrome.send('confirm');
10 } 10 }
11 11
12 function onUndo(e) { 12 function onUndo(e) {
13 chrome.send('undo'); 13 chrome.send('undo');
14 } 14 }
15 15
16 function onGoToSettings(e) { 16 function onGoToSettings(e) {
17 chrome.send('goToSettings'); 17 chrome.send('goToSettings');
18 } 18 }
19 19
20 function initialize() { 20 function initialize() {
21 document.addEventListener('keydown', onKeyDown); 21 document.addEventListener('keydown', onKeyDown);
22 $('confirmButton').addEventListener('click', onConfirm); 22 $('confirmButton').addEventListener('click', onConfirm);
23 $('undoButton').addEventListener('click', onUndo); 23 $('undoButton').addEventListener('click', onUndo);
24 $('settingsLink').addEventListener('click', onGoToSettings); 24 $('settingsLink').addEventListener('click', onGoToSettings);
25 $('profile-picture').addEventListener('load', onPictureLoaded); 25 $('profile-picture').addEventListener('load', onPictureLoaded);
26 chrome.send('initializedWithSize', [document.body.scrollHeight]); 26 chrome.send('initializedWithSize', [document.body.scrollHeight]);
27 } 27 }
28 28
29 function clearFocus() {
30 document.activeElement.blur();
31 }
32
29 function setUserImageURL(url) { 33 function setUserImageURL(url) {
30 $('profile-picture').src = url; 34 $('profile-picture').src = url;
31 } 35 }
32 36
33 function onPictureLoaded(e) { 37 function onPictureLoaded(e) {
34 $('picture-container').classList.add('loaded'); 38 $('picture-container').classList.add('loaded');
35 } 39 }
36 40
37 function onKeyDown(e) { 41 function onKeyDown(e) {
38 // If the currently focused element isn't something that performs an action 42 // If the currently focused element isn't something that performs an action
39 // on "enter" being pressed and the user hits "enter", perform the default 43 // on "enter" being pressed and the user hits "enter", perform the default
40 // action of the dialog, which is "OK, Got It". 44 // action of the dialog, which is "OK, Got It".
41 if (e.keyIdentifier == 'Enter' && 45 if (e.keyIdentifier == 'Enter' &&
42 !/^(A|PAPER-BUTTON)$/.test(document.activeElement.tagName)) { 46 !/^(A|PAPER-BUTTON)$/.test(document.activeElement.tagName)) {
43 $('confirmButton').click(); 47 $('confirmButton').click();
44 e.preventDefault(); 48 e.preventDefault();
45 } 49 }
46 } 50 }
47 51
48 return { 52 return {
53 clearFocus: clearFocus,
49 initialize: initialize, 54 initialize: initialize,
50 setUserImageURL: setUserImageURL 55 setUserImageURL: setUserImageURL
51 }; 56 };
52 }); 57 });
53 58
54 document.addEventListener('DOMContentLoaded', sync.confirmation.initialize); 59 document.addEventListener('DOMContentLoaded', sync.confirmation.initialize);
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/signin/sync_confirmation_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698