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 | 5 |
6 cr.define('bmm', function() { | 6 cr.define('bmm', function() { |
7 /** @const */ var Tree = cr.ui.Tree; | 7 /** @const */ var Tree = cr.ui.Tree; |
8 /** @const */ var TreeItem = cr.ui.TreeItem; | 8 /** @const */ var TreeItem = cr.ui.TreeItem; |
9 | 9 |
10 var treeLookup = {}; | 10 var treeLookup = {}; |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 var parentItem = treeLookup[bookmarkNode.parentId]; | 186 var parentItem = treeLookup[bookmarkNode.parentId]; |
187 var newItem = new BookmarkTreeItem(bookmarkNode); | 187 var newItem = new BookmarkTreeItem(bookmarkNode); |
188 addTreeItem(parentItem, newItem); | 188 addTreeItem(parentItem, newItem); |
189 } | 189 } |
190 }, | 190 }, |
191 | 191 |
192 handleMoved: function(id, moveInfo) { | 192 handleMoved: function(id, moveInfo) { |
193 var treeItem = treeLookup[id]; | 193 var treeItem = treeLookup[id]; |
194 if (treeItem) { | 194 if (treeItem) { |
195 var oldParentItem = treeLookup[moveInfo.oldParentId]; | 195 var oldParentItem = treeLookup[moveInfo.oldParentId]; |
196 oldParentItem.remove(treeItem); | 196 TreeItem.prototype.remove.call(oldParentItem, treeItem); |
arv (Not doing code reviews)
2012/12/20 14:54:51
This seems pretty hacky. Is there an alternative s
| |
197 var newParentItem = treeLookup[moveInfo.parentId]; | 197 var newParentItem = treeLookup[moveInfo.parentId]; |
198 // The tree only shows folders so the index is not the index we want. We | 198 // The tree only shows folders so the index is not the index we want. We |
199 // therefore get the children need to adjust the index. | 199 // therefore get the children need to adjust the index. |
200 addTreeItem(newParentItem, treeItem); | 200 addTreeItem(newParentItem, treeItem); |
201 } | 201 } |
202 }, | 202 }, |
203 | 203 |
204 handleRemoved: function(id, removeInfo) { | 204 handleRemoved: function(id, removeInfo) { |
205 var parentItem = treeLookup[removeInfo.parentId]; | 205 var parentItem = treeLookup[removeInfo.parentId]; |
206 var itemToRemove = treeLookup[id]; | 206 var itemToRemove = treeLookup[id]; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
287 } | 287 } |
288 }; | 288 }; |
289 | 289 |
290 return { | 290 return { |
291 BookmarkTree: BookmarkTree, | 291 BookmarkTree: BookmarkTree, |
292 BookmarkTreeItem: BookmarkTreeItem, | 292 BookmarkTreeItem: BookmarkTreeItem, |
293 treeLookup: treeLookup, | 293 treeLookup: treeLookup, |
294 tree: tree | 294 tree: tree |
295 }; | 295 }; |
296 }); | 296 }); |
OLD | NEW |