OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 ExpandableList and ExpandableListItem, served from | 6 * Javascript for ExpandableList and ExpandableListItem, served from |
7 * chrome://bluetooth-internals/. | 7 * chrome://bluetooth-internals/. |
8 */ | 8 */ |
9 | 9 |
10 cr.define('expandable_list', function() { | 10 cr.define('expandable_list', function() { |
(...skipping 22 matching lines...) Expand all Loading... |
33 this.briefContent_.addEventListener( | 33 this.briefContent_.addEventListener( |
34 'click', this.toggleExpand_.bind(this)); | 34 'click', this.toggleExpand_.bind(this)); |
35 this.appendChild(this.briefContent_); | 35 this.appendChild(this.briefContent_); |
36 | 36 |
37 this.expandedContent_ = document.createElement('div'); | 37 this.expandedContent_ = document.createElement('div'); |
38 this.expandedContent_.classList.add('expanded-content'); | 38 this.expandedContent_.classList.add('expanded-content'); |
39 this.appendChild(this.expandedContent_); | 39 this.appendChild(this.expandedContent_); |
40 }, | 40 }, |
41 | 41 |
42 /** | 42 /** |
| 43 * Called when the list item is expanded or collapsed. |
| 44 * @param {boolean} expanded |
| 45 */ |
| 46 onExpand: function(expanded) {}, |
| 47 |
| 48 /** |
43 * Toggles the expanded class on the item. | 49 * Toggles the expanded class on the item. |
44 * @private | 50 * @private |
45 */ | 51 */ |
46 toggleExpand_: function() { | 52 toggleExpand_: function() { |
47 this.classList.toggle('expanded'); | 53 this.onExpand(this.classList.toggle('expanded')); |
48 }, | 54 }, |
49 }; | 55 }; |
50 | 56 |
51 /** | 57 /** |
52 * A list that contains expandable list items. | 58 * A list that contains expandable list items. |
53 * @abstract | 59 * @abstract |
54 * @constructor | 60 * @constructor |
55 */ | 61 */ |
56 var ExpandableList = cr.ui.define('list'); | 62 var ExpandableList = cr.ui.define('list'); |
57 | 63 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 /** | 111 /** |
106 * Sets the loading state of the list. If |loading| is true, the loading | 112 * Sets the loading state of the list. If |loading| is true, the loading |
107 * spinner is dispayed. | 113 * spinner is dispayed. |
108 * @param {boolean} loading | 114 * @param {boolean} loading |
109 */ | 115 */ |
110 setLoading: function(loading) { | 116 setLoading: function(loading) { |
111 this.spinner_.hidden = !loading; | 117 this.spinner_.hidden = !loading; |
112 }, | 118 }, |
113 | 119 |
114 /** | 120 /** |
| 121 * Gets the loading state of the list. Returns true if the list is loading. |
| 122 * @return {boolean} |
| 123 */ |
| 124 isLoading: function() { |
| 125 return !this.spinner_.hidden; |
| 126 }, |
| 127 |
| 128 /** |
115 * Updates the display state of the empty message. If there are no items in | 129 * Updates the display state of the empty message. If there are no items in |
116 * the data model, the empty message is displayed. | 130 * the data model, the empty message is displayed. |
117 */ | 131 */ |
118 updateMessageDisplay_: function() { | 132 updateMessageDisplay_: function() { |
119 this.emptyMessage_.hidden = this.dataModel.length > 0; | 133 this.emptyMessage_.hidden = this.dataModel.length > 0; |
120 }, | 134 }, |
121 }; | 135 }; |
122 | 136 |
123 return { | 137 return { |
124 ExpandableListItem: ExpandableListItem, | 138 ExpandableListItem: ExpandableListItem, |
125 ExpandableList: ExpandableList, | 139 ExpandableList: ExpandableList, |
126 } | 140 } |
127 }); | 141 }); |
OLD | NEW |