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 this.pageDiv.appendChild(document.importNode($('page-template').content, | |
ortuno
2016/12/05 05:45:28
Could we just have a single header and change its
mbrunson
2016/12/06 00:25:45
Done.
| |
22 true /* deep */)); | |
23 | |
24 this.pageDiv.querySelector('.page-title').textContent = devicesHeaderTitle; | |
25 this.pageDiv.querySelector('.menu-btn').addEventListener('click', | |
26 function() { | |
27 this.pageDiv.dispatchEvent(new CustomEvent('menupressed')); | |
28 }.bind(this)); | |
29 | |
30 this.devicesView = new DevicesView(); | |
31 this.pageDiv.querySelector('.page-content').appendChild(this.devicesView); | |
32 } | |
33 | |
34 cr.addSingletonGetter(DevicesPage); | |
ortuno
2016/12/05 05:45:28
Why use a singleton?
mbrunson
2016/12/06 00:25:45
Other internal pages that use PageManager tend to
| |
35 | |
36 DevicesPage.prototype = { | |
37 __proto__: Page.prototype, | |
38 | |
39 /** | |
40 * Sets the DevicesView's device collection. | |
41 * @param {!device_collection.DeviceCollection} devices | |
42 */ | |
43 setDevices: function(devices) { | |
44 this.devicesView.setDevices(devices); | |
45 }, | |
46 }; | |
47 | |
48 /** | |
49 * An element that contains a device table and its associated controls. | |
50 * @constructor | |
51 * @extends {HTMLDivElement} | |
52 */ | |
53 var DevicesView = cr.ui.define('div'); | |
54 | |
55 DevicesView.prototype = { | |
56 __proto__: HTMLDivElement.prototype, | |
57 | |
58 decorate: function() { | |
59 this.deviceTable = new device_table.DeviceTable(); | |
60 this.appendChild(this.deviceTable); | |
ortuno
2016/12/05 05:45:28
I'm so sad that we can't use Custom Elements :(
mbrunson
2016/12/06 00:25:46
:'(
| |
61 }, | |
62 | |
63 /** | |
64 * Sets the device table's device collection. | |
65 * @param {!device_collection.DeviceCollection} devices | |
66 */ | |
67 setDevices: function(devices) { | |
68 this.deviceTable.setDevices(devices); | |
69 }, | |
70 }; | |
71 | |
72 return { | |
73 DevicesPage: DevicesPage | |
74 }; | |
75 }); | |
OLD | NEW |