| 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 /** @const {!cr.ui.pageManager.PageManager}*/ | 10 /** @const {!cr.ui.pageManager.PageManager}*/ |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 this.sidebarList_ = this.sidebarContent_.querySelector('ul'); | 25 this.sidebarList_ = this.sidebarContent_.querySelector('ul'); |
| 26 | 26 |
| 27 this.sidebarList_.querySelectorAll('li button').forEach(function(item) { | 27 this.sidebarList_.querySelectorAll('li button').forEach(function(item) { |
| 28 item.addEventListener('click', this.onItemClick_.bind(this)); | 28 item.addEventListener('click', this.onItemClick_.bind(this)); |
| 29 }, this); | 29 }, this); |
| 30 | 30 |
| 31 /** @private {!Element} */ | 31 /** @private {!Element} */ |
| 32 this.overlayDiv_ = this.sidebarDiv_.querySelector('.overlay'); | 32 this.overlayDiv_ = this.sidebarDiv_.querySelector('.overlay'); |
| 33 this.overlayDiv_.addEventListener('click', this.close.bind(this)); | 33 this.overlayDiv_.addEventListener('click', this.close.bind(this)); |
| 34 | 34 |
| 35 window.matchMedia('screen and (max-width: 600px)').addListener( | 35 window.matchMedia('screen and (max-width: 600px)') |
| 36 function(query) { if (!query.matches) this.close(); }.bind(this)); | 36 .addListener(function(query) { |
| 37 if (!query.matches) |
| 38 this.close(); |
| 39 }.bind(this)); |
| 37 } | 40 } |
| 38 | 41 |
| 39 Sidebar.prototype = { | 42 Sidebar.prototype = { |
| 40 __proto__: PageManager.Observer.prototype, | 43 __proto__: PageManager.Observer.prototype, |
| 41 | 44 |
| 42 /** | 45 /** |
| 43 * Closes the sidebar. Only applies to layouts with window width <= 600px. | 46 * Closes the sidebar. Only applies to layouts with window width <= 600px. |
| 44 */ | 47 */ |
| 45 close: function() { | 48 close: function() { |
| 46 this.sidebarDiv_.classList.remove('open'); | 49 this.sidebarDiv_.classList.remove('open'); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 72 * Switches the page based on which sidebar list button was clicked. | 75 * Switches the page based on which sidebar list button was clicked. |
| 73 * @param {!Event} event | 76 * @param {!Event} event |
| 74 * @private | 77 * @private |
| 75 */ | 78 */ |
| 76 onItemClick_: function(event) { | 79 onItemClick_: function(event) { |
| 77 this.close(); | 80 this.close(); |
| 78 PageManager.showPageByName(event.target.parentNode.dataset.pageName); | 81 PageManager.showPageByName(event.target.parentNode.dataset.pageName); |
| 79 }, | 82 }, |
| 80 }; | 83 }; |
| 81 | 84 |
| 82 return { | 85 return {Sidebar: Sidebar}; |
| 83 Sidebar: Sidebar | |
| 84 }; | |
| 85 }); | 86 }); |
| OLD | NEW |