*
* @cfg {String} title
* @cfg {String} subtitle
- * @cfg {String} html -- html contents - or just use children..
+ * @cfg {String|Boolean} html -- html contents - or just use children.. use false to hide it..
* @cfg {String} footer
* @cfg {String} weight (primary|warning|info|danger|secondary|success|light|dark)
collapsable : false,
collapsed : false,
+ rotateable : false,
+ rotated : false,
dragable : false,
drag_group : false,
cfg.cls += this.layoutCls();
- var hdr = false;
+ var hdr = false;
if (this.header.length) {
hdr = {
tag : this.header_size > 0 ? 'h' + this.header_size : 'div',
cls : 'card-header',
- cn : []
+ cn : []
};
- cfg.cn.push(hdr);
- hdr_ctr = hdr;
+ cfg.cn.push(hdr);
+ hdr_ctr = hdr;
} else {
- hdr = {
+ hdr = {
tag : 'div',
cls : 'card-header d-none',
- cn : []
+ cn : []
};
- cfg.cn.push(hdr);
- }
- if (this.collapsable) {
- hdr_ctr = {
- tag : 'a',
- cls : 'd-block user-select-none',
- cn: [
- {
- tag: 'i',
- cls : 'roo-collapse-toggle fa fa-chevron-down float-right'
- }
-
- ]
- };
- hdr.cn.push(hdr_ctr);
- }
- if (this.header.length) {
- hdr_ctr.cn.push( {
- tag: 'span',
- cls: 'roo-card-header-ctr',
- html : this.header
- })
- }
-
+ cfg.cn.push(hdr);
+ }
+ if (this.collapsable) {
+ hdr_ctr = {
+ tag : 'a',
+ cls : 'd-block user-select-none',
+ cn: [
+ {
+ tag: 'i',
+ cls : 'roo-collapse-toggle fa fa-chevron-down float-right ' + (this.collapsed ? 'collapsed' : '')
+ }
+
+ ]
+ };
+ hdr.cn.push(hdr_ctr);
+ }
+ if (this.header.length) {
+ hdr_ctr.cn.push( {
+ tag: 'span',
+ cls: 'roo-card-header-ctr',
+ html : this.header
+ })
+ }
+
if (this.header_image.length) {
cfg.cn.push({
tag : 'img',
src: this.header_image // escape?
});
} else {
- cfg.cn.push({
- tag : 'div',
- cls : 'card-img-top d-none'
- });
- }
-
+ cfg.cn.push({
+ tag : 'div',
+ cls : 'card-img-top d-none'
+ });
+ }
+
var body = {
tag : 'div',
- cls : 'card-body',
+ cls : 'card-body' + (this.html === false ? ' d-none' : ''),
cn : []
};
- var obody = body;
- if (this.collapsable) {
- obody = {
- tag: 'div',
- cls : 'roo-collapsable collapse ' + (this.collapsed ? '' : 'show'),
- cn : [ body ]
- };
- }
-
+ var obody = body;
+ if (this.collapsable) {
+ obody = {
+ tag: 'div',
+ cls : 'roo-collapsable collapse ' + (this.collapsed ? '' : 'show'),
+ cn : [ body ]
+ };
+ }
+
cfg.cn.push(obody);
if (this.title.length) {
cls : 'card-title',
src: this.title // escape?
});
- }
+ }
if (this.subtitle.length) {
body.cn.push({
});
}
// fixme ? handle objects?
+
if (this.footer.length) {
+
cfg.cn.push({
- tag : 'div',
cls : 'card-footer',
- html: this.footer // escape?
+ html : this.footer
});
+
+ } else {
+ cfg.cn.push({cls : 'card-footer d-none'});
}
+
// footer...
return cfg;
getCardHeader : function()
{
var ret = this.el.select('.card-header',true).first();
- if (ret.hasClass('d-none')) {
- ret.removeClass('d-none');
- }
+ if (ret.hasClass('d-none')) {
+ ret.removeClass('d-none');
+ }
+
+ return ret;
+ },
+ getCardFooter : function()
+ {
+ var ret = this.el.select('.card-footer',true).first();
+ if (ret.hasClass('d-none')) {
+ ret.removeClass('d-none');
+ }
return ret;
},
-
getCardImageTop : function()
{
var ret = this.el.select('.card-img-top',true).first();
- if (ret.hasClass('d-none')) {
- ret.removeClass('d-none');
- }
-
+ if (ret.hasClass('d-none')) {
+ ret.removeClass('d-none');
+ }
+
return ret;
},
initEvents: function()
{
- this.bodyEl = this.getChildContainer();
- if(this.dragable){
+ this.bodyEl = this.getChildContainer();
+ if(this.dragable){
this.dragZone = new Roo.dd.DragZone(this.getEl(), {
containerScroll: true,
ddGroup: this.drag_group || 'default_card_drag_group'
this.dragZone.getDragData = this.getDragData.createDelegate(this);
}
if (this.dropable) {
- this.dropZone = new Roo.dd.DropZone(this.el.select('.card-body',true).first() , {
- containerScroll: true,
- ddGroup: this.drop_group || 'default_card_drag_group'
- });
- this.dropZone.getTargetFromEvent = this.getTargetFromEvent.createDelegate(this);
- this.dropZone.onNodeEnter = this.onNodeEnter.createDelegate(this);
- this.dropZone.onNodeOver = this.onNodeOver.createDelegate(this);
- this.dropZone.onNodeOut = this.onNodeOut.createDelegate(this);
- this.dropZone.onNodeDrop = this.onNodeDrop.createDelegate(this);
- }
+ this.dropZone = new Roo.dd.DropZone(this.el.select('.card-body',true).first() , {
+ containerScroll: true,
+ ddGroup: this.drop_group || 'default_card_drag_group'
+ });
+ this.dropZone.getTargetFromEvent = this.getTargetFromEvent.createDelegate(this);
+ this.dropZone.onNodeEnter = this.onNodeEnter.createDelegate(this);
+ this.dropZone.onNodeOver = this.onNodeOver.createDelegate(this);
+ this.dropZone.onNodeOut = this.onNodeOut.createDelegate(this);
+ this.dropZone.onNodeDrop = this.onNodeDrop.createDelegate(this);
+ }
if (this.collapsable) {
- this.el.select('.card-header',true).on('click', this.onToggleCollapse, this);
- }
+ this.el.select('.card-header',true).on('click', this.onToggleCollapse, this);
+ }
+ if (this.rotateable) {
+ this.el.select('.card-header',true).on('click', this.onToggleRotate, this);
+ }
+
},
getDragData : function(e)
{
ret.position = cards_len > 0 ? 'below' : pos;
ret.items_n = i > 0 ? i - 1 : 0;
ret.card_n = cards_len > 0 ? cards_len - 1 : 0;
+ ret.card = ret.cards[ret.card_n];
}
}
if (!ret.cards.length) {
ret.card = true;
- ret.position = below;
+ ret.position = 'below';
ret.items_n;
return ret;
}
ret.card_n = last_card_n;
ret.card = ret.cards[last_card_n];
ret.items_n = this.items.indexOf(ret.cards[last_card_n]);
- cpos = 'below';
+ ret.position = 'below';
}
if (this.items[ret.items_n].el == dragged_card_el) {
onNodeDrop : function(n, dd, e, data)
{
- // call drop - return false if
- if (this.fireEvent("drop", this, n, dd, e, data) === false) {
+ // call drop - return false if
+
+ // this could actually fail - if the Network drops..
+ // we will ignore this at present..- client should probably reload
+ // the whole set of cards if stuff like that fails.
+
+
+ var info = this.getTargetFromEvent(e,data.source.el);
+ if (info === false) {
return false;
}
- var target_info = this.getTargetFromEvent(e,data.source.el);
- if (target_info === false) {
+ if (this.fireEvent("drop", this, n, dd, e, data) === false) {
return false;
}
+
+ this.dropPlaceHolder('hide');
- var pt = this.getDropPoint(e, n, dd);
- var insertAt = (n == this.bodyEl.dom) ? this.items.length : n.nodeIndex;
- if (pt == "below") {
- insertAt++;
- }
- for (var i = 0; i < this.items.length; i++) {
- var r = this.items[i];
- //var dup = this.store.getById(r.id);
- if (dup && (dd != this.dragZone)) {
- Roo.fly(this.getNode(this.store.indexOf(dup))).frame("red", 1);
- } else {
- if (data.copy) {
- this.store.insert(insertAt++, r.copy());
+ // do the dom manipulation first..
+ var dom = data.source.el.dom;
+ dom.parentNode.removeChild(dom);
+
+
+ if (info.card !== true) {
+ var cardel = info.card.el.dom;
+
+ if (info.position == 'above') {
+ cardel.parentNode.insertBefore(dom, cardel);
+ } else if (cardel.nextSibling) {
+ cardel.parentNode.insertBefore(dom,cardel.nextSibling);
} else {
- data.source.isDirtyFlag = true;
- r.store.remove(r);
- this.store.insert(insertAt++, r);
+ cardel.parentNode.append(dom);
}
- this.isDirtyFlag = true;
+ } else {
+ // card container???
+ this.bodyEl.dom.append(dom);
+ }
+
+ //FIXME HANDLE card = true
+
+ // add this to the correct place in items.
+
+
+
+ // remove Card from items.
+
+ var old_parent = data.source.parent();
+
+ old_parent.items = old_parent.items.filter(function(e) { return e != data.source });
+
+ if (this.items.length) {
+ var nitems = [];
+ Roo.log([info.items_n, info.position, this.items.length])
+ for (var i =0; i < this.items.length; i++) {
+ if (i == info.items_n && info.position == 'above') {
+ nitems.push(data.source);
+ }
+ nitems.push(this.items[i]);
+ if (i == info.items_n && info.position == 'below') {
+ nitems.push(data.source);
+ }
}
+ this.items = nitems;
+ Roo.log(this.items);
+ } else {
+ this.items.push(data.source);
}
- this.dragZone.cachedTarget = null;
+
+
+
return true;
},
this.dropEl.addClass('d-none');
return;
}
- var cardel = info.card.el.dom;
-
+ // FIXME - info.card == true!!!
this.dropEl.dom.parentNode.removeChild(this.dropEl.dom);
- if (info.position == 'above') {
- cardel.parentNode.insertBefore(this.dropEl.dom, cardel);
- } else if (cardel.nextSibling) {
- cardel.parentNode.insertBefore(this.dropEl.dom,cardel.nextSibling);
+
+ if (info.card !== true) {
+ var cardel = info.card.el.dom;
+
+ if (info.position == 'above') {
+ cardel.parentNode.insertBefore(this.dropEl.dom, cardel);
+ } else if (cardel.nextSibling) {
+ cardel.parentNode.insertBefore(this.dropEl.dom,cardel.nextSibling);
+ } else {
+ cardel.parentNode.append(this.dropEl.dom);
+ }
} else {
- cardel.parentNode.append(this.dropEl.dom);
+ // card container???
+ this.bodyEl.dom.append(this.dropEl.dom);
}
+
this.dropEl.addClass('d-block roo-card-dropzone');
this.dropEl.setHeight( Roo.get(data.ddel).getHeight() );