incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtu...@apache.org
Subject svn commit: r518313 [10/43] - in /incubator/xap/trunk/codebase/src/dojo: ./ src/ src/animation/ src/cal/ src/charting/ src/charting/svg/ src/charting/vml/ src/collections/ src/crypto/ src/data/ src/data/core/ src/data/old/ src/data/old/format/ src/data...
Date Wed, 14 Mar 2007 20:37:27 GMT
Added: incubator/xap/trunk/codebase/src/dojo/src/date/serialize.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/date/serialize.js?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/date/serialize.js (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/date/serialize.js Wed Mar 14 13:36:44 2007
@@ -0,0 +1,175 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.date.serialize");
+
+dojo.require("dojo.string.common");
+
+/* ISO 8601 Functions
+ *********************/
+
+dojo.date.setIso8601 = function(/*Date*/dateObject, /*String*/formattedString){
+	// summary: sets a Date object based on an ISO 8601 formatted string (uses date and time)
+	var comps = (formattedString.indexOf("T") == -1) ? formattedString.split(" ") : formattedString.split("T");
+	dateObject = dojo.date.setIso8601Date(dateObject, comps[0]);
+	if(comps.length == 2){ dateObject = dojo.date.setIso8601Time(dateObject, comps[1]); }
+	return dateObject; /* Date or null */
+};
+
+dojo.date.fromIso8601 = function(/*String*/formattedString){
+	// summary: returns a Date object based on an ISO 8601 formatted string (uses date and time)
+	return dojo.date.setIso8601(new Date(0, 0), formattedString);
+};
+
+dojo.date.setIso8601Date = function(/*String*/dateObject, /*String*/formattedString){
+	// summary: sets a Date object based on an ISO 8601 formatted string (date only)
+	var regexp = "^([0-9]{4})((-?([0-9]{2})(-?([0-9]{2}))?)|" +
+			"(-?([0-9]{3}))|(-?W([0-9]{2})(-?([1-7]))?))?$";
+	var d = formattedString.match(new RegExp(regexp));
+	if(!d){
+		dojo.debug("invalid date string: " + formattedString);
+		return null; // null
+	}
+	var year = d[1];
+	var month = d[4];
+	var date = d[6];
+	var dayofyear = d[8];
+	var week = d[10];
+	var dayofweek = d[12] ? d[12] : 1;
+
+	dateObject.setFullYear(year);
+
+	if(dayofyear){
+		dateObject.setMonth(0);
+		dateObject.setDate(Number(dayofyear));
+	}
+	else if(week){
+		dateObject.setMonth(0);
+		dateObject.setDate(1);
+		var gd = dateObject.getDay();
+		var day =  gd ? gd : 7;
+		var offset = Number(dayofweek) + (7 * Number(week));
+		
+		if(day <= 4){ dateObject.setDate(offset + 1 - day); }
+		else{ dateObject.setDate(offset + 8 - day); }
+	} else{
+		if(month){
+			dateObject.setDate(1);
+			dateObject.setMonth(month - 1); 
+		}
+		if(date){ dateObject.setDate(date); }
+	}
+	
+	return dateObject; // Date
+};
+
+dojo.date.fromIso8601Date = function(/*String*/formattedString){
+	// summary: returns a Date object based on an ISO 8601 formatted string (date only)
+	return dojo.date.setIso8601Date(new Date(0, 0), formattedString);
+};
+
+dojo.date.setIso8601Time = function(/*Date*/dateObject, /*String*/formattedString){
+	// summary: sets a Date object based on an ISO 8601 formatted string (time only)
+
+	// first strip timezone info from the end
+	var timezone = "Z|(([-+])([0-9]{2})(:?([0-9]{2}))?)$";
+	var d = formattedString.match(new RegExp(timezone));
+
+	var offset = 0; // local time if no tz info
+	if(d){
+		if(d[0] != 'Z'){
+			offset = (Number(d[3]) * 60) + Number(d[5]);
+			offset *= ((d[2] == '-') ? 1 : -1);
+		}
+		offset -= dateObject.getTimezoneOffset();
+		formattedString = formattedString.substr(0, formattedString.length - d[0].length);
+	}
+
+	// then work out the time
+	var regexp = "^([0-9]{2})(:?([0-9]{2})(:?([0-9]{2})(\.([0-9]+))?)?)?$";
+	d = formattedString.match(new RegExp(regexp));
+	if(!d){
+		dojo.debug("invalid time string: " + formattedString);
+		return null; // null
+	}
+	var hours = d[1];
+	var mins = Number((d[3]) ? d[3] : 0);
+	var secs = (d[5]) ? d[5] : 0;
+	var ms = d[7] ? (Number("0." + d[7]) * 1000) : 0;
+
+	dateObject.setHours(hours);
+	dateObject.setMinutes(mins);
+	dateObject.setSeconds(secs);
+	dateObject.setMilliseconds(ms);
+
+	if(offset !== 0){
+		dateObject.setTime(dateObject.getTime() + offset * 60000);
+	}	
+	return dateObject; // Date
+};
+
+dojo.date.fromIso8601Time = function(/*String*/formattedString){
+	// summary: returns a Date object based on an ISO 8601 formatted string (date only)
+	return dojo.date.setIso8601Time(new Date(0, 0), formattedString);
+};
+
+
+/* RFC-3339 Date Functions
+ *************************/
+
+dojo.date.toRfc3339 = function(/*Date?*/dateObject, /*String?*/selector){
+//	summary:
+//		Format a JavaScript Date object as a string according to RFC 3339
+//
+//	dateObject:
+//		A JavaScript date, or the current date and time, by default
+//
+//	selector:
+//		"dateOnly" or "timeOnly" to format selected portions of the Date object.
+//		Date and time will be formatted by default.
+
+//FIXME: tolerate Number, string input?
+	if(!dateObject){
+		dateObject = new Date();
+	}
+
+	var _ = dojo.string.pad;
+	var formattedDate = [];
+	if(selector != "timeOnly"){
+		var date = [_(dateObject.getFullYear(),4), _(dateObject.getMonth()+1,2), _(dateObject.getDate(),2)].join('-');
+		formattedDate.push(date);
+	}
+	if(selector != "dateOnly"){
+		var time = [_(dateObject.getHours(),2), _(dateObject.getMinutes(),2), _(dateObject.getSeconds(),2)].join(':');
+		var timezoneOffset = dateObject.getTimezoneOffset();
+		time += (timezoneOffset > 0 ? "-" : "+") + 
+					_(Math.floor(Math.abs(timezoneOffset)/60),2) + ":" +
+					_(Math.abs(timezoneOffset)%60,2);
+		formattedDate.push(time);
+	}
+	return formattedDate.join('T'); // String
+};
+
+dojo.date.fromRfc3339 = function(/*String*/rfcDate){
+//	summary:
+//		Create a JavaScript Date object from a string formatted according to RFC 3339
+//
+//	rfcDate:
+//		A string such as 2005-06-30T08:05:00-07:00
+//		"any" is also supported in place of a time.
+
+	// backwards compatible support for use of "any" instead of just not 
+	// including the time
+	if(rfcDate.indexOf("Tany")!=-1){
+		rfcDate = rfcDate.replace("Tany","");
+	}
+	var dateObject = new Date();
+	return dojo.date.setIso8601(dateObject, rfcDate); // Date or null
+};

Added: incubator/xap/trunk/codebase/src/dojo/src/date/supplemental.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/date/supplemental.js?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/date/supplemental.js (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/date/supplemental.js Wed Mar 14 13:36:44 2007
@@ -0,0 +1,76 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.date.supplemental");
+
+dojo.date.getFirstDayOfWeek = function(/*String?*/locale){
+// summary: Returns a zero-based index for first day of the week
+// description:
+//		Returns a zero-based index for first day of the week, as used by the local (Gregorian) calendar.
+//		e.g. Sunday (returns 0), or Monday (returns 1)
+
+	// from http://www.unicode.org/cldr/data/common/supplemental/supplementalData.xml:supplementalData/weekData/firstDay
+	var firstDay = {/*default is 1=Monday*/
+		mv:5,
+		ae:6,af:6,bh:6,dj:6,dz:6,eg:6,er:6,et:6,iq:6,ir:6,jo:6,ke:6,kw:6,lb:6,ly:6,ma:6,om:6,qa:6,sa:6,
+		sd:6,so:6,tn:6,ye:6,
+		as:0,au:0,az:0,bw:0,ca:0,cn:0,fo:0,ge:0,gl:0,gu:0,hk:0,ie:0,il:0,is:0,jm:0,jp:0,kg:0,kr:0,la:0,
+		mh:0,mo:0,mp:0,mt:0,nz:0,ph:0,pk:0,sg:0,th:0,tt:0,tw:0,um:0,us:0,uz:0,vi:0,za:0,zw:0,
+		et:0,mw:0,ng:0,tj:0,
+		gb:0,
+		sy:4
+	};
+
+	locale = dojo.hostenv.normalizeLocale(locale);
+	var country = locale.split("-")[1];
+	var dow = firstDay[country];
+	return (typeof dow == 'undefined') ? 1 : dow; /*Number*/
+};
+
+dojo.date.getWeekend = function(/*String?*/locale){
+// summary: Returns a hash containing the start and end days of the weekend
+// description:
+//		Returns a hash containing the start and end days of the weekend according to local custom using locale,
+//		or by default in the user's locale.
+//		e.g. {start:6, end:0}
+
+	// from http://www.unicode.org/cldr/data/common/supplemental/supplementalData.xml:supplementalData/weekData/weekend{Start,End}
+	var weekendStart = {/*default is 6=Saturday*/
+		eg:5,il:5,sy:5,
+		'in':0,
+		ae:4,bh:4,dz:4,iq:4,jo:4,kw:4,lb:4,ly:4,ma:4,om:4,qa:4,sa:4,sd:4,tn:4,ye:4		
+	};
+
+	var weekendEnd = {/*default is 0=Sunday*/
+		ae:5,bh:5,dz:5,iq:5,jo:5,kw:5,lb:5,ly:5,ma:5,om:5,qa:5,sa:5,sd:5,tn:5,ye:5,af:5,ir:5,
+		eg:6,il:6,sy:6
+	};
+
+	locale = dojo.hostenv.normalizeLocale(locale);
+	var country = locale.split("-")[1];
+	var start = weekendStart[country];
+	var end = weekendEnd[country];
+	if(typeof start == 'undefined'){start=6;}
+	if(typeof end == 'undefined'){end=0;}
+	return {start:start, end:end}; /*Object {start,end}*/
+};
+
+dojo.date.isWeekend = function(/*Date?*/dateObj, /*String?*/locale){
+// summary:
+//	Determines if the date falls on a weekend, according to local custom.
+
+	var weekend = dojo.date.getWeekend(locale);
+	var day = (dateObj || new Date()).getDay();
+	if(weekend.end<weekend.start){
+		weekend.end+=7;
+		if(day<weekend.start){ day+=7; }
+	}
+	return day >= weekend.start && day <= weekend.end; // Boolean
+};

Added: incubator/xap/trunk/codebase/src/dojo/src/debug.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/debug.js?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/debug.js (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/debug.js Wed Mar 14 13:36:44 2007
@@ -0,0 +1,91 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.debug = function(/*...*/){
+	// summary:
+	//		Produce a line of debug output. Does nothing unless
+	//		djConfig.isDebug is true. Accepts any nubmer of args, joined with
+	//		' ' to produce a single line of debugging output.  Caller should not
+	//		supply a trailing "\n".
+	if (!djConfig.isDebug) { return; }
+	var args = arguments;
+	if(dj_undef("println", dojo.hostenv)){
+		dojo.raise("dojo.debug not available (yet?)");
+	}
+	var isJUM = dj_global["jum"] && !dj_global["jum"].isBrowser;
+	var s = [(isJUM ? "": "DEBUG: ")];
+	for(var i=0;i<args.length;++i){
+		if(!false && args[i] && args[i] instanceof Error){
+			var msg = "[" + args[i].name + ": " + dojo.errorToString(args[i]) +
+				(args[i].fileName ? ", file: " + args[i].fileName : "") +
+				(args[i].lineNumber ? ", line: " + args[i].lineNumber : "") + "]";
+		} else {
+			try {
+				var msg = String(args[i]);
+			} catch(e) {
+				if(dojo.render.html.ie) {
+					var msg = "[ActiveXObject]";
+				} else {
+					var msg = "[unknown]";
+				}
+			}
+		}
+		s.push(msg);
+	}
+	
+	dojo.hostenv.println(s.join(" "));
+}
+
+/**
+ * this is really hacky for now - just 
+ * display the properties of the object
+**/
+
+dojo.debugShallow = function(/*Object*/obj){
+	// summary:
+	//		outputs a "name: value" style listing of all enumerable properties
+	//		in obj. Does nothing if djConfig.isDebug == false.
+	// obj: the object to be enumerated
+	if (!djConfig.isDebug) { return; }
+	dojo.debug('------------------------------------------------------------');
+	dojo.debug('Object: '+obj);
+	var props = [];
+	for(var prop in obj){
+		try {
+			props.push(prop + ': ' + obj[prop]);
+		} catch(E) {
+			props.push(prop + ': ERROR - ' + E.message);
+		}
+	}
+	props.sort();
+	for(var i = 0; i < props.length; i++) {
+		dojo.debug(props[i]);
+	}
+	dojo.debug('------------------------------------------------------------');
+}
+
+dojo.debugDeep = function(/*Object*/obj){
+	// summary:
+	//		provides an "object explorer" view of the passed obj in a popup
+	//		window.
+	// obj: the object to be examined
+	if (!djConfig.isDebug) { return; }
+	if (!dojo.uri || !dojo.uri.dojoUri){ return dojo.debug("You'll need to load dojo.uri.* for deep debugging - sorry!"); }
+	if (!window.open){ return dojo.debug('Deep debugging is only supported in host environments with window.open'); }
+	var idx = dojo.debugDeep.debugVars.length;
+	dojo.debugDeep.debugVars.push(obj);
+	// dojo.undo.browser back and forward breaks relpaths
+	var url = new dojo.uri.Uri(location, dojo.uri.dojoUri("src/debug/deep.html?var="+idx)).toString();
+	var win = window.open(url, '_blank', 'width=600, height=400, resizable=yes, scrollbars=yes, status=yes');
+	try{
+		win.debugVar = obj;
+	}catch(e){}
+}
+dojo.debugDeep.debugVars = [];

Added: incubator/xap/trunk/codebase/src/dojo/src/debug/Firebug.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/debug/Firebug.js?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/debug/Firebug.js (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/debug/Firebug.js Wed Mar 14 13:36:44 2007
@@ -0,0 +1,62 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.debug.Firebug");
+dojo.deprecated("dojo.debug.Firebug is slated for removal in 0.5; use dojo.debug.console instead.", "0.5");
+
+// summary
+// Firebug Console logger.
+// This package redirects the normal dojo debugging output to the firebug console.  It does
+// so by sending the entire object to the console, rather than just overriding dojo.hostenv.println
+// so that firebugs object inspector can be taken advantage of.
+
+if (dojo.render.html.moz) {
+	if (console && console.log) {
+		var consoleLog = function() {
+			if (!djConfig.isDebug) { return ; }
+
+			var args = dojo.lang.toArray(arguments);
+			args.splice(0,0, "DEBUG: ");
+			console.log.apply(console, args);
+		}
+
+		dojo.debug = consoleLog;
+
+		dojo.debugDeep=consoleLog;
+
+		dojo.debugShallow=function(obj) {
+			if (!djConfig.isDebug) { return; }
+
+			if (dojo.lang.isArray(obj)) {
+				console.log('Array: ', obj);
+				for (var i=0; x<obj.length; i++) {
+					console.log('    ', '['+i+']', obj[i]);
+				}
+			} else {
+				console.log('Object: ', obj);
+				var propNames = [];
+				for (var prop in obj) {
+					propNames.push(prop);
+				}
+				propNames.sort();
+				dojo.lang.forEach(propNames, function(prop) {
+					try {
+						console.log('    ', prop, obj[prop]);
+					} catch(e) {
+						console.log('    ', prop, 'ERROR', e.message, e);
+					}
+				});
+			}
+		}
+
+	} else {
+		dojo.debug("dojo.debug.Firebug requires Firebug > 0.4");
+	}
+}

Added: incubator/xap/trunk/codebase/src/dojo/src/debug/arrow_hide.gif
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/debug/arrow_hide.gif?view=auto&rev=518313
==============================================================================
Binary file - no diff available.

Propchange: incubator/xap/trunk/codebase/src/dojo/src/debug/arrow_hide.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/xap/trunk/codebase/src/dojo/src/debug/arrow_show.gif
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/debug/arrow_show.gif?view=auto&rev=518313
==============================================================================
Binary file - no diff available.

Propchange: incubator/xap/trunk/codebase/src/dojo/src/debug/arrow_show.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/xap/trunk/codebase/src/dojo/src/debug/console.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/debug/console.js?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/debug/console.js (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/debug/console.js Wed Mar 14 13:36:44 2007
@@ -0,0 +1,115 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.debug.console");
+dojo.require("dojo.logging.ConsoleLogger");
+
+// summary:
+// 	Console logger, for use with FireFox Firebug, Safari and Opera's consoles.
+// description:
+//  This package redirects the normal dojo debugging output to the console log in modern browsers.
+//  When using Firebug, it does this  by sending the entire object to the console, 
+//	rather than just overriding dojo.hostenv.println, so that Firebug's interactive 
+//	object inspector is available.
+// see: http://www.joehewitt.com/software/firebug/docs.php
+
+if (window.console) {
+	if (console.info != null) {
+		// using a later version of Firebug -- lots of fun stuff!
+		
+		dojo.hostenv.println = function() {
+			// summary: Write all of the arguments to the Firebug console
+			// description: Uses console.info() so that the (i) icon prints next to the debug line
+			//	rather than munging the arguments by adding "DEBUG:" in front of them.
+			//	This allows us to use Firebug's string handling to do interesting things
+			if (!djConfig.isDebug)	{	 return;	}
+			console.info.apply(console, arguments);
+		}
+		dojo.debug=dojo.hostenv.println;
+		dojo.debugDeep = dojo.debug;
+
+		dojo.debugShallow = function(/*Object*/ obj, /*Boolean?*/showMethods, /*Boolean?*/sort) {
+			// summary:  Write first-level properties of obj to the console.
+			//	obj:			Object or Array to debug
+			//	showMethods:	Pass false to skip outputing methods of object, any other value will output them.
+			//	sort:			Pass false to skip sorting properties, any other value will sort.
+			if (!djConfig.isDebug) { return; }
+
+			showMethods = (showMethods != false);
+			sort = (sort != false);
+
+			// handle null or something without a constructor (in which case we don't know the type)
+			if (obj == null || obj.constructor == null) {
+				return dojo.debug(obj);
+			}
+	
+			// figure out type via a standard constructor (Object, String, Date, etc)
+			var type = obj.declaredClass;
+			if (type == null) {
+				type = obj.constructor.toString().match(/function\s*(.*)\(/);
+				if (type) {	type = type[1]	};
+			}
+			// if we got a viable type, use Firebug's interactive property dump feature
+			if (type) {
+				if (type == "String" || type == "Number") {
+					return dojo.debug(type+": ", obj);
+				}
+				if (showMethods && !sort) {
+					var sortedObj = obj;
+				} else {
+					var propNames = [];
+					if (showMethods) {
+						for (var prop in obj) {	
+							propNames.push(prop);
+						}
+					} else {
+						for (var prop in obj) {	
+							if (typeof obj[prop] != "function") { propNames.push(prop);	}
+							else dojo.debug(prop);
+						}					
+					}
+					if (sort) propNames.sort();
+					var sortedObj = {};
+					dojo.lang.forEach(propNames, function(prop) {
+						sortedObj[prop] = obj[prop];
+					});
+				}
+
+				return dojo.debug(type+": %o\n%2.o",obj,sortedObj);
+			}
+		
+			// otherwise just output the constructor + object, 
+			//	which is nice for a DOM element, etc
+			return dojo.debug(obj.constructor + ": ", obj);
+		}
+		
+	} else if (console.log != null) {
+		// using Safari or an old version of Firebug
+		dojo.hostenv.println=function() {
+			if (!djConfig.isDebug) { return ; }
+			// make sure we're only writing a single string to Safari's console
+			var args = dojo.lang.toArray(arguments);
+			console.log("DEBUG: " + args.join(" "));
+		}
+		dojo.debug=dojo.hostenv.println;
+	} else {
+		// not supported
+		dojo.debug("dojo.debug.console requires Firebug > 0.4");
+	}
+} else if (dojo.render.html.opera) {
+	// using Opera 8.0 or later
+	if (opera && opera.postError) {
+		dojo.hostenv.println=opera.postError;
+		// summary:  hook debugging up to Opera's postError routine
+	} else {
+		dojo.debug("dojo.debug.Opera requires Opera > 8.0");
+	}
+}
+

Added: incubator/xap/trunk/codebase/src/dojo/src/debug/deep.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/debug/deep.html?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/debug/deep.html (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/debug/deep.html Wed Mar 14 13:36:44 2007
@@ -0,0 +1,362 @@
+<html>
+<head>
+<title>Deep Debugger</title>
+<script>
+
+var tableRows = {};
+var tableCels = {};
+var tableObjs = {};
+var tablesBuilt = {};
+var tableShows = {};
+var tableHides = {};
+
+// IE: nodes w/id need to be redeclared or getElementById is b0rked
+var frame = null;
+
+window.onload = function(){
+	// if IE loads this page too quickly (instantly) then 
+	// window.debugVar might not have been set
+	window.setTimeout(startMeUp, 100);
+}
+
+function startMeUp(){
+	frame = document.getElementById('frame');
+	// GET string 
+	var index = location.search.split("=").pop();
+	var debugObj = window.opener.dojo.debugDeep;
+	var debugVar = debugObj.debugVars[index] || window.debugVar;
+	buildTable('root', frame, debugVar);
+}
+
+function buildTable(path, parent, obj){
+	var keys = [];
+	var vals = [];
+	for(var prop in obj){
+		keys.push(prop);
+		try {
+			vals[prop] = obj[prop];
+		} catch(E) {
+			vals[prop] = 'ERROR: ' + E.message;
+		}
+	}
+	keys.sort(keySorter);
+
+	if (!keys.length){
+
+		var div = document.createElement('div');
+		div.appendChild(document.createTextNode('Object has no properties.'));
+
+		parent.appendChild(div);
+		return;
+	}
+
+
+	var t = document.createElement('table');
+	t.border = "1";
+
+	var tb = document.createElement('tbody');
+	t.appendChild(tb);
+
+
+	for(var i = 0; i < keys.length; i++) {
+		buildTableRow(path+'-'+keys[i], tb, keys[i], vals[keys[i]]);
+	}
+
+	if (path == 'root'){
+		//t.style.width = '90%';
+	}
+	t.style.width = '100%';
+
+	parent.appendChild(t);
+
+	tablesBuilt[path] = true;
+}
+
+function buildTableRow(path, tb, name, value) {
+
+	var simpleType = typeof(value);
+	var createSubrow = (simpleType == 'object');
+	var complexType = simpleType;
+
+	if (simpleType == 'object'){
+		var cls = getConstructorClass(value);
+		if (cls){
+			if (cls == 'Object'){
+			}else if (cls == 'Array'){
+				complexType = 'array';
+			}else{
+				complexType += ' ('+cls+')';
+			}
+		}
+	}
+
+/*var tr1 = document.createElement('tr');
+	var td1 = document.createElement('td');
+	var td2 = document.createElement('td');
+	var td3 = document.createElement('td');
+	var td4 = document.createElement('td');*/
+
+	var row = tb.rows.length;
+	var tr1 = tb.insertRow(row++);
+	var td1 = tr1.insertCell(0);
+	var td2 = tr1.insertCell(1);
+	var td3 = tr1.insertCell(2);
+	var td4 = tr1.insertCell(3);
+	
+	tr1.style.verticalAlign = 'top';
+	td1.style.verticalAlign = 'middle';
+
+	td1.className = 'propPlus';
+	td2.className = 'propName';
+	td3.className = 'propType';
+	td4.className = 'propVal';
+
+	//tr1.appendChild(td1);
+	//tr1.appendChild(td2);
+	//tr1.appendChild(td3);
+	//tr1.appendChild(td4);
+
+	if (createSubrow){
+		var img1 = document.createElement('img');
+		img1.width = 9;
+		img1.height = 9;
+		img1.src = 'arrow_show.gif';
+		var a1 = document.createElement('a');
+		a1.appendChild(img1);
+		a1.href = '#';
+		a1.onclick = function(){ showTableRow(path); return false; };
+
+		var img2 = document.createElement('img');
+		img2.width = 9;
+		img2.height = 9;
+		img2.src = 'arrow_hide.gif';
+		var a2 = document.createElement('a');
+		a2.appendChild(img2);
+		a2.href = '#';
+		a2.onclick = function(){ hideTableRow(path); return false; };
+		a2.style.display = 'none';
+
+		tableShows[path] = a1;
+		tableHides[path] = a2;
+
+		td1.appendChild(a1);
+		td1.appendChild(a2);
+	}else{
+		var img = document.createElement('img');
+		img.width = 9;
+		img.height = 9;
+		img.src = 'spacer.gif';
+
+		td1.appendChild(img);
+	}
+
+	td2.appendChild(document.createTextNode(name));
+	td3.appendChild(document.createTextNode(complexType));
+	td4.appendChild(buildPreBlock(value));
+
+	//tb.appendChild(tr1);
+
+	if (createSubrow){
+		var tr2 = tb.insertRow(row++);
+		var td5 = tr2.insertCell(0);
+		var td6 = tr2.insertCell(1);
+		
+		//var tr2 = document.createElement('tr');
+		//var td5 = document.createElement('td');
+		//var td6 = document.createElement('td');
+
+		td5.innerHTML = '&nbsp;';
+		//td6.innerHTML = '&nbsp;';
+
+		td6.colSpan = '3';
+
+		tr2.appendChild(td5);
+		tr2.appendChild(td6);
+
+		tr2.style.display = 'none';
+
+		tb.appendChild(tr2);
+
+		tableRows[path] = tr2;
+		tableCels[path] = td6;
+		tableObjs[path] = value;
+	}
+}
+
+function showTableRow(path){
+
+	var tr = tableRows[path];
+	var td = tableCels[path];
+	var a1 = tableShows[path];
+	var a2 = tableHides[path];
+
+	if (!tablesBuilt[path]){
+
+		//alert('building table for '+path);
+		buildTable(path, td, tableObjs[path]);
+	}
+
+	tr.style.display = 'table-row';
+
+	a1.style.display = 'none';
+	a2.style.display = 'inline';
+}
+
+function hideTableRow(path){
+
+	var tr = tableRows[path];
+	var a1 = tableShows[path];
+	var a2 = tableHides[path];
+
+	tr.style.display = 'none';
+
+	a1.style.display = 'inline';
+	a2.style.display = 'none';
+}
+
+function buildPreBlock(value){
+
+	//
+	// how many lines ?
+	//
+
+	var s = ''+value;
+	s = s.replace("\r\n", "\n");
+	s = s.replace("\r", "");
+	var lines = s.split("\n");
+
+
+	if (lines.length < 2){
+
+		if (lines[0].length < 60){
+
+			var pre = document.createElement('pre');
+			pre.appendChild(document.createTextNode(s));
+			return pre;
+		}
+	}
+
+
+	//
+	// multiple lines :(
+	//
+
+	var preview = lines[0].substr(0, 60) + ' ...';
+
+	var pre1 = document.createElement('pre');
+	pre1.appendChild(document.createTextNode(preview));
+	pre1.className = 'clicky';
+
+	var pre2 = document.createElement('pre');
+	pre2.appendChild(document.createTextNode(s));
+	pre2.style.display = 'none';
+	pre2.className = 'clicky';
+
+	pre1.onclick = function(){
+		pre1.style.display = 'none';
+		pre2.style.display = 'block';
+	}
+
+	pre2.onclick = function(){
+		pre1.style.display = 'block';
+		pre2.style.display = 'none';
+	}
+
+	var pre = document.createElement('div');
+
+	pre.appendChild(pre1);
+	pre.appendChild(pre2);
+
+	return pre;
+}
+
+function getConstructorClass(obj){
+
+	if (!obj.constructor || !obj.constructor.toString) return;
+
+	var m = obj.constructor.toString().match(/function\s*(\w+)/);
+
+	if (m && m.length == 2) return m[1];
+
+	return null;
+}
+
+function keySorter(a, b){
+
+	if (a == parseInt(a) && b == parseInt(b)){
+
+		return (parseInt(a) > parseInt(b)) ? 1 : ((parseInt(a) < parseInt(b)) ? -1 : 0);
+	}
+
+	// sort by lowercase string
+
+	var a2 = String(a).toLowerCase();
+	var b2 = String(b).toLowerCase();
+
+	return (a2 > b2) ? 1 : ((a2 < b2) ? -1 : 0);
+}
+
+</script>
+<style>
+
+body {
+	font-family: arial, helvetica, sans-serif;
+}
+
+table {
+	border-width: 0px;
+	border-spacing: 1px;
+	border-collapse: separate;
+}
+
+td {
+	border-width: 0px;
+	padding: 2px;
+}
+
+img {
+	border: 0;
+}
+
+pre {
+	margin: 0;
+	padding: 0;
+	white-space: -moz-pre-wrap;  /* Mozilla, supported since 1999 */
+	white-space: -pre-wrap;      /* Opera 4 - 6 */
+	white-space: -o-pre-wrap;    /* Opera 7 */
+	white-space: pre-wrap;       /* CSS3 - Text module (Candidate Recommendation) http://www.w3.org/TR/css3-text/#white-space */
+	word-wrap: break-word;       /* IE 5.5+ */
+}
+
+pre.clicky {
+	cursor: hand;
+	cursor: pointer;
+}
+
+td.propPlus {
+	width: 9px;
+	background-color: #ddd;
+}
+
+td.propName {
+	background-color: #ddd;
+}
+
+td.propType {
+	background-color: #ddd;
+}
+
+td.propVal {
+	background-color: #ddd;
+}
+
+</style>
+</head>
+<body>
+
+<h2>Javascript Object Browser</h2>
+
+<div id="frame"></div>
+
+</body>
+</html>
\ No newline at end of file

Added: incubator/xap/trunk/codebase/src/dojo/src/debug/spacer.gif
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/debug/spacer.gif?view=auto&rev=518313
==============================================================================
Binary file - no diff available.

Propchange: incubator/xap/trunk/codebase/src/dojo/src/debug/spacer.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/xap/trunk/codebase/src/dojo/src/dnd/DragAndDrop.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/dnd/DragAndDrop.js?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/dnd/DragAndDrop.js (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/dnd/DragAndDrop.js Wed Mar 14 13:36:44 2007
@@ -0,0 +1,264 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.require("dojo.lang.common");
+dojo.require("dojo.lang.func");
+dojo.require("dojo.lang.declare");
+dojo.provide("dojo.dnd.DragAndDrop");
+
+// summary:
+//		Core "interfaces" for the participants in all DnD operations.
+//		Subclasses implement all of the actions outlined by these APIs, with
+//		most of the ones you probably care about being defined in
+//		HtmlDragAndDrop.js, which will be automatically included should you
+//		dojo.require("dojo.dnd.*");.
+//
+//		In addition to the various actor classes, a global manager will be
+//		created/installed at dojo.dnd.dragManager. This manager object is of
+//		type dojo.dnd.DragManager and will be replaced by environment-specific
+//		managers.
+//
+// 		The 3 object types involved in any Drag and Drop operation are:
+//			* DragSource
+//				This is the item that can be selected for dragging. Drag
+//				sources can have "types" to help mediate whether or not various
+//				DropTargets will accept (or reject them). Most dragging actions
+//				are handled by the DragObject which the DragSource generates
+//				from its onDragStart method.
+//			* DragObject
+//				This, along with the manger, does most of the hard work of DnD.
+//				Implementations may rely on DragObject instances to implement
+//				"shadowing", "movement", or other kinds of DnD variations that
+//				affect the visual representation of the drag operation.
+//			* DropTarget
+//				Represents some section of the screen that can accept drag
+//				and drop events. DropTargets keep a list of accepted types
+//				which is checked agains the types of the respective DragSource
+//				objects that pass over it. DropTargets may implement behaviors
+//				that respond to drop events to take application-level actions.
+
+dojo.declare("dojo.dnd.DragSource", null, {
+	// String: 
+	//		what kind of drag source are we? Used to determine if we can be
+	//		dropped on a given DropTarget
+	type: "",
+
+	onDragEnd: function(/*dojo.dnd.DragEvent*/evt){
+		// summary:
+		//		stub handler that is called when dragging finishes.
+	},
+
+	onDragStart: function(/*dojo.dnd.DragEvent*/evt){ // dojo.dnd.DragObject
+		// summary:
+		//		stub handler that is called when dragging starts. Subclasses
+		//		should ensure that onDragStart *always* returns a
+		//		dojo.dnd.DragObject instance.
+	},
+
+	onSelected: function(/*dojo.dnd.DragEvent*/evt){
+		// summary:
+		//		This function gets called when the DOM element was selected for
+		//		dragging by the HtmlDragAndDropManager.
+	},
+
+	unregister: function(){
+		// summary: remove this drag source from the manager
+		dojo.dnd.dragManager.unregisterDragSource(this);
+	},
+
+	reregister: function(){
+		// summary: add this drag source to the manager
+		dojo.dnd.dragManager.registerDragSource(this);
+	}
+});
+
+dojo.declare("dojo.dnd.DragObject", null, {
+	// String: 
+	//		what kind of drag object are we? Used to determine if we can be
+	//		dropped on a given DropTarget
+	type: "",
+	
+	register: function(){
+		// summary: register this DragObject with the manager
+		var dm = dojo.dnd.dragManager;
+		if(dm["registerDragObject"]){ // side-effect prevention
+			dm.registerDragObject(this);
+		}
+	},
+
+	onDragStart: function(/*dojo.dnd.DragEvent*/evt){
+		// summary:
+		// 		over-ridden by subclasses. Gets called directly after being
+		// 		created by the DragSource default action is to clone self as
+		// 		icon
+	},
+
+	onDragMove: function(/*dojo.dnd.DragEvent*/evt){
+		// summary: 
+		//		Implemented by subclasses. Should change the UI for the drag
+		//		icon i.e., "it moves itself"
+	},
+
+	onDragOver: function(/*dojo.dnd.DragEvent*/evt){
+		// summary:
+		//		stub handler that is called when the DragObject instance is
+		//		"over" a DropTarget.
+	},
+
+	onDragOut: function(/*dojo.dnd.DragEvent*/evt){
+		// summary:
+		//		stub handler that is called when the DragObject instance leaves
+		//		a DropTarget.
+	},
+
+	onDragEnd: function(/*dojo.dnd.DragEvent*/evt){
+		// summary:
+		//		stub handler that is called when dragging ends, either through
+		//		dropping or cancelation.
+	},
+
+	// normal aliases
+	onDragLeave: dojo.lang.forward("onDragOut"),
+	onDragEnter: dojo.lang.forward("onDragOver"),
+
+	// non-camel aliases
+	ondragout: dojo.lang.forward("onDragOut"),
+	ondragover: dojo.lang.forward("onDragOver")
+});
+
+dojo.declare("dojo.dnd.DropTarget", null, {
+
+	acceptsType: function(/*String*/type){
+		// summary: 
+		//		determines whether or not this DropTarget will accept the given
+		//		type. The default behavior is to consult this.acceptedTypes and
+		//		if "*" is a member, to always accept the type.
+		if(!dojo.lang.inArray(this.acceptedTypes, "*")){ // wildcard
+			if(!dojo.lang.inArray(this.acceptedTypes, type)) { return false; } // Boolean
+		}
+		return true; // Boolean
+	},
+
+	accepts: function(/*Array*/dragObjects){
+		// summary: 
+		//		determines if we'll accept all members of the passed array of
+		//		dojo.dnd.DragObject instances
+		if(!dojo.lang.inArray(this.acceptedTypes, "*")){ // wildcard
+			for (var i = 0; i < dragObjects.length; i++) {
+				if (!dojo.lang.inArray(this.acceptedTypes,
+					dragObjects[i].type)) { return false; } // Boolean
+			}
+		}
+		return true; // Boolean
+	},
+
+	unregister: function(){
+		// summary: remove from the drag manager
+		dojo.dnd.dragManager.unregisterDropTarget(this);
+	},
+
+	onDragOver: function(/*dojo.dnd.DragEvent*/evt){
+		// summary:
+		//		stub handler that is called when DragObject instances are
+		//		"over" this DropTarget.
+	},
+
+	onDragOut: function(/*dojo.dnd.DragEvent*/evt){
+		// summary:
+		//		stub handler that is called when DragObject instances are
+		//		"leave" this DropTarget.
+	},
+
+	onDragMove: function(/*dojo.dnd.DragEvent*/evt){
+		// summary:
+		//		stub handler that is called when DragObject instances are
+		//		moved across this DropTarget. May fire many times in the course
+		//		of the drag operation but will end after onDragOut
+	},
+
+	onDropStart: function(/*dojo.dnd.DragEvent*/evt){ // Boolean
+		// summary:
+		//		stub handler that is called when DragObject instances are
+		//		dropped on this target. If true is returned from onDropStart,
+		//		dropping proceeds, otherwise it's cancled.
+	},
+
+	onDrop: function(/*dojo.dnd.DragEvent*/evt){
+		// summary: we're getting dropped on!
+	},
+
+	onDropEnd: function(){
+		// summary: dropping is over
+	}
+}, function(){
+	this.acceptedTypes = [];
+});
+
+// NOTE: this interface is defined here for the convenience of the DragManager
+// implementor. It is expected that in most cases it will be satisfied by
+// extending a native event (DOM event in HTML and SVG).
+dojo.dnd.DragEvent = function(){
+	this.dragSource = null;
+	this.dragObject = null;
+	this.target = null;
+	this.eventStatus = "success";
+	//
+	// can be one of:
+	//	[	"dropSuccess", "dropFailure", "dragMove",
+	//		"dragStart", "dragEnter", "dragLeave"]
+	//
+}
+/*
+ *	The DragManager handles listening for low-level events and dispatching
+ *	them to higher-level primitives like drag sources and drop targets. In
+ *	order to do this, it must keep a list of the items.
+ */
+dojo.declare("dojo.dnd.DragManager", null, {
+	// Array: an array of currently selected DragSource objects
+	selectedSources: [],
+	// Array: all DragObjects we know about
+	dragObjects: [],
+	// Array: all DragSources we know about
+	dragSources: [],
+	registerDragSource: function(/*dojo.dnd.DragSource*/ source){
+		// summary: called by DragSource class constructor
+	},
+	// Array: all DropTargets we know about
+	dropTargets: [],
+	registerDropTarget: function(/*dojo.dnd.DropTarget*/ target){
+		// summary: called by DropTarget class constructor
+	},
+	// dojo.dnd.DropTarget:
+	//		what was the last DropTarget instance we left in the drag phase?
+	lastDragTarget: null,
+	// dojo.dnd.DropTarget:
+	//		the DropTarget the mouse is currently over
+	currentDragTarget: null,
+	onKeyDown: function(){
+		// summary: generic handler called by low-level events
+	},
+	onMouseOut: function(){
+		// summary: generic handler called by low-level events
+	},
+	onMouseMove: function(){
+		// summary: generic handler called by low-level events
+	},
+	onMouseUp: function(){
+		// summary: generic handler called by low-level events
+	}
+});
+
+// NOTE: despite the existance of the DragManager class, there will be a
+// singleton drag manager provided by the renderer-specific D&D support code.
+// It is therefore sane for us to assign instance variables to the DragManager
+// prototype
+
+// The renderer-specific file will define the following object:
+// dojo.dnd.dragManager = null;

Added: incubator/xap/trunk/codebase/src/dojo/src/dnd/HtmlDragAndDrop.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/dnd/HtmlDragAndDrop.js?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/dnd/HtmlDragAndDrop.js (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/dnd/HtmlDragAndDrop.js Wed Mar 14 13:36:44 2007
@@ -0,0 +1,519 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.dnd.HtmlDragAndDrop");
+
+dojo.require("dojo.dnd.HtmlDragManager");
+dojo.require("dojo.dnd.DragAndDrop");
+
+dojo.require("dojo.html.*");
+dojo.require("dojo.html.display");
+dojo.require("dojo.html.util");
+dojo.require("dojo.html.selection");
+dojo.require("dojo.html.iframe");
+dojo.require("dojo.lang.extras");
+dojo.require("dojo.lfx.*");
+dojo.require("dojo.event.*");
+
+dojo.declare("dojo.dnd.HtmlDragSource", dojo.dnd.DragSource, {
+		dragClass: "", // CSS classname(s) applied to node when it is being dragged
+
+		onDragStart: function(){
+			var dragObj = new dojo.dnd.HtmlDragObject(this.dragObject, this.type);
+			if(this.dragClass){
+				dragObj.dragClass = this.dragClass;
+			}
+
+			if(this.constrainToContainer){
+				dragObj.constrainTo(this.constrainingContainer || this.domNode.parentNode);
+			}
+
+			return dragObj;
+		},
+
+		setDragHandle: function(node){
+			node = dojo.byId(node);
+			dojo.dnd.dragManager.unregisterDragSource(this);
+			this.domNode = node;
+			dojo.dnd.dragManager.registerDragSource(this);
+		},
+
+		setDragTarget: function(node){
+			this.dragObject = node;
+		},
+
+		constrainTo: function(container){
+			this.constrainToContainer = true;
+			if(container){
+				this.constrainingContainer = container;
+			}
+		},
+		
+		/*
+		*
+		* see dojo.dnd.DragSource.onSelected
+		*/
+		onSelected: function(){
+			for(var i=0; i<this.dragObjects.length; i++){
+				dojo.dnd.dragManager.selectedSources.push(new dojo.dnd.HtmlDragSource(this.dragObjects[i]));
+			}
+		},
+
+		/**
+		* Register elements that should be dragged along with
+		* the actual DragSource.
+		*
+		* Example usage:
+		* 	var dragSource = new dojo.dnd.HtmlDragSource(...);
+		*	// add a single element
+		*	dragSource.addDragObjects(dojo.byId('id1'));
+		*	// add multiple elements to drag along
+		*	dragSource.addDragObjects('id2', dojo.byId('id3'));
+		*
+		* el A dom node to add to the drag list.
+		*/
+		addDragObjects: function(/*DOMNode*/ el){
+			for(var i=0; i<arguments.length; i++){
+				this.dragObjects.push(dojo.byId(arguments[i]));
+			}
+		}
+	}, 
+
+	function(node, type){
+		node = dojo.byId(node);
+		this.dragObjects = [];
+		this.constrainToContainer = false;
+		if(node){
+			this.domNode = node;
+			this.dragObject = node;
+			// set properties that might have been clobbered by the mixin
+			this.type = (type)||(this.domNode.nodeName.toLowerCase());
+			dojo.dnd.DragSource.prototype.reregister.call(this);
+		}
+	}
+);
+
+dojo.declare("dojo.dnd.HtmlDragObject", 
+	dojo.dnd.DragObject, 
+	{
+		dragClass: "",
+		opacity: 0.5,
+		createIframe: true,		// workaround IE6 bug
+
+		// if true, node will not move in X and/or Y direction
+		disableX: false,
+		disableY: false,
+
+		createDragNode: function() {
+			var node = this.domNode.cloneNode(true);
+			if(this.dragClass) { dojo.html.addClass(node, this.dragClass); }
+			if(this.opacity < 1) { dojo.html.setOpacity(node, this.opacity); }
+			var ltn = node.tagName.toLowerCase();
+			var isTr = (ltn == "tr");
+			if((isTr)||(ltn == "tbody")){
+				// dojo.debug("Dragging table row")
+				// Create a table for the cloned row
+				var doc = this.domNode.ownerDocument;
+				var table = doc.createElement("table");
+				if(isTr){
+					var tbody = doc.createElement("tbody");
+					table.appendChild(tbody);
+					tbody.appendChild(node);
+				}else{
+					table.appendChild(node);
+				}
+
+				// Set a fixed width to the cloned TDs
+				var tmpSrcTr = ((isTr) ? this.domNode : this.domNode.firstChild);
+				var tmpDstTr = ((isTr) ? node : node.firstChild);
+				var domTds = tdp.childNodes;
+				var cloneTds = tmpDstTr.childNodes;
+				for(var i = 0; i < domTds.length; i++){
+					if((cloneTds[i])&&(cloneTds[i].style)){
+						cloneTds[i].style.width = dojo.html.getContentBox(domTds[i]).width + "px";
+					}
+				}
+				node = table;
+			}
+
+			if((dojo.render.html.ie55||dojo.render.html.ie60) && this.createIframe){
+				with(node.style) {
+					top="0px";
+					left="0px";
+				}
+				var outer = document.createElement("div");
+				outer.appendChild(node);
+				this.bgIframe = new dojo.html.BackgroundIframe(outer);
+				outer.appendChild(this.bgIframe.iframe);
+				node = outer;
+			}
+			node.style.zIndex = 999;
+
+			return node;
+		},
+
+		onDragStart: function(e){
+			dojo.html.clearSelection();
+
+			this.scrollOffset = dojo.html.getScroll().offset;
+			this.dragStartPosition = dojo.html.getAbsolutePosition(this.domNode, true);
+
+			this.dragOffset = {y: this.dragStartPosition.y - e.pageY,
+				x: this.dragStartPosition.x - e.pageX};
+
+			this.dragClone = this.createDragNode();
+
+			this.containingBlockPosition = this.domNode.offsetParent ? 
+				dojo.html.getAbsolutePosition(this.domNode.offsetParent, true) : {x:0, y:0};
+
+			if(this.constrainToContainer){
+				this.constraints = this.getConstraints();
+			}
+
+			// set up for dragging
+			with(this.dragClone.style){
+				position = "absolute";
+				top = this.dragOffset.y + e.pageY + "px";
+				left = this.dragOffset.x + e.pageX + "px";
+			}
+
+			dojo.body().appendChild(this.dragClone);
+
+			dojo.event.topic.publish('dragStart', { source: this } );
+		},
+
+		/** Return min/max x/y (relative to document.body) for this object) **/
+		getConstraints: function(){
+			if(this.constrainingContainer.nodeName.toLowerCase() == 'body'){
+				var viewport = dojo.html.getViewport();
+				var width = viewport.width;
+				var height = viewport.height;
+				var scroll = dojo.html.getScroll().offset;
+				var x = scroll.x;
+				var y = scroll.y;
+			}else{
+				var content = dojo.html.getContentBox(this.constrainingContainer);
+				width = content.width;
+				height = content.height;
+				x =
+					this.containingBlockPosition.x +
+					dojo.html.getPixelValue(this.constrainingContainer, "padding-left", true) +
+					dojo.html.getBorderExtent(this.constrainingContainer, "left");
+				y =
+					this.containingBlockPosition.y +
+					dojo.html.getPixelValue(this.constrainingContainer, "padding-top", true) +
+					dojo.html.getBorderExtent(this.constrainingContainer, "top");
+			}
+
+			// TODO: should handle left/top/right/bottom margin separately; left/top should affect minX/minY
+			var mb = dojo.html.getMarginBox(this.domNode);
+			return {
+				minX: x,
+				minY: y,
+				maxX: x + width - mb.width,
+				maxY: y + height - mb.height
+			}
+		},
+
+		updateDragOffset: function(){
+			var scroll = dojo.html.getScroll().offset;
+			if(scroll.y != this.scrollOffset.y){
+				var diff = scroll.y - this.scrollOffset.y;
+				this.dragOffset.y += diff;
+				this.scrollOffset.y = scroll.y;
+			}
+			if(scroll.x != this.scrollOffset.x){
+				var diff = scroll.x - this.scrollOffset.x;
+				this.dragOffset.x += diff;
+				this.scrollOffset.x = scroll.x;
+			}
+		},
+
+		/** Moves the node to follow the mouse */
+		onDragMove: function(e){
+			this.updateDragOffset();
+			var x = this.dragOffset.x + e.pageX;
+			var y = this.dragOffset.y + e.pageY;
+
+			if (this.constrainToContainer) {
+				if (x < this.constraints.minX) { x = this.constraints.minX; }
+				if (y < this.constraints.minY) { y = this.constraints.minY; }
+				if (x > this.constraints.maxX) { x = this.constraints.maxX; }
+				if (y > this.constraints.maxY) { y = this.constraints.maxY; }
+			}
+
+			this.setAbsolutePosition(x, y);
+
+			dojo.event.topic.publish('dragMove', { source: this } );
+		},
+
+		/**
+		 * Set the position of the drag clone.  (x,y) is relative to <body>.
+		 */
+		setAbsolutePosition: function(x, y){
+			// The drag clone is attached to document.body so this is trivial
+			if(!this.disableY) { this.dragClone.style.top = y + "px"; }
+			if(!this.disableX) { this.dragClone.style.left = x + "px"; }
+		},
+
+
+		/**
+		 * If the drag operation returned a success we remove the clone of
+		 * ourself from the original position. If the drag operation returned
+		 * failure we slide back over to where we came from and end the operation
+		 * with a little grace.
+		 */
+		onDragEnd: function(e){
+			switch(e.dragStatus){
+
+				case "dropSuccess":
+					dojo.html.removeNode(this.dragClone);
+					this.dragClone = null;
+					break;
+
+				case "dropFailure": // slide back to the start
+					var startCoords = dojo.html.getAbsolutePosition(this.dragClone, true);
+					// offset the end so the effect can be seen
+					var endCoords = { left: this.dragStartPosition.x + 1,
+						top: this.dragStartPosition.y + 1};
+
+					// animate
+					var anim = dojo.lfx.slideTo(this.dragClone, endCoords, 300);
+					var dragObject = this;
+					dojo.event.connect(anim, "onEnd", function(e){
+						// pause for a second (not literally) and disappear
+						// dojo.lang.setTimeout(function() {
+								dojo.html.removeNode(dragObject.dragClone);
+								// Allow drag clone to be gc'ed
+								dragObject.dragClone = null;
+						// 	},
+						// 	50);
+					});
+					anim.play();
+					break;
+			}
+
+			dojo.event.topic.publish('dragEnd', { source: this } );
+		},
+
+		constrainTo: function(container){
+			this.constrainToContainer=true;
+			if(container){
+				this.constrainingContainer = container;
+			}else{
+				this.constrainingContainer = this.domNode.parentNode;
+			}
+		}
+	}, 
+	function(node, type){
+		this.domNode = dojo.byId(node);
+		this.type = type;
+		this.constrainToContainer = false;
+		this.dragSource = null;
+		// this.register();
+		dojo.dnd.DragObject.prototype.register.call(this);
+	}
+);
+
+dojo.declare("dojo.dnd.HtmlDropTarget", 
+	dojo.dnd.DropTarget, 
+	{
+		vertical: false,
+		onDragOver: function(e){
+			if(!this.accepts(e.dragObjects)){ return false; }
+
+			// cache the positions of the child nodes
+			this.childBoxes = [];
+			for(var i = 0, child; i < this.domNode.childNodes.length; i++){
+				child = this.domNode.childNodes[i];
+				if(child.nodeType != dojo.html.ELEMENT_NODE){ continue; }
+				var pos = dojo.html.getAbsolutePosition(child, true);
+				var inner = dojo.html.getBorderBox(child);
+				this.childBoxes.push({top: pos.y, bottom: pos.y+inner.height,
+					left: pos.x, right: pos.x+inner.width, height: inner.height, 
+					width: inner.width, node: child});
+			}
+
+			// TODO: use dummy node
+
+			return true;
+		},
+
+		_getNodeUnderMouse: function(e){
+			// find the child
+			for(var i = 0, child; i < this.childBoxes.length; i++){
+				with(this.childBoxes[i]){
+					if (e.pageX >= left && e.pageX <= right &&
+						e.pageY >= top && e.pageY <= bottom){ return i; }
+				}
+			}
+
+			return -1;
+		},
+
+		createDropIndicator: function(){
+			this.dropIndicator = document.createElement("div");
+			with(this.dropIndicator.style){
+				position = "absolute";
+				zIndex = 999;
+				if(this.vertical){
+					borderLeftWidth = "1px";
+					borderLeftColor = "black";
+					borderLeftStyle = "solid";
+					height = dojo.html.getBorderBox(this.domNode).height + "px";
+					top = dojo.html.getAbsolutePosition(this.domNode, true).y + "px";
+				}else{
+					borderTopWidth = "1px";
+					borderTopColor = "black";
+					borderTopStyle = "solid";
+					width = dojo.html.getBorderBox(this.domNode).width + "px";
+					left = dojo.html.getAbsolutePosition(this.domNode, true).x + "px";
+				}
+			}
+		},
+
+		onDragMove: function(e, dragObjects){
+			var i = this._getNodeUnderMouse(e);
+
+			if(!this.dropIndicator){
+				this.createDropIndicator();
+			}
+
+			var gravity = this.vertical ? dojo.html.gravity.WEST : dojo.html.gravity.NORTH;
+			var hide = false;
+			if(i < 0){
+				if(this.childBoxes.length){
+					var before = (dojo.html.gravity(this.childBoxes[0].node, e) & gravity);
+					if(before){ hide = true; }
+				}else{
+					var before = true;
+				}
+			}else{
+				var child = this.childBoxes[i];
+				var before = (dojo.html.gravity(child.node, e) & gravity);
+				if(child.node === dragObjects[0].dragSource.domNode){
+					hide = true;
+				}else{
+					var currentPosChild = before ? 
+							(i>0?this.childBoxes[i-1]:child) : 
+							(i<this.childBoxes.length-1?this.childBoxes[i+1]:child);
+					if(currentPosChild.node === dragObjects[0].dragSource.domNode){
+						hide = true;
+					}
+				}
+			}
+
+			if(hide){
+				this.dropIndicator.style.display="none";
+				return;
+			}else{
+				this.dropIndicator.style.display="";
+			}
+
+			this.placeIndicator(e, dragObjects, i, before);
+
+			if(!dojo.html.hasParent(this.dropIndicator)) {
+				dojo.body().appendChild(this.dropIndicator);
+			}
+		},
+
+		/**
+		 * Position the horizontal line that indicates "insert between these two items"
+		 */
+		placeIndicator: function(e, dragObjects, boxIndex, before) {
+			var targetProperty = this.vertical ? "left" : "top";
+			var child;
+			if(boxIndex < 0){
+				if(this.childBoxes.length){
+					child = before ? this.childBoxes[0]
+						: this.childBoxes[this.childBoxes.length - 1];
+				}else{
+					this.dropIndicator.style[targetProperty] = dojo.html.getAbsolutePosition(this.domNode, true)[this.vertical?"x":"y"] + "px";
+				}
+			}else{
+				child = this.childBoxes[boxIndex];
+			}
+			if(child){
+				this.dropIndicator.style[targetProperty] = (before ? child[targetProperty] : child[this.vertical?"right":"bottom"]) + "px";
+				if(this.vertical){
+					this.dropIndicator.style.height = child.height + "px";
+					this.dropIndicator.style.top = child.top + "px";
+				}else{
+					this.dropIndicator.style.width = child.width + "px";
+					this.dropIndicator.style.left = child.left + "px";
+				}
+			}
+		},
+
+		onDragOut: function(e) {
+			if(this.dropIndicator) {
+				dojo.html.removeNode(this.dropIndicator);
+				delete this.dropIndicator;
+			}
+		},
+
+		/**
+		 * Inserts the DragObject as a child of this node relative to the
+		 * position of the mouse.
+		 *
+		 * @return true if the DragObject was inserted, false otherwise
+		 */
+		onDrop: function(e){
+			this.onDragOut(e);
+
+			var i = this._getNodeUnderMouse(e);
+
+			var gravity = this.vertical ? dojo.html.gravity.WEST : dojo.html.gravity.NORTH;
+			if(i < 0){
+				if(this.childBoxes.length){
+					if(dojo.html.gravity(this.childBoxes[0].node, e) & gravity){
+						return this.insert(e, this.childBoxes[0].node, "before");
+					}else{
+						return this.insert(e, this.childBoxes[this.childBoxes.length-1].node, "after");
+					}
+				}
+				return this.insert(e, this.domNode, "append");
+			}
+
+			var child = this.childBoxes[i];
+			if(dojo.html.gravity(child.node, e) & gravity){
+				return this.insert(e, child.node, "before");
+			}else{
+				return this.insert(e, child.node, "after");
+			}
+		},
+
+		insert: function(e, refNode, position){
+			var node = e.dragObject.domNode;
+
+			if(position == "before"){
+				return dojo.html.insertBefore(node, refNode);
+			}else if(position == "after"){
+				return dojo.html.insertAfter(node, refNode);
+			}else if(position == "append"){
+				refNode.appendChild(node);
+				return true;
+			}
+
+			return false;
+		}
+	}, 
+
+	function(node, types){
+		if(arguments.length == 0){ return; }
+		this.domNode = dojo.byId(node);
+		dojo.dnd.DropTarget.call(this);
+		if(types && dojo.lang.isString(types)) {
+			types = [types];
+		}
+		this.acceptedTypes = types || [];
+		dojo.dnd.dragManager.registerDropTarget(this);
+	}
+);

Added: incubator/xap/trunk/codebase/src/dojo/src/dnd/HtmlDragCopy.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/dnd/HtmlDragCopy.js?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/dnd/HtmlDragCopy.js (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/dnd/HtmlDragCopy.js Wed Mar 14 13:36:44 2007
@@ -0,0 +1,85 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.dnd.HtmlDragCopy");
+dojo.require("dojo.dnd.*");
+
+dojo.declare("dojo.dnd.HtmlDragCopySource", dojo.dnd.HtmlDragSource,
+function(node, type, copyOnce){
+		this.copyOnce = copyOnce;
+		this.makeCopy = true;
+},
+{
+	onDragStart: function(){
+		var dragObj = new dojo.dnd.HtmlDragCopyObject(this.dragObject, this.type, this);
+		if(this.dragClass) { dragObj.dragClass = this.dragClass; }
+
+		if (this.constrainToContainer) {
+			dragObj.constrainTo(this.constrainingContainer || this.domNode.parentNode);
+		}
+
+		return dragObj;
+	},
+	onSelected: function() {
+		for (var i=0; i<this.dragObjects.length; i++) {
+			dojo.dnd.dragManager.selectedSources.push(new dojo.dnd.HtmlDragCopySource(this.dragObjects[i]));
+		}
+	}
+});
+
+dojo.declare("dojo.dnd.HtmlDragCopyObject", dojo.dnd.HtmlDragObject,
+function(dragObject, type, source){
+		this.copySource = source;
+},
+{
+	onDragStart: function(e) {
+		dojo.dnd.HtmlDragCopyObject.superclass.onDragStart.apply(this, arguments);
+		if(this.copySource.makeCopy) {
+			this.sourceNode = this.domNode;
+			this.domNode    = this.domNode.cloneNode(true);
+		}
+	},
+	onDragEnd: function(e){
+		switch(e.dragStatus){
+			case "dropFailure": // slide back to the start
+				var startCoords = dojo.html.getAbsolutePosition(this.dragClone, true);
+				// offset the end so the effect can be seen
+				var endCoords = { left: this.dragStartPosition.x + 1,
+					top: this.dragStartPosition.y + 1};
+
+				// animate
+				var anim = dojo.lfx.slideTo(this.dragClone, endCoords, 500, dojo.lfx.easeOut);
+				var dragObject = this;
+				dojo.event.connect(anim, "onEnd", function (e) {
+					// pause for a second (not literally) and disappear
+					dojo.lang.setTimeout(function() {
+							dojo.html.removeNode(dragObject.dragClone);
+							dragObject.dragClone = null;
+							if(dragObject.copySource.makeCopy) {
+								dojo.html.removeNode(dragObject.domNode);
+								dragObject.domNode = dragObject.sourceNode;
+								dragObject.sourceNode = null;
+							}
+						},
+						200);
+				});
+				anim.play();
+				dojo.event.topic.publish('dragEnd', { source: this } );
+				return;
+		}
+		dojo.dnd.HtmlDragCopyObject.superclass.onDragEnd.apply(this, arguments);
+		this.copySource.dragObject = this.domNode;
+		if(this.copySource.copyOnce){
+			this.copySource.makeCopy = false;
+		}
+		new dojo.dnd.HtmlDragCopySource(this.sourceNode, this.type, this.copySource.copyOnce);
+		this.sourceNode = null;
+	}
+});

Added: incubator/xap/trunk/codebase/src/dojo/src/dnd/HtmlDragManager.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/dnd/HtmlDragManager.js?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/dnd/HtmlDragManager.js (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/dnd/HtmlDragManager.js Wed Mar 14 13:36:44 2007
@@ -0,0 +1,506 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.dnd.HtmlDragManager");
+dojo.require("dojo.dnd.DragAndDrop");
+dojo.require("dojo.event.*");
+dojo.require("dojo.lang.array");
+dojo.require("dojo.html.common");
+dojo.require("dojo.html.layout");
+
+// NOTE: there will only ever be a single instance of HTMLDragManager, so it's
+// safe to use prototype properties for book-keeping.
+dojo.declare("dojo.dnd.HtmlDragManager", dojo.dnd.DragManager, {
+	/**
+	 * There are several sets of actions that the DnD code cares about in the
+	 * HTML context:
+	 *	1.) mouse-down ->
+	 *			(draggable selection)
+	 *			(dragObject generation)
+	 *		mouse-move ->
+	 *			(draggable movement)
+	 *			(droppable detection)
+	 *			(inform droppable)
+	 *			(inform dragObject)
+	 *		mouse-up
+	 *			(inform/destroy dragObject)
+	 *			(inform draggable)
+	 *			(inform droppable)
+	 *	2.) mouse-down -> mouse-down
+	 *			(click-hold context menu)
+	 *	3.) mouse-click ->
+	 *			(draggable selection)
+	 *		shift-mouse-click ->
+	 *			(augment draggable selection)
+	 *		mouse-down ->
+	 *			(dragObject generation)
+	 *		mouse-move ->
+	 *			(draggable movement)
+	 *			(droppable detection)
+	 *			(inform droppable)
+	 *			(inform dragObject)
+	 *		mouse-up
+	 *			(inform draggable)
+	 *			(inform droppable)
+	 *	4.) mouse-up
+	 *			(clobber draggable selection)
+	 */
+	disabled: false, // to kill all dragging!
+	nestedTargets: false,
+	mouseDownTimer: null, // used for click-hold operations
+	dsCounter: 0,
+	dsPrefix: "dojoDragSource",
+
+	// dimension calculation cache for use durring drag
+	dropTargetDimensions: [],
+
+	currentDropTarget: null,
+	// currentDropTargetPoints: null,
+	previousDropTarget: null,
+	_dragTriggered: false,
+
+	selectedSources: [],
+	dragObjects: [],
+	dragSources: [],
+
+	// mouse position properties
+	currentX: null,
+	currentY: null,
+	lastX: null,
+	lastY: null,
+	mouseDownX: null,
+	mouseDownY: null,
+	threshold: 7,
+
+	dropAcceptable: false,
+
+	cancelEvent: function(e){ e.stopPropagation(); e.preventDefault();},
+
+	// method over-rides
+	registerDragSource: function(ds){
+		//dojo.profile.start("register DragSource");
+
+		if(ds["domNode"]){
+			// FIXME: dragSource objects SHOULD have some sort of property that
+			// references their DOM node, we shouldn't just be passing nodes and
+			// expecting it to work.
+			//dojo.profile.start("register DragSource 1");
+			var dp = this.dsPrefix;
+			var dpIdx = dp+"Idx_"+(this.dsCounter++);
+			ds.dragSourceId = dpIdx;
+			this.dragSources[dpIdx] = ds;
+			ds.domNode.setAttribute(dp, dpIdx);
+			//dojo.profile.end("register DragSource 1");
+
+			//dojo.profile.start("register DragSource 2");
+
+			// so we can drag links
+			if(dojo.render.html.ie){
+				//dojo.profile.start("register DragSource IE");
+				
+				dojo.event.browser.addListener(ds.domNode, "ondragstart", this.cancelEvent);
+				// terribly slow
+				//dojo.event.connect(ds.domNode, "ondragstart", this.cancelEvent);
+				//dojo.profile.end("register DragSource IE");
+
+			}
+			//dojo.profile.end("register DragSource 2");
+
+		}
+		//dojo.profile.end("register DragSource");
+	},
+
+	unregisterDragSource: function(ds){
+		if (ds["domNode"]){
+			var dp = this.dsPrefix;
+			var dpIdx = ds.dragSourceId;
+			delete ds.dragSourceId;
+			delete this.dragSources[dpIdx];
+			ds.domNode.setAttribute(dp, null);
+			if(dojo.render.html.ie){
+				dojo.event.browser.removeListener(ds.domNode, "ondragstart", this.cancelEvent);			
+			}
+		}
+	},
+
+	registerDropTarget: function(dt){
+		this.dropTargets.push(dt);
+	},
+
+	unregisterDropTarget: function(dt){
+		var index = dojo.lang.find(this.dropTargets, dt, true);
+		if (index>=0) {
+			this.dropTargets.splice(index, 1);
+		}
+	},
+
+	/**
+	* Get the DOM element that is meant to drag.
+	* Loop through the parent nodes of the event target until
+	* the element is found that was created as a DragSource and 
+	* return it.
+	*
+	* @param event object The event for which to get the drag source.
+	*/
+	getDragSource: function(e){
+		var tn = e.target;
+		if(tn === dojo.body()){ return; }
+		var ta = dojo.html.getAttribute(tn, this.dsPrefix);
+		while((!ta)&&(tn)){
+			tn = tn.parentNode;
+			if((!tn)||(tn === dojo.body())){ return; }
+			ta = dojo.html.getAttribute(tn, this.dsPrefix);
+		}
+		return this.dragSources[ta];
+	},
+
+	onKeyDown: function(e){
+	},
+
+	onMouseDown: function(e){
+		if(this.disabled) { return; }
+
+		// only begin on left click
+		if(dojo.render.html.ie) {
+			if(e.button != 1) { return; }
+		} else if(e.which != 1) {
+			return;
+		}
+
+		var target = e.target.nodeType == dojo.html.TEXT_NODE ?
+			e.target.parentNode : e.target;
+
+		// do not start drag involvement if the user is interacting with
+		// a form element.
+		if(dojo.html.isTag(target, "button", "textarea", "input", "select", "option")) {
+			return;
+		}
+
+		// find a selection object, if one is a parent of the source node
+		var ds = this.getDragSource(e);
+		
+		// this line is important.  if we aren't selecting anything then
+		// we need to return now, so preventDefault() isn't called, and thus
+		// the event is propogated to other handling code
+		if(!ds){ return; }
+
+		if(!dojo.lang.inArray(this.selectedSources, ds)){
+			this.selectedSources.push(ds);
+			ds.onSelected();
+		}
+
+ 		this.mouseDownX = e.pageX;
+ 		this.mouseDownY = e.pageY;
+
+		// Must stop the mouse down from being propogated, or otherwise can't
+		// drag links in firefox.
+		// WARNING: preventing the default action on all mousedown events
+		// prevents user interaction with the contents.
+		e.preventDefault();
+
+		dojo.event.connect(document, "onmousemove", this, "onMouseMove");
+	},
+
+	onMouseUp: function(e, cancel){
+		// if we aren't dragging then ignore the mouse-up
+		// (in particular, don't call preventDefault(), because other
+		// code may need to process this event)
+		if(this.selectedSources.length==0){
+			return;
+		}
+
+		this.mouseDownX = null;
+		this.mouseDownY = null;
+		this._dragTriggered = false;
+ 		// e.preventDefault();
+		e.dragSource = this.dragSource;
+		// let ctrl be used for multiselect or another action
+		// if I use same key to trigger treeV3 node selection and here,
+		// I have bugs with drag'n'drop. why ?? no idea..
+		if((!e.shiftKey)&&(!e.ctrlKey)){ 
+		//if(!e.shiftKey){
+			if(this.currentDropTarget) {
+				this.currentDropTarget.onDropStart();
+			}
+			dojo.lang.forEach(this.dragObjects, function(tempDragObj){
+				var ret = null;
+				if(!tempDragObj){ return; }
+				if(this.currentDropTarget) {
+					e.dragObject = tempDragObj;
+
+					// NOTE: we can't get anything but the current drop target
+					// here since the drag shadow blocks mouse-over events.
+					// This is probelematic for dropping "in" something
+					var ce = this.currentDropTarget.domNode.childNodes;
+					if(ce.length > 0){
+						e.dropTarget = ce[0];
+						while(e.dropTarget == tempDragObj.domNode){
+							e.dropTarget = e.dropTarget.nextSibling;
+						}
+					}else{
+						e.dropTarget = this.currentDropTarget.domNode;
+					}
+					if(this.dropAcceptable){
+						ret = this.currentDropTarget.onDrop(e);
+					}else{
+						 this.currentDropTarget.onDragOut(e);
+					}
+				}
+
+				e.dragStatus = this.dropAcceptable && ret ? "dropSuccess" : "dropFailure";
+				// decouple the calls for onDragEnd, so they don't block the execution here
+				// ie. if the onDragEnd would call an alert, the execution here is blocked until the
+				// user has confirmed the alert box and then the rest of the dnd code is executed
+				// while the mouse doesnt "hold" the dragged object anymore ... and so on
+				dojo.lang.delayThese([
+					function() {
+						// in FF1.5 this throws an exception, see 
+						// http://dojotoolkit.org/pipermail/dojo-interest/2006-April/006751.html
+						try{
+							tempDragObj.dragSource.onDragEnd(e)
+						} catch(err) {
+							// since the problem seems passing e, we just copy all 
+							// properties and try the copy ...
+							var ecopy = {};
+							for (var i in e) {
+								if (i=="type") { // the type property contains the exception, no idea why...
+									ecopy.type = "mouseup";
+									continue;
+								}
+								ecopy[i] = e[i];
+							}
+							tempDragObj.dragSource.onDragEnd(ecopy);
+						}
+					}
+					, function() {tempDragObj.onDragEnd(e)}]);
+			}, this);
+
+			this.selectedSources = [];
+			this.dragObjects = [];
+			this.dragSource = null;
+			if(this.currentDropTarget) {
+				this.currentDropTarget.onDropEnd();
+			}
+		} else {
+			//dojo.debug("special click");
+		}
+
+		dojo.event.disconnect(document, "onmousemove", this, "onMouseMove");
+		this.currentDropTarget = null;
+	},
+
+	onScroll: function(){
+		//dojo.profile.start("DNDManager updateoffset");
+		for(var i = 0; i < this.dragObjects.length; i++) {
+			if(this.dragObjects[i].updateDragOffset) {
+				this.dragObjects[i].updateDragOffset();
+			}
+		}
+		//dojo.profile.end("DNDManager updateoffset");
+
+		// TODO: do not recalculate, only adjust coordinates
+		if (this.dragObjects.length) {
+			this.cacheTargetLocations();
+		}
+	},
+
+	_dragStartDistance: function(x, y){
+		if((!this.mouseDownX)||(!this.mouseDownX)){
+			return;
+		}
+		var dx = Math.abs(x-this.mouseDownX);
+		var dx2 = dx*dx;
+		var dy = Math.abs(y-this.mouseDownY);
+		var dy2 = dy*dy;
+		return parseInt(Math.sqrt(dx2+dy2), 10);
+	},
+
+	cacheTargetLocations: function(){
+		dojo.profile.start("cacheTargetLocations");
+
+		this.dropTargetDimensions = [];
+		dojo.lang.forEach(this.dropTargets, function(tempTarget){
+			var tn = tempTarget.domNode;
+			//only cache dropTarget which can accept current dragSource
+			if(!tn || !tempTarget.accepts([this.dragSource])){ return; }
+			var abs = dojo.html.getAbsolutePosition(tn, true);
+			var bb = dojo.html.getBorderBox(tn);
+			this.dropTargetDimensions.push([
+				[abs.x, abs.y],	// upper-left
+				// lower-right
+				[ abs.x+bb.width, abs.y+bb.height ],
+				tempTarget
+			]);
+			//dojo.debug("Cached for "+tempTarget)
+		}, this);
+
+		dojo.profile.end("cacheTargetLocations");
+
+		//dojo.debug("Cache locations")
+	},
+
+	onMouseMove: function(e){
+		if((dojo.render.html.ie)&&(e.button != 1)){
+			// Oooops - mouse up occurred - e.g. when mouse was not over the
+			// window. I don't think we can detect this for FF - but at least
+			// we can be nice in IE.
+			this.currentDropTarget = null;
+			this.onMouseUp(e, true);
+			return;
+		}
+
+		// if we've got some sources, but no drag objects, we need to send
+		// onDragStart to all the right parties and get things lined up for
+		// drop target detection
+
+		if(	(this.selectedSources.length)&&
+			(!this.dragObjects.length) ){
+			var dx;
+			var dy;
+			if(!this._dragTriggered){
+				this._dragTriggered = (this._dragStartDistance(e.pageX, e.pageY) > this.threshold);
+				if(!this._dragTriggered){ return; }
+				dx = e.pageX - this.mouseDownX;
+				dy = e.pageY - this.mouseDownY;
+			}
+
+			// the first element is always our dragSource, if there are multiple
+			// selectedSources (elements that move along) then the first one is the master
+			// and for it the events will be fired etc.
+			this.dragSource = this.selectedSources[0];
+			
+			dojo.lang.forEach(this.selectedSources, function(tempSource){
+				if(!tempSource){ return; }
+				var tdo = tempSource.onDragStart(e);
+				if(tdo){
+					tdo.onDragStart(e);
+
+					// "bump" the drag object to account for the drag threshold
+					tdo.dragOffset.y += dy;
+					tdo.dragOffset.x += dx;
+					tdo.dragSource = tempSource;
+
+					this.dragObjects.push(tdo);
+				}
+			}, this);
+
+			/* clean previous drop target in dragStart */
+			this.previousDropTarget = null;
+
+			this.cacheTargetLocations();
+		}
+
+		// FIXME: we need to add dragSources and dragObjects to e
+		dojo.lang.forEach(this.dragObjects, function(dragObj){
+			if(dragObj){ dragObj.onDragMove(e); }
+		});
+
+		// if we have a current drop target, check to see if we're outside of
+		// it. If so, do all the actions that need doing.
+		if(this.currentDropTarget){
+			//dojo.debug(dojo.html.hasParent(this.currentDropTarget.domNode))
+			var c = dojo.html.toCoordinateObject(this.currentDropTarget.domNode, true);
+			//		var dtp = this.currentDropTargetPoints;
+			var dtp = [
+				[c.x,c.y], [c.x+c.width, c.y+c.height]
+			];
+		}
+
+		if((!this.nestedTargets)&&(dtp)&&(this.isInsideBox(e, dtp))){
+			if(this.dropAcceptable){
+				this.currentDropTarget.onDragMove(e, this.dragObjects);
+			}
+		}else{
+			// FIXME: need to fix the event object!
+			// see if we can find a better drop target
+			var bestBox = this.findBestTarget(e);
+
+			if(bestBox.target === null){
+				if(this.currentDropTarget){
+					this.currentDropTarget.onDragOut(e);
+					this.previousDropTarget = this.currentDropTarget;
+					this.currentDropTarget = null;
+					// this.currentDropTargetPoints = null;
+				}
+				this.dropAcceptable = false;
+				return;
+			}
+
+			if(this.currentDropTarget !== bestBox.target){
+				if(this.currentDropTarget){
+					this.previousDropTarget = this.currentDropTarget;
+					this.currentDropTarget.onDragOut(e);
+				}
+				this.currentDropTarget = bestBox.target;
+				// this.currentDropTargetPoints = bestBox.points;
+				e.dragObjects = this.dragObjects;
+				this.dropAcceptable = this.currentDropTarget.onDragOver(e);
+
+			}else{
+				if(this.dropAcceptable){
+					this.currentDropTarget.onDragMove(e, this.dragObjects);
+				}
+			}
+		}
+	},
+
+	findBestTarget: function(e) {
+		var _this = this;
+		var bestBox = new Object();
+		bestBox.target = null;
+		bestBox.points = null;
+		dojo.lang.every(this.dropTargetDimensions, function(tmpDA) {
+			if(!_this.isInsideBox(e, tmpDA)){
+				return true;
+			}
+
+			bestBox.target = tmpDA[2];
+			bestBox.points = tmpDA;
+			// continue iterating only if _this.nestedTargets == true
+			return Boolean(_this.nestedTargets);
+		});
+
+		return bestBox;
+	},
+
+	isInsideBox: function(e, coords){
+		if(	(e.pageX > coords[0][0])&&
+			(e.pageX < coords[1][0])&&
+			(e.pageY > coords[0][1])&&
+			(e.pageY < coords[1][1]) ){
+			return true;
+		}
+		return false;
+	},
+
+	onMouseOver: function(e){
+	},
+
+	onMouseOut: function(e){
+	}
+});
+
+dojo.dnd.dragManager = new dojo.dnd.HtmlDragManager();
+
+// global namespace protection closure
+(function(){
+	var d = document;
+	var dm = dojo.dnd.dragManager;
+	//TODO: when focus manager is ready, dragManager should be rewritten to use it
+	// set up event handlers on the document (or no?)
+	dojo.event.connect(d, "onkeydown", dm, "onKeyDown");
+	dojo.event.connect(d, "onmouseover", dm, "onMouseOver");
+	dojo.event.connect(d, "onmouseout", dm, "onMouseOut");
+	dojo.event.connect(d, "onmousedown", dm, "onMouseDown");
+	dojo.event.connect(d, "onmouseup", dm, "onMouseUp");
+	// TODO: process scrolling of elements, not only window (focus manager would 
+	// probably come to rescue here as well)
+	dojo.event.connect(window, "onscroll", dm, "onScroll");
+})();

Added: incubator/xap/trunk/codebase/src/dojo/src/dnd/HtmlDragMove.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/dnd/HtmlDragMove.js?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/dnd/HtmlDragMove.js (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/dnd/HtmlDragMove.js Wed Mar 14 13:36:44 2007
@@ -0,0 +1,89 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.dnd.HtmlDragMove");
+dojo.require("dojo.dnd.*");
+
+dojo.declare("dojo.dnd.HtmlDragMoveSource", dojo.dnd.HtmlDragSource, {
+	onDragStart: function(){
+		var dragObj =  new dojo.dnd.HtmlDragMoveObject(this.dragObject, this.type);
+		if (this.constrainToContainer) {
+			dragObj.constrainTo(this.constrainingContainer);
+		}
+		return dragObj;
+	},
+	/*
+	 * see dojo.dnd.HtmlDragSource.onSelected
+	 */
+	onSelected: function() {
+		for (var i=0; i<this.dragObjects.length; i++) {
+			dojo.dnd.dragManager.selectedSources.push(new dojo.dnd.HtmlDragMoveSource(this.dragObjects[i]));
+		}
+	}
+});
+
+dojo.declare("dojo.dnd.HtmlDragMoveObject", dojo.dnd.HtmlDragObject, {
+	onDragStart: function(e){
+		dojo.html.clearSelection();
+
+		this.dragClone = this.domNode;
+
+		// Record drag start position, where "position" is simply the top/left style values for
+		// the node (the meaning of top/left is dependent on whether node is position:absolute or
+		// position:relative, and also on the container).
+		// Not sure if we should support moving nodes that aren't position:absolute,
+		// but supporting it for now
+		if(dojo.html.getComputedStyle(this.domNode, 'position') != 'absolute'){
+			this.domNode.style.position = "relative";
+		}
+		var left = parseInt(dojo.html.getComputedStyle(this.domNode, 'left'));
+		var top = parseInt(dojo.html.getComputedStyle(this.domNode, 'top'));
+		this.dragStartPosition = {
+			x: isNaN(left) ? 0 : left,
+			y: isNaN(top) ? 0 : top
+		};
+
+		this.scrollOffset = dojo.html.getScroll().offset;
+
+		// used to convert mouse position into top/left value for node
+		this.dragOffset = {y: this.dragStartPosition.y - e.pageY,
+			x: this.dragStartPosition.x - e.pageX};
+
+		// since the DragObject's position is relative to the containing block, for our purposes
+		// the containing block's position is just (0,0)
+		this.containingBlockPosition = {x:0, y:0};
+
+		if (this.constrainToContainer) {
+			this.constraints = this.getConstraints();
+		}
+
+		// shortly the browser will fire an onClick() event,
+		// but since this was really a drag, just squelch it
+		dojo.event.connect(this.domNode, "onclick", this, "_squelchOnClick");
+	},
+
+	onDragEnd: function(e){
+	},
+
+	setAbsolutePosition: function(x, y){
+		// summary: Set the top & left style attributes of the drag node (TODO: function is poorly named)
+		if(!this.disableY) { this.domNode.style.top = y + "px"; }
+		if(!this.disableX) { this.domNode.style.left = x + "px"; }
+	},
+
+	_squelchOnClick: function(e){
+		// summary
+		//	this function is called to squelch this onClick() event because
+		//	it's the result of a drag (ie, it's not a real click)
+
+		dojo.event.browser.stopEvent(e);
+		dojo.event.disconnect(this.domNode, "onclick", this, "_squelchOnClick");
+	}
+});

Added: incubator/xap/trunk/codebase/src/dojo/src/dnd/Sortable.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/dojo/src/dnd/Sortable.js?view=auto&rev=518313
==============================================================================
--- incubator/xap/trunk/codebase/src/dojo/src/dnd/Sortable.js (added)
+++ incubator/xap/trunk/codebase/src/dojo/src/dnd/Sortable.js Wed Mar 14 13:36:44 2007
@@ -0,0 +1,28 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.dnd.Sortable");
+dojo.require("dojo.dnd.*");
+
+dojo.dnd.Sortable = function () {}
+
+dojo.lang.extend(dojo.dnd.Sortable, {
+
+	ondragstart: function (e) {
+		var dragObject = e.target;
+		while (dragObject.parentNode && dragObject.parentNode != this) {
+			dragObject = dragObject.parentNode;
+		}
+		// TODO: should apply HtmlDropTarget interface to self
+		// TODO: should apply HtmlDragObject interface?
+		return dragObject;
+	}
+
+});



Mime
View raw message