| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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.network', function() { | 5 cr.define('options.network', function() { |
| 6 | |
| 7 var ArrayDataModel = cr.ui.ArrayDataModel; | 6 var ArrayDataModel = cr.ui.ArrayDataModel; |
| 8 var List = cr.ui.List; | 7 var List = cr.ui.List; |
| 9 var ListItem = cr.ui.ListItem; | 8 var ListItem = cr.ui.ListItem; |
| 10 var ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; | 9 var ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; |
| 11 var Menu = cr.ui.Menu; | 10 var Menu = cr.ui.Menu; |
| 12 var MenuItem = cr.ui.MenuItem; | 11 var MenuItem = cr.ui.MenuItem; |
| 13 var ControlledSettingIndicator = options.ControlledSettingIndicator; | 12 var ControlledSettingIndicator = options.ControlledSettingIndicator; |
| 14 | 13 |
| 15 /** | 14 /** |
| 16 * Network settings constants. These enums usually match their C++ | 15 * Network settings constants. These enums usually match their C++ |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 this.menu_.hidden = false; | 359 this.menu_.hidden = false; |
| 361 } | 360 } |
| 362 if (rescan) | 361 if (rescan) |
| 363 chrome.send('refreshNetworks'); | 362 chrome.send('refreshNetworks'); |
| 364 }, | 363 }, |
| 365 }; | 364 }; |
| 366 | 365 |
| 367 /** | 366 /** |
| 368 * Creates a control for selecting or configuring a network connection based | 367 * Creates a control for selecting or configuring a network connection based |
| 369 * on the type of connection (e.g. wifi versus vpn). | 368 * on the type of connection (e.g. wifi versus vpn). |
| 370 * @param {{key: string, | 369 * @param {Object} data Description of the network. |
| 371 * networkList: Array.<Object>} data Description of the network. | 370 * @param {string} data.key Item key. |
| 371 * @param {Array.<Object>} data.networkList Description of the network. |
| 372 * @constructor | 372 * @constructor |
| 373 */ | 373 */ |
| 374 function NetworkSelectorItem(data) { | 374 function NetworkSelectorItem(data) { |
| 375 var el = new NetworkMenuItem(data); | 375 var el = new NetworkMenuItem(data); |
| 376 el.__proto__ = NetworkSelectorItem.prototype; | 376 el.__proto__ = NetworkSelectorItem.prototype; |
| 377 el.decorate(); | 377 el.decorate(); |
| 378 return el; | 378 return el; |
| 379 } | 379 } |
| 380 | 380 |
| 381 NetworkSelectorItem.prototype = { | 381 NetworkSelectorItem.prototype = { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 self.menu_ = null; | 472 self.menu_ = null; |
| 473 }; | 473 }; |
| 474 } | 474 } |
| 475 addendum.push(entry); | 475 addendum.push(entry); |
| 476 } | 476 } |
| 477 var list = this.data.rememberedNetworks; | 477 var list = this.data.rememberedNetworks; |
| 478 if (list && list.length > 0) { | 478 if (list && list.length > 0) { |
| 479 var callback = function(list) { | 479 var callback = function(list) { |
| 480 $('remembered-network-list').clear(); | 480 $('remembered-network-list').clear(); |
| 481 var dialog = options.PreferredNetworks.getInstance(); | 481 var dialog = options.PreferredNetworks.getInstance(); |
| 482 OptionsPage.showPageByName('preferredNetworksPage', false); | 482 PageManager.showPageByName('preferredNetworksPage', false); |
| 483 dialog.update(list); | 483 dialog.update(list); |
| 484 chrome.send('coreOptionsUserMetricsAction', | 484 chrome.send('coreOptionsUserMetricsAction', |
| 485 ['Options_NetworkShowPreferred']); | 485 ['Options_NetworkShowPreferred']); |
| 486 }; | 486 }; |
| 487 addendum.push({label: loadTimeData.getString('preferredNetworks'), | 487 addendum.push({label: loadTimeData.getString('preferredNetworks'), |
| 488 command: callback, | 488 command: callback, |
| 489 data: list}); | 489 data: list}); |
| 490 } | 490 } |
| 491 | 491 |
| 492 var networkGroup = this.ownerDocument.createElement('div'); | 492 var networkGroup = this.ownerDocument.createElement('div'); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 data.ConnectionState == 'Connecting') { | 651 data.ConnectionState == 'Connecting') { |
| 652 var label = menuItem.getElementsByClassName( | 652 var label = menuItem.getElementsByClassName( |
| 653 'network-menu-item-label')[0]; | 653 'network-menu-item-label')[0]; |
| 654 label.classList.add('active-network'); | 654 label.classList.add('active-network'); |
| 655 } | 655 } |
| 656 } | 656 } |
| 657 }; | 657 }; |
| 658 | 658 |
| 659 /** | 659 /** |
| 660 * Creates a button-like control for configurating internet connectivity. | 660 * Creates a button-like control for configurating internet connectivity. |
| 661 * @param {{key: string, | 661 * @param {Object} data Description of the network control. |
| 662 * subtitle: string, | 662 * @param {string} data.key Item key. |
| 663 * command: function} data Description of the network control. | 663 * @param {string} data.subtitle Subtitle. |
| 664 * @param {function} data.command Item callback. |
| 664 * @constructor | 665 * @constructor |
| 665 */ | 666 */ |
| 666 function NetworkButtonItem(data) { | 667 function NetworkButtonItem(data) { |
| 667 var el = new NetworkListItem(data); | 668 var el = new NetworkListItem(data); |
| 668 el.__proto__ = NetworkButtonItem.prototype; | 669 el.__proto__ = NetworkButtonItem.prototype; |
| 669 el.decorate(); | 670 el.decorate(); |
| 670 return el; | 671 return el; |
| 671 } | 672 } |
| 672 | 673 |
| 673 NetworkButtonItem.prototype = { | 674 NetworkButtonItem.prototype = { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 this.selectionModel.unselectAll(); | 802 this.selectionModel.unselectAll(); |
| 802 closeMenu_(); | 803 closeMenu_(); |
| 803 }, | 804 }, |
| 804 | 805 |
| 805 /** | 806 /** |
| 806 * Close bubble and menu when a different list item is selected. | 807 * Close bubble and menu when a different list item is selected. |
| 807 * @param {Event} event Event detailing the selection change. | 808 * @param {Event} event Event detailing the selection change. |
| 808 * @private | 809 * @private |
| 809 */ | 810 */ |
| 810 onSelectionChange_: function(event) { | 811 onSelectionChange_: function(event) { |
| 811 OptionsPage.hideBubble(); | 812 PageManager.hideBubble(); |
| 812 // A list item may temporarily become unselected while it is constructing | 813 // A list item may temporarily become unselected while it is constructing |
| 813 // its menu. The menu should therefore only be closed if a different item | 814 // its menu. The menu should therefore only be closed if a different item |
| 814 // is selected, not when the menu's owner item is deselected. | 815 // is selected, not when the menu's owner item is deselected. |
| 815 if (activeMenu_) { | 816 if (activeMenu_) { |
| 816 for (var i = 0; i < event.changes.length; ++i) { | 817 for (var i = 0; i < event.changes.length; ++i) { |
| 817 if (event.changes[i].selected) { | 818 if (event.changes[i].selected) { |
| 818 var item = this.dataModel.item(event.changes[i].index); | 819 var item = this.dataModel.item(event.changes[i].index); |
| 819 if (!item.getMenuName || item.getMenuName() != activeMenu_) { | 820 if (!item.getMenuName || item.getMenuName() != activeMenu_) { |
| 820 closeMenu_(); | 821 closeMenu_(); |
| 821 return; | 822 return; |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 event.preventDefault(); | 1057 event.preventDefault(); |
| 1057 event.stopPropagation(); | 1058 event.stopPropagation(); |
| 1058 }, | 1059 }, |
| 1059 | 1060 |
| 1060 /** @override */ | 1061 /** @override */ |
| 1061 toggleBubble_: function() { | 1062 toggleBubble_: function() { |
| 1062 if (activeMenu_ && !$(activeMenu_).contains(this)) | 1063 if (activeMenu_ && !$(activeMenu_).contains(this)) |
| 1063 closeMenu_(); | 1064 closeMenu_(); |
| 1064 ControlledSettingIndicator.prototype.toggleBubble_.call(this); | 1065 ControlledSettingIndicator.prototype.toggleBubble_.call(this); |
| 1065 if (this.showingBubble) { | 1066 if (this.showingBubble) { |
| 1066 var bubble = OptionsPage.getVisibleBubble(); | 1067 var bubble = PageManager.getVisibleBubble(); |
| 1067 bubble.addEventListener('mousedown', this.stopEvent); | 1068 bubble.addEventListener('mousedown', this.stopEvent); |
| 1068 bubble.addEventListener('click', this.stopEvent); | 1069 bubble.addEventListener('click', this.stopEvent); |
| 1069 } | 1070 } |
| 1070 } | 1071 } |
| 1071 }; | 1072 }; |
| 1072 | 1073 |
| 1073 /** | 1074 /** |
| 1074 * Updates the list of available networks and their status, filtered by | 1075 * Updates the list of available networks and their status, filtered by |
| 1075 * network type. | 1076 * network type. |
| 1076 * @param {string} type The type of network. | 1077 * @param {string} type The type of network. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1144 * Whether the Network list is disabled. Only used for display purpose. | 1145 * Whether the Network list is disabled. Only used for display purpose. |
| 1145 * @type {boolean} | 1146 * @type {boolean} |
| 1146 */ | 1147 */ |
| 1147 cr.defineProperty(NetworkList, 'disabled', cr.PropertyKind.BOOL_ATTR); | 1148 cr.defineProperty(NetworkList, 'disabled', cr.PropertyKind.BOOL_ATTR); |
| 1148 | 1149 |
| 1149 // Export | 1150 // Export |
| 1150 return { | 1151 return { |
| 1151 NetworkList: NetworkList | 1152 NetworkList: NetworkList |
| 1152 }; | 1153 }; |
| 1153 }); | 1154 }); |
| OLD | NEW |