OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 /** | 5 /** |
6 * Javascript for bluetooth_internals.html, served from | 6 * Javascript for bluetooth_internals.html, served from |
7 * chrome://bluetooth-internals/. | 7 * chrome://bluetooth-internals/. |
8 */ | 8 */ |
9 | 9 |
10 // Expose for testing. | 10 // Expose for testing. |
11 var adapterBroker = null; | 11 var adapterBroker = null; |
12 var devices = null; | 12 var devices = null; |
| 13 var sidebarObj = null; |
13 | 14 |
14 cr.define('bluetooth_internals', function() { | 15 cr.define('bluetooth_internals', function() { |
15 /** @const */ var DevicesPage = devices_page.DevicesPage; | 16 /** @const */ var DevicesPage = devices_page.DevicesPage; |
16 /** @const */ var PageManager = cr.ui.pageManager.PageManager; | 17 /** @const */ var PageManager = cr.ui.pageManager.PageManager; |
17 | 18 |
18 /** | 19 /** |
19 * Observer for page changes. Used to update page title header. | 20 * Observer for page changes. Used to update page title header. |
20 * @extends {cr.ui.pageManager.PageManager.Observer} | 21 * @extends {cr.ui.pageManager.PageManager.Observer} |
21 */ | 22 */ |
22 var PageObserver = function() {}; | 23 var PageObserver = function() {}; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 }).catch(function(error) { | 103 }).catch(function(error) { |
103 devices.updateConnectionStatus( | 104 devices.updateConnectionStatus( |
104 address, | 105 address, |
105 device_collection.ConnectionStatus.DISCONNECTED, | 106 device_collection.ConnectionStatus.DISCONNECTED, |
106 error); | 107 error); |
107 }); | 108 }); |
108 }); | 109 }); |
109 } | 110 } |
110 | 111 |
111 function setupPages() { | 112 function setupPages() { |
112 var sidebar = new window.sidebar.Sidebar($('sidebar')); | 113 sidebarObj = new window.sidebar.Sidebar($('sidebar')); |
113 $('menu-btn').addEventListener('click', function() { sidebar.open(); }); | 114 $('menu-btn').addEventListener('click', function() { sidebarObj.open(); }); |
114 PageManager.addObserver(sidebar); | 115 PageManager.addObserver(sidebarObj); |
115 PageManager.addObserver(new PageObserver()); | 116 PageManager.addObserver(new PageObserver()); |
116 | 117 |
117 devicesPage = new DevicesPage(); | 118 devicesPage = new DevicesPage(); |
118 PageManager.register(devicesPage); | 119 PageManager.register(devicesPage); |
119 | 120 |
120 // Set up hash-based navigation. | 121 // Set up hash-based navigation. |
121 window.addEventListener('hashchange', function() { | 122 window.addEventListener('hashchange', function() { |
122 PageManager.showPageByName(window.location.hash.substr(1)); | 123 PageManager.showPageByName(window.location.hash.substr(1)); |
123 }); | 124 }); |
124 | 125 |
(...skipping 17 matching lines...) Expand all Loading... |
142 .catch(function(error) { console.error(error); }); | 143 .catch(function(error) { console.error(error); }); |
143 } | 144 } |
144 | 145 |
145 return { | 146 return { |
146 initializeViews: initializeViews | 147 initializeViews: initializeViews |
147 }; | 148 }; |
148 }); | 149 }); |
149 | 150 |
150 document.addEventListener( | 151 document.addEventListener( |
151 'DOMContentLoaded', bluetooth_internals.initializeViews); | 152 'DOMContentLoaded', bluetooth_internals.initializeViews); |
OLD | NEW |