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(arv): Now that this is driven by a data model, implement a data model | 5 // TODO(arv): Now that this is driven by a data model, implement a data model |
6 // that handles the loading and the events from the bookmark backend. | 6 // that handles the loading and the events from the bookmark backend. |
7 | 7 |
8 cr.define('bmm', function() { | 8 cr.define('bmm', function() { |
9 const List = cr.ui.List; | 9 const List = cr.ui.List; |
10 const ListItem = cr.ui.ListItem; | 10 const ListItem = cr.ui.ListItem; |
11 const ArrayDataModel = cr.ui.ArrayDataModel; | 11 const ArrayDataModel = cr.ui.ArrayDataModel; |
12 const ContextMenuButton = cr.ui.ContextMenuButton; | 12 const ContextMenuButton = cr.ui.ContextMenuButton; |
13 | 13 |
| 14 var list; |
| 15 |
14 /** | 16 /** |
15 * Basic array data model for use with bookmarks. | 17 * Basic array data model for use with bookmarks. |
16 * @param {!Array.<!BookmarkTreeNode>} items The bookmark items. | 18 * @param {!Array.<!BookmarkTreeNode>} items The bookmark items. |
17 * @constructor | 19 * @constructor |
18 * @extends {ArrayDataModel} | 20 * @extends {ArrayDataModel} |
19 */ | 21 */ |
20 function BookmarksArrayDataModel(items) { | 22 function BookmarksArrayDataModel(items) { |
21 this.bookmarksArrayDataModelArray_ = items; | 23 this.bookmarksArrayDataModelArray_ = items; |
22 ArrayDataModel.call(this, items); | 24 ArrayDataModel.call(this, items); |
23 } | 25 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 decorate: function() { | 71 decorate: function() { |
70 List.prototype.decorate.call(this); | 72 List.prototype.decorate.call(this); |
71 this.addEventListener('mousedown', this.handleMouseDown_); | 73 this.addEventListener('mousedown', this.handleMouseDown_); |
72 | 74 |
73 // HACK(arv): http://crbug.com/40902 | 75 // HACK(arv): http://crbug.com/40902 |
74 window.addEventListener('resize', this.redraw.bind(this)); | 76 window.addEventListener('resize', this.redraw.bind(this)); |
75 | 77 |
76 // We could add the ContextMenuButton in the BookmarkListItem but it slows | 78 // We could add the ContextMenuButton in the BookmarkListItem but it slows |
77 // down redraws a lot so we do this on mouseovers instead. | 79 // down redraws a lot so we do this on mouseovers instead. |
78 this.addEventListener('mouseover', this.handleMouseOver_.bind(this)); | 80 this.addEventListener('mouseover', this.handleMouseOver_.bind(this)); |
| 81 |
| 82 bmm.list = this; |
79 }, | 83 }, |
80 | 84 |
81 createItem: function(bookmarkNode) { | 85 createItem: function(bookmarkNode) { |
82 return new BookmarkListItem(bookmarkNode); | 86 return new BookmarkListItem(bookmarkNode); |
83 }, | 87 }, |
84 | 88 |
85 parentId_: '', | 89 parentId_: '', |
86 | 90 |
87 /** | 91 /** |
88 * Reloads the list from the bookmarks backend. | 92 * Reloads the list from the bookmarks backend. |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 cr.dispatchSimpleEvent(this, 'rename', true); | 564 cr.dispatchSimpleEvent(this, 'rename', true); |
561 } | 565 } |
562 } else if (newLabel != title || newUrl != url) { | 566 } else if (newLabel != title || newUrl != url) { |
563 cr.dispatchSimpleEvent(this, 'edit', true); | 567 cr.dispatchSimpleEvent(this, 'edit', true); |
564 } | 568 } |
565 } | 569 } |
566 } | 570 } |
567 }; | 571 }; |
568 | 572 |
569 return { | 573 return { |
570 BookmarkList: BookmarkList | 574 BookmarkList: BookmarkList, |
| 575 list: list |
571 }; | 576 }; |
572 }); | 577 }); |
OLD | NEW |