4 * This is BS4's Card element.. - similar to our containers probably..
8 * @class Roo.bootstrap.Card
9 * @extends Roo.bootstrap.Component
10 * Bootstrap Card class
13 * possible... may not be implemented..
14 * @cfg {String} header_image src url of image.
15 * @cfg {String|Object} header
16 * @cfg {Number} header_size (0|1|2|3|4|5) H1 or H2 etc.. 0 indicates default
19 * @cfg {String} subtitle
20 * @cfg {String} html -- html contents - or just use children..
21 * @cfg {String} footer
23 * @cfg {String} weight (primary|warning|info|danger|secondary|success|light|dark)
25 * @cfg {String} margin (0|1|2|3|4|5|auto)
26 * @cfg {String} margin_top (0|1|2|3|4|5|auto)
27 * @cfg {String} margin_bottom (0|1|2|3|4|5|auto)
28 * @cfg {String} margin_left (0|1|2|3|4|5|auto)
29 * @cfg {String} margin_right (0|1|2|3|4|5|auto)
30 * @cfg {String} margin_x (0|1|2|3|4|5|auto)
31 * @cfg {String} margin_y (0|1|2|3|4|5|auto)
33 * @cfg {String} padding (0|1|2|3|4|5)
34 * @cfg {String} padding_top (0|1|2|3|4|5)
35 * @cfg {String} padding_bottom (0|1|2|3|4|5)
36 * @cfg {String} padding_left (0|1|2|3|4|5)
37 * @cfg {String} padding_right (0|1|2|3|4|5)
38 * @cfg {String} padding_x (0|1|2|3|4|5)
39 * @cfg {String} padding_y (0|1|2|3|4|5)
41 * @cfg {String} display (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
42 * @cfg {String} display_xs (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
43 * @cfg {String} display_sm (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
44 * @cfg {String} display_lg (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
45 * @cfg {String} display_xl (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
47 * @config {Boolean} dragable if this card can be dragged.
48 * @config {Boolean} drag_group group for drag
52 * Create a new Container
53 * @param {Object} config The config object
56 Roo.bootstrap.Card = function(config){
57 Roo.bootstrap.Card.superclass.constructor.call(this, config);
65 Roo.extend(Roo.bootstrap.Card, Roo.bootstrap.Component, {
70 margin: '', /// may be better in component?
103 childContainer : false,
105 layoutCls : function()
109 Roo.log(this.margin_bottom.length);
110 ['', 'top', 'bottom', 'left', 'right', 'x', 'y' ].forEach(function(v) {
111 // in theory these can do margin_top : ml-xs-3 ??? but we don't support that yet
113 if (('' + t['margin' + (v.length ? '_' : '') + v]).length) {
114 cls += ' m' + (v.length ? v[0] : '') + '-' + t['margin' + (v.length ? '_' : '') + v];
116 if (('' + t['padding' + (v.length ? '_' : '') + v]).length) {
117 cls += ' p' + (v.length ? v[0] : '') + '-' + t['padding' + (v.length ? '_' : '') + v];
121 ['', 'xs', 'sm', 'lg', 'xl'].forEach(function(v) {
122 if (('' + t['display' + (v.length ? '_' : '') + v]).length) {
123 cls += ' d' + (v.length ? '-' : '') + v + '-' + t['margin' + (v.length ? '_' : '') + v]
127 // more generic support?
135 // Roo.log("Call onRender: " + this.xtype);
136 /* We are looking at something like this.
138 <img src="..." class="card-img-top" alt="...">
139 <div class="card-body">
140 <h5 class="card-title">Card title</h5>
141 <h6 class="card-subtitle mb-2 text-muted">Card subtitle</h6>
143 >> this bit is really the body...
144 <div> << we will ad dthis in hopefully it will not break shit.
146 ** card text does not actually have any styling...
148 <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>
151 <a href="#" class="card-link">Card link</a>
154 <div class="card-footer">
155 <small class="text-muted">Last updated 3 mins ago</small>
159 getAutoCreate : function(){
167 if (this.weight.length && this.weight != 'light') {
168 cfg.cls += ' text-white';
170 cfg.cls += ' text-dark'; // need as it's nested..
172 if (this.weight.length) {
173 cfg.cls += ' bg-' + this.weight;
176 cfg.cls += this.layoutCls();
178 if (this.header.length) {
180 tag : this.header_size > 0 ? 'h' + this.header_size : 'div',
182 html : this.header // escape?
187 cls : 'card-header d-none'
190 if (this.header_image.length) {
193 cls : 'card-img-top',
194 src: this.header_image // escape?
205 if (this.title.length) {
209 src: this.title // escape?
213 if (this.subtitle.length) {
217 src: this.subtitle // escape?
223 cls : 'roo-card-body-ctr'
226 if (this.html.length) {
232 // fixme ? handle objects?
233 if (this.footer.length) {
237 html: this.footer // escape?
246 getCardHeader : function()
248 var ret = this.el.select('.card-header',true).first();
249 if (ret.hasClass('d-none')) {
250 ret.removeClass('d-none');
256 getCardImageTop : function()
258 var ret = this.el.select('.card-img-top',true).first();
259 if (ret.hasClass('d-none')) {
260 ret.removeClass('d-none');
266 getChildContainer : function()
272 return this.el.select('.roo-card-body-ctr',true).first();
275 initEvents: function()
278 this.dragZone = new Roo.dd.DragZone(this.getEl(), {
279 containerScroll: true,
280 ddGroup: this.drag_group || 'default_card_drag_group'
282 this.dragZone.getDragData = this.getDragData.createDelegate(this);
288 getDragData : function(e) {
289 var target = this.getEl();
291 //this.handleSelection(e);
301 dragData.ddel = target.dom ; // the div element
302 Roo.log(target.getWidth( ));
303 dragData.ddel.style.width = target.getWidth() + 'px';