Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Side by Side Diff: ui/webui/resources/js/cr/ui/list.js

Issue 688043003: Maintain focused column in chrome://settings/searchEngines (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@split1_05
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // require: array_data_model.js 5 // require: array_data_model.js
6 // require: list_selection_model.js 6 // require: list_selection_model.js
7 // require: list_selection_controller.js 7 // require: list_selection_controller.js
8 // require: list_item.js 8 // require: list_item.js
9 9
10 /** 10 /**
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 get selectionModel() { 174 get selectionModel() {
175 return this.selectionModel_; 175 return this.selectionModel_;
176 }, 176 },
177 set selectionModel(sm) { 177 set selectionModel(sm) {
178 var oldSm = this.selectionModel_; 178 var oldSm = this.selectionModel_;
179 if (oldSm == sm) 179 if (oldSm == sm)
180 return; 180 return;
181 181
182 if (!this.boundHandleOnChange_) { 182 if (!this.boundHandleOnChange_) {
183 this.boundHandleOnChange_ = this.handleOnChange_.bind(this); 183 this.boundHandleOnChange_ = this.handleOnChange_.bind(this);
184 this.boundHandleLeadChange_ = this.handleLeadChange_.bind(this); 184 this.boundHandleLeadChange_ = this.handleLeadChange.bind(this);
185 } 185 }
186 186
187 if (oldSm) { 187 if (oldSm) {
188 oldSm.removeEventListener('change', this.boundHandleOnChange_); 188 oldSm.removeEventListener('change', this.boundHandleOnChange_);
189 oldSm.removeEventListener('leadIndexChange', 189 oldSm.removeEventListener('leadIndexChange',
190 this.boundHandleLeadChange_); 190 this.boundHandleLeadChange_);
191 } 191 }
192 192
193 this.selectionModel_ = sm; 193 this.selectionModel_ = sm;
194 this.selectionController_ = this.createSelectionController(sm); 194 this.selectionController_ = this.createSelectionController(sm);
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 listItem.removeAttribute('aria-setsize'); 589 listItem.removeAttribute('aria-setsize');
590 } 590 }
591 } 591 }
592 }, this); 592 }, this);
593 593
594 cr.dispatchSimpleEvent(this, 'change'); 594 cr.dispatchSimpleEvent(this, 'change');
595 }, 595 },
596 596
597 /** 597 /**
598 * Handles a change of the lead item from the selection model. 598 * Handles a change of the lead item from the selection model.
599 * @param {Event} pe The property change event. 599 * @param {Event} e The property change event.
600 * @private 600 * @protected
601 */ 601 */
602 handleLeadChange_: function(pe) { 602 handleLeadChange: function(e) {
603 var element; 603 var element;
604 if (pe.oldValue != -1) { 604 if (e.oldValue != -1) {
605 if ((element = this.getListItemByIndex(pe.oldValue))) 605 if ((element = this.getListItemByIndex(e.oldValue)))
606 element.lead = false; 606 element.lead = false;
607 } 607 }
608 608
609 if (pe.newValue != -1) { 609 if (e.newValue != -1) {
610 if ((element = this.getListItemByIndex(pe.newValue))) 610 if ((element = this.getListItemByIndex(e.newValue)))
611 element.lead = true; 611 element.lead = true;
612 if (pe.oldValue != pe.newValue) { 612 if (e.oldValue != e.newValue) {
613 this.scrollIndexIntoView(pe.newValue); 613 this.scrollIndexIntoView(e.newValue);
614 // If the lead item has a different height than other items, then we 614 // If the lead item has a different height than other items, then we
615 // may run into a problem that requires a second attempt to scroll 615 // may run into a problem that requires a second attempt to scroll
616 // it into view. The first scroll attempt will trigger a redraw, 616 // it into view. The first scroll attempt will trigger a redraw,
617 // which will clear out the list and repopulate it with new items. 617 // which will clear out the list and repopulate it with new items.
618 // During the redraw, the list may shrink temporarily, which if the 618 // During the redraw, the list may shrink temporarily, which if the
619 // lead item is the last item, will move the scrollTop up since it 619 // lead item is the last item, will move the scrollTop up since it
620 // cannot extend beyond the end of the list. (Sadly, being scrolled to 620 // cannot extend beyond the end of the list. (Sadly, being scrolled to
621 // the bottom of the list is not "sticky.") So, we set a timeout to 621 // the bottom of the list is not "sticky.") So, we set a timeout to
622 // rescroll the list after this all gets sorted out. This is perhaps 622 // rescroll the list after this all gets sorted out. This is perhaps
623 // not the most elegant solution, but no others seem obvious. 623 // not the most elegant solution, but no others seem obvious.
624 var self = this; 624 var self = this;
625 window.setTimeout(function() { 625 window.setTimeout(function() {
626 self.scrollIndexIntoView(pe.newValue); 626 self.scrollIndexIntoView(e.newValue);
627 }, 0); 627 }, 0);
628 } 628 }
629 } 629 }
630 }, 630 },
631 631
632 /** 632 /**
633 * This handles data model 'permuted' event. 633 * This handles data model 'permuted' event.
634 * this event is dispatched as a part of sort or splice. 634 * this event is dispatched as a part of sort or splice.
635 * We need to 635 * We need to
636 * - adjust the cache. 636 * - adjust the cache.
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 if (element.tabIndex >= 0 && !element.disabled) 1358 if (element.tabIndex >= 0 && !element.disabled)
1359 return true; 1359 return true;
1360 } 1360 }
1361 return false; 1361 return false;
1362 } 1362 }
1363 1363
1364 return { 1364 return {
1365 List: List 1365 List: List
1366 }; 1366 };
1367 }); 1367 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698