2 * This is BS4's Card element.. - similar to our containers probably..
6 * @class Roo.bootstrap.Card
7 * @extends Roo.bootstrap.Component
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
19 * @cfg {String} weight (primary|warning|info|danger|secondary|success|light|dark)
21 * @cfg {String} margin (0|1|2|3|4|5|auto)
22 * @cfg {String} margin_top (0|1|2|3|4|5|auto)
23 * @cfg {String} margin_bottom (0|1|2|3|4|5|auto)
24 * @cfg {String} margin_left (0|1|2|3|4|5|auto)
25 * @cfg {String} margin_right (0|1|2|3|4|5|auto)
26 * @cfg {String} margin_x (0|1|2|3|4|5|auto)
27 * @cfg {String} margin_y (0|1|2|3|4|5|auto)
29 * @cfg {String} padding (0|1|2|3|4|5)
30 * @cfg {String} padding_top (0|1|2|3|4|5)
31 * @cfg {String} padding_bottom (0|1|2|3|4|5)
32 * @cfg {String} padding_left (0|1|2|3|4|5)
33 * @cfg {String} padding_right (0|1|2|3|4|5)
34 * @cfg {String} padding_x (0|1|2|3|4|5)
35 * @cfg {String} padding_y (0|1|2|3|4|5)
37 * @cfg {String} display (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
38 * @cfg {String} display_xs (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
39 * @cfg {String} display_sm (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
40 * @cfg {String} display_lg (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
41 * @cfg {String} display_xl (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
44 * Create a new Container
45 * @param {Object} config The config object
48 Roo.bootstrap.Card = function(config){
49 Roo.bootstrap.Card.superclass.constructor.call(this, config);
57 Roo.extend(Roo.bootstrap.Card, Roo.bootstrap.Component, {
61 margin: '', /// may be better in component?
84 layoutCls : function()
89 ['', 'top', 'bottom', 'left', 'right', 'x', 'y' ].forEach(function(v) {
90 // in theory these can do margin_top : ml-xs-3 ??? but we don't support that yet
92 if (t['margin' + (v.length ? '_' : '') + v].length) {
93 cls += ' m' + (v.length ? v[0] : '') + '-' + t['margin' + (v.length ? '_' : '') + v];
95 if (t['padding' + (v.length ? '_' : '') + v].length) {
96 cls += ' p' + (v.length ? v[0] : '') + '-' + t['padding' + (v.length ? '_' : '') + v];
100 ['', 'xs', 'sm', 'lg', 'xl', ].forEach(function(v) {
101 if (t['display' + (v.length ? '_' : '') + v].length) {
102 cls += ' d' + (v.length ? '-' : '') + v + '-' + t['margin' + (v.length ? '_' : '') + v].length
109 // Roo.log("Call onRender: " + this.xtype);
110 /* We are looking at something like this.
112 <img src="..." class="card-img-top" alt="...">
113 <div class="card-body">
114 <h5 class="card-title">Card title</h5>
115 <h6 class="card-subtitle mb-2 text-muted">Card subtitle</h6>
117 >> this bit is really the body...
118 <div> << we will ad dthis in hopefully it will not break shit.
120 <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>
123 <a href="#" class="card-link">Card link</a>
126 <div class="card-footer">
127 <small class="text-muted">Last updated 3 mins ago</small>
131 getAutoCreate : function(){
134 tag : this.tag || 'div',
139 if (this.weight.length && this.weight != 'light') {
140 cfg.cls += ' text-white'
142 if (this.weight.length) {
143 cfg.cls += ' bg-' + this.weight;
147 if (this.margin.length) {
148 var bits = this.margin.split(" ");
149 bits.forEach(function (b) {
150 cfg.cls += ' m' + (b.length == 1 ? '-' : '') + b;
153 if (this.padding.length) {
154 var bits = this.padding.split(" ");
155 bits.forEach(function (b) {
156 cfg.cls += ' p' + (b.length == 1 ? '-' : '') + b;
160 // - this is applied by the parent..
162 // cfg.cls = this.cls + '';
165 if (this.sticky.length) {
167 var bd = Roo.get(document.body);
168 if (!bd.hasClass('bootstrap-sticky')) {
169 bd.addClass('bootstrap-sticky');
170 Roo.select('html',true).setStyle('height', '100%');
173 cfg.cls += 'bootstrap-sticky-' + this.sticky;
177 if (this.well.length) {
181 cfg.cls +=' well well-' +this.well;
190 cfg.cls += ' hidden';
194 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
195 cfg.cls +=' alert alert-' + this.alert;
200 if (this.panel.length) {
201 cfg.cls += ' panel panel-' + this.panel;
203 if (this.header.length) {
209 cfg.cls = cfg.cls + ' expandable';
213 cls: (this.expanded ? 'fa fa-minus' : 'fa fa-plus')
222 html : (this.expandable ? ' ' : '') + this.header
226 cls: 'panel-header-right',
232 cls : 'panel-heading',
233 style : this.expandable ? 'cursor: pointer' : '',
241 cls : 'panel-body' + (this.expanded ? '' : ' hide'),
246 if (this.footer.length) {
248 cls : 'panel-footer',
257 body.html = this.html || cfg.html;
258 // prefix with the icons..
260 body.html = '<i class="fa fa-'+this.fa + '"></i>' + body.html ;
263 body.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + body.html ;
268 if ((!this.cls || !this.cls.length) && (!cfg.cls || !cfg.cls.length)) {
269 cfg.cls = 'container';