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