merge changes for seperator change
[roojs1] / docs / Roo.docs.init.js
index ec9b745..278c16b 100644 (file)
@@ -3,31 +3,35 @@
 Roo.docs.init = {
     
     classes : false, // flat version of list of classes 
-    currentClass : '', // currently viewed class name
+    currentClass : '--none--', // currently viewed class name
     
+    prefix : '',
+    hash : '',
     
     onReady : function()
     {
        
-        //if (typeof(pagedata) == 'undefined') {
-        //    Site.onReady.defer(100, Roo.docs.init);
-        //    return;
-        //}
-        //Roo.debug = 1;
         
         Roo.XComponent.hideProgress = true;
         Roo.XComponent.build();
-        
-        
-        
+         
         
         Roo.XComponent.on('buildcomplete', function() {
             
             //Roo.XComponent.modules[0].el.fireEvent('render');
-             this.loadTree();
+            this.loadTree();
+            if (window.location.search.length > 0) {
+                Roo.docs.roo_title.el.dom.innerHTML = "Flutter Documentation";
+            }
+            
         }, this);
-        Roo.get(document.body).on('click', this.onClick, this);
-      
+        if (window.location.search.length > 0) {
+            this.prefix = "/flutter/";
+            
+        }
+        
+        window.onhashchange = function() { Roo.docs.init.onHashChange(); }
+         
         
     },
     
@@ -36,28 +40,55 @@ Roo.docs.init = {
         Roo.docs.doc_body_content.hide();
         
         Roo.Ajax.request({
-            url : 'tree.json',
+            url : this.prefix + 'tree.json',
             method : 'GET',
             success : function(res, o)
             {
                 var d = Roo.decode(res.responseText);
-                Roo.log(d);
-                this.classes = [];
+                //Roo.log(d);
+                this.classes = {};
+                
+                d = d.sort(Roo.docs.template.makeSortby("name"));
+                
                 // 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' ,true);
+                    }
+                }, this);
+                
+                // mobile....
+                
+                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.navGroup, e, 'NavSidebarItem');
+                        this.addTreeItem(Roo.docs.mobileNavGroup, e, 'NavSidebarItem', false);
                     }
                 }, this);
+                
                 var roo = Roo.docs.navGroup.items[1].menu;
-                roo.show(roo.triggerEl, '?', false);
+                if (!Roo.docs.init.prefix.length) {
+                    roo.show(roo.triggerEl, '?', false);
+                }
+                
+                if (location.hash.length) {
+                    this.loadHash();
+                    return;
+                }
+                
                 this.loadIntro();
                 
                 
@@ -67,35 +98,51 @@ Roo.docs.init = {
         
         
     },
