OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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('options', function() { |
| 6 var Page = cr.ui.pageManager.Page; |
| 7 var PageManager = cr.ui.pageManager.PageManager; |
| 8 |
| 9 /** |
| 10 * EasyUnlockTurnOffOverlay class |
| 11 * Encapsulated handling of the Factory Reset confirmation overlay page. |
| 12 * @class |
| 13 */ |
| 14 function EasyUnlockTurnOffOverlay() { |
| 15 Page.call(this, 'easyUnlockTurnOffOverlay', |
| 16 loadTimeData.getString('easyUnlockTurnOffTitle'), |
| 17 'easy-unlock-turn-off-overlay'); |
| 18 } |
| 19 |
| 20 cr.addSingletonGetter(EasyUnlockTurnOffOverlay); |
| 21 |
| 22 EasyUnlockTurnOffOverlay.prototype = { |
| 23 // Inherit EasyUnlockTurnOffOverlay from Page. |
| 24 __proto__: Page.prototype, |
| 25 |
| 26 /** @override */ |
| 27 initializePage: function() { |
| 28 Page.prototype.initializePage.call(this); |
| 29 |
| 30 $('easy-unlock-turn-off-dismiss').onclick = function(event) { |
| 31 EasyUnlockTurnOffOverlay.dismiss(); |
| 32 }; |
| 33 $('easy-unlock-turn-off-confirm').onclick = function(event) { |
| 34 $('easy-unlock-turn-off-confirm').disabled = true; |
| 35 this.setSpinnerVisible_(true); |
| 36 |
| 37 // TODO(xiyuan): Wire this up. |
| 38 // chrome.send('turnOffEasyUnlock'); |
| 39 }.bind(this); |
| 40 }, |
| 41 |
| 42 /** @override */ |
| 43 didShowPage: function() { |
| 44 if (navigator.onLine) { |
| 45 this.setUpTurnOffUI_(); |
| 46 } else { |
| 47 this.setUpOfflineUI_(); |
| 48 } |
| 49 }, |
| 50 |
| 51 /** |
| 52 * Returns the button strip element. |
| 53 * @return {HTMLDivElement} The container div of action buttons. |
| 54 */ |
| 55 get buttonStrip() { |
| 56 return this.pageDiv.querySelector('.button-strip'); |
| 57 }, |
| 58 |
| 59 /** |
| 60 * Set visibility of action buttons in button strip. |
| 61 * @private |
| 62 */ |
| 63 setActionButtonsVisible_: function(visible) { |
| 64 var buttons = this.buttonStrip.querySelectorAll('button'); |
| 65 for (var i = 0; i < buttons.length; ++i) { |
| 66 buttons[i].hidden = !visible; |
| 67 } |
| 68 }, |
| 69 |
| 70 /** |
| 71 * Set visibility of spinner. |
| 72 * @private |
| 73 */ |
| 74 setSpinnerVisible_: function(visible) { |
| 75 $('easy-unlock-turn-off-spinner').hidden = !visible; |
| 76 }, |
| 77 |
| 78 /** |
| 79 * Set up UI for showing offline message. |
| 80 * @private |
| 81 */ |
| 82 setUpOfflineUI_: function() { |
| 83 $('easy-unlock-turn-off-title').textContent = |
| 84 loadTimeData.getString('easyUnlockTurnOffOfflineTitle'); |
| 85 $('easy-unlock-turn-off-messagee').textContent = |
| 86 loadTimeData.getString('easyUnlockTurnOffOfflineMessage'); |
| 87 |
| 88 this.setActionButtonsVisible_(false); |
| 89 this.setSpinnerVisible_(false); |
| 90 }, |
| 91 |
| 92 /** |
| 93 * Set up UI for turning off Easy Unlock. |
| 94 * @private |
| 95 */ |
| 96 setUpTurnOffUI_: function() { |
| 97 $('easy-unlock-turn-off-title').textContent = |
| 98 loadTimeData.getString('easyUnlockTurnOffTitle'); |
| 99 $('easy-unlock-turn-off-messagee').textContent = |
| 100 loadTimeData.getString('easyUnlockTurnOffDescription'); |
| 101 $('easy-unlock-turn-off-confirm').textContent = |
| 102 loadTimeData.getString('easyUnlockTurnOffButton'); |
| 103 |
| 104 this.setActionButtonsVisible_(true); |
| 105 this.setSpinnerVisible_(false); |
| 106 $('easy-unlock-turn-off-confirm').disabled = false; |
| 107 $('easy-unlock-turn-off-dismiss').hidden = false; |
| 108 }, |
| 109 |
| 110 /** |
| 111 * Set up UI for showing server error. |
| 112 * @private |
| 113 */ |
| 114 setUpServerErrorUI_: function() { |
| 115 $('easy-unlock-turn-off-title').textContent = |
| 116 loadTimeData.getString('easyUnlockTurnOffErrorTitle'); |
| 117 $('easy-unlock-turn-off-messagee').textContent = |
| 118 loadTimeData.getString('easyUnlockTurnOffErrorMessage'); |
| 119 $('easy-unlock-turn-off-confirm').textContent = |
| 120 loadTimeData.getString('easyUnlockTurnOffRetryButton'); |
| 121 |
| 122 this.setActionButtonsVisible_(true); |
| 123 this.setSpinnerVisible_(false); |
| 124 $('easy-unlock-turn-off-confirm').disabled = false; |
| 125 $('easy-unlock-turn-off-dismiss').hidden = true; |
| 126 }, |
| 127 }; |
| 128 |
| 129 EasyUnlockTurnOffOverlay.dismiss = function() { |
| 130 PageManager.closeOverlay(); |
| 131 }; |
| 132 |
| 133 // Export |
| 134 return { |
| 135 EasyUnlockTurnOffOverlay: EasyUnlockTurnOffOverlay |
| 136 }; |
| 137 }); |
OLD | NEW |