| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 5 |
| 6 cr.define('mobile', function() { | 6 cr.define('mobile', function() { |
| 7 | 7 |
| 8 function MobileSetup() { | 8 function MobileSetup() { |
| 9 } | 9 } |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // UI states. | 43 // UI states. |
| 44 state_ : -1, | 44 state_ : -1, |
| 45 STATE_UNKNOWN_: "unknown", | 45 STATE_UNKNOWN_: "unknown", |
| 46 STATE_CONNECTING_: "connecting", | 46 STATE_CONNECTING_: "connecting", |
| 47 STATE_ERROR_: "error", | 47 STATE_ERROR_: "error", |
| 48 STATE_PAYMENT_: "payment", | 48 STATE_PAYMENT_: "payment", |
| 49 STATE_ACTIVATING_: "activating", | 49 STATE_ACTIVATING_: "activating", |
| 50 STATE_CONNECTED_: "connected", | 50 STATE_CONNECTED_: "connected", |
| 51 | 51 |
| 52 initialize: function(frame_name, carrierPage) { | 52 initialize: function(frame_name, carrierPage) { |
| 53 this.confirm_ = new cr.ui.dialogs.ConfirmDialog(document.body); |
| 53 if (this.initialized_) { | 54 if (this.initialized_) { |
| 54 console.log('calling initialize() again?'); | 55 console.log('calling initialize() again?'); |
| 55 return; | 56 return; |
| 56 } | 57 } |
| 57 this.initialized_ = true; | 58 this.initialized_ = true; |
| 58 self = this; | 59 self = this; |
| 59 this.frameName_ = frame_name; | 60 this.frameName_ = frame_name; |
| 61 |
| 60 window.addEventListener('message', function(e) { | 62 window.addEventListener('message', function(e) { |
| 61 self.onMessageReceived_(e); | 63 self.onMessageReceived_(e); |
| 62 }); | 64 }); |
| 65 |
| 63 $('closeButton').addEventListener('click', function(e) { | 66 $('closeButton').addEventListener('click', function(e) { |
| 64 $('finalStatus').classList.add('hidden'); | 67 $('finalStatus').classList.add('hidden'); |
| 68 }); |
| 69 |
| 70 $('cancelButton').addEventListener('click', function(e) { |
| 71 if (self.state_ == MobileSetup.PLAN_ACTIVATION_DONE || |
| 72 self.state_ == MobileSetup.PLAN_ACTIVATION_ERROR) { |
| 73 window.close(); |
| 74 return; |
| 75 } |
| 76 self.confirm_.show( |
| 77 MobileSetup.localStrings_.getString('cancel_question'), function() { |
| 78 window.close(); |
| 79 }); |
| 65 }); | 80 }); |
| 66 | 81 |
| 67 this.changeState_({state: MobileSetup.PLAN_ACTIVATION_PAGE_LOADING}); | 82 this.changeState_({state: MobileSetup.PLAN_ACTIVATION_PAGE_LOADING}); |
| 68 setInterval(mobile.MobileSetup.drawProgress, 100); | 83 setInterval(mobile.MobileSetup.drawProgress, 100); |
| 69 // Kick off activation process. | 84 // Kick off activation process. |
| 70 chrome.send('startActivation', []); | 85 chrome.send('startActivation', []); |
| 71 }, | 86 }, |
| 72 | 87 |
| 73 setupPaymentFrameListener_: function() { | 88 setupPaymentFrameListener_: function() { |
| 74 $(this.frameName_).addEventListener('load', function(e) { | 89 $(this.frameName_).addEventListener('load', function(e) { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 $('finalHeader').textContent = | 189 $('finalHeader').textContent = |
| 175 MobileSetup.localStrings_.getString('completed_header'); | 190 MobileSetup.localStrings_.getString('completed_header'); |
| 176 $('finalMessage').textContent = | 191 $('finalMessage').textContent = |
| 177 MobileSetup.localStrings_.getString('completed_text'); | 192 MobileSetup.localStrings_.getString('completed_text'); |
| 178 $('systemStatus').classList.add('hidden'); | 193 $('systemStatus').classList.add('hidden'); |
| 179 $('canvas').classList.add('hidden'); | 194 $('canvas').classList.add('hidden'); |
| 180 $('carrierPage').classList.add('hidden'); | 195 $('carrierPage').classList.add('hidden'); |
| 181 $('paymentForm').classList.remove('hidden'); | 196 $('paymentForm').classList.remove('hidden'); |
| 182 $('closeButton').classList.remove('hidden'); | 197 $('closeButton').classList.remove('hidden'); |
| 183 $('finalStatus').classList.remove('hidden'); | 198 $('finalStatus').classList.remove('hidden'); |
| 184 if (this.payment_shown_) | 199 if (this.payment_shown_) { |
| 185 $('closeButton').classList.remove('hidden'); | 200 $('closeButton').classList.remove('hidden'); |
| 186 else | 201 } else { |
| 187 $('closeButton').classList.add('hidden'); | 202 $('closeButton').classList.add('hidden'); |
| 203 $('cancelButton').textContent = |
| 204 MobileSetup.localStrings_.getString('close_button'); |
| 205 } |
| 188 break; | 206 break; |
| 189 case MobileSetup.PLAN_ACTIVATION_ERROR: | 207 case MobileSetup.PLAN_ACTIVATION_ERROR: |
| 190 $('statusHeader').textContent = ''; | 208 $('statusHeader').textContent = ''; |
| 191 $('auxHeader').textContent = ''; | 209 $('auxHeader').textContent = ''; |
| 192 $('finalHeader').textContent = | 210 $('finalHeader').textContent = |
| 193 MobileSetup.localStrings_.getString('error_header'); | 211 MobileSetup.localStrings_.getString('error_header'); |
| 194 $('finalMessage').textContent = deviceInfo.error; | 212 $('finalMessage').textContent = deviceInfo.error; |
| 195 $('systemStatus').classList.add('hidden'); | 213 $('systemStatus').classList.add('hidden'); |
| 196 $('canvas').classList.add('hidden'); | 214 $('canvas').classList.add('hidden'); |
| 197 $('carrierPage').classList.add('hidden'); | 215 $('carrierPage').classList.add('hidden'); |
| 198 $('paymentForm').classList.remove('hidden'); | 216 $('paymentForm').classList.remove('hidden'); |
| 199 if (this.payment_shown_) | 217 if (this.payment_shown_) { |
| 200 $('closeButton').classList.remove('hidden'); | 218 $('closeButton').classList.remove('hidden'); |
| 201 else | 219 } else { |
| 202 $('closeButton').classList.add('hidden'); | 220 $('closeButton').classList.add('hidden'); |
| 221 $('cancelButton').textContent = |
| 222 MobileSetup.localStrings_.getString('close_button'); |
| 223 } |
| 203 $('finalStatus').classList.remove('hidden'); | 224 $('finalStatus').classList.remove('hidden'); |
| 204 break; | 225 break; |
| 205 } | 226 } |
| 206 this.state_ = new_state; | 227 this.state_ = new_state; |
| 207 }, | 228 }, |
| 208 | 229 |
| 209 updateDeviceStatus_: function(deviceInfo) { | 230 updateDeviceStatus_: function(deviceInfo) { |
| 210 this.changeState_(deviceInfo); | 231 this.changeState_(deviceInfo); |
| 211 }, | 232 }, |
| 212 | 233 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 mobile.MobileSetup.ACTIVATION_PAGE_URL); | 300 mobile.MobileSetup.ACTIVATION_PAGE_URL); |
| 280 }; | 301 }; |
| 281 | 302 |
| 282 // Export | 303 // Export |
| 283 return { | 304 return { |
| 284 MobileSetup: MobileSetup | 305 MobileSetup: MobileSetup |
| 285 }; | 306 }; |
| 286 | 307 |
| 287 }); | 308 }); |
| 288 | 309 |
| OLD | NEW |