try and get ctrl-enter to add a clear all
[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 (php|txt|sql) code language.
12  * @cfg {String} code  example code
13  * @cfg {String} output The expected output from the code
14  * @cfg {String} outputlang php|txt|sql) output language
15  *
16  * 
17  * @constructor
18  * Create a new Synopsis
19  * @param {Object} config The config object
20  */
21
22 Roo.doc.Example = function(config){
23     Roo.doc.Example.superclass.constructor.call(this, config);
24 };
25
26 Roo.extend(Roo.doc.Example, Roo.bootstrap.Component,  {
27     
28     title : '',
29     lang:   'php',
30     code : '',
31     output : '',
32     outputlang : 'txt',
33     
34     getAutoCreate : function(){
35         
36         // no colour highlighting in here....
37         
38         var code = hljs ? hljs.highlight(this.lang,this.code).value :
39                 String.format('{0}',this.code).replace(/\n/g, '<br/>');
40         
41         Roo.log("code=" + code);
42         var cfg ={
43             cls : 'panel panel-info',
44             cn : [
45                 {
46                     cls : 'panel-heading',
47                     html : this.title
48                 },
49                 {
50                     cls : 'panel-body',
51                     cn : [
52                         {
53                             tag: 'pre',
54                             cls : 'lang-' + this.lang,
55                             html :  code
56                         }
57                     ]
58                 }
59             ]
60         };
61         
62         if (this.output) {
63             
64             var out = hljs ? hljs.highlight(this.outputlang,this.output).value :
65                     String.format('{0}',this.output).replace(/\n/g, '<br/>');
66             cfg.cn.push(
67
68                 {
69                     cls : 'panel-footer',
70                     cn : {
71                         tag: 'pre',
72                         html : out 
73                     }
74                 }
75             
76                 
77             );      
78         }
79         
80         
81         
82         return cfg;
83     }
84   
85     
86     
87    
88 });
89
90  
91
92