| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 TreeOutline.prototype.expand = function() | 408 TreeOutline.prototype.expand = function() |
| 409 { | 409 { |
| 410 // this is the root, do nothing | 410 // this is the root, do nothing |
| 411 } | 411 } |
| 412 | 412 |
| 413 TreeOutline.prototype.collapse = function() | 413 TreeOutline.prototype.collapse = function() |
| 414 { | 414 { |
| 415 // this is the root, do nothing | 415 // this is the root, do nothing |
| 416 } | 416 } |
| 417 | 417 |
| 418 /** |
| 419 * @return {boolean} |
| 420 */ |
| 418 TreeOutline.prototype.revealed = function() | 421 TreeOutline.prototype.revealed = function() |
| 419 { | 422 { |
| 420 return true; | 423 return true; |
| 421 } | 424 } |
| 422 | 425 |
| 423 TreeOutline.prototype.reveal = function() | 426 TreeOutline.prototype.reveal = function() |
| 424 { | 427 { |
| 425 // this is the root, do nothing | 428 // this is the root, do nothing |
| 426 } | 429 } |
| 427 | 430 |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 maxDepth = 3; | 761 maxDepth = 3; |
| 759 | 762 |
| 760 while (item) { | 763 while (item) { |
| 761 if (depth < maxDepth) | 764 if (depth < maxDepth) |
| 762 item.expand(); | 765 item.expand(); |
| 763 item = item.traverseNextTreeElement(false, this, (depth >= maxDepth), in
fo); | 766 item = item.traverseNextTreeElement(false, this, (depth >= maxDepth), in
fo); |
| 764 depth += info.depthChange; | 767 depth += info.depthChange; |
| 765 } | 768 } |
| 766 } | 769 } |
| 767 | 770 |
| 771 /** |
| 772 * @param {?TreeElement} ancestor |
| 773 * @return {boolean} |
| 774 */ |
| 768 TreeElement.prototype.hasAncestor = function(ancestor) { | 775 TreeElement.prototype.hasAncestor = function(ancestor) { |
| 769 if (!ancestor) | 776 if (!ancestor) |
| 770 return false; | 777 return false; |
| 771 | 778 |
| 772 var currentNode = this.parent; | 779 var currentNode = this.parent; |
| 773 while (currentNode) { | 780 while (currentNode) { |
| 774 if (ancestor === currentNode) | 781 if (ancestor === currentNode) |
| 775 return true; | 782 return true; |
| 776 currentNode = currentNode.parent; | 783 currentNode = currentNode.parent; |
| 777 } | 784 } |
| 778 | 785 |
| 779 return false; | 786 return false; |
| 780 } | 787 } |
| 781 | 788 |
| 782 TreeElement.prototype.reveal = function() | 789 TreeElement.prototype.reveal = function() |
| 783 { | 790 { |
| 784 var currentAncestor = this.parent; | 791 var currentAncestor = this.parent; |
| 785 while (currentAncestor && !currentAncestor.root) { | 792 while (currentAncestor && !currentAncestor.root) { |
| 786 if (!currentAncestor.expanded) | 793 if (!currentAncestor.expanded) |
| 787 currentAncestor.expand(); | 794 currentAncestor.expand(); |
| 788 currentAncestor = currentAncestor.parent; | 795 currentAncestor = currentAncestor.parent; |
| 789 } | 796 } |
| 790 | 797 |
| 791 this.onreveal(); | 798 this.onreveal(); |
| 792 } | 799 } |
| 793 | 800 |
| 801 /** |
| 802 * @return {boolean} |
| 803 */ |
| 794 TreeElement.prototype.revealed = function() | 804 TreeElement.prototype.revealed = function() |
| 795 { | 805 { |
| 796 var currentAncestor = this.parent; | 806 var currentAncestor = this.parent; |
| 797 while (currentAncestor && !currentAncestor.root) { | 807 while (currentAncestor && !currentAncestor.root) { |
| 798 if (!currentAncestor.expanded) | 808 if (!currentAncestor.expanded) |
| 799 return false; | 809 return false; |
| 800 currentAncestor = currentAncestor.parent; | 810 currentAncestor = currentAncestor.parent; |
| 801 } | 811 } |
| 802 | 812 |
| 803 return true; | 813 return true; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 * @param {boolean=} omitFocus | 851 * @param {boolean=} omitFocus |
| 842 */ | 852 */ |
| 843 TreeElement.prototype.revealAndSelect = function(omitFocus) | 853 TreeElement.prototype.revealAndSelect = function(omitFocus) |
| 844 { | 854 { |
| 845 this.reveal(); | 855 this.reveal(); |
| 846 this.select(omitFocus); | 856 this.select(omitFocus); |
| 847 } | 857 } |
| 848 | 858 |
| 849 /** | 859 /** |
| 850 * @param {boolean=} supressOnDeselect | 860 * @param {boolean=} supressOnDeselect |
| 861 * @return {boolean} |
| 851 */ | 862 */ |
| 852 TreeElement.prototype.deselect = function(supressOnDeselect) | 863 TreeElement.prototype.deselect = function(supressOnDeselect) |
| 853 { | 864 { |
| 854 if (!this.treeOutline || this.treeOutline.selectedTreeElement !== this || !t
his.selected) | 865 if (!this.treeOutline || this.treeOutline.selectedTreeElement !== this || !t
his.selected) |
| 855 return false; | 866 return false; |
| 856 | 867 |
| 857 this.selected = false; | 868 this.selected = false; |
| 858 this.treeOutline.selectedTreeElement = null; | 869 this.treeOutline.selectedTreeElement = null; |
| 859 if (this._listItemNode) | 870 if (this._listItemNode) |
| 860 this._listItemNode.classList.remove("selected"); | 871 this._listItemNode.classList.remove("selected"); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 | 971 |
| 961 if (element) | 972 if (element) |
| 962 return element; | 973 return element; |
| 963 | 974 |
| 964 if (!this.parent || this.parent.root) | 975 if (!this.parent || this.parent.root) |
| 965 return null; | 976 return null; |
| 966 | 977 |
| 967 return this.parent; | 978 return this.parent; |
| 968 } | 979 } |
| 969 | 980 |
| 981 /** |
| 982 * @return {boolean} |
| 983 */ |
| 970 TreeElement.prototype.isEventWithinDisclosureTriangle = function(event) | 984 TreeElement.prototype.isEventWithinDisclosureTriangle = function(event) |
| 971 { | 985 { |
| 972 // FIXME: We should not use getComputedStyle(). For that we need to get rid
of using ::before for disclosure triangle. (http://webk.it/74446) | 986 // FIXME: We should not use getComputedStyle(). For that we need to get rid
of using ::before for disclosure triangle. (http://webk.it/74446) |
| 973 var paddingLeftValue = window.getComputedStyle(this._listItemNode).getProper
tyCSSValue("padding-left"); | 987 var paddingLeftValue = window.getComputedStyle(this._listItemNode).getProper
tyCSSValue("padding-left"); |
| 974 var computedLeftPadding = paddingLeftValue ? paddingLeftValue.getFloatValue(
CSSPrimitiveValue.CSS_PX) : 0; | 988 var computedLeftPadding = paddingLeftValue ? paddingLeftValue.getFloatValue(
CSSPrimitiveValue.CSS_PX) : 0; |
| 975 var left = this._listItemNode.totalOffsetLeft() + computedLeftPadding; | 989 var left = this._listItemNode.totalOffsetLeft() + computedLeftPadding; |
| 976 return event.pageX >= left && event.pageX <= left + this.arrowToggleWidth &&
this.hasChildren; | 990 return event.pageX >= left && event.pageX <= left + this.arrowToggleWidth &&
this.hasChildren; |
| 977 } | 991 } |
| OLD | NEW |