| OLD | NEW |
| 1 /* Copyright 2016 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('signin.error', function() { | 5 cr.define('signin.error', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 function initialize() { | 8 function initialize() { |
| 9 document.addEventListener('keydown', onKeyDown); | 9 document.addEventListener('keydown', onKeyDown); |
| 10 $('confirmButton').addEventListener('click', onConfirm); | 10 $('confirmButton').addEventListener('click', onConfirm); |
| 11 $('closeButton').addEventListener('click', onConfirm); | 11 $('closeButton').addEventListener('click', onConfirm); |
| 12 $('switchButton').addEventListener('click', onSwitchToExistingProfile); | 12 $('switchButton').addEventListener('click', onSwitchToExistingProfile); |
| 13 $('learnMoreLink').addEventListener('click', onLearnMore); | 13 $('learnMoreLink').addEventListener('click', onLearnMore); |
| 14 if (loadTimeData.getBoolean('isSystemProfile')) { | 14 if (loadTimeData.getBoolean('isSystemProfile')) { |
| 15 $('learnMoreLink').hidden = true; | 15 $('learnMoreLink').hidden = true; |
| 16 } | 16 } |
| 17 chrome.send('initializedWithSize', [document.body.scrollHeight]); | 17 |
| 18 // Prefer using |document.body.offsetHeight| instead of |
| 19 // |document.body.scrollHeight| as it returns the correct height of the |
| 20 // even when the page zoom in Chrome is different than 100%. |
| 21 chrome.send('initializedWithSize', [document.body.offsetHeight]); |
| 18 } | 22 } |
| 19 | 23 |
| 20 function onKeyDown(e) { | 24 function onKeyDown(e) { |
| 21 // If the currently focused element isn't something that performs an action | 25 // If the currently focused element isn't something that performs an action |
| 22 // on "enter" being pressed and the user hits "enter", perform the default | 26 // on "enter" being pressed and the user hits "enter", perform the default |
| 23 // action of the dialog, which is "OK". | 27 // action of the dialog, which is "OK". |
| 24 if (e.key == 'Enter' && | 28 if (e.key == 'Enter' && |
| 25 !/^(A|PAPER-BUTTON)$/.test(document.activeElement.tagName)) { | 29 !/^(A|PAPER-BUTTON)$/.test(document.activeElement.tagName)) { |
| 26 $('confirmButton').click(); | 30 $('confirmButton').click(); |
| 27 e.preventDefault(); | 31 e.preventDefault(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 51 } | 55 } |
| 52 | 56 |
| 53 return { | 57 return { |
| 54 initialize: initialize, | 58 initialize: initialize, |
| 55 clearFocus: clearFocus, | 59 clearFocus: clearFocus, |
| 56 removeSwitchButton: removeSwitchButton | 60 removeSwitchButton: removeSwitchButton |
| 57 }; | 61 }; |
| 58 }); | 62 }); |
| 59 | 63 |
| 60 document.addEventListener('DOMContentLoaded', signin.error.initialize); | 64 document.addEventListener('DOMContentLoaded', signin.error.initialize); |
| OLD | NEW |