OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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 /** | |
6 * Javascript for DevicesPage and DevicesView, served from | |
7 * chrome://bluetooth-internals/. | |
8 */ | |
9 | |
10 cr.define('devices_page', function() { | |
11 /** @const */ var Page = cr.ui.pageManager.Page; | |
12 | |
13 /** | |
14 * Page that contains a header and a DevicesView. | |
15 * @constructor | |
16 * @extends {cr.ui.pageManager.Page} | |
17 */ | |
18 function DevicesPage() { | |
19 var devicesHeaderTitle = 'Devices'; | |
20 Page.call(this, 'devices', devicesHeaderTitle, 'devices'); | |
21 | |
22 var pageContent = document.createElement('section'); | |
23 pageContent.classList.add('page-content'); | |
24 this.pageDiv.appendChild(pageContent); | |
25 | |
26 this.devicesView = new DevicesView(); | |
27 this.pageDiv.querySelector('.page-content').appendChild(this.devicesView); | |
28 } | |
29 | |
30 cr.addSingletonGetter(DevicesPage); | |
31 | |
32 DevicesPage.prototype = { | |
33 __proto__: Page.prototype, | |
34 | |
35 /** | |
36 * Sets the DevicesView's device collection. | |
37 * @param {!device_collection.DeviceCollection} devices | |
38 */ | |
39 setDevices: function(devices) { | |
40 this.devicesView.setDevices(devices); | |
41 }, | |
42 }; | |
43 | |
44 /** | |
45 * An element that contains a device table and its associated controls. | |
ortuno
2016/12/06 10:16:05
Why not just add the table directly to pageDiv?
mbrunson
2016/12/07 01:12:14
This is a holdover from adding the PageManager. I
| |
46 * @constructor | |
47 * @extends {HTMLDivElement} | |
48 */ | |
49 var DevicesView = cr.ui.define('div'); | |
50 | |
51 DevicesView.prototype = { | |
52 __proto__: HTMLDivElement.prototype, | |
53 | |
54 decorate: function() { | |
ortuno
2016/12/06 10:16:05
q: Who calls this?
mbrunson
2016/12/07 01:12:14
It's called in the cr library when the constructor
| |
55 this.deviceTable = new device_table.DeviceTable(); | |
56 this.appendChild(this.deviceTable); | |
57 }, | |
58 | |
59 /** | |
60 * Sets the device table's device collection. | |
61 * @param {!device_collection.DeviceCollection} devices | |
62 */ | |
63 setDevices: function(devices) { | |
64 this.deviceTable.setDevices(devices); | |
65 }, | |
66 }; | |
67 | |
68 return { | |
69 DevicesPage: DevicesPage | |
70 }; | |
71 }); | |
OLD | NEW |