OLD | NEW |
---|---|
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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * Entry of NavigationListModel. This construtor should be called only from | 8 * Entry of NavigationListModel. This construtor should be called only from |
9 * the helper methods (NavigationModelItem.createWithPath/createWithEntry). | 9 * the helper methods (NavigationModelItem.createWithPath/createWithEntry). |
10 * | 10 * |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
439 function NavigationList() { | 439 function NavigationList() { |
440 } | 440 } |
441 | 441 |
442 /** | 442 /** |
443 * NavigationList inherits cr.ui.List. | 443 * NavigationList inherits cr.ui.List. |
444 */ | 444 */ |
445 NavigationList.prototype = { | 445 NavigationList.prototype = { |
446 __proto__: cr.ui.List.prototype, | 446 __proto__: cr.ui.List.prototype, |
447 | 447 |
448 set dataModel(dataModel) { | 448 set dataModel(dataModel) { |
449 if (!this.boundHandleListChanged_) | |
450 this.boundHandleListChanged_ = this.onListContentChanged_.bind(this); | |
451 | |
452 if (this.dataModel_) { | |
453 dataModel.removeEventListener('change', this.boundHandleListChanged_); | |
454 dataModel.removeEventListener('permuted', this.boundHandleListChanged_); | |
455 } | |
456 | |
457 dataModel.addEventListener('change', this.boundHandleListChanged_); | |
458 dataModel.addEventListener('permuted', this.boundHandleListChanged_); | |
459 | |
460 var parentSetter = cr.ui.List.prototype.__lookupSetter__('dataModel'); | 449 var parentSetter = cr.ui.List.prototype.__lookupSetter__('dataModel'); |
461 return parentSetter.call(this, dataModel); | 450 return parentSetter.call(this, dataModel); |
462 }, | 451 }, |
463 | 452 |
464 get dataModel() { | 453 get dataModel() { |
465 return this.dataModel_; | 454 return this.dataModel_; |
466 }, | 455 }, |
467 | 456 |
468 // TODO(yoshiki): Add a setter of 'directoryModel'. | 457 // TODO(yoshiki): Add a setter of 'directoryModel'. |
469 }; | 458 }; |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
685 /** | 674 /** |
686 * Invoked when the current directory is changed. | 675 * Invoked when the current directory is changed. |
687 * @param {Event} event The event. | 676 * @param {Event} event The event. |
688 * @private | 677 * @private |
689 */ | 678 */ |
690 NavigationList.prototype.onCurrentDirectoryChanged_ = function(event) { | 679 NavigationList.prototype.onCurrentDirectoryChanged_ = function(event) { |
691 this.selectBestMatchItem_(); | 680 this.selectBestMatchItem_(); |
692 }; | 681 }; |
693 | 682 |
694 /** | 683 /** |
695 * Invoked when the content in the data model is changed. | 684 * Invoked when the batch update is finished. |
696 * @param {Event} event The event. | 685 * @override |
686 */ | |
687 NavigationList.prototype.endBatchUpdates = function() { | |
hirono
2013/09/03 08:20:30
It seems that the endBatchUpdates will not be call
yoshiki
2013/09/03 09:33:32
Good catch. Fixed.
| |
688 // Calls the parent class method. | |
689 cr.ui.List.prototype.endBatchUpdates.call(this); | |
690 | |
691 this.onListContentChanged_(); | |
692 }; | |
693 | |
694 /** | |
695 * Invoked when the elements in the list is updated. | |
697 * @private | 696 * @private |
698 */ | 697 */ |
699 NavigationList.prototype.onListContentChanged_ = function(event) { | 698 NavigationList.prototype.onListContentChanged_ = function() { |
700 this.selectBestMatchItem_(); | 699 this.selectBestMatchItem_(); |
701 }; | 700 }; |
702 | 701 |
703 /** | 702 /** |
704 * Synchronizes the volume list selection with the current directory, after | 703 * Synchronizes the volume list selection with the current directory, after |
705 * it is changed outside of the volume list. | 704 * it is changed outside of the volume list. |
706 * @private | 705 * @private |
707 */ | 706 */ |
708 NavigationList.prototype.selectBestMatchItem_ = function() { | 707 NavigationList.prototype.selectBestMatchItem_ = function() { |
709 var entry = this.directoryModel_.getCurrentDirEntry(); | 708 var entry = this.directoryModel_.getCurrentDirEntry(); |
(...skipping 27 matching lines...) Expand all Loading... | |
737 var itemPath = this.dataModel.item(i).path; | 736 var itemPath = this.dataModel.item(i).path; |
738 if (PathUtil.getRootPath(itemPath) == newRootPath) { | 737 if (PathUtil.getRootPath(itemPath) == newRootPath) { |
739 // Not to invoke the handler of this instance, sets the guard. | 738 // Not to invoke the handler of this instance, sets the guard. |
740 this.dontHandleSelectionEvent_ = true; | 739 this.dontHandleSelectionEvent_ = true; |
741 this.selectionModel.selectedIndex = i; | 740 this.selectionModel.selectedIndex = i; |
742 this.dontHandleSelectionEvent_ = false; | 741 this.dontHandleSelectionEvent_ = false; |
743 return; | 742 return; |
744 } | 743 } |
745 } | 744 } |
746 }; | 745 }; |
OLD | NEW |