OLD | NEW |
---|---|
(Empty) | |
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 | |
3 * found in the LICENSE file. */ | |
4 | |
5 cr.define('signin.error', function() { | |
6 'use strict'; | |
7 | |
8 function onConfirm(e) { | |
9 chrome.send('confirm'); | |
10 } | |
11 | |
12 function onSwitchToExistingProfile(e) { | |
13 chrome.send('switchToExistingProfile'); | |
14 } | |
15 | |
16 function onLearnMore(e) { | |
17 chrome.send('learnMore'); | |
18 } | |
19 | |
20 function initialize() { | |
21 document.addEventListener('keydown', onKeyDown); | |
22 $('primaryConfirmButton').addEventListener('click', onConfirm); | |
23 $('secondaryConfirmButton').addEventListener('click', onConfirm); | |
24 $('switchButton').addEventListener('click', onSwitchToExistingProfile); | |
25 $('learnMoreLink').addEventListener('click', onLearnMore); | |
26 chrome.send('initializedWithSize', [document.body.scrollHeight]); | |
27 } | |
28 | |
29 function clearFocus() { | |
tommycli
2016/08/24 17:22:52
Can we confirm that this is still needed? Esp. if
Jane
2016/08/25 16:35:29
Confirmed that on mac, the "Learn more" link would
| |
30 document.activeElement.blur(); | |
31 } | |
32 | |
33 function onKeyDown(e) { | |
tommycli
2016/08/24 17:22:52
nit: would be good to make the order of these func
Jane
2016/08/25 16:35:29
Done nit.
I talked to anthonyvd@ who did this for
| |
34 // If the currently focused element isn't something that performs an action | |
35 // on "enter" being pressed and the user hits "enter", perform the default | |
36 // action of the dialog, which is "OK". | |
37 if (e.key == 'Enter' && | |
38 !/^(A|PAPER-BUTTON)$/.test(document.activeElement.tagName)) { | |
39 $('primaryConfirmButton').click(); | |
40 e.preventDefault(); | |
41 } | |
42 } | |
43 | |
44 function removeSwitchButton() { | |
45 $('switchButton').style.display = 'none'; | |
46 $('secondaryConfirmButton').style.display = 'none'; | |
47 $('primaryConfirmButton').style.display = ''; | |
48 } | |
49 | |
50 return { | |
51 clearFocus: clearFocus, | |
52 initialize: initialize, | |
53 removeSwitchButton: removeSwitchButton | |
54 }; | |
55 }); | |
56 | |
57 document.addEventListener('DOMContentLoaded', signin.error.initialize); | |
OLD | NEW |