Fix #5660 - roojs docs - linking and other tidy ups
[roojs1] / docs / Roo.docs.init.js
index b315fb8..62ad990 100644 (file)
@@ -3,7 +3,7 @@
 Roo.docs.init = {
     
     classes : false, // flat version of list of classes 
-    currentClass : '', // currently viewed class name
+    currentClass : '--none--', // currently viewed class name
     
     hash : '',
     
@@ -49,21 +49,35 @@ Roo.docs.init = {
             success : function(res, o)
             {
                 var d = Roo.decode(res.responseText);
-                Roo.log(d);
+                //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.addTreeItem(Roo.docs.navGroup, e, 'NavSidebarItem', true);
                         
                     }
                 }, this);
                 
                 d.forEach(function(e) {
                     if (!e.cn.length) {
-                        this.addTreeItem(Roo.docs.navGroup, e, 'NavSidebarItem');
+                        this.addTreeItem(Roo.docs.navGroup, e, 'NavSidebarItem' ,true);
                     }
                 }, this);
+                
+                d.forEach(function(e) {
+                    if (e.cn.length) {
+                        this.addTreeItem(Roo.docs.mobileNavGroup, e, 'NavSidebarItem', false);
+                        
+                    }
+                }, this);
+                
+                d.forEach(function(e) {
+                    if (!e.cn.length) {
+                        this.addTreeItem(Roo.docs.mobileNavGroup, e, 'NavSidebarItem', false);
+                    }
+                }, this);
+                
                 var roo = Roo.docs.navGroup.items[1].menu;
                 roo.show(roo.triggerEl, '?', false);
                 if (location.hash.length) {
@@ -112,7 +126,7 @@ Roo.docs.init = {
                     ev.stopPropagation();
                      
                     if (c.cn.length) {
-                        Roo.log(ev);
+                        //Roo.log(ev);
                         if (mi.menu.el.hasClass('show')) {
                             this.hideChildren(c); //mi.menu.hide();
                             // collapse children..
@@ -149,9 +163,20 @@ Roo.docs.init = {
                 
             })
         }));
-        e.node = node;
-        e.parent_menu = parent;
-        e.parent = parent_e;
+        
+        // mobile nodes..?
+        
+       
+        
+        
+        
+        
+        if (parent_e !== false) {
+            e.node = node;
+            e.parent_menu = parent;
+            e.parent = parent_e == true ? null : parent_e;
+        }
+        
         parent.items.push(node);
         if (e.cn.length  && type == 'NavSidebarItem') {
             this.topm = node.menu;
@@ -163,16 +188,16 @@ Roo.docs.init = {
         }
         e.cn.forEach(function(ec) {
             var cn = ec.name.split('.').pop();
-            Roo.log(cn);
+            //Roo.log(cn);
             if (cn == cn.toLowerCase()) {
-                this.addTreeItem(node.menu, ec,'MenuItem', e);
+                this.addTreeItem(node.menu, ec,'MenuItem', parent_e !== false ? e : false);
             }
             
         }, this);
         e.cn.forEach(function(ec) {
             var cn = ec.name.split('.').pop();
             if (cn != cn.toLowerCase()) {
-                this.addTreeItem(node.menu, ec,'MenuItem', e);
+                this.addTreeItem(node.menu, ec,'MenuItem', parent_e !== false ? e : false);
             }
         }, this);
         
@@ -211,7 +236,13 @@ Roo.docs.init = {
     
     loadDoc : function(cls)
     {
+        if (this.currentClass == cls.name) {
+            return;
+        }
+        //Roo.docs.mobileNavGroup.hide();
+        Roo.log("loadDoc?");
         Roo.docs.doc_body_content.hide();
+        
         this.currentClass = cls.name;
         if (!cls ) {
             Roo.docs.introBody.show();
@@ -329,7 +360,7 @@ Roo.docs.init = {
     loadHash : function()
     {
         if (location.hash.length < 2) {
-            this.loadClass('');
+            this.loadDoc(false);
         }
         this.loadClass(location.hash.substring(1));
         this.hash = location.hash;
@@ -372,14 +403,14 @@ Roo.docs.init = {
             var sm = line.match(/^(\s+)(.*)/);
             
             var sml = sm ? sm[1].length: 0;
-            Roo.log(sml);
+            //Roo.log(sml);
             sml = sml / 4; // 4 spaces indent?
             var add = { name : sm ?  sm[2] : line, cn : [] };
             state[sml].cn.push(add);
             state[sml+1] = add;
             
         }
-        Roo.log(tree);
+        //Roo.log(tree);
         
         for(var i = 0; i < tree.cn.length; i++) {
             // make a container..
@@ -426,7 +457,7 @@ Roo.docs.init = {
                     if (treeiii.name == 'Examples') {
                         for (var j =0;j< treeiii.cn.length; j++) {
                             var exs = treeiii.cn[j].name.match(/^\[([^\]]+)\](.*)$/);
-                            footer += '<li><a href="../' + exs[1] + '">'+exs[2] + '</a></li>';
+                            footer += '<li><a target="_blank" href="../' + exs[1] + '">'+exs[2] + '</a></li>';
                         }
                         continue;
                         
@@ -444,7 +475,7 @@ Roo.docs.init = {
                                    xtype : 'Link',
                                     href : '#' + ( ll ? ll[1] : treeiii.name ) ,
                                     html : ll ? ll[1] : treeiii.name,
-                                    target : "_new",
+                                    
                                     xns : Roo.bootstrap 
                                 },
                                 {
@@ -462,7 +493,7 @@ Roo.docs.init = {
                     
                 }
                 if (footer.length) {
-                    Roo.log("footer:"+  footer);
+                    //Roo.log("footer:"+  footer);
                     ctreei.footer = '<h5>Examples:</h5><ul>'+footer +'</ul>';
                 }