incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtu...@apache.org
Subject svn commit: r519074 - in /incubator/xap/trunk/codebase/src/xap: bridges/basic/AbstractWidgetBridge.js widgets/dojo/RichtextTooltip.js
Date Fri, 16 Mar 2007 17:44:07 GMT
Author: mturyn
Date: Fri Mar 16 10:44:06 2007
New Revision: 519074

URL: http://svn.apache.org/viewvc?view=rev&rev=519074
Log:
The method of creating tooltips in Dojo 0.4 now requires that our bridge supply a connexion
to the document in the form of a valid dom node with an id, since 
	1.) often our dom node didn't have an id for dojo.byId() to use in locating it,
	2.) even when there was a valid id, as of the creation process the dom node hasn't
		been appended to the DOM tree, so dojo.byId()/document.getElementById() can't
        find it---Dojo uses these methods a lot because it expects the entire initial
		tree to have been built from the standard html part of their markup (and I think 
		Dojo gives anything with a dojoType attribute an id if it doesn't already have one).

Modified:
    incubator/xap/trunk/codebase/src/xap/bridges/basic/AbstractWidgetBridge.js
    incubator/xap/trunk/codebase/src/xap/widgets/dojo/RichtextTooltip.js

Modified: incubator/xap/trunk/codebase/src/xap/bridges/basic/AbstractWidgetBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/bridges/basic/AbstractWidgetBridge.js?view=diff&rev=519074&r1=519073&r2=519074
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/basic/AbstractWidgetBridge.js (original)
+++ incubator/xap/trunk/codebase/src/xap/bridges/basic/AbstractWidgetBridge.js Fri Mar 16
10:44:06 2007
@@ -718,12 +718,38 @@
 	//TODO should this accept a popup reference like #myTip ?
 	//TODO if they have OLD tooltip need to unregister it!!!
 	
-	//for some reason you have to do this sort of thing for it to appear properly,
-	//not sure why, but same as dojo widget bridge...
-	var tmp = document.createElement('div');
-	var tmp2 = document.createElement('div');
-	tmp2.appendChild(tmp);
-	var tooltip = dojo.widget.createWidget('richtexttooltip',{caption:text},tmp);
+	// Dojo, as a result of its primarily "pre-existing HTML DOM" orientation,
+	// needs a base element for the tooltip...
+	var tmp = document.createElement("span");
+	// ...and to have a parentNode---and the body element
+	// is guarantied to be there; it's even vaguely possible
+	// that putting the tips as high up in the DOM tree as 
+	// possible will make finding them faster if getElementById
+	// does a DOM tree traversal every time::
+	document.body.appendChild(tmp);
+	
+	var myRoot = this.getRootDomNode() ;
+
+	// Dojo 0.4 tooltips use getElementbyId, so we'll need to have an
+	// id for this dom node:
+	if( !myRoot.id ){
+		myRoot.id = "rootNode_"+(this.getElement().getAttribute("id")).replace(":","_") ;
+	}
+	var args = {connectId:myRoot.id,caption:text}
+	
+	// Unless something changes in our bridge building
+	// process (head recursion?), the dom node will quite 
+	// likely at this point a.) Exist but b.) Not yet have
+	// been attached to the document.  This will mean that
+	// the dojo.byId --> document.getElementById won't be 
+	// able to find that node.  Therefore, the we will supply
+	// the _connectNode as part of the args object, and will 
+	// be be used properly by RichTextTooltip::postCreate():
+	if( !dojo.byId(myRoot.id) ){
+		args._connectNode = myRoot ;
+	}
+	
+	var tooltip = dojo.widget.createWidget('richtexttooltip',args,tmp);
 	tooltip.domNode.enabled=false;	
 	
 	//in postCreate or fillInTemplate dojo tried to connect to "connectNode"

Modified: incubator/xap/trunk/codebase/src/xap/widgets/dojo/RichtextTooltip.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/widgets/dojo/RichtextTooltip.js?view=diff&rev=519074&r1=519073&r2=519074
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/widgets/dojo/RichtextTooltip.js (original)
+++ incubator/xap/trunk/codebase/src/xap/widgets/dojo/RichtextTooltip.js Fri Mar 16 10:44:06
2007
@@ -38,22 +38,70 @@
 	// that would otherwise be picked up in extend() 
 	// below:
 	this.widgetType = "RichtextTooltip" ;
-	this.showDelay = 400 ;
-	this.hideDelay = 300 ;	
-	this.fillInTemplate = function(args, frag){
+	this.showDelay = 500 ;
+	this.hideDelay = 200 ;
+
+
+	this.fillInTemplate =  function(args, frag){
 		if(this.caption != ""){
+			//this.domNode.appendChild(document.createTextNode(this.caption));
 			// Let's make life a little easier by allowing users to
 			// use \n's or \r's for new-lines in their text:
 			var text= this.caption.split(/\\[rn]/g).join("<br/>")  ;
-			this.domNode.innerHTML = text ;
+			this.domNode.innerHTML = text ;						
 		}
-		this.connectNode = dojo.byId(this.connectId);
-		// This is intentional---we _don't_ want Tooltip's
-		// fillInTemplate() called:		
+		this._connectNode = dojo.byId(this.connectId);
+		
+		// In our bridge, the dom node quite likely
+		// a.) Exists but b.) Has not yet been attached
+		// to the document yet; this will mean that
+		// the dojo.byId --> document.getElementById
+		// won't be able to find that node.  Therefore, 
+		// the bridge will supply the _connectNode
+		// as part of the args:
+		if(!this._connectNode && args._connectNode ){
+			this._connectNode = args._connectNode ;
+		}		
+		
 		dojo.widget.Tooltip.superclass.fillInTemplate.call(this, args, frag);
+
+		this.addOnLoad(this, "_loadedContent");
+		dojo.html.addClass(this.domNode, "dojoTooltip");
+
+		//copy style from input node to output node
+		var source = this.getFragNodeRef(frag);
+		dojo.html.copyStyle(this.domNode, source);
+
+		//apply the necessary css rules to the node so that it can popup
+		this.applyPopupBasicStyle();
 	}	
-	
+	this.postCreate = function(args, frag){
+		dojo.event.connect(this._connectNode, "onmouseover", this, "_onMouseOver");
+		dojo.widget.Tooltip.superclass.postCreate.call(this, args, frag);
+		dojo.widget.Tooltip.superclass.postCreate.call(this,args,frag);
+		// Give it a little border, inverse of the background colour:
+		this.domNode.style.border="1px solid rgb(10,10,35)" ;
+	}
 }
+
+
+
+
+
+		_onMouseOver: function(e){
+			this._mouse = {x: e.pageX, y: e.pageY};
+
+			// Start tracking mouse movements, so we know when to cancel timers or erase the tooltip
+			if(!this._tracking){
+				dojo.event.connect(document.documentElement, "onmousemove", this, "_onMouseMove");
+				this._tracking=true;
+			}
+
+			this._onHover(e);			
+		}
+
+
+
 dojo.inherits(xap.widgets.dojo.RichtextTooltip, dojo.widget.Tooltip);
 
 // As noted above, the fillInTemplate() and widgetType have



Mime
View raw message