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