OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 cr.define('options', function() { | 5 cr.define('options', function() { |
6 const DeletableItemList = options.DeletableItemList; | 6 const DeletableItemList = options.DeletableItemList; |
7 const DeletableItem = options.DeletableItem; | 7 const DeletableItem = options.DeletableItem; |
8 const ArrayDataModel = cr.ui.ArrayDataModel; | 8 const ArrayDataModel = cr.ui.ArrayDataModel; |
9 const ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; | 9 const ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; |
10 | 10 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 this.expanded_ = expanded; | 153 this.expanded_ = expanded; |
154 if (expanded) { | 154 if (expanded) { |
155 var oldExpanded = this.list.expandedItem; | 155 var oldExpanded = this.list.expandedItem; |
156 this.list.expandedItem = this; | 156 this.list.expandedItem = this; |
157 this.updateItems_(); | 157 this.updateItems_(); |
158 if (oldExpanded) | 158 if (oldExpanded) |
159 oldExpanded.expanded = false; | 159 oldExpanded.expanded = false; |
160 this.classList.add('show-items'); | 160 this.classList.add('show-items'); |
161 } else { | 161 } else { |
162 if (this.list.expandedItem == this) { | 162 if (this.list.expandedItem == this) { |
163 this.list.leadItemHeight = 0; | |
164 this.list.expandedItem = null; | 163 this.list.expandedItem = null; |
165 } | 164 } |
166 this.style.height = ''; | 165 this.style.height = ''; |
167 this.itemsChild.style.height = ''; | 166 this.itemsChild.style.height = ''; |
168 this.classList.remove('show-items'); | 167 this.classList.remove('show-items'); |
169 } | 168 } |
170 }, | 169 }, |
171 | 170 |
172 /** | 171 /** |
173 * The callback for the "remove" button shown when an item is selected. | 172 * The callback for the "remove" button shown when an item is selected. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 var itemsHeight = getItemHeight(this.itemsChild); | 205 var itemsHeight = getItemHeight(this.itemsChild); |
207 var fixedHeight = getItemHeight(this) + itemsHeight - this.itemsHeight_; | 206 var fixedHeight = getItemHeight(this) + itemsHeight - this.itemsHeight_; |
208 this.itemsChild.style.height = this.itemsHeight_ + 'px'; | 207 this.itemsChild.style.height = this.itemsHeight_ + 'px'; |
209 // Force relayout before enabling animation, so that if we have | 208 // Force relayout before enabling animation, so that if we have |
210 // changed things since the last layout, they will not be animated | 209 // changed things since the last layout, they will not be animated |
211 // during subsequent layouts. | 210 // during subsequent layouts. |
212 this.itemsChild.offsetHeight; | 211 this.itemsChild.offsetHeight; |
213 this.classList.remove('measure-items'); | 212 this.classList.remove('measure-items'); |
214 this.itemsChild.style.height = itemsHeight + 'px'; | 213 this.itemsChild.style.height = itemsHeight + 'px'; |
215 this.style.height = fixedHeight + 'px'; | 214 this.style.height = fixedHeight + 'px'; |
216 if (this.expanded) | |
217 this.list.leadItemHeight = fixedHeight; | |
218 }, | 215 }, |
219 | 216 |
220 /** | 217 /** |
221 * Updates the origin summary to reflect changes in its items. | 218 * Updates the origin summary to reflect changes in its items. |
222 * Both CookieListItem and CookieTreeNode implement this API. | 219 * Both CookieListItem and CookieTreeNode implement this API. |
223 * This implementation scans the descendants to update the text. | 220 * This implementation scans the descendants to update the text. |
224 */ | 221 */ |
225 updateOrigin: function() { | 222 updateOrigin: function() { |
226 var info = { | 223 var info = { |
227 cookies: 0, | 224 cookies: 0, |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 DeletableItemList.prototype.decorate.call(this); | 613 DeletableItemList.prototype.decorate.call(this); |
617 this.classList.add('cookie-list'); | 614 this.classList.add('cookie-list'); |
618 this.data_ = []; | 615 this.data_ = []; |
619 this.dataModel = new ArrayDataModel(this.data_); | 616 this.dataModel = new ArrayDataModel(this.data_); |
620 this.addEventListener('keydown', this.handleKeyLeftRight_.bind(this)); | 617 this.addEventListener('keydown', this.handleKeyLeftRight_.bind(this)); |
621 var sm = new ListSingleSelectionModel(); | 618 var sm = new ListSingleSelectionModel(); |
622 sm.addEventListener('change', this.cookieSelectionChange_.bind(this)); | 619 sm.addEventListener('change', this.cookieSelectionChange_.bind(this)); |
623 sm.addEventListener('leadIndexChange', this.cookieLeadChange_.bind(this)); | 620 sm.addEventListener('leadIndexChange', this.cookieLeadChange_.bind(this)); |
624 this.selectionModel = sm; | 621 this.selectionModel = sm; |
625 this.infoNodes = {}; | 622 this.infoNodes = {}; |
| 623 this.fixedHeight = false; |
626 var doc = this.ownerDocument; | 624 var doc = this.ownerDocument; |
627 // Create a table for each type of site data (e.g. cookies, databases, | 625 // Create a table for each type of site data (e.g. cookies, databases, |
628 // etc.) and save it so that we can reuse it for all origins. | 626 // etc.) and save it so that we can reuse it for all origins. |
629 for (var type in cookieInfo) { | 627 for (var type in cookieInfo) { |
630 var table = doc.createElement('table'); | 628 var table = doc.createElement('table'); |
631 table.className = 'cookie-details-table'; | 629 table.className = 'cookie-details-table'; |
632 var tbody = doc.createElement('tbody'); | 630 var tbody = doc.createElement('tbody'); |
633 table.appendChild(tbody); | 631 table.appendChild(tbody); |
634 var info = {}; | 632 var info = {}; |
635 for (var i = 0; i < cookieInfo[type].length; i++) { | 633 for (var i = 0; i < cookieInfo[type].length; i++) { |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 parent.clear(); | 844 parent.clear(); |
847 this.addByParent_(parent, 0, children); | 845 this.addByParent_(parent, 0, children); |
848 parent.endBatchUpdates(); | 846 parent.endBatchUpdates(); |
849 }, | 847 }, |
850 }; | 848 }; |
851 | 849 |
852 return { | 850 return { |
853 CookiesList: CookiesList | 851 CookiesList: CookiesList |
854 }; | 852 }; |
855 }); | 853 }); |
OLD | NEW |