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() { |
dpapad
2017/01/17 20:01:01
Things need to be renamed. The event listener "tog
mbrunson
2017/01/17 21:05:49
Done.
| |
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 /** | 110 /** |
105 * Sets the loading state of the list. If |loading| is true, the loading | 111 * Sets the loading state of the list. If |loading| is true, the loading |
106 * spinner is dispayed. | 112 * spinner is dispayed. |
107 * @param {boolean} loading | 113 * @param {boolean} loading |
108 */ | 114 */ |
109 setLoading: function(loading) { | 115 setLoading: function(loading) { |
110 this.spinner_.hidden = !loading; | 116 this.spinner_.hidden = !loading; |
111 }, | 117 }, |
112 | 118 |
113 /** | 119 /** |
120 * Gets the loading state of the list. Returns true if the list is loading. | |
121 * @return {boolean} | |
122 */ | |
123 isLoading: function() { | |
124 return !this.spinner_.hidden; | |
125 }, | |
126 | |
127 /** | |
114 * Updates the display state of the empty message. If there are no items in | 128 * Updates the display state of the empty message. If there are no items in |
115 * the data model, the empty message is displayed. | 129 * the data model, the empty message is displayed. |
116 */ | 130 */ |
117 updateMessageDisplay_: function() { | 131 updateMessageDisplay_: function() { |
118 this.emptyMessage_.hidden = this.dataModel.length > 0; | 132 this.emptyMessage_.hidden = this.dataModel.length > 0; |
119 }, | 133 }, |
120 }; | 134 }; |
121 | 135 |
122 return { | 136 return { |
123 ExpandableListItem: ExpandableListItem, | 137 ExpandableListItem: ExpandableListItem, |
124 ExpandableList: ExpandableList, | 138 ExpandableList: ExpandableList, |
125 } | 139 } |
126 }); | 140 }); |
OLD | NEW |