| 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 // TODO(gbillock): refactor this together with CookiesList once we have | 5 // TODO(gbillock): refactor this together with CookiesList once we have |
| 6 // a better sense from UX design what it'll look like and so what'll be shared. | 6 // a better sense from UX design what it'll look like and so what'll be shared. |
| 7 cr.define('options', function() { | 7 cr.define('options', function() { |
| 8 const DeletableItemList = options.DeletableItemList; | 8 const DeletableItemList = options.DeletableItemList; |
| 9 const DeletableItem = options.DeletableItem; | 9 const DeletableItem = options.DeletableItem; |
| 10 const ArrayDataModel = cr.ui.ArrayDataModel; | 10 const ArrayDataModel = cr.ui.ArrayDataModel; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 if (expanded) { | 108 if (expanded) { |
| 109 var oldExpanded = this.list.expandedItem; | 109 var oldExpanded = this.list.expandedItem; |
| 110 this.list.expandedItem = this; | 110 this.list.expandedItem = this; |
| 111 this.updateItems_(); | 111 this.updateItems_(); |
| 112 if (oldExpanded) | 112 if (oldExpanded) |
| 113 oldExpanded.expanded = false; | 113 oldExpanded.expanded = false; |
| 114 this.classList.add('show-items'); | 114 this.classList.add('show-items'); |
| 115 this.dataChild.hidden = true; | 115 this.dataChild.hidden = true; |
| 116 } else { | 116 } else { |
| 117 if (this.list.expandedItem == this) { | 117 if (this.list.expandedItem == this) { |
| 118 this.list.leadItemHeight = 0; | |
| 119 this.list.expandedItem = null; | 118 this.list.expandedItem = null; |
| 120 } | 119 } |
| 121 this.style.height = ''; | 120 this.style.height = ''; |
| 122 this.itemsChild.style.height = ''; | 121 this.itemsChild.style.height = ''; |
| 123 this.classList.remove('show-items'); | 122 this.classList.remove('show-items'); |
| 124 this.dataChild.hidden = false; | 123 this.dataChild.hidden = false; |
| 125 } | 124 } |
| 126 }, | 125 }, |
| 127 | 126 |
| 128 /** | 127 /** |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 var itemsHeight = getItemHeight(this.itemsChild); | 161 var itemsHeight = getItemHeight(this.itemsChild); |
| 163 var fixedHeight = getItemHeight(this) + itemsHeight - this.itemsHeight_; | 162 var fixedHeight = getItemHeight(this) + itemsHeight - this.itemsHeight_; |
| 164 this.itemsChild.style.height = this.itemsHeight_ + 'px'; | 163 this.itemsChild.style.height = this.itemsHeight_ + 'px'; |
| 165 // Force relayout before enabling animation, so that if we have | 164 // Force relayout before enabling animation, so that if we have |
| 166 // changed things since the last layout, they will not be animated | 165 // changed things since the last layout, they will not be animated |
| 167 // during subsequent layouts. | 166 // during subsequent layouts. |
| 168 this.itemsChild.offsetHeight; | 167 this.itemsChild.offsetHeight; |
| 169 this.classList.remove('measure-items'); | 168 this.classList.remove('measure-items'); |
| 170 this.itemsChild.style.height = itemsHeight + 'px'; | 169 this.itemsChild.style.height = itemsHeight + 'px'; |
| 171 this.style.height = fixedHeight + 'px'; | 170 this.style.height = fixedHeight + 'px'; |
| 172 if (this.expanded) | |
| 173 this.list.leadItemHeight = fixedHeight; | |
| 174 }, | 171 }, |
| 175 | 172 |
| 176 /** | 173 /** |
| 177 * Updates the origin summary to reflect changes in its items. | 174 * Updates the origin summary to reflect changes in its items. |
| 178 * Both IntentsListItem and IntentsTreeNode implement this API. | 175 * Both IntentsListItem and IntentsTreeNode implement this API. |
| 179 * This implementation scans the descendants to update the text. | 176 * This implementation scans the descendants to update the text. |
| 180 */ | 177 */ |
| 181 updateOrigin: function() { | 178 updateOrigin: function() { |
| 182 var text = ''; | 179 var text = ''; |
| 183 for (var i = 0; i < this.origin.children.length; ++i) { | 180 for (var i = 0; i < this.origin.children.length; ++i) { |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 decorate: function() { | 487 decorate: function() { |
| 491 DeletableItemList.prototype.decorate.call(this); | 488 DeletableItemList.prototype.decorate.call(this); |
| 492 this.classList.add('intents-list'); | 489 this.classList.add('intents-list'); |
| 493 this.data_ = []; | 490 this.data_ = []; |
| 494 this.dataModel = new ArrayDataModel(this.data_); | 491 this.dataModel = new ArrayDataModel(this.data_); |
| 495 this.addEventListener('keydown', this.handleKeyLeftRight_.bind(this)); | 492 this.addEventListener('keydown', this.handleKeyLeftRight_.bind(this)); |
| 496 var sm = new ListSingleSelectionModel(); | 493 var sm = new ListSingleSelectionModel(); |
| 497 sm.addEventListener('change', this.cookieSelectionChange_.bind(this)); | 494 sm.addEventListener('change', this.cookieSelectionChange_.bind(this)); |
| 498 sm.addEventListener('leadIndexChange', this.cookieLeadChange_.bind(this)); | 495 sm.addEventListener('leadIndexChange', this.cookieLeadChange_.bind(this)); |
| 499 this.selectionModel = sm; | 496 this.selectionModel = sm; |
| 497 this.fixedHeight = false; |
| 500 }, | 498 }, |
| 501 | 499 |
| 502 /** | 500 /** |
| 503 * Handles key down events and looks for left and right arrows, then | 501 * Handles key down events and looks for left and right arrows, then |
| 504 * dispatches to the currently expanded item, if any. | 502 * dispatches to the currently expanded item, if any. |
| 505 * @param {Event} e The keydown event. | 503 * @param {Event} e The keydown event. |
| 506 * @private | 504 * @private |
| 507 */ | 505 */ |
| 508 handleKeyLeftRight_: function(e) { | 506 handleKeyLeftRight_: function(e) { |
| 509 var id = e.keyIdentifier; | 507 var id = e.keyIdentifier; |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 parent.clear(); | 698 parent.clear(); |
| 701 this.addByParent_(parent, 0, children); | 699 this.addByParent_(parent, 0, children); |
| 702 parent.endBatchUpdates(); | 700 parent.endBatchUpdates(); |
| 703 }, | 701 }, |
| 704 }; | 702 }; |
| 705 | 703 |
| 706 return { | 704 return { |
| 707 IntentsList: IntentsList | 705 IntentsList: IntentsList |
| 708 }; | 706 }; |
| 709 }); | 707 }); |
| OLD | NEW |