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 Sidebar, served from chrome://bluetooth-internals/. | 6 * Javascript for Sidebar, served from chrome://bluetooth-internals/. |
7 */ | 7 */ |
8 | 8 |
9 cr.define('sidebar', function() { | 9 cr.define('sidebar', function() { |
10 /** @typedef {{pageName: string, text: string}} */ | 10 /** @typedef {{pageName: string, text: string}} */ |
(...skipping 17 matching lines...) Expand all Loading... |
28 this.sidebarList_ = this.sidebarContent_.querySelector('ul'); | 28 this.sidebarList_ = this.sidebarContent_.querySelector('ul'); |
29 | 29 |
30 this.sidebarList_.querySelectorAll('li button').forEach(function(item) { | 30 this.sidebarList_.querySelectorAll('li button').forEach(function(item) { |
31 item.addEventListener('click', this.onItemClick_.bind(this)); | 31 item.addEventListener('click', this.onItemClick_.bind(this)); |
32 }, this); | 32 }, this); |
33 | 33 |
34 /** @private {!Element} */ | 34 /** @private {!Element} */ |
35 this.overlayDiv_ = this.sidebarDiv_.querySelector('.overlay'); | 35 this.overlayDiv_ = this.sidebarDiv_.querySelector('.overlay'); |
36 this.overlayDiv_.addEventListener('click', this.close.bind(this)); | 36 this.overlayDiv_.addEventListener('click', this.close.bind(this)); |
37 | 37 |
38 window.matchMedia('screen and (max-width: 600px)').addListener( | 38 window.matchMedia('screen and (max-width: 600px)') |
39 function(query) { if (!query.matches) this.close(); }.bind(this)); | 39 .addListener(function(query) { |
| 40 if (!query.matches) |
| 41 this.close(); |
| 42 }.bind(this)); |
40 } | 43 } |
41 | 44 |
42 Sidebar.prototype = { | 45 Sidebar.prototype = { |
43 __proto__: PageManager.Observer.prototype, | 46 __proto__: PageManager.Observer.prototype, |
44 | 47 |
45 /** | 48 /** |
46 * Adds a new list item to the sidebar using the given |item|. | 49 * Adds a new list item to the sidebar using the given |item|. |
47 * @param {!SidebarItem} item | 50 * @param {!SidebarItem} item |
48 */ | 51 */ |
49 addItem: function(item) { | 52 addItem: function(item) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 * Switches the page based on which sidebar list button was clicked. | 105 * Switches the page based on which sidebar list button was clicked. |
103 * @param {!Event} event | 106 * @param {!Event} event |
104 * @private | 107 * @private |
105 */ | 108 */ |
106 onItemClick_: function(event) { | 109 onItemClick_: function(event) { |
107 this.close(); | 110 this.close(); |
108 PageManager.showPageByName(event.target.parentNode.dataset.pageName); | 111 PageManager.showPageByName(event.target.parentNode.dataset.pageName); |
109 }, | 112 }, |
110 }; | 113 }; |
111 | 114 |
112 return { | 115 return {Sidebar: Sidebar}; |
113 Sidebar: Sidebar | |
114 }; | |
115 }); | 116 }); |
OLD | NEW |