changeset 1:ef88131dbd73

Added a 'landscape' option, though it's disabled for now.
author Atul Varma <varmaa@toolness.com>
date Sat, 12 Dec 2009 15:18:01 -0800
parents 100c148d285c
children e282ed20b426
files moztree.js
diffstat 1 files changed, 19 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/moztree.js	Sat Dec 12 14:11:02 2009 -0800
+++ b/moztree.js	Sat Dec 12 15:18:01 2009 -0800
@@ -55,9 +55,23 @@
 
 function makeTree(tree, options) {
   var svg = document.createElementNS(SVG_NS, "svg");
-  svg.setAttribute("width", options.dirWidth * options.dirDepth);
-  svg.setAttribute("height", options.height);
-  drawDir(svg, tree, options.dirDepth,
+  var group = document.createElementNS(SVG_NS, "g");
+  var svgHeight = options.height;
+  var svgWidth = options.dirWidth * options.dirDepth;
+
+  if (options.landscape) {
+    var temp = svgWidth;
+    group.setAttribute("transform",
+                       "translate(" + svgHeight + ", 0) rotate(90)");
+    svgWidth = svgHeight;
+    svgHeight = temp;
+  }
+
+  svg.setAttribute("width", svgWidth);
+  svg.setAttribute("height", svgHeight);
+  svg.appendChild(group);
+
+  drawDir(group, tree, options.dirDepth,
           {x: 0,
            y: 0,
            width: options.dirWidth,
@@ -73,7 +87,8 @@
             function(tree) {
               var svg = makeTree(tree, {height: 2800,
                                         dirWidth: 100,
-                                        dirDepth: 8,
+                                        dirDepth: 6,
+                                        landscape: false,
                                         textPadding: 4,
                                         minHeight: 16});
               $(document.body).append(svg);