fe7af1065f7d629f9b3f025a64f0ade2e0d647ea
[roojs1] / Roo / bootstrap / Card.js
1 /*
2  * This is BS4's Card element.. - similar to our containers probably..
3  * 
4  */
5 /**
6  * @class Roo.bootstrap.Card
7  * @extends Roo.bootstrap.Component
8  * Bootstrap Card class
9  *
10  *
11  * possible... may not be implemented..
12  * @cfg {String} header content of header (for panel)
13  * @cfg {String|Object} - title
14  * @cfg {String|Object} - subtitle
15  * @cfg {String|Object} - body
16  * @cfg {String|Object} - footer
17  * @cfg {Array} - links
18  *     
19  * @constructor
20  * Create a new Container
21  * @param {Object} config The config object
22  */
23
24 Roo.bootstrap.Card = function(config){
25     Roo.bootstrap.Card.superclass.constructor.call(this, config);
26     
27     this.addEvents({
28         
29     });
30 };
31
32
33 Roo.extend(Roo.bootstrap.Card, Roo.bootstrap.Component,  {
34     
35    
36    
37        // Roo.log("Call onRender: " + this.xtype);
38         /*  We are looking at something like this.
39 <div class="card">
40     <img src="..." class="card-img-top" alt="...">
41     <div class="card-body">
42         <h5 class="card-title">Card title</h5>
43          <h6 class="card-subtitle mb-2 text-muted">Card subtitle</h6>
44
45         >> this bit is really the body...
46         <div> << we will ad dthis in hopefully it will not break shit.
47         
48             <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
49         
50         </div> <<
51           <a href="#" class="card-link">Card link</a>
52           
53     </div>
54     <div class="card-footer">
55         <small class="text-muted">Last updated 3 mins ago</small>
56     </div>
57 </div>
58          */
59     getAutoCreate : function(){
60         
61         var cfg = {
62             tag : this.tag || 'div',
63             html : '',
64             cls : ''
65         };
66         if (this.jumbotron) {
67             cfg.cls = 'jumbotron';
68         }
69         
70         
71         
72         // - this is applied by the parent..
73         //if (this.cls) {
74         //    cfg.cls = this.cls + '';
75         //}
76         
77         if (this.sticky.length) {
78             
79             var bd = Roo.get(document.body);
80             if (!bd.hasClass('bootstrap-sticky')) {
81                 bd.addClass('bootstrap-sticky');
82                 Roo.select('html',true).setStyle('height', '100%');
83             }
84              
85             cfg.cls += 'bootstrap-sticky-' + this.sticky;
86         }
87         
88         
89         if (this.well.length) {
90             switch (this.well) {
91                 case 'lg':
92                 case 'sm':
93                     cfg.cls +=' well well-' +this.well;
94                     break;
95                 default:
96                     cfg.cls +=' well';
97                     break;
98             }
99         }
100         
101         if (this.hidden) {
102             cfg.cls += ' hidden';
103         }
104         
105         
106         if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
107             cfg.cls +=' alert alert-' + this.alert;
108         }
109         
110         var body = cfg;
111         
112         if (this.panel.length) {
113             cfg.cls += ' panel panel-' + this.panel;
114             cfg.cn = [];
115             if (this.header.length) {
116                 
117                 var h = [];
118                 
119                 if(this.expandable){
120                     
121                     cfg.cls = cfg.cls + ' expandable';
122                     
123                     h.push({
124                         tag: 'i',
125                         cls: (this.expanded ? 'fa fa-minus' : 'fa fa-plus') 
126                     });
127                     
128                 }
129                 
130                 h.push(
131                     {
132                         tag: 'span',
133                         cls : 'panel-title',
134                         html : (this.expandable ? '&nbsp;' : '') + this.header
135                     },
136                     {
137                         tag: 'span',
138                         cls: 'panel-header-right',
139                         html: this.rheader
140                     }
141                 );
142                 
143                 cfg.cn.push({
144                     cls : 'panel-heading',
145                     style : this.expandable ? 'cursor: pointer' : '',
146                     cn : h
147                 });
148                 
149             }
150             
151             body = false;
152             cfg.cn.push({
153                 cls : 'panel-body' + (this.expanded ? '' : ' hide'),
154                 html : this.html
155             });
156             
157             
158             if (this.footer.length) {
159                 cfg.cn.push({
160                     cls : 'panel-footer',
161                     html : this.footer
162                     
163                 });
164             }
165             
166         }
167         
168         if (body) {
169             body.html = this.html || cfg.html;
170             // prefix with the icons..
171             if (this.fa) {
172                 body.html = '<i class="fa fa-'+this.fa + '"></i>' + body.html ;
173             }
174             if (this.icon) {
175                 body.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + body.html ;
176             }
177             
178             
179         }
180         if ((!this.cls || !this.cls.length) && (!cfg.cls || !cfg.cls.length)) {
181             cfg.cls =  'container';
182         }
183         
184         return cfg;
185     },
186 }