| 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 onSwitch(e) { |
| 13 chrome.send('switch'); |
| 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', onSwitch); |
| 25 $('learnMoreLink').addEventListener('click', onLearnMore); |
| 26 chrome.send('initializedWithSize', [document.body.scrollHeight]); |
| 27 $('primaryConfirmButton').style.display = 'none'; |
| 28 } |
| 29 |
| 30 function clearFocus() { |
| 31 document.activeElement.blur(); |
| 32 } |
| 33 |
| 34 function onKeyDown(e) { |
| 35 // If the currently focused element isn't something that performs an action |
| 36 // on "enter" being pressed and the user hits "enter", perform the default |
| 37 // action of the dialog, which is "OK". |
| 38 if (e.key == 'Enter' && |
| 39 !/^(A|PAPER-BUTTON)$/.test(document.activeElement.tagName)) { |
| 40 $('primaryConfirmButton').click(); |
| 41 e.preventDefault(); |
| 42 } |
| 43 } |
| 44 |
| 45 function removeSwitchButton() { |
| 46 $('switchButton').style.display = 'none'; |
| 47 $('secondaryConfirmButton').style.display = 'none'; |
| 48 $('primaryConfirmButton').style.display = ''; |
| 49 } |
| 50 |
| 51 return { |
| 52 clearFocus: clearFocus, |
| 53 initialize: initialize, |
| 54 removeSwitchButton: removeSwitchButton |
| 55 }; |
| 56 }); |
| 57 |
| 58 document.addEventListener('DOMContentLoaded', signin.error.initialize); |
| OLD | NEW |