| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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.internet', function() { | 5 cr.define('options.internet', function() { |
| 6 /** | 6 /** |
| 7 * Creates a new network list div. | 7 * Creates a new network list div. |
| 8 * @param {Object=} opt_propertyBag Optional properties. | 8 * @param {Object=} opt_propertyBag Optional properties. |
| 9 * @constructor | 9 * @constructor |
| 10 * @extends {HTMLDivElement} | 10 * @extends {HTMLDivElement} |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 if (!(el.buttonType && el.networkType && el.servicePath)) { | 50 if (!(el.buttonType && el.networkType && el.servicePath)) { |
| 51 if (el.buttonType) { | 51 if (el.buttonType) { |
| 52 return; | 52 return; |
| 53 } | 53 } |
| 54 // If click is on a network item or its label, walk up the DOM tree | 54 // If click is on a network item or its label, walk up the DOM tree |
| 55 // to find the network item. | 55 // to find the network item. |
| 56 var item = el; | 56 var item = el; |
| 57 while (item && !item.data) { | 57 while (item && !item.data) { |
| 58 item = item.parentNode; | 58 item = item.parentNode; |
| 59 } | 59 } |
| 60 if (item.connecting) | 60 if (item.connecting || !item.connectable) |
| 61 return; | 61 return; |
| 62 | 62 |
| 63 if (item) { | 63 if (item) { |
| 64 var data = item.data; | 64 var data = item.data; |
| 65 // Don't try to connect to Ethernet or unactivated Cellular. | 65 // Don't try to connect to Ethernet or unactivated Cellular. |
| 66 if (data && (data.networkType == 1 || | 66 if (data && (data.networkType == 1 || |
| 67 (data.networkType == 5 && data.activation_state != 1))) | 67 (data.networkType == 5 && data.activation_state != 1))) |
| 68 return; | 68 return; |
| 69 for (var i = 0; i < this.childNodes.length; i++) { | 69 for (var i = 0; i < this.childNodes.length; i++) { |
| 70 if (this.childNodes[i] != item) | 70 if (this.childNodes[i] != item) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 99 el.data = { | 99 el.data = { |
| 100 servicePath: network[0], | 100 servicePath: network[0], |
| 101 networkName: network[1], | 101 networkName: network[1], |
| 102 networkStatus: network[2], | 102 networkStatus: network[2], |
| 103 networkType: network[3], | 103 networkType: network[3], |
| 104 connected: network[4], | 104 connected: network[4], |
| 105 connecting: network[5], | 105 connecting: network[5], |
| 106 iconURL: network[6], | 106 iconURL: network[6], |
| 107 remembered: network[7], | 107 remembered: network[7], |
| 108 activation_state: network[8], | 108 activation_state: network[8], |
| 109 restricted: network[9] | 109 restricted: network[9], |
| 110 connectable: network[10] |
| 110 }; | 111 }; |
| 111 NetworkItem.decorate(el); | 112 NetworkItem.decorate(el); |
| 112 return el; | 113 return el; |
| 113 } | 114 } |
| 114 | 115 |
| 115 | 116 |
| 116 /** | 117 /** |
| 117 * Minimum length for wireless network password. | 118 * Minimum length for wireless network password. |
| 118 * @type {number} | 119 * @type {number} |
| 119 */ | 120 */ |
| (...skipping 21 matching lines...) Expand all Loading... |
| 141 el.decorate(); | 142 el.decorate(); |
| 142 }; | 143 }; |
| 143 | 144 |
| 144 NetworkItem.prototype = { | 145 NetworkItem.prototype = { |
| 145 __proto__: HTMLDivElement.prototype, | 146 __proto__: HTMLDivElement.prototype, |
| 146 | 147 |
| 147 /** @inheritDoc */ | 148 /** @inheritDoc */ |
| 148 decorate: function() { | 149 decorate: function() { |
| 149 this.className = 'network-item'; | 150 this.className = 'network-item'; |
| 150 this.connected = this.data.connected; | 151 this.connected = this.data.connected; |
| 152 this.connectable = this.data.connectable; |
| 151 this.other = this.data.servicePath == '?'; | 153 this.other = this.data.servicePath == '?'; |
| 152 this.id = this.data.servicePath; | 154 this.id = this.data.servicePath; |
| 153 // textDiv holds icon, name and status text. | 155 // textDiv holds icon, name and status text. |
| 154 var textDiv = this.ownerDocument.createElement('div'); | 156 var textDiv = this.ownerDocument.createElement('div'); |
| 155 textDiv.className = 'network-item-text'; | 157 textDiv.className = 'network-item-text'; |
| 156 if (this.data.iconURL) { | 158 if (this.data.iconURL) { |
| 157 textDiv.style.backgroundImage = url(this.data.iconURL); | 159 textDiv.style.backgroundImage = url(this.data.iconURL); |
| 158 } | 160 } |
| 159 | 161 |
| 160 var nameEl = this.ownerDocument.createElement('div'); | 162 var nameEl = this.ownerDocument.createElement('div'); |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 */ | 466 */ |
| 465 cr.defineProperty(NetworkItem, 'connecting', cr.PropertyKind.BOOL_ATTR); | 467 cr.defineProperty(NetworkItem, 'connecting', cr.PropertyKind.BOOL_ATTR); |
| 466 | 468 |
| 467 /** | 469 /** |
| 468 * Whether the underlying network is an other network for adding networks. | 470 * Whether the underlying network is an other network for adding networks. |
| 469 * Only used for display purpose. | 471 * Only used for display purpose. |
| 470 * @type {boolean} | 472 * @type {boolean} |
| 471 */ | 473 */ |
| 472 cr.defineProperty(NetworkItem, 'other', cr.PropertyKind.BOOL_ATTR); | 474 cr.defineProperty(NetworkItem, 'other', cr.PropertyKind.BOOL_ATTR); |
| 473 | 475 |
| 476 /** |
| 477 * Whether the underlying network is connectable. |
| 478 * @type {boolean} |
| 479 */ |
| 480 cr.defineProperty(NetworkItem, 'connectable', cr.PropertyKind.BOOL_ATTR); |
| 481 |
| 474 return { | 482 return { |
| 475 NetworkElement: NetworkElement | 483 NetworkElement: NetworkElement |
| 476 }; | 484 }; |
| 477 }); | 485 }); |
| OLD | NEW |