From: Alan Knowles Date: Thu, 8 Apr 2021 09:26:33 +0000 (+0800) Subject: Fix #6673 - mobile cards issues X-Git-Url: http://git.roojs.org/?p=roojs1;a=commitdiff_plain;h=e599b9bdeca13a5523e8880f93a34825051622fb Fix #6673 - mobile cards issues --- diff --git a/Roo/Element.js b/Roo/Element.js index fef561b314..5d3361fe66 100644 --- a/Roo/Element.js +++ b/Roo/Element.js @@ -1172,7 +1172,32 @@ if(opt.anim.isAnimated()){ if (this.dom) { Roo.EventManager.on(this.dom, eventName, fn, scope || this, options); } + if (eventName == 'dblclick') { + this.addListener('touchstart', this.onTapHandler, this); + } }, + tapedTwice : false, + onTapHandler : function(event) + { + if(!this.tapedTwice) { + this.tapedTwice = true; + var s = this; + setTimeout( function() { + s.tapedTwice = false; + }, 300 ); + return; + } + event.preventDefault(); + var revent = new MouseEvent('dblclick', { + view: window, + bubbles: true, + cancelable: true + }); + + this.dom.dispatchEvent(revent); + //action on double tap goes below + + }, /** * Removes an event handler from this element @@ -2304,7 +2329,7 @@ if(opt.anim.isAnimated()){ /** * @private */ - fitToParentDelegate : Roo.emptyFn, // keep a reference to the fitToParent delegate + fitToParentDelegate : Roo.emptyFn, // keep a reference to the fitToParent delegate /** * Sizes this element to its parent element's dimensions performing diff --git a/Roo/EventManager.js b/Roo/EventManager.js index fc718c78a8..3c9a41a0b8 100644 --- a/Roo/EventManager.js +++ b/Roo/EventManager.js @@ -122,6 +122,7 @@ Roo.EventManager = function(){ } } + var listen = function(element, ename, opt, fn, scope){ var o = (!opt || typeof opt == "boolean") ? {} : opt; diff --git a/Roo/bootstrap/Card.js b/Roo/bootstrap/Card.js index 04dc146eaa..58c24ac626 100644 --- a/Roo/bootstrap/Card.js +++ b/Roo/bootstrap/Card.js @@ -91,8 +91,8 @@ Roo.bootstrap.Card = function(config){ * @param {Roo.bootstrap.Card} this * @param {Object} data from dragdrop */ - 'cardover' : true - + 'cardover' : true + }); }; diff --git a/Roo/bootstrap/Element.js b/Roo/bootstrap/Element.js index bed0e4a189..5756f64438 100644 --- a/Roo/bootstrap/Element.js +++ b/Roo/bootstrap/Element.js @@ -31,7 +31,9 @@ Roo.bootstrap.Element = function(config){ * @param {Roo.bootstrap.Element} this * @param {Roo.EventObject} e */ - "click" : true + "click" : true + + }); }; @@ -42,6 +44,7 @@ Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, { html: '', preventDefault: false, clickable: false, + tapedTwice : false, getAutoCreate : function(){ @@ -62,6 +65,7 @@ Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, { this.el.on('click', this.onClick, this); } + }, onClick : function(e) @@ -70,9 +74,14 @@ Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, { e.preventDefault(); } - this.fireEvent('click', this, e); + this.fireEvent('dblclick', this, e); }, + + + + + getValue : function() { return this.el.dom.innerHTML; diff --git a/docs/src/Roo_Element.js.html b/docs/src/Roo_Element.js.html index b21072f1ea..787257e1ac 100644 --- a/docs/src/Roo_Element.js.html +++ b/docs/src/Roo_Element.js.html @@ -1172,7 +1172,32 @@ if(opt.anim.isAnimated()){ if (this.dom) { Roo.EventManager.on(this.dom, eventName, fn, scope || this, options); } + if (eventName == 'dblclick') { + this.addListener('touchstart', this.onTapHandler, this); + } }, + tapedTwice : false, + onTapHandler : function(event) + { + if(!this.tapedTwice) { + this.tapedTwice = true; + var s = this; + setTimeout( function() { + s.tapedTwice = false; + }, 300 ); + return; + } + event.preventDefault(); + var revent = new MouseEvent('dblclick', { + view: window, + bubbles: true, + cancelable: true + }); + + this.dom.dispatchEvent(revent); + //action on double tap goes below + + }, /** * Removes an event handler from this element @@ -2304,7 +2329,7 @@ if(opt.anim.isAnimated()){ /** * @private */ - fitToParentDelegate : Roo.emptyFn, // keep a reference to the fitToParent delegate + fitToParentDelegate : Roo.emptyFn, // keep a reference to the fitToParent delegate /** * Sizes this element to its parent element's dimensions performing diff --git a/docs/src/Roo_EventManager.js.html b/docs/src/Roo_EventManager.js.html index 01b2244df4..b03cb8e881 100644 --- a/docs/src/Roo_EventManager.js.html +++ b/docs/src/Roo_EventManager.js.html @@ -123,6 +123,7 @@ } + var listen = function(element, ename, opt, fn, scope){ var o = (!opt || typeof opt == "boolean") ? {} : opt; fn = fn || o.fn; scope = scope || o.scope; diff --git a/docs/src/Roo_bootstrap_Element.js.html b/docs/src/Roo_bootstrap_Element.js.html index b77877f757..986f374f76 100644 --- a/docs/src/Roo_bootstrap_Element.js.html +++ b/docs/src/Roo_bootstrap_Element.js.html @@ -32,6 +32,8 @@ * @param {Roo.EventObject} e */ "click" : true + + }); }; @@ -42,6 +44,7 @@ html: '', preventDefault: false, clickable: false, + tapedTwice : false, getAutoCreate : function(){ @@ -62,6 +65,7 @@ this.el.on('click', this.onClick, this); } + }, onClick : function(e) @@ -70,9 +74,14 @@ e.preventDefault(); } - this.fireEvent('click', this, e); + this.fireEvent('dblclick', this, e); }, + + + + + getValue : function() { return this.el.dom.innerHTML; diff --git a/roojs-all.js b/roojs-all.js index 3786462545..3c0949254a 100644 --- a/roojs-all.js +++ b/roojs-all.js @@ -344,11 +344,12 @@ if(!h){h=parseInt(this.getStyle('height'),10)||0;if(!this.isBorderBox()){h+=this }else{this.anim({height:{to:J}},this.preanim(arguments,1));}return this;},setSize:function(J,K,L){if(typeof J=="object"){K=J.height;J=J.width;}J=this.adjustWidth(J);K=this.adjustHeight(K);if(!L||!A){this.dom.style.width=this.addUnits(J);this.dom.style.height=this.addUnits(K); }else{this.anim({width:{to:J},height:{to:K}},this.preanim(arguments,2));}return this;},setBounds:function(x,y,J,K,L){if(!L||!A){this.setSize(J,K);this.setLocation(x,y);}else{J=this.adjustWidth(J);K=this.adjustHeight(K);this.anim({points:{to:[x,y]},width:{to:J} ,height:{to:K}},this.preanim(arguments,4),'motion');}return this;},setRegion:function(J,K){this.setBounds(J.left,J.top,J.right-J.left,J.bottom-J.top,this.preanim(arguments,1));return this;},addListener:function(J,fn,K,L){if(this.dom){Roo.EventManager.on(this.dom,J,fn,K||this,L); -}},removeListener:function(J,fn){Roo.EventManager.removeListener(this.dom,J,fn);return this;},removeAllListeners:function(){E.purgeElement(this.dom);return this;},relayEvent:function(J,K){this.on(J,function(e){K.fireEvent(J,e);});},setOpacity:function(J,K){if(!K||!A){var s=this.dom.style; -if(Roo.isIE){s.zoom=1;s.filter=(s.filter||'').replace(/alpha\([^\)]*\)/gi,"")+(J==1?"":"alpha(opacity="+J*100+")");}else{s.opacity=J;}}else{this.anim({opacity:{to:J}},this.preanim(arguments,1),null,.35,'easeIn');}return this;},getLeft:function(J){if(!J){return this.getX(); -}else{return parseInt(this.getStyle("left"),10)||0;}},getRight:function(J){if(!J){return this.getX()+this.getWidth();}else{return (this.getLeft(true)+this.getWidth())||0;}},getTop:function(J){if(!J){return this.getY();}else{return parseInt(this.getStyle("top"),10)||0; -}},getBottom:function(J){if(!J){return this.getY()+this.getHeight();}else{return (this.getTop(true)+this.getHeight())||0;}},position:function(J,K,x,y){if(!J){if(this.getStyle('position')=='static'){this.setStyle('position','relative');}}else{this.setStyle("position",J); -}if(K){this.setStyle("z-index",K);}if(x!==undefined&&y!==undefined){this.setXY([x,y]);}else if(x!==undefined){this.setX(x);}else if(y!==undefined){this.setY(y);}},clearPositioning:function(J){J=J||'';this.setStyle({"left":J,"right":J,"top":J,"bottom":J,"z-index":"","position":"static"} +}if(J=='dblclick'){this.addListener('touchstart',this.onTapHandler,this);}},tapedTwice:false,onTapHandler:function(J){if(!this.tapedTwice){this.tapedTwice=true;var s=this;setTimeout(function(){s.tapedTwice=false;},300);return;}J.preventDefault();var K=new MouseEvent('dblclick',{view:window,bubbles:true,cancelable:true} +);this.dom.dispatchEvent(K);},removeListener:function(J,fn){Roo.EventManager.removeListener(this.dom,J,fn);return this;},removeAllListeners:function(){E.purgeElement(this.dom);return this;},relayEvent:function(J,K){this.on(J,function(e){K.fireEvent(J,e);} +);},setOpacity:function(J,K){if(!K||!A){var s=this.dom.style;if(Roo.isIE){s.zoom=1;s.filter=(s.filter||'').replace(/alpha\([^\)]*\)/gi,"")+(J==1?"":"alpha(opacity="+J*100+")");}else{s.opacity=J;}}else{this.anim({opacity:{to:J}},this.preanim(arguments,1),null,.35,'easeIn'); +}return this;},getLeft:function(J){if(!J){return this.getX();}else{return parseInt(this.getStyle("left"),10)||0;}},getRight:function(J){if(!J){return this.getX()+this.getWidth();}else{return (this.getLeft(true)+this.getWidth())||0;}},getTop:function(J){if(!J){return this.getY(); +}else{return parseInt(this.getStyle("top"),10)||0;}},getBottom:function(J){if(!J){return this.getY()+this.getHeight();}else{return (this.getTop(true)+this.getHeight())||0;}},position:function(J,K,x,y){if(!J){if(this.getStyle('position')=='static'){this.setStyle('position','relative'); +}}else{this.setStyle("position",J);}if(K){this.setStyle("z-index",K);}if(x!==undefined&&y!==undefined){this.setXY([x,y]);}else if(x!==undefined){this.setX(x);}else if(y!==undefined){this.setY(y);}},clearPositioning:function(J){J=J||'';this.setStyle({"left":J,"right":J,"top":J,"bottom":J,"z-index":"","position":"static"} );return this;},getPositioning:function(){var l=this.getStyle("left");var t=this.getStyle("top");return {"position":this.getStyle("position"),"left":l,"right":l?"":this.getStyle("right"),"top":t,"bottom":t?"":this.getStyle("bottom"),"z-index":this.getStyle("z-index")} ;},getBorderWidth:function(J){return this.addStyles(J,El.borders);},getPadding:function(J){return this.addStyles(J,El.paddings);},setPositioning:function(pc){this.applyStyles(pc);if(pc.right=="auto"){this.dom.style.right="";}if(pc.bottom=="auto"){this.dom.style.bottom=""; }return this;},fixDisplay:function(){if(this.getStyle("display")=="none"){this.setStyle("visibility","hidden");this.setStyle("display",this.originalDisplay);if(this.getStyle("display")=="none"){this.setStyle("display","block");}}},setLeftTop:function(J,K){this.dom.style.left=this.addUnits(J); diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index 3216ddc043..c88dee99cd 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -667,7 +667,9 @@ Roo.bootstrap.Element = function(config){ * @param {Roo.bootstrap.Element} this * @param {Roo.EventObject} e */ - "click" : true + "click" : true + + }); }; @@ -678,6 +680,7 @@ Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, { html: '', preventDefault: false, clickable: false, + tapedTwice : false, getAutoCreate : function(){ @@ -698,6 +701,7 @@ Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, { this.el.on('click', this.onClick, this); } + }, onClick : function(e) @@ -706,9 +710,14 @@ Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, { e.preventDefault(); } - this.fireEvent('click', this, e); + this.fireEvent('dblclick', this, e); }, + + + + + getValue : function() { return this.el.dom.innerHTML; @@ -2028,8 +2037,8 @@ Roo.bootstrap.Card = function(config){ * @param {Roo.bootstrap.Card} this * @param {Object} data from dragdrop */ - 'cardover' : true - + 'cardover' : true + }); }; diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index 693eac7b35..e691d479ec 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -25,8 +25,8 @@ return cn;}var I=A.items;delete A.items;if(!skip_children){for(var i=0;i