Fix #5654 - roojspacker - get it working as a doc tool...
[roojs1] / docs / Roo.docs.init.js
similarity index 81%
rename from docs2/Roo.docs.init.js
rename to docs/Roo.docs.init.js
index ebdce4c..2866e61 100644 (file)
@@ -2,6 +2,10 @@
 
 Roo.docs.init = {
     
+    classes : false, // flat version of list of classes 
+    currentClass : '', // currently viewed class name
+    
+    
     onReady : function()
     {
        
@@ -22,7 +26,7 @@ Roo.docs.init = {
             //Roo.XComponent.modules[0].el.fireEvent('render');
              this.loadTree();
         }, this);
-        
+        Roo.get(document.body).on('click', this.onClick, this);
       
         
     },
@@ -38,11 +42,15 @@ Roo.docs.init = {
             {
                 var d = Roo.decode(res.responseText);
                 Roo.log(d);
+                this.classes = [];
+                // our classes witch children first..
                 d.forEach(function(e) {
                     if (e.cn.length) {
                         this.addTreeItem(Roo.docs.navGroup, e, 'NavSidebarItem');
+                        
                     }
                 }, this);
+                
                 d.forEach(function(e) {
                     if (!e.cn.length) {
                         this.addTreeItem(Roo.docs.navGroup, e, 'NavSidebarItem');
@@ -51,6 +59,7 @@ Roo.docs.init = {
                 var roo = Roo.docs.navGroup.items[1].menu;
                 roo.show(roo.triggerEl, '?', false);
                 
+                
             },
             scope : this
         });
@@ -58,6 +67,8 @@ Roo.docs.init = {
         
     },
     addTreeItem : function(parent, e, type) {
+        
+        this.classes[e.name] = e; 
         // add a node..
         var node = parent.addxtypeChild(Roo.factory({
             html: e.name.split('.').pop(),
@@ -132,6 +143,38 @@ Roo.docs.init = {
         }, this);
         
     },
+    
+    loadClass : function(name)
+    {
+        if(typeof(this.classes[name]) != 'undefined') {
+            this.loadDoc(this.classes[name]);
+        }
+        
+        
+        
+    },
+    
+    loadSource : function( )
+    {
+        
+       
+        Roo.Ajax.request({
+            url : 'src/' +this.currentClass.replace(/\./g,'_') + '.js.html',
+            method : 'GET',
+            success : function(res, o)
+            {
+                Roo.docs.ViewSource.show({
+                        source : res.responseText,
+                        fname : this.currentClass.replace(/\./g,'/') + ".js"
+                });
+                
+            },
+            scope : this
+        });
+        
+        
+    },
+    
     loadDoc : function(cls)
     {
         Roo.docs.doc_body_content.hide();
@@ -154,6 +197,7 @@ Roo.docs.init = {
         
         
     },
+    
     fillDoc : function(d)
     {
         /*{
@@ -170,7 +214,7 @@ Roo.docs.init = {
         document.body.scrollTop  = 0;
         for (var k in d) {
             if (typeof(Roo.docs['doc_' + k])  !=  'undefined') {
-                Roo.docs['doc_' + k].el.dom.innerHTML = d[k].split("\n").join("<br/>");
+                Roo.docs['doc_' + k].el.dom.innerHTML = Roo.docs.template.resolveLinks(d[k]);;
             }
         }
         Roo.docs.doc_extends.hide();
@@ -209,6 +253,19 @@ Roo.docs.init = {
         }
         
         
+    },
+    onClick : function(e)
+    {
+        if (e.target.nodeName != 'A') {
+            return;
+        }
+        if (!e.target.href.match(/#/)) {
+            return;
+        }
+        e.stopPropagation();
+        var link = e.target.href.split('#')[1];
+        this.loadClass(link);
+        
     }