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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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_) | 449 if (!this.boundHandleListChanged_) |
450 this.boundHandleListChanged_ = this.onListContentChanged_.bind(this); | 450 this.boundHandleListChanged_ = this.onListContentChanged_.bind(this); |
451 | 451 |
452 if (this.dataModel_) { | 452 if (this.dataModel_) { |
453 dataModel.removeEventListener('change', this.boundHandleListChanged_); | 453 this.dataModel_.removeEventListener( |
454 dataModel.removeEventListener('permuted', this.boundHandleListChanged_); | 454 'change', this.boundHandleListChanged_); |
hirono
2013/09/04 13:39:25
nit: The name pattern of xxxBound is more likely t
yoshiki
2013/09/04 14:26:55
Done.
| |
455 this.dataModel_.removeEventListener( | |
456 'permuted', this.boundHandleListChanged_); | |
455 } | 457 } |
456 | 458 |
459 var parentSetter = cr.ui.List.prototype.__lookupSetter__('dataModel'); | |
460 parentSetter.call(this, dataModel); | |
461 | |
462 // This must be placed after the parent method is called, in order to make | |
463 // it sure that the list was changed. | |
457 dataModel.addEventListener('change', this.boundHandleListChanged_); | 464 dataModel.addEventListener('change', this.boundHandleListChanged_); |
458 dataModel.addEventListener('permuted', this.boundHandleListChanged_); | 465 dataModel.addEventListener('permuted', this.boundHandleListChanged_); |
459 | |
460 var parentSetter = cr.ui.List.prototype.__lookupSetter__('dataModel'); | |
461 return parentSetter.call(this, dataModel); | |
462 }, | 466 }, |
463 | 467 |
464 get dataModel() { | 468 get dataModel() { |
465 return this.dataModel_; | 469 return this.dataModel_; |
466 }, | 470 }, |
467 | 471 |
468 // TODO(yoshiki): Add a setter of 'directoryModel'. | 472 // TODO(yoshiki): Add a setter of 'directoryModel'. |
469 }; | 473 }; |
470 | 474 |
471 /** | 475 /** |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
737 var itemPath = this.dataModel.item(i).path; | 741 var itemPath = this.dataModel.item(i).path; |
738 if (PathUtil.getRootPath(itemPath) == newRootPath) { | 742 if (PathUtil.getRootPath(itemPath) == newRootPath) { |
739 // Not to invoke the handler of this instance, sets the guard. | 743 // Not to invoke the handler of this instance, sets the guard. |
740 this.dontHandleSelectionEvent_ = true; | 744 this.dontHandleSelectionEvent_ = true; |
741 this.selectionModel.selectedIndex = i; | 745 this.selectionModel.selectedIndex = i; |
742 this.dontHandleSelectionEvent_ = false; | 746 this.dontHandleSelectionEvent_ = false; |
743 return; | 747 return; |
744 } | 748 } |
745 } | 749 } |
746 }; | 750 }; |
OLD | NEW |