Roo/doc/Section.js
[roojs1] / Roo / doc / Section.js
1 /*
2  * - LGPL
3  *
4  */
5
6 /**
7  * @class Roo.doc.Section
8  * @extends Roo.bootstrap.Component
9  * SectionElement class
10  * @cfg {String} stype (desc|parameter|return|note|example) section type.
11  * 
12  * @constructor
13  * Create a new Synopsis
14  * @param {Object} config The config object
15  */
16
17 Roo.doc.Section = function(config){
18     Roo.doc.Section.superclass.constructor.call(this, config);
19 };
20
21 Roo.extend(Roo.doc.Section, Roo.bootstrap.Component,  {
22     
23     
24     stype:   '',
25      
26     getAutoCreate : function(){
27         
28         
29         var syn = Roo.factory(this.parent().items[0]);
30         
31         var cfg ={
32             
33             cls : 'refsection',
34             // id... ?
35             cn : [
36                 {
37                     tag: 'h3',
38                     cls : 'title',
39                     html : Roo.doc.Section.map[this.stype] 
40                 }
41             ]
42         };
43         if (this.stype == 'parameter') {
44             
45             // db package uses variable list here... - it results in dd/dl but the layout is messed up..
46             
47             var ul = {
48                 tag: 'ul',
49                 cls: 'itemizedlist roo-params',
50                 cn : []
51             };
52             // might not have any..
53             var params = syn.items;
54             for (var i =0; i < params.length;i++) {
55                 ul.cn.push( Roo.factory(params[i]).getAutoCreateParamSection() )
56             }
57             
58             
59             cfg.cn.push(ul);
60         }
61         if (this.stype == 'return' && (syn.returndesc.length || syn.returntype.length )) {
62             
63             cfg.cn.push({
64                 tag: 'p',
65                 cls : 'para',
66                 cn : [
67                 
68                     {
69                         tag: 'code',
70                         cls: 'parameter',
71                         html : syn.returntype
72                     },
73                     syn.returndesc
74                 ]
75                 
76             });
77         }
78         
79         return cfg;
80     },
81     getChildContainer : function(build_call)
82     {
83          
84         if (this.stype == 'parameter') {
85             return this.el.select('.roo-params',true).first();
86         }
87        
88         return this.el;
89     }
90     
91     
92    
93 });
94
95  
96 Roo.doc.Section.map = {
97     'desc' : 'Description',
98     'parameter' : 'Parameters',
99     'return' : 'Return Value',
100     'note' : 'Notes',
101     'example' : 'Examples',
102     'throws' : 'Throws Exception'
103 }