-    addTreeItem : function(parent, e, type) {
+    
+    hideChildren : function(c)
+    {
+        if (c.node.menu) {
+            c.node.menu.hide();
+        }
+        for (var i =0; i < c.cn.length; i++) {
+            this.hideChildren(c.cn[i]);
+        }
+        
+    },
+    
+    
+    addTreeItem : function(parent, e, type , parent_e) {
         
         this.classes[e.name] = e; 
         // add a node..
         var node = parent.addxtypeChild(Roo.factory({
             html: e.name.split('.').pop(),
-            id : e.name,
+           // id : e.name,
             xns : Roo.bootstrap,
             showArrow: false,
             xtype : type,
             preventDefault : true,
           //  cls : type == 'NavSidebarItem' ? 'open' : '',
             listeners : {
-                click : (function(mi,ev,c)
+                click : (function(mi,ev, c)
                 {
-                    
-                    ev.stopPropagation();
+                     ev.stopEvent();
                      
-                    if (c.cn.length) {
-                        Roo.log(ev);
+                    if (c.cn.length && mi.xtype == 'MenuItem') {
+                        //Roo.log(ev);
                         if (mi.menu.el.hasClass('show')) {
-                            mi.menu.hide();
+                            this.hideChildren(c); //mi.menu.hide();
+                            // collapse children..
+                            
+                            
+                            
                         } else {
                             mi.menu.show(mi.menu.triggerEl,'?', false);
                         }
                         
                     }
-                    
-                    Roo.docs.init.loadDoc(c);
+                    location.hash = '#' + c.name;
+                    //Roo.docs.init.loadDoc(c);
                     
                 }).createDelegate(this,[e], true)
                 
@@ -106,9 +153,13 @@ Roo.docs.init = {
                 xns: Roo.bootstrap,
                 xtype : 'Menu',
                 listeners : {
-                    beforehide : (function(mi,c)
+                    beforehide : (function(mi, c)
                     {
-                        if (c.name.split('.').length < 2) {
+                        if (Roo.docs.init.prefix.length) {
+                            return;
+                        }
+                        
+                        if ( c.name.split('.').length < 2)  {
                             return false;
                         }
                         return true;
@@ -119,6 +170,20 @@ Roo.docs.init = {
                 
             })
         }));
+        
+        // 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;
@@ -130,16 +195,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');
+                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');
+                this.addTreeItem(node.menu, ec,'MenuItem', parent_e !== false ? e : false);
             }
         }, this);
         
@@ -147,7 +212,7 @@ Roo.docs.init = {
     
     loadClass : function(name)
     {
-        if(typeof(this.classes[name]) != 'undefined') {
+        if(typeof(this.classes[name]) != 'undefined' && this.classes[name].is_class ) {
             this.loadDoc(this.classes[name]);
         }
         
@@ -178,29 +243,132 @@ 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();
+        Roo.docs.navHeaderBar.collapse();
         this.currentClass = cls.name;
-        if (!cls.is_class) {
+        if (!cls ) {
             Roo.docs.introBody.show();
             return;
         }
+        
+        // expand parents..
+        
+        var m = cls.parent_menu;
+        m.show(m.triggerEl,'?', false);
+        var mp = cls;
+        while ((mp = mp.parent)) {
+            m = mp.parent_menu;
+            m.show(m.triggerEl,'?', false);
+        }
+        cls.node.el.scrollIntoView(Roo.docs.sidebar.el,false);
+        Roo.docs.sidebar.el.select('.active').removeClass('active');
+        cls.node.el.addClass('active');
+        
         Roo.docs.introBody.hide();
         Roo.docs.doc_body_content.show();
         Roo.Ajax.request({
-            url : 'symbols/' + cls.name + '.json',
+            url : this.prefix + 'symbols/' + cls.name + '.json',
             method : 'GET',
             success : function(res, o)
             {
+                
                 var d = Roo.decode(res.responseText);
+                
+                if (typeof(d.augments) == 'undefined') {
+                    d.augments = [];
+                    d.config = []; // props for ctor?
+                    d.isFlutter  = true;
+                    d.config= d.props; // hack..
+                    Roo.docs.init.n = 0;
+                    this.fillAugments(d, d.extends, Roo.docs.init.fillDoc);
+                    return;
+                }
                 this.fillDoc(d);
                 
+                
+                
             },
             scope : this
         });
         
+    },
+    n : 0,
+    fillAugments : function(d, ext, cb )
+    {
+        Roo.docs.init.n++;
+        if (Roo.docs.init.n > 20) {
+            return;
+        }
+        if (!ext.length) {
+            cb(d);
+            return;
+        }
+        var next = ext.shift();
+        d.augments.push(next);
+        var ax =   new Roo.data.Connection({});
+        ax.request({
+            url : this.prefix + 'symbols/' + next + '.json',
+            method : 'GET',
+            success : function(res, o)
+            {
+                
+                var r = Roo.decode(res.responseText);
+                
+                
+                    // copy methods that are not constructors..
+                
+                r.methods.forEach(function(m) {
+                    
+                    if (d.methods.find(function(e) {
+                        return e.name == m.name;
+                    })) {
+                        return;
+                    }
+                    if (m.isConstructor || m.static) {
+                        return;
+                    }
+                    d.methods.push(m);  
+                });
+                
+                r.props.forEach(function(m) {
+                    if (m.isConstant) {
+                        return;
+                    }
+                    if (d.props.find(function(e) {
+                        return e.name == m.name;
+                    })) {
+                        return;
+                    }
+                    
+                    d.props.push(m);  
+                });
+                
+                r.events.forEach(function(m) {
+                    if (d.events.find(function(e) {
+                        return e.name == m.name;
+                    })) {
+                        return;
+                    }
+                    d.events.push(m);  
+                });
+             
+            
+            
+                this.fillAugments(d,ext, cb)
+                
+            },
+            scope : this
+        });
         
     },
     
+    
+    
     fillDoc : function(d)
     {
         /*{
@@ -214,20 +382,33 @@ Roo.docs.init = {
             "config" : [
               {
         */
-        document.body.scrollTop  = 0;
-        for (var k in d) {
-            if (typeof(Roo.docs['doc_' + k])  !=  'undefined') {
-                Roo.docs['doc_' + k].el.dom.innerHTML = Roo.docs.template.resolveLinks(d[k]);;
-            }
+        
+        Roo.docs.classType.el.dom.firstChild.textContent  = 'Class ';
+        if (d.isAbstract) {
+            Roo.docs.classType.el.dom.firstChild.textContent  = 'abstract class ';
+        }
+        if (d.is_enum) {
+            Roo.docs.classType.el.dom.firstChild.textContent  = 'enum ';
         }
+        if (d.is_mixin) {
+            Roo.docs.classType.el.dom.firstChild.textContent  = 'mixin ';
+        }
+        document.body.scrollTop  = 0;
+        Roo.docs.doc_name.el.dom.innerHTML = Roo.docs.template.resolveLinks(d.name);
+        Roo.docs.doc_desc.el.dom.innerHTML = Roo.docs.template.summary(d);
         Roo.docs.doc_extends.hide();
         Roo.docs.doc_extends_sep.hide();
         if (d.augments.length) {
             Roo.docs.doc_extends.show();
             Roo.docs.doc_extends_sep.show();
             Roo.docs.doc_extends.el.dom.innerHTML = d.augments[0];
+            Roo.docs.doc_extends.el.dom.href= '#' + d.augments[0];
         }
         Roo.docs.doc_source.el.dom.innerHTML = d.name.replace(/\./g,"/") + ".js";
+        if (Roo.docs.init.prefix.length) {
+            Roo.docs.doc_source_row.hide();
+        }
+        
         
         if (d.augments.length) {
             Roo.docs.augments.show();
@@ -236,6 +417,12 @@ Roo.docs.init = {
             Roo.docs.augments.hide();
         }
         
+        if (d.realImplementors && d.realImplementors.length) { 
+            Roo.docs.implementors.show();
+            Roo.docs.implementors.bodyEl().dom.innerHTML = Roo.docs.template.implementors(d);
+        } else {
+            Roo.docs.implementors.hide();
+        }
         
         
         Roo.docs.configTableContainer.hide();
@@ -270,6 +457,24 @@ Roo.docs.init = {
         this.loadClass(link);
         
     },
+    
+    onHashChange : function()
+    {
+        if (this.hash == location.hash) {
+            return;
+        }
+        this.loadHash();
+        
+    },
+    loadHash : function()
+    {
+        if (location.hash.length < 2) {
+            this.loadDoc(false);
+        }
+        this.loadClass(location.hash.substring(1));
+        this.hash = location.hash;
+    },
+    
       
     loadIntro : function()
     {
@@ -292,6 +497,10 @@ Roo.docs.init = {
     // render the really simple markdown data
     renderIntro : function(intro)
     {
+        
+        Roo.docs.doc_body_content.hide();
+
+        
         var lines = intro.split("\n");
         var tree = { 'name' : 'root', cn : []};
         var state = [ tree ];
@@ -303,14 +512,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..
@@ -357,7 +566,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;
                         
@@ -375,6 +584,7 @@ Roo.docs.init = {
                                    xtype : 'Link',
                                     href : '#' + ( ll ? ll[1] : treeiii.name ) ,
                                     html : ll ? ll[1] : treeiii.name,
+                                    
                                     xns : Roo.bootstrap 
                                 },
                                 {
@@ -392,7 +602,7 @@ Roo.docs.init = {
                     
                 }
                 if (footer.length) {
-                    Roo.log("footer:"+  footer);
+                    //Roo.log("footer:"+  footer);
                     ctreei.footer = '<h5>Examples:</h5><ul>'+footer +'</ul>';
                 }