Reviewed by Mitz.
authorthatcher <thatcher@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 22 Apr 2007 22:12:00 +0000 (22:12 +0000)
committerthatcher <thatcher@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 22 Apr 2007 22:12:00 +0000 (22:12 +0000)
        Bug 13436: Make Option-clicking a disclosure triangle expand the entire subtree
        http://bugs.webkit.org/show_bug.cgi?id=13436

        Makes option-click recursively expand and collapse the sub-tree. Pressing option-left
        and -right also recursively expands and collapses the sub-tree.

        * WebInspector/webInspector/treeoutline.js:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@21007 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/ChangeLog
WebKit/WebInspector/webInspector/treeoutline.js

index 4ad85892d6ab8a89ba71dd415d1ba6b5bb30e5fb..199780db8aa0c312a4badb39d7392fe90f7ec529 100644 (file)
@@ -1,3 +1,15 @@
+2007-04-22  Timothy Hatcher  <timothy@apple.com>
+
+        Reviewed by Mitz.
+
+        Bug 13436: Make Option-clicking a disclosure triangle expand the entire subtree
+        http://bugs.webkit.org/show_bug.cgi?id=13436
+
+        Makes option-click recursively expand and collapse the sub-tree. Pressing option-left
+        and -right also recursively expands and collapses the sub-tree.
+
+        * WebInspector/webInspector/treeoutline.js:
+
 2007-04-22  Timothy Hatcher  <timothy@apple.com>
 
         Reviewed by Mitz.
index f229b608b1195a31fbd777ef2503930590e726b5..3867e2a9426c14fb506cb3b83b77b3fb03ee88bc 100644 (file)
@@ -187,20 +187,23 @@ TreeOutline.prototype.findTreeElement = function(representedObject)
 
 TreeOutline.prototype.handleKeyEvent = function(event)
 {
-    if (!this.selectedTreeElement || event.shiftKey || event.metaKey || event.altKey || event.ctrlKey)
+    if (!this.selectedTreeElement || event.shiftKey || event.metaKey || event.ctrlKey)
         return;
 
     var handled = false;
     var nextSelectedElement;
-    if (event.keyIdentifier === "Up") {
+    if (event.keyIdentifier === "Up" && !event.altKey) {
         nextSelectedElement = this.selectedTreeElement.traversePreviousTreeElement(true);
         handled = true;
-    } else if (event.keyIdentifier === "Down") {
+    } else if (event.keyIdentifier === "Down" && !event.altKey) {
         nextSelectedElement = this.selectedTreeElement.traverseNextTreeElement(true);
         handled = true;
     } else if (event.keyIdentifier === "Left") {
         if (this.selectedTreeElement.expanded) {
-            this.selectedTreeElement.collapse();
+            if (event.altKey)
+                this.selectedTreeElement.collapseRecursively();
+            else
+                this.selectedTreeElement.collapse();
             handled = true;
         } else if (this.selectedTreeElement.parent && !this.selectedTreeElement.parent.root) {
             nextSelectedElement = this.selectedTreeElement.parent;
@@ -208,7 +211,10 @@ TreeOutline.prototype.handleKeyEvent = function(event)
         }
     } else if (event.keyIdentifier === "Right") {
         if (this.selectedTreeElement.hasChildren) {
-            this.selectedTreeElement.expand();
+            if (event.altKey)
+                this.selectedTreeElement.expandRecursively();
+            else
+                this.selectedTreeElement.expand();
             handled = true;
         }
     }
@@ -346,9 +352,15 @@ TreeElement.treeElementToggled = function(event)
 
     if (event.offsetX <= 20 && element.treeElement.hasChildren) {
         if (element.treeElement.expanded) {
-            element.treeElement.collapse();
+            if (event.altKey)
+                element.treeElement.collapseRecursively();
+            else
+                element.treeElement.collapse();
         } else {
-            element.treeElement.expand();
+            if (event.altKey)
+                element.treeElement.expandRecursively();
+            else
+                element.treeElement.expand();
         }
     }
 }
@@ -381,6 +393,16 @@ TreeElement.prototype.collapse = function()
         this.oncollapse(this);
 }
 
+TreeElement.prototype.collapseRecursively = function()
+{
+    var item = this;
+    while (item) {
+        if (item.expanded)
+            item.collapse();
+        item = item.traverseNextTreeElement(false, this, true);
+    }
+}
+
 TreeElement.prototype.expand = function()
 {
     if (!this.hasChildren || (this.expanded && !this.refreshChildren && this._childrenListNode))
@@ -424,6 +446,15 @@ TreeElement.prototype.expand = function()
         this.onexpand(this);
 }
 
+TreeElement.prototype.expandRecursively = function()
+{
+    var item = this;
+    while (item) {
+        item.expand();
+        item = item.traverseNextTreeElement(false, this);
+    }
+}
+
 TreeElement.prototype.reveal = function()
 {
     var currentAncestor = this.parent;