OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 // TODO(yoshiki): rename this sidebar.js to directory_tree.js. | 7 // TODO(yoshiki): rename this sidebar.js to directory_tree.js. |
8 | 8 |
9 //////////////////////////////////////////////////////////////////////////////// | 9 //////////////////////////////////////////////////////////////////////////////// |
10 // DirectoryTreeUtil | 10 // DirectoryTreeUtil |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 | 366 |
367 if (parentDirItem.expanded) | 367 if (parentDirItem.expanded) |
368 this.updateSubDirectories(false /* recursive */); | 368 this.updateSubDirectories(false /* recursive */); |
369 }; | 369 }; |
370 | 370 |
371 /** | 371 /** |
372 * Overrides WebKit's scrollIntoViewIfNeeded, which doesn't work well with | 372 * Overrides WebKit's scrollIntoViewIfNeeded, which doesn't work well with |
373 * a complex layout. This call is not necessary, so we are ignoring it. | 373 * a complex layout. This call is not necessary, so we are ignoring it. |
374 * | 374 * |
375 * @param {boolean} unused Unused. | 375 * @param {boolean} unused Unused. |
| 376 * @override |
376 */ | 377 */ |
377 DirectoryItem.prototype.scrollIntoViewIfNeeded = function(unused) { | 378 DirectoryItem.prototype.scrollIntoViewIfNeeded = function(unused) { |
378 }; | 379 }; |
379 | 380 |
380 /** | 381 /** |
| 382 * Removes the child node, but without selecting the parent item, to avoid |
| 383 * unintended changing of directories. Removing is done externally, and other |
| 384 * code will navigate to another directory. |
| 385 * |
| 386 * @param {!cr.ui.TreeItem} child The tree item child to remove. |
| 387 * @override |
| 388 */ |
| 389 DirectoryItem.prototype.remove = function(child) { |
| 390 this.lastElementChild.removeChild(child); |
| 391 if (this.items.length == 0) |
| 392 this.hasChildren = false; |
| 393 }; |
| 394 |
| 395 /** |
381 * Invoked when the item is being expanded. | 396 * Invoked when the item is being expanded. |
382 * @param {!UIEvent} e Event. | 397 * @param {!UIEvent} e Event. |
383 * @private | 398 * @private |
384 **/ | 399 **/ |
385 DirectoryItem.prototype.onExpand_ = function(e) { | 400 DirectoryItem.prototype.onExpand_ = function(e) { |
386 this.updateSubDirectories( | 401 this.updateSubDirectories( |
387 true /* recursive */, | 402 true /* recursive */, |
388 function() {}, | 403 function() {}, |
389 function() { | 404 function() { |
390 this.expanded = false; | 405 this.expanded = false; |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 cr.dispatchSimpleEvent(this, 'content-updated'); | 784 cr.dispatchSimpleEvent(this, 'content-updated'); |
770 } | 785 } |
771 }; | 786 }; |
772 | 787 |
773 /** | 788 /** |
774 * Updates the UI after the layout has changed. | 789 * Updates the UI after the layout has changed. |
775 */ | 790 */ |
776 DirectoryTree.prototype.relayout = function() { | 791 DirectoryTree.prototype.relayout = function() { |
777 cr.dispatchSimpleEvent(this, 'relayout'); | 792 cr.dispatchSimpleEvent(this, 'relayout'); |
778 }; | 793 }; |
OLD | NEW |