Roo/doc/Example.js
[roojs1] / Roo / doc / Example.js
1 /*
2  * - LGPL
3  *
4  */
5
6 /**
7  * @class Roo.doc.Example
8  * @extends Roo.bootstrap.Component
9  * Example Element class
10  * @cfg {String} title short title describing example
11  * @cfg {String} lang (phpcode|programlisting) section type.
12  * @cfg {String} code  example code
13  * @cfg {String} output The expected output from the code
14  *
15  * 
16  * @constructor
17  * Create a new Synopsis
18  * @param {Object} config The config object
19  */
20
21 Roo.doc.Example = function(config){
22     Roo.doc.Example.superclass.constructor.call(this, config);
23 };
24
25 Roo.extend(Roo.doc.Example, Roo.bootstrap.Component,  {
26     
27     title : '',
28     lang:   'php',
29     code : '',
30     output : '',
31     
32     getAutoCreate : function(){
33         
34         // no colour highlighting in here....
35         
36         var cfg ={
37             cls : 'panel panel-info',
38             cn : [
39                 {
40                     cls : 'panel-heading',
41                     html : this.title
42                 },
43                 {
44                     cls : 'panel-body',
45                     cn : [
46                         {
47                             tag: 'pre',
48                             cls : this.lang,
49                             html :  String.format('{0}',this.code).replace(/\n/g, '<br/>')
50                         }
51                     ]
52                 }
53             ]
54         };
55         
56         if (this.output) {
57             cfg.cn.push(
58
59                 {
60                     cls : 'panel-footer',
61                     cn : {
62                         tag: 'code',
63                         html :  String.format('{0}',this.output).replace(/\n/g, '<br/>')
64                     }
65                 }
66             
67                 
68             );
69         }
70         
71         
72         
73         return cfg;
74     }
75   
76     
77     
78    
79 });
80
81  
82
83