Chromium Code Reviews| Index: chrome/browser/resources/signin_error/signin_error.js |
| diff --git a/chrome/browser/resources/signin_error/signin_error.js b/chrome/browser/resources/signin_error/signin_error.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..28c179beaffa91e68d1b92307486d78e4a947e32 |
| --- /dev/null |
| +++ b/chrome/browser/resources/signin_error/signin_error.js |
| @@ -0,0 +1,57 @@ |
| +/* Copyright 2016 The Chromium Authors. All rights reserved. |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. */ |
| + |
| +cr.define('signin.error', function() { |
| + 'use strict'; |
| + |
| + function onConfirm(e) { |
| + chrome.send('confirm'); |
| + } |
| + |
| + function onSwitchToExistingProfile(e) { |
| + chrome.send('switchToExistingProfile'); |
| + } |
| + |
| + function onLearnMore(e) { |
| + chrome.send('learnMore'); |
| + } |
| + |
| + function initialize() { |
| + document.addEventListener('keydown', onKeyDown); |
| + $('primaryConfirmButton').addEventListener('click', onConfirm); |
| + $('secondaryConfirmButton').addEventListener('click', onConfirm); |
| + $('switchButton').addEventListener('click', onSwitchToExistingProfile); |
| + $('learnMoreLink').addEventListener('click', onLearnMore); |
| + chrome.send('initializedWithSize', [document.body.scrollHeight]); |
| + } |
| + |
| + 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
|
| + document.activeElement.blur(); |
| + } |
| + |
| + 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
|
| + // If the currently focused element isn't something that performs an action |
| + // on "enter" being pressed and the user hits "enter", perform the default |
| + // action of the dialog, which is "OK". |
| + if (e.key == 'Enter' && |
| + !/^(A|PAPER-BUTTON)$/.test(document.activeElement.tagName)) { |
| + $('primaryConfirmButton').click(); |
| + e.preventDefault(); |
| + } |
| + } |
| + |
| + function removeSwitchButton() { |
| + $('switchButton').style.display = 'none'; |
| + $('secondaryConfirmButton').style.display = 'none'; |
| + $('primaryConfirmButton').style.display = ''; |
| + } |
| + |
| + return { |
| + clearFocus: clearFocus, |
| + initialize: initialize, |
| + removeSwitchButton: removeSwitchButton |
| + }; |
| +}); |
| + |
| +document.addEventListener('DOMContentLoaded', signin.error.initialize); |