Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: chrome/browser/resources/options/chromeos_internet_network_list.js

Issue 3036020: Port network options to DOM UI. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 cr.define('options.internet', function() {
6 const List = cr.ui.List;
7 const ListItem = cr.ui.ListItem;
8 const ArrayDataModel = cr.ui.ArrayDataModel;
9
10 /**
11 * Creates a new network list.
12 * @param {Object=} opt_propertyBag Optional properties.
13 * @constructor
14 * @extends {cr.ui.List}
15 */
16 var NetworkList = cr.ui.define('list');
17
18 NetworkList.prototype = {
19 __proto__: List.prototype,
20
21 createItem: function(network) {
22 return new NetworkListItem(network);
23 },
24
25 /**
26 * Loads given network list.
27 * @param {Array} users An array of user object.
28 */
29 load: function(networks) {
30 this.dataModel = new ArrayDataModel(networks);
31 },
32
33 };
34
35 /**
36 * Creates a new network list item.
37 * @param {!ListValue} network The network this represents.
38 * @constructor
39 * @extends {cr.ui.ListItem}
40 */
41 function NetworkListItem(network) {
42 var el = cr.doc.createElement('div');
43 el.servicePath = network[0];
44 el.networkName = network[1];
45 el.networkStatus = network[2];
46 el.networkType = network[3];
47 el.connected = network[4];
48 el.connecting = network[5];
49 el.iconURL = network[6];
50 el.remembered = network[7];
51 NetworkListItem.decorate(el);
52 return el;
53 }
54
55 /**
56 * Decorates an element as a network list item.
57 * @param {!HTMLElement} el The element to decorate.
58 */
59 NetworkListItem.decorate = function(el) {
60 el.__proto__ = NetworkListItem.prototype;
61 el.decorate();
62 };
63
64 NetworkListItem.prototype = {
65 __proto__: ListItem.prototype,
66
67 /** @inheritDoc */
68 decorate: function() {
69 ListItem.prototype.decorate.call(this);
70
71 // icon and name
72 var nameEl = this.ownerDocument.createElement('span');
73 nameEl.className = 'label';
74 // TODO(xiyuan): Use css for this.
75 if (this.connected)
76 nameEl.style.fontWeight = 'bold';
77 nameEl.textContent = this.networkName;
78 nameEl.style.backgroundImage = url(this.iconURL);
79 this.appendChild(nameEl);
80
81 // status
82 var statusEl = this.ownerDocument.createElement('span');
83 statusEl.className = 'label';
84 statusEl.textContent = this.networkStatus;
85 this.appendChild(statusEl);
86
87 if (!this.remembered) {
88 if (this.connected) {
89 // disconnect button (if not ethernet)
90 if (this.networkType != 1)
91 this.appendChild(this.createButton_('disconnect_button',
92 'disconnect'));
93
94 // options button
95 this.appendChild(this.createButton_('options_button', 'options'));
96 } else if (!this.connecting) {
97 // connect button
98 this.appendChild(this.createButton_('connect_button', 'connect'));
99 }
100 } else {
101 // forget button
102 this.appendChild(this.createButton_('forget_button', 'forget'));
103 }
104 },
105
106 /**
107 * Creates a button for interacting with a network.
108 * @param {Object} name The name of the localStrings to use for the text.
109 * @param {Object} type The type of button.
110 */
111 createButton_: function(name, type) {
112 var buttonEl = this.ownerDocument.createElement('button');
113 buttonEl.textContent = localStrings.getString(name);
114 var networkType = this.networkType;
115 var servicePath = this.servicePath;
116 buttonEl.onclick = function(event) {
117 chrome.send('buttonClickCallback',
118 [String(networkType), String(servicePath), String(type)]);
119 };
120 return buttonEl;
121 }
122 };
123
124 return {
125 NetworkList: NetworkList
126 };
127 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options.html ('k') | chrome/browser/resources/options/chromeos_internet_options.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698