OLD | NEW |
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 if (loadTimeData.getBoolean('isSyncAllowed')) { |
25 $('profile-picture').addEventListener('load', onPictureLoaded); | 25 $('settingsLink').addEventListener('click', onGoToSettings); |
| 26 $('profile-picture').addEventListener('load', onPictureLoaded); |
| 27 $('syncDisabledDetails').hidden = true; |
| 28 } else { |
| 29 $('syncConfirmationDetails').hidden = true; |
| 30 } |
26 chrome.send('initializedWithSize', [document.body.scrollHeight]); | 31 chrome.send('initializedWithSize', [document.body.scrollHeight]); |
27 } | 32 } |
28 | 33 |
29 function clearFocus() { | 34 function clearFocus() { |
30 document.activeElement.blur(); | 35 document.activeElement.blur(); |
31 } | 36 } |
32 | 37 |
33 function setUserImageURL(url) { | 38 function setUserImageURL(url) { |
34 $('profile-picture').src = url; | 39 if (loadTimeData.getBoolean('isSyncAllowed')) { |
| 40 $('profile-picture').src = url; |
| 41 } |
35 } | 42 } |
36 | 43 |
37 function onPictureLoaded(e) { | 44 function onPictureLoaded(e) { |
38 $('picture-container').classList.add('loaded'); | 45 if (loadTimeData.getBoolean('isSyncAllowed')) { |
| 46 $('picture-container').classList.add('loaded'); |
| 47 } |
39 } | 48 } |
40 | 49 |
41 function onKeyDown(e) { | 50 function onKeyDown(e) { |
42 // If the currently focused element isn't something that performs an action | 51 // If the currently focused element isn't something that performs an action |
43 // on "enter" being pressed and the user hits "enter", perform the default | 52 // on "enter" being pressed and the user hits "enter", perform the default |
44 // action of the dialog, which is "OK, Got It". | 53 // action of the dialog, which is "OK, Got It". |
45 if (e.key == 'Enter' && | 54 if (e.key == 'Enter' && |
46 !/^(A|PAPER-BUTTON)$/.test(document.activeElement.tagName)) { | 55 !/^(A|PAPER-BUTTON)$/.test(document.activeElement.tagName)) { |
47 $('confirmButton').click(); | 56 $('confirmButton').click(); |
48 e.preventDefault(); | 57 e.preventDefault(); |
49 } | 58 } |
50 } | 59 } |
51 | 60 |
52 return { | 61 return { |
53 clearFocus: clearFocus, | 62 clearFocus: clearFocus, |
54 initialize: initialize, | 63 initialize: initialize, |
55 setUserImageURL: setUserImageURL | 64 setUserImageURL: setUserImageURL |
56 }; | 65 }; |
57 }); | 66 }); |
58 | 67 |
59 document.addEventListener('DOMContentLoaded', sync.confirmation.initialize); | 68 document.addEventListener('DOMContentLoaded', sync.confirmation.initialize); |
OLD | NEW |