incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtu...@apache.org
Subject svn commit: r483328 - in /incubator/xap/trunk/src/xap/bridges: basic/AbstractWidgetBridge.js xap/ButtonBridge.js
Date Thu, 07 Dec 2006 02:51:09 GMT
Author: mturyn
Date: Wed Dec  6 18:51:05 2006
New Revision: 483328

URL: http://svn.apache.org/viewvc?view=rev&rev=483328
Log:
>From Rob Gagne

Code for XAP-202

Modified:
    incubator/xap/trunk/src/xap/bridges/basic/AbstractWidgetBridge.js
    incubator/xap/trunk/src/xap/bridges/xap/ButtonBridge.js

Modified: incubator/xap/trunk/src/xap/bridges/basic/AbstractWidgetBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/basic/AbstractWidgetBridge.js?view=diff&rev=483328&r1=483327&r2=483328
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/basic/AbstractWidgetBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/basic/AbstractWidgetBridge.js Wed Dec  6 18:51:05
2006
@@ -68,6 +68,7 @@
  */
 xap.bridges.basic.AbstractWidgetBridge =  function() {
 	this._disabled = false;
+	/* this._wantsMouseEvents = false; used to determine if we want to listen to mouse events
*/
 	xap.taghandling.AbstractTagImpl.call( this );
 }
 
@@ -221,8 +222,21 @@
 		dojo.event.connect(rootNode,"onkeypress", this, "onKeyPress");
 		dojo.event.connect(rootNode,"onmousedown", this, "onMouseDown");
 		dojo.event.connect(rootNode,"onmouseup", this, "onMouseUp");
-		dojo.event.connect(rootNode,"onmouseover", this, "onMouseOver");
-		dojo.event.connect(rootNode,"onmouseout", this, "onMouseOut");
+		
+		/* only setup mouse events if they're needed, use the IE specific ones on IE */
+		if ( this._wantsMouseEvents ) {
+			if (dojo.render.html.ie) {
+				this._onEnter = "onmouseenter";
+				this._onLeave = "onmouseleave";
+			}
+			else {
+				this._onEnter = "onmouseover";
+				this._onLeave = "onmouseout";
+			}
+			dojo.event.connect(rootNode, this._onEnter, this, "onMouseOver");
+			dojo.event.connect(rootNode, this._onLeave, this, "onMouseOut");
+		}
+		dojo.event.connect(rootNode,"onclick", this, "onClick");
 	}
 }
 
@@ -732,11 +746,17 @@
 	this.fireMouseEvent("onDoubleClick",e);
 }
 
+xap.bridges.basic.AbstractWidgetBridge.prototype.onClick = function(e){
+	this.stopEvent(e);
+}
+
 xap.bridges.basic.AbstractWidgetBridge.prototype.onMouseDown = function(e){
 	if (!this._disabled){
 		this.addStyleState("MouseDown");
 		this.fireMouseEvent("onMouseDown",e);
 	}
+	
+	this.stopEvent(e);
 }
 
 xap.bridges.basic.AbstractWidgetBridge.prototype.onMouseUp = function(e){
@@ -747,12 +767,18 @@
 		this.removeStyleState("MouseDown");
 		this.fireMouseEvent("onMouseUp",e);
 	}
+	
+	this.stopEvent(e);
 }
 
 xap.bridges.basic.AbstractWidgetBridge.prototype.onMouseOver= function(e){
-	//TODO fire event?
-	if (!this._disabled){
+	
+	/* add the style - disconnect the mouse move event and set us into MouseOver style */
+	if (!this._disabled && !this._isMouseOver){
 		this.addStyleState("MouseOver");
+		this._isMouseOver = true;
+		dojo.event.disconnect(this.getRootDomNode(), this._onEnter, this, "onMouseOver");
+		this.stopEvent(e);
 	}
 }
 
@@ -762,6 +788,8 @@
 	//it moving from one descendent to another, so check for that.
 	//In that case we are still in the mouseOver style as the mouse just
 	//moved internally. This is only an issue in IE
+	/*
+	OBSOLETE - We're now using OnmouseEnter and onmouseleave on IE
 	if (e.srcElement && e.srcElement != this.getRootDomNode())
 		if (e.toElement){
 			var element = e.toElement;
@@ -776,8 +804,14 @@
 			}
 		}
 	//TODO fire event?
-	if (!this._disabled){
+	*/	
+
+	/* only if we are in MouseOver state - remove the style and reconnect the mouse move */
+	if (!this._disabled && this._isMouseOver){
+		this._isMouseOver = false;
 		this.removeStyleState("MouseOver");
+		dojo.event.connect(this.getRootDomNode(), this._onEnter, this, "onMouseOver");
+		this.stopEvent(e);
 	}
 }
 
@@ -799,6 +833,16 @@
 	}
 }
 
+xap.bridges.basic.AbstractWidgetBridge.prototype.stopEvent = function(evt){
+	if (window.event){
+		window.event.returnValue=false;
+		window.event.cancelBubble=true;
+	}
+	else if (evt.getPreventDefault){
+		evt.preventDefault();
+		evt.stopPropagation();
+	}
+}
 
 xap.bridges.basic.AbstractWidgetBridge.prototype.fireMouseEvent = function( eventName, htmlEvent){
 	var clientEvent = new xap.session.ClientEvent(this.getElement(),this.getSession());

Modified: incubator/xap/trunk/src/xap/bridges/xap/ButtonBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/xap/ButtonBridge.js?view=diff&rev=483328&r1=483327&r2=483328
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/xap/ButtonBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/xap/ButtonBridge.js Wed Dec  6 18:51:05 2006
@@ -22,6 +22,7 @@
 
 xap.bridges.xap.ButtonBridge = function() {
 	xap.bridges.xap.LabelBridge.call(this);
+	this._wantsMouseEvents = true;
 }
 
 Xap.setupClassAsSubclassOf("xap.bridges.xap.ButtonBridge", "xap.bridges.xap.LabelBridge");



Mime
View raw message