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 cr.define('options', function() { | 5 cr.define('options', function() { |
6 var OptionsPage = options.OptionsPage; | 6 var OptionsPage = options.OptionsPage; |
7 const ArrayDataModel = cr.ui.ArrayDataModel; | 7 const ArrayDataModel = cr.ui.ArrayDataModel; |
8 | 8 |
9 ///////////////////////////////////////////////////////////////////////////// | 9 ///////////////////////////////////////////////////////////////////////////// |
10 // InternetOptions class: | 10 // InternetOptions class: |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 inetGateway = data.ipconfigStatic.gateway; | 329 inetGateway = data.ipconfigStatic.gateway; |
330 inetDns = data.ipconfigStatic.dns; | 330 inetDns = data.ipconfigStatic.dns; |
331 $('ipTypeStatic').checked = true; | 331 $('ipTypeStatic').checked = true; |
332 } else if (data.ipconfigDHCP) { | 332 } else if (data.ipconfigDHCP) { |
333 inetAddress = data.ipconfigDHCP.address; | 333 inetAddress = data.ipconfigDHCP.address; |
334 inetSubnetAddress = data.ipconfigDHCP.subnetAddress; | 334 inetSubnetAddress = data.ipconfigDHCP.subnetAddress; |
335 inetGateway = data.ipconfigDHCP.gateway; | 335 inetGateway = data.ipconfigDHCP.gateway; |
336 inetDns = data.ipconfigDHCP.dns; | 336 inetDns = data.ipconfigDHCP.dns; |
337 } | 337 } |
338 | 338 |
| 339 // Hide the dhcp/static radio if not ethernet or wifi |
| 340 var ethernet_wifi = data.type == options.internet.Constants.TYPE_WIFI || |
| 341 data.type == options.internet.Constants.TYPE_ETHERNET; |
| 342 $('ipTypeDHCPDiv').hidden = !ethernet_wifi; |
| 343 $('ipTypeStaticDiv').hidden = !ethernet_wifi; |
| 344 |
339 var ipConfigList = $('ipConfigList'); | 345 var ipConfigList = $('ipConfigList'); |
340 ipConfigList.disabled = $('ipTypeDHCP').checked; | 346 ipConfigList.disabled = $('ipTypeDHCP').checked || !ethernet_wifi; |
341 options.internet.IPConfigList.decorate(ipConfigList); | 347 options.internet.IPConfigList.decorate(ipConfigList); |
342 ipConfigList.autoExpands = true; | 348 ipConfigList.autoExpands = true; |
343 var model = new ArrayDataModel([]); | 349 var model = new ArrayDataModel([]); |
344 model.push({ | 350 model.push({ |
345 'property': 'inetAddress', | 351 'property': 'inetAddress', |
346 'name': localStrings.getString('inetAddress'), | 352 'name': localStrings.getString('inetAddress'), |
347 'value': inetAddress, | 353 'value': inetAddress, |
348 }); | 354 }); |
349 model.push({ | 355 model.push({ |
350 'property': 'inetSubnetAddress', | 356 'property': 'inetSubnetAddress', |
(...skipping 23 matching lines...) Expand all Loading... |
374 ipConfigList.dataModel.updateIndex(0); | 380 ipConfigList.dataModel.updateIndex(0); |
375 ipConfigList.dataModel.updateIndex(1); | 381 ipConfigList.dataModel.updateIndex(1); |
376 ipConfigList.dataModel.updateIndex(2); | 382 ipConfigList.dataModel.updateIndex(2); |
377 ipConfigList.dataModel.updateIndex(3); | 383 ipConfigList.dataModel.updateIndex(3); |
378 // Unselect all so we don't keep the currently selected field editable. | 384 // Unselect all so we don't keep the currently selected field editable. |
379 ipConfigList.selectionModel.unselectAll(); | 385 ipConfigList.selectionModel.unselectAll(); |
380 ipConfigList.disabled = true; | 386 ipConfigList.disabled = true; |
381 }); | 387 }); |
382 | 388 |
383 $('ipTypeStatic').addEventListener('click', function(event) { | 389 $('ipTypeStatic').addEventListener('click', function(event) { |
384 // enable ipConfigList and switch back to static values (if any) | 390 // enable ipConfigList |
385 if (data.ipconfigStatic) { | |
386 ipConfigList.dataModel.item(0).value = data.ipconfigStatic.address; | |
387 ipConfigList.dataModel.item(1).value = | |
388 data.ipconfigStatic.subnetAddress; | |
389 ipConfigList.dataModel.item(2).value = data.ipconfigStatic.gateway; | |
390 ipConfigList.dataModel.item(3).value = data.ipconfigStatic.dns; | |
391 } | |
392 ipConfigList.dataModel.updateIndex(0); | |
393 ipConfigList.dataModel.updateIndex(1); | |
394 ipConfigList.dataModel.updateIndex(2); | |
395 ipConfigList.dataModel.updateIndex(3); | |
396 ipConfigList.disabled = false; | 391 ipConfigList.disabled = false; |
397 ipConfigList.focus(); | 392 ipConfigList.focus(); |
398 ipConfigList.selectionModel.selectedIndex = 0; | 393 ipConfigList.selectionModel.selectedIndex = 0; |
399 }); | 394 }); |
400 | 395 |
401 if (data.hardwareAddress) { | 396 if (data.hardwareAddress) { |
402 $('hardwareAddress').textContent = data.hardwareAddress; | 397 $('hardwareAddress').textContent = data.hardwareAddress; |
403 $('hardwareAddressRow').style.display = 'table-row'; | 398 $('hardwareAddressRow').style.display = 'table-row'; |
404 } else { | 399 } else { |
405 // This is most likely a device without a hardware address. | 400 // This is most likely a device without a hardware address. |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 detailsPage.gsm = false; | 499 detailsPage.gsm = false; |
505 } | 500 } |
506 OptionsPage.navigateToPage('detailsInternetPage'); | 501 OptionsPage.navigateToPage('detailsInternetPage'); |
507 }; | 502 }; |
508 | 503 |
509 // Export | 504 // Export |
510 return { | 505 return { |
511 InternetOptions: InternetOptions | 506 InternetOptions: InternetOptions |
512 }; | 507 }; |
513 }); | 508 }); |
OLD | NEW |