From 08476adcea7a25008953a3c0051d9a1222074104 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Wed, 7 Apr 2021 17:46:25 +0800 Subject: [PATCH] Partial Fix #6524 - test client access --- Roo/bootstrap/Card.js | 32 ++++++++++++++++++++++++++------ roojs-bootstrap-debug.js | 32 ++++++++++++++++++++++++++------ roojs-bootstrap.js | 28 ++++++++++++++-------------- 3 files changed, 66 insertions(+), 26 deletions(-) diff --git a/Roo/bootstrap/Card.js b/Roo/bootstrap/Card.js index 60eaa034dc..04dc146eaa 100644 --- a/Roo/bootstrap/Card.js +++ b/Roo/bootstrap/Card.js @@ -80,11 +80,18 @@ Roo.bootstrap.Card = function(config){ /** * @event rotate * When a element a card is rotate - * @param {Roo.bootstrap.Element} this + * @param {Roo.bootstrap.Card} this * @param {Roo.Element} n the node being dropped? * @param {Boolean} rotate status */ - 'rotate' : true + 'rotate' : true, + /** + * @event cardover + * When a card element is dragged over ready to drop (return false to block dropable) + * @param {Roo.bootstrap.Card} this + * @param {Object} data from dragdrop + */ + 'cardover' : true }); }; @@ -437,6 +444,17 @@ Roo.extend(Roo.bootstrap.Card, Roo.bootstrap.Component, { /** * Part of the Roo.dd.DropZone interface. If no target node is found, the * whole Element becomes the target, and this causes the drop gesture to append. + * + * Returns an object: + * { + + position : 'below' or 'above' + card : relateive to card OBJECT (or true for no cards listed) + items_n : relative to nth item in list + card_n : relative to nth card in list + } + * + * */ getTargetFromEvent : function(e, dragged_card_el) { @@ -530,7 +548,11 @@ Roo.extend(Roo.bootstrap.Card, Roo.bootstrap.Component, { } Roo.log(['getTargetFromEvent', target_info ]); - + + if (this.fireEvent('cardover', this, [ data ]) === false) { + return false; + } + this.dropPlaceHolder('show', target_info,data); return false; @@ -555,9 +577,7 @@ Roo.extend(Roo.bootstrap.Card, Roo.bootstrap.Component, { } this.dropPlaceHolder('hide'); - - - + this.acceptCard(data.source, info.position, info.card, info.items_n); return true; diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index 24d5a98772..3216ddc043 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -2017,11 +2017,18 @@ Roo.bootstrap.Card = function(config){ /** * @event rotate * When a element a card is rotate - * @param {Roo.bootstrap.Element} this + * @param {Roo.bootstrap.Card} this * @param {Roo.Element} n the node being dropped? * @param {Boolean} rotate status */ - 'rotate' : true + 'rotate' : true, + /** + * @event cardover + * When a card element is dragged over ready to drop (return false to block dropable) + * @param {Roo.bootstrap.Card} this + * @param {Object} data from dragdrop + */ + 'cardover' : true }); }; @@ -2374,6 +2381,17 @@ Roo.extend(Roo.bootstrap.Card, Roo.bootstrap.Component, { /** * Part of the Roo.dd.DropZone interface. If no target node is found, the * whole Element becomes the target, and this causes the drop gesture to append. + * + * Returns an object: + * { + + position : 'below' or 'above' + card : relateive to card OBJECT (or true for no cards listed) + items_n : relative to nth item in list + card_n : relative to nth card in list + } + * + * */ getTargetFromEvent : function(e, dragged_card_el) { @@ -2467,7 +2485,11 @@ Roo.extend(Roo.bootstrap.Card, Roo.bootstrap.Component, { } Roo.log(['getTargetFromEvent', target_info ]); - + + if (this.fireEvent('cardover', this, [ data ]) === false) { + return false; + } + this.dropPlaceHolder('show', target_info,data); return false; @@ -2492,9 +2514,7 @@ Roo.extend(Roo.bootstrap.Card, Roo.bootstrap.Component, { } this.dropPlaceHolder('hide'); - - - + this.acceptCard(data.source, info.position, info.card, info.items_n); return true; diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index e2ca0f417f..693eac7b35 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -81,7 +81,7 @@ return this.el.select('.panel-body',true).first()},titleEl:function(){if(!this.e },getTitle:function(){var A=this.titleEl();if(!A){return '';}return A.dom.innerHTML;},setRightTitle:function(v){var t=this.el.select('.panel-header-right',true).first();if(!t){return;}t.dom.innerHTML=v;},onClick:function(e){e.preventDefault();this.fireEvent('click',this,e); }}); // Roo/bootstrap/Card.js -Roo.bootstrap.Card=function(A){Roo.bootstrap.Card.superclass.constructor.call(this,A);this.addEvents({'drop':true,'rotate':true});};Roo.extend(Roo.bootstrap.Card,Roo.bootstrap.Component,{weight:'',margin:'',margin_top:'',margin_bottom:'',margin_left:'',margin_right:'',margin_x:'',margin_y:'',padding:'',padding_top:'',padding_bottom:'',padding_left:'',padding_right:'',padding_x:'',padding_y:'',display:'',display_xs:'',display_sm:'',display_lg:'',display_xl:'',header_image:'',header:'',header_size:0,title:'',subtitle:'',html:'',footer:'',collapsable:false,collapsed:false,rotateable:false,rotated:false,dragable:false,drag_group:false,dropable:false,drop_group:false,childContainer:false,dropEl:false,containerEl:false,bodyEl:false,headerContainerEl:false,headerEl:false,header_imageEl:false,layoutCls:function(){var A=''; +Roo.bootstrap.Card=function(A){Roo.bootstrap.Card.superclass.constructor.call(this,A);this.addEvents({'drop':true,'rotate':true,'cardover':true});};Roo.extend(Roo.bootstrap.Card,Roo.bootstrap.Component,{weight:'',margin:'',margin_top:'',margin_bottom:'',margin_left:'',margin_right:'',margin_x:'',margin_y:'',padding:'',padding_top:'',padding_bottom:'',padding_left:'',padding_right:'',padding_x:'',padding_y:'',display:'',display_xs:'',display_sm:'',display_lg:'',display_xl:'',header_image:'',header:'',header_size:0,title:'',subtitle:'',html:'',footer:'',collapsable:false,collapsed:false,rotateable:false,rotated:false,dragable:false,drag_group:false,dropable:false,drop_group:false,childContainer:false,dropEl:false,containerEl:false,bodyEl:false,headerContainerEl:false,headerEl:false,header_imageEl:false,layoutCls:function(){var A=''; var t=this;Roo.log(this.margin_bottom.length);['','top','bottom','left','right','x','y'].forEach(function(v){if((''+t['margin'+(v.length?'_':'')+v]).length){A+=' m'+(v.length?v[0]:'')+'-'+t['margin'+(v.length?'_':'')+v];}if((''+t['padding'+(v.length?'_':'')+v]).length){A+=' p'+(v.length?v[0]:'')+'-'+t['padding'+(v.length?'_':'')+v]; }});['','xs','sm','lg','xl'].forEach(function(v){if((''+t['display'+(v.length?'_':'')+v]).length){A+=' d'+(v.length?'-':'')+v+'-'+t['display'+(v.length?'_':'')+v]}});if(this.hidden){A+=' d-none';}return A;},getAutoCreate:function(){var A={tag:'div',cls:'card',cn:[]} ;if(this.weight.length&&this.weight!='light'){A.cls+=' text-white';}else{A.cls+=' text-dark';}if(this.weight.length){A.cls+=' bg-'+this.weight;}A.cls+=' '+this.layoutCls();var B=false;var C=false;if(this.header.length){B={tag:this.header_size>0?'h'+this.header_size:'div',cls:'card-header '+(this.header_weight?'bg-'+this.header_weight:''),cn:[]} @@ -101,19 +101,19 @@ this.header_imageEl.on('load',this.onHeaderImageLoad,this);},getDragData:functio }D=this.getDropPoint(e,this.items[i].el.dom);F=C.cards.length;C.cards.push(this.items[i]);E=i;if(C.card_n<0&&D=='above'){C.position=F>0?'below':D;C.items_n=i>0?i-1:0;C.card_n=F>0?F-1:0;C.card=C.cards[C.card_n];}}if(!C.cards.length){C.card=true;C.position='below'; C.items_n;return C;}if(C.card_n<0){C.card_n=E;C.card=C.cards[E];C.items_n=this.items.indexOf(C.cards[E]);C.position='below';}if(this.items[C.items_n].el==A){return false;}if(C.position=='below'){var G=C.card_n+1==C.cards.length?false:C.cards[C.card_n+1];if(G&&G.el==A){return false; }return C;}var H=C.card_n>0?C.cards[C.card_n-1]:false;if(H&&H.el==A){return false;}return C;},onNodeEnter:function(n,dd,e,A){return false;},onNodeOver:function(n,dd,e,A){var B=this.getTargetFromEvent(e,A.source.el);if(B===false){this.dropPlaceHolder('hide'); -return false;}Roo.log(['getTargetFromEvent',B]);this.dropPlaceHolder('show',B,A);return false;},onNodeOut:function(n,dd,e,A){this.dropPlaceHolder('hide');},onNodeDrop:function(n,dd,e,A){var B=this.getTargetFromEvent(e,A.source.el);if(B===false){return false; -}this.dropPlaceHolder('hide');this.acceptCard(A.source,B.position,B.card,B.items_n);return true;},firstChildCard:function(){for(var i=0;i1){var nw=(ww*(1/hw));Roo.get(he).setSize(ww*(1/hw),ww);he.style.left=((ww-nw)/2)+'px'; -he.style.position='relative';}}}); +return false;}Roo.log(['getTargetFromEvent',B]);if(this.fireEvent('cardover',this,[A])===false){return false;}this.dropPlaceHolder('show',B,A);return false;},onNodeOut:function(n,dd,e,A){this.dropPlaceHolder('hide');},onNodeDrop:function(n,dd,e,A){var B=this.getTargetFromEvent(e,A.source.el); +if(B===false){return false;}this.dropPlaceHolder('hide');this.acceptCard(A.source,B.position,B.card,B.items_n);return true;},firstChildCard:function(){for(var i=0;i1){var nw=(ww*(1/hw));Roo.get(he).setSize(ww*(1/hw),ww);he.style.left=((ww-nw)/2)+'px';he.style.position='relative';}}}); // Roo/bootstrap/CardHeader.js Roo.bootstrap.CardHeader=function(A){Roo.bootstrap.CardHeader.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.CardHeader,Roo.bootstrap.Element,{container_method:'getCardHeader'}); // Roo/bootstrap/CardFooter.js -- 2.39.2