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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 STATE_CONNECTED_: "connected", | 50 STATE_CONNECTED_: "connected", |
51 | 51 |
52 initialize: function(frame_name, carrierPage) { | 52 initialize: function(frame_name, carrierPage) { |
53 if (this.initialized_) { | 53 if (this.initialized_) { |
54 console.log('calling initialize() again?'); | 54 console.log('calling initialize() again?'); |
55 return; | 55 return; |
56 } | 56 } |
57 this.initialized_ = true; | 57 this.initialized_ = true; |
58 self = this; | 58 self = this; |
59 this.frameName_ = frame_name; | 59 this.frameName_ = frame_name; |
| 60 |
| 61 cr.ui.dialogs.BaseDialog.OK_LABEL = |
| 62 MobileSetup.localStrings_.getString('ok_button'); |
| 63 cr.ui.dialogs.BaseDialog.CANCEL_LABEL = |
| 64 MobileSetup.localStrings_.getString('cancel_button'); |
| 65 this.confirm_ = new cr.ui.dialogs.ConfirmDialog(document.body); |
| 66 |
60 window.addEventListener('message', function(e) { | 67 window.addEventListener('message', function(e) { |
61 self.onMessageReceived_(e); | 68 self.onMessageReceived_(e); |
62 }); | 69 }); |
| 70 |
63 $('closeButton').addEventListener('click', function(e) { | 71 $('closeButton').addEventListener('click', function(e) { |
64 $('finalStatus').classList.add('hidden'); | 72 $('finalStatus').classList.add('hidden'); |
| 73 }); |
| 74 |
| 75 $('cancelButton').addEventListener('click', function(e) { |
| 76 if (self.state_ == MobileSetup.PLAN_ACTIVATION_DONE || |
| 77 self.state_ == MobileSetup.PLAN_ACTIVATION_ERROR) { |
| 78 window.close(); |
| 79 return; |
| 80 } |
| 81 self.confirm_.show( |
| 82 MobileSetup.localStrings_.getString('cancel_question'), function() { |
| 83 window.close(); |
| 84 }); |
65 }); | 85 }); |
66 | 86 |
67 this.changeState_({state: MobileSetup.PLAN_ACTIVATION_PAGE_LOADING}); | 87 this.changeState_({state: MobileSetup.PLAN_ACTIVATION_PAGE_LOADING}); |
68 setInterval(mobile.MobileSetup.drawProgress, 100); | 88 setInterval(mobile.MobileSetup.drawProgress, 100); |
69 // Kick off activation process. | 89 // Kick off activation process. |
70 chrome.send('startActivation', []); | 90 chrome.send('startActivation', []); |
71 }, | 91 }, |
72 | 92 |
73 setupPaymentFrameListener_: function() { | 93 setupPaymentFrameListener_: function() { |
74 $(this.frameName_).addEventListener('load', function(e) { | 94 $(this.frameName_).addEventListener('load', function(e) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 $('finalHeader').textContent = | 194 $('finalHeader').textContent = |
175 MobileSetup.localStrings_.getString('completed_header'); | 195 MobileSetup.localStrings_.getString('completed_header'); |
176 $('finalMessage').textContent = | 196 $('finalMessage').textContent = |
177 MobileSetup.localStrings_.getString('completed_text'); | 197 MobileSetup.localStrings_.getString('completed_text'); |
178 $('systemStatus').classList.add('hidden'); | 198 $('systemStatus').classList.add('hidden'); |
179 $('canvas').classList.add('hidden'); | 199 $('canvas').classList.add('hidden'); |
180 $('carrierPage').classList.add('hidden'); | 200 $('carrierPage').classList.add('hidden'); |
181 $('paymentForm').classList.remove('hidden'); | 201 $('paymentForm').classList.remove('hidden'); |
182 $('closeButton').classList.remove('hidden'); | 202 $('closeButton').classList.remove('hidden'); |
183 $('finalStatus').classList.remove('hidden'); | 203 $('finalStatus').classList.remove('hidden'); |
184 if (this.payment_shown_) | 204 if (this.payment_shown_) { |
185 $('closeButton').classList.remove('hidden'); | 205 $('closeButton').classList.remove('hidden'); |
186 else | 206 } else { |
187 $('closeButton').classList.add('hidden'); | 207 $('closeButton').classList.add('hidden'); |
| 208 $('cancelButton').textContent = |
| 209 MobileSetup.localStrings_.getString('close_button'); |
| 210 } |
188 break; | 211 break; |
189 case MobileSetup.PLAN_ACTIVATION_ERROR: | 212 case MobileSetup.PLAN_ACTIVATION_ERROR: |
190 $('statusHeader').textContent = ''; | 213 $('statusHeader').textContent = ''; |
191 $('auxHeader').textContent = ''; | 214 $('auxHeader').textContent = ''; |
192 $('finalHeader').textContent = | 215 $('finalHeader').textContent = |
193 MobileSetup.localStrings_.getString('error_header'); | 216 MobileSetup.localStrings_.getString('error_header'); |
194 $('finalMessage').textContent = deviceInfo.error; | 217 $('finalMessage').textContent = deviceInfo.error; |
195 $('systemStatus').classList.add('hidden'); | 218 $('systemStatus').classList.add('hidden'); |
196 $('canvas').classList.add('hidden'); | 219 $('canvas').classList.add('hidden'); |
197 $('carrierPage').classList.add('hidden'); | 220 $('carrierPage').classList.add('hidden'); |
198 $('paymentForm').classList.remove('hidden'); | 221 $('paymentForm').classList.remove('hidden'); |
199 if (this.payment_shown_) | 222 if (this.payment_shown_) { |
200 $('closeButton').classList.remove('hidden'); | 223 $('closeButton').classList.remove('hidden'); |
201 else | 224 } else { |
202 $('closeButton').classList.add('hidden'); | 225 $('closeButton').classList.add('hidden'); |
| 226 $('cancelButton').textContent = |
| 227 MobileSetup.localStrings_.getString('close_button'); |
| 228 } |
203 $('finalStatus').classList.remove('hidden'); | 229 $('finalStatus').classList.remove('hidden'); |
204 break; | 230 break; |
205 } | 231 } |
206 this.state_ = new_state; | 232 this.state_ = new_state; |
207 }, | 233 }, |
208 | 234 |
209 updateDeviceStatus_: function(deviceInfo) { | 235 updateDeviceStatus_: function(deviceInfo) { |
210 this.changeState_(deviceInfo); | 236 this.changeState_(deviceInfo); |
211 }, | 237 }, |
212 | 238 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 mobile.MobileSetup.ACTIVATION_PAGE_URL); | 305 mobile.MobileSetup.ACTIVATION_PAGE_URL); |
280 }; | 306 }; |
281 | 307 |
282 // Export | 308 // Export |
283 return { | 309 return { |
284 MobileSetup: MobileSetup | 310 MobileSetup: MobileSetup |
285 }; | 311 }; |
286 | 312 |
287 }); | 313 }); |
288 | 314 |
OLD | NEW |