You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xap-commits@incubator.apache.org by jm...@apache.org on 2006/06/27 22:35:13 UTC

svn commit: r417609 [1/2] - in /incubator/xap/trunk/src/dojo/src: debug/ dnd/ event/ flash/ flash/flash6/ flash/flash8/ fx/ graphics/ graphics/color/

Author: jmargaris
Date: Tue Jun 27 15:35:12 2006
New Revision: 417609

URL: http://svn.apache.org/viewvc?rev=417609&view=rev
Log:
dojo 0.3

Added:
    incubator/xap/trunk/src/dojo/src/debug/
    incubator/xap/trunk/src/dojo/src/debug/Firebug.js   (with props)
    incubator/xap/trunk/src/dojo/src/debug/arrow_hide.gif   (with props)
    incubator/xap/trunk/src/dojo/src/debug/arrow_show.gif   (with props)
    incubator/xap/trunk/src/dojo/src/debug/deep.html   (with props)
    incubator/xap/trunk/src/dojo/src/debug/spacer.gif   (with props)
    incubator/xap/trunk/src/dojo/src/dnd/
    incubator/xap/trunk/src/dojo/src/dnd/DragAndDrop.js   (with props)
    incubator/xap/trunk/src/dojo/src/dnd/HtmlDragAndDrop.js   (with props)
    incubator/xap/trunk/src/dojo/src/dnd/HtmlDragManager.js   (with props)
    incubator/xap/trunk/src/dojo/src/dnd/HtmlDragMove.js   (with props)
    incubator/xap/trunk/src/dojo/src/dnd/Sortable.js   (with props)
    incubator/xap/trunk/src/dojo/src/dnd/TreeDragAndDrop.js   (with props)
    incubator/xap/trunk/src/dojo/src/dnd/__package__.js   (with props)
    incubator/xap/trunk/src/dojo/src/event/
    incubator/xap/trunk/src/dojo/src/event/__package__.js   (with props)
    incubator/xap/trunk/src/dojo/src/event/browser.js   (with props)
    incubator/xap/trunk/src/dojo/src/event/topic.js   (with props)
    incubator/xap/trunk/src/dojo/src/flash/
    incubator/xap/trunk/src/dojo/src/flash/flash6/
    incubator/xap/trunk/src/dojo/src/flash/flash6/DojoExternalInterface.as
    incubator/xap/trunk/src/dojo/src/flash/flash6/flash6_gateway.fla   (with props)
    incubator/xap/trunk/src/dojo/src/flash/flash8/
    incubator/xap/trunk/src/dojo/src/flash/flash8/DojoExternalInterface.as
    incubator/xap/trunk/src/dojo/src/flash/flash8/ExpressInstall.as
    incubator/xap/trunk/src/dojo/src/fx/
    incubator/xap/trunk/src/dojo/src/fx/__package__.js   (with props)
    incubator/xap/trunk/src/dojo/src/fx/html.js   (with props)
    incubator/xap/trunk/src/dojo/src/fx/svg.js   (with props)
    incubator/xap/trunk/src/dojo/src/graphics/
    incubator/xap/trunk/src/dojo/src/graphics/Colorspace.js   (with props)
    incubator/xap/trunk/src/dojo/src/graphics/__package__.js   (with props)
    incubator/xap/trunk/src/dojo/src/graphics/color/
    incubator/xap/trunk/src/dojo/src/graphics/color.js   (with props)
    incubator/xap/trunk/src/dojo/src/graphics/color/hsl.js   (with props)
    incubator/xap/trunk/src/dojo/src/graphics/color/hsv.js   (with props)

Added: incubator/xap/trunk/src/dojo/src/debug/Firebug.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/dojo/src/debug/Firebug.js?rev=417609&view=auto
==============================================================================
--- incubator/xap/trunk/src/dojo/src/debug/Firebug.js (added)
+++ incubator/xap/trunk/src/dojo/src/debug/Firebug.js Tue Jun 27 15:35:12 2006
@@ -0,0 +1,24 @@
+/*
+	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.debug.firebug = function(){}
+dojo.debug.firebug.printfire = function () {
+	printfire=function(){}
+	printfire.args = arguments;
+	var ev = document.createEvent("Events");
+	ev.initEvent("printfire", false, true);
+	dispatchEvent(ev);
+}
+
+if (dojo.render.html.moz) {
+	dojo.hostenv.println=dojo.debug.firebug.printfire;
+}

Propchange: incubator/xap/trunk/src/dojo/src/debug/Firebug.js
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

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

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

Added: incubator/xap/trunk/src/dojo/src/debug/deep.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/dojo/src/debug/deep.html?rev=417609&view=auto
==============================================================================
--- incubator/xap/trunk/src/dojo/src/debug/deep.html (added)
+++ incubator/xap/trunk/src/dojo/src/debug/deep.html Tue Jun 27 15:35:12 2006
@@ -0,0 +1,359 @@
+<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');
+	buildTable('root', frame, window.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

Propchange: incubator/xap/trunk/src/dojo/src/debug/deep.html
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

Added: incubator/xap/trunk/src/dojo/src/dnd/DragAndDrop.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/dojo/src/dnd/DragAndDrop.js?rev=417609&view=auto
==============================================================================
--- incubator/xap/trunk/src/dojo/src/dnd/DragAndDrop.js (added)
+++ incubator/xap/trunk/src/dojo/src/dnd/DragAndDrop.js Tue Jun 27 15:35:12 2006
@@ -0,0 +1,168 @@
+/*
+	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");
+dojo.provide("dojo.dnd.DragSource");
+dojo.provide("dojo.dnd.DropTarget");
+dojo.provide("dojo.dnd.DragObject");
+dojo.provide("dojo.dnd.DragAndDrop");
+
+dojo.dnd.DragSource = function(){
+	var dm = dojo.dnd.dragManager;
+	if(dm["registerDragSource"]){ // side-effect prevention
+		dm.registerDragSource(this);
+	}
+}
+
+dojo.lang.extend(dojo.dnd.DragSource, {
+	type: "",
+
+	onDragEnd: function(){
+	},
+
+	onDragStart: function(){
+	},
+
+	unregister: function(){
+		dojo.dnd.dragManager.unregisterDragSource(this);
+	},
+
+	reregister: function(){
+		dojo.dnd.dragManager.registerDragSource(this);
+	}
+});
+
+dojo.dnd.DragObject = function(){
+	var dm = dojo.dnd.dragManager;
+	if(dm["registerDragObject"]){ // side-effect prevention
+		dm.registerDragObject(this);
+	}
+}
+
+dojo.lang.extend(dojo.dnd.DragObject, {
+	type: "",
+
+	onDragStart: function(){
+		// gets called directly after being created by the DragSource
+		// default action is to clone self as icon
+	},
+
+	onDragMove: function(){
+		// this changes the UI for the drag icon
+		//	"it moves itself"
+	},
+
+	onDragOver: function(){
+	},
+
+	onDragOut: function(){
+	},
+
+	onDragEnd: function(){
+	},
+
+	// normal aliases
+	onDragLeave: this.onDragOut,
+	onDragEnter: this.onDragOver,
+
+	// non-camel aliases
+	ondragout: this.onDragOut,
+	ondragover: this.onDragOver
+});
+
+dojo.dnd.DropTarget = function(){
+	if (this.constructor == dojo.dnd.DropTarget) { return; } // need to be subclassed
+	this.acceptedTypes = [];
+	dojo.dnd.dragManager.registerDropTarget(this);
+}
+
+dojo.lang.extend(dojo.dnd.DropTarget, {
+
+	acceptsType: function(type){
+		if(!dojo.lang.inArray(this.acceptedTypes, "*")){ // wildcard
+			if(!dojo.lang.inArray(this.acceptedTypes, type)) { return false; }
+		}
+		return true;
+	},
+
+	accepts: function(dragObjects){
+		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; }
+			}
+		}
+		return true;
+	},
+
+	onDragOver: function(){
+	},
+
+	onDragOut: function(){
+	},
+
+	onDragMove: function(){
+	},
+
+	onDropStart: function(){
+	},
+
+	onDrop: function(){
+	},
+
+	onDropEnd: function(){
+	}
+});
+
+// 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"]
+	//
+}
+
+dojo.dnd.DragManager = function(){
+	/*
+	 *	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.lang.extend(dojo.dnd.DragManager, {
+	selectedSources: [],
+	dragObjects: [],
+	dragSources: [],
+	registerDragSource: function(){},
+	dropTargets: [],
+	registerDropTarget: function(){},
+	lastDragTarget: null,
+	currentDragTarget: null,
+	onKeyDown: function(){},
+	onMouseOut: function(){},
+	onMouseMove: function(){},
+	onMouseUp: function(){}
+});
+
+// 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;

Propchange: incubator/xap/trunk/src/dojo/src/dnd/DragAndDrop.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/xap/trunk/src/dojo/src/dnd/HtmlDragAndDrop.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/dojo/src/dnd/HtmlDragAndDrop.js?rev=417609&view=auto
==============================================================================
--- incubator/xap/trunk/src/dojo/src/dnd/HtmlDragAndDrop.js (added)
+++ incubator/xap/trunk/src/dojo/src/dnd/HtmlDragAndDrop.js Tue Jun 27 15:35:12 2006
@@ -0,0 +1,409 @@
+/*
+	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.provide("dojo.dnd.HtmlDragSource");
+dojo.provide("dojo.dnd.HtmlDropTarget");
+dojo.provide("dojo.dnd.HtmlDragObject");
+
+dojo.require("dojo.dnd.HtmlDragManager");
+dojo.require("dojo.dnd.DragAndDrop");
+
+dojo.require("dojo.dom");
+dojo.require("dojo.style");
+dojo.require("dojo.html");
+dojo.require("dojo.html.extras");
+dojo.require("dojo.lang.extras");
+dojo.require("dojo.lfx.*");
+
+dojo.dnd.HtmlDragSource = function(node, type){
+	node = dojo.byId(node);
+	this.constrainToContainer = false;
+	if(node){
+		this.domNode = node;
+		this.dragObject = node;
+
+		// register us
+		dojo.dnd.DragSource.call(this);
+
+		// set properties that might have been clobbered by the mixin
+		this.type = type||this.domNode.nodeName.toLowerCase();
+	}
+
+}
+
+dojo.inherits(dojo.dnd.HtmlDragSource, dojo.dnd.DragSource);
+
+dojo.lang.extend(dojo.dnd.HtmlDragSource, {
+	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;
+		}
+	}
+});
+
+dojo.dnd.HtmlDragObject = function(node, type){
+	this.domNode = dojo.byId(node);
+	this.type = type;
+	this.constrainToContainer = false;
+	this.dragSource = null;
+}
+
+dojo.inherits(dojo.dnd.HtmlDragObject, dojo.dnd.DragObject);
+
+dojo.lang.extend(dojo.dnd.HtmlDragObject, {
+	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.style.setOpacity(node, this.opacity); }
+		if(dojo.render.html.ie && 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.getScrollOffset();
+		this.dragStartPosition = dojo.style.getAbsolutePosition(this.domNode, true);
+
+		this.dragOffset = {y: this.dragStartPosition.y - e.pageY,
+			x: this.dragStartPosition.x - e.pageX};
+
+		this.dragClone = this.createDragNode();
+
+ 		if ((this.domNode.parentNode.nodeName.toLowerCase() == 'body') || (dojo.style.getComputedStyle(this.domNode.parentNode,"position") == "static")) {
+			this.parentPosition = {y: 0, x: 0};
+		} else {
+			this.parentPosition = dojo.style.getAbsolutePosition(this.domNode.parentNode, true);
+		}
+
+		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";
+		}
+
+		document.body.appendChild(this.dragClone);
+	},
+
+	getConstraints: function() {
+
+		if (this.constrainingContainer.nodeName.toLowerCase() == 'body') {
+			width = dojo.html.getViewportWidth();
+			height = dojo.html.getViewportHeight();
+			padLeft = 0;
+			padTop = 0;
+		} else {
+			width = dojo.style.getContentWidth(this.constrainingContainer);
+			height = dojo.style.getContentHeight(this.constrainingContainer);
+			padLeft = dojo.style.getPixelValue(this.constrainingContainer, "padding-left", true);
+			padTop = dojo.style.getPixelValue(this.constrainingContainer, "padding-top", true);
+		}
+
+		return {
+			minX: padLeft,
+			minY: padTop,
+			maxX: padLeft+width - dojo.style.getOuterWidth(this.domNode),
+			maxY: padTop+height - dojo.style.getOuterHeight(this.domNode)
+		}
+	},
+
+	updateDragOffset: function() {
+		var scroll = dojo.html.getScrollOffset();
+		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; }
+		}
+
+		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 reomve 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.dom.removeNode(this.dragClone);
+				this.dragClone = null;
+				break;
+
+			case "dropFailure": // slide back to the start
+				var startCoords = dojo.style.getAbsolutePosition(this.dragClone, true);
+				// offset the end so the effect can be seen
+				var endCoords = [this.dragStartPosition.x + 1,
+					this.dragStartPosition.y + 1];
+
+				// animate
+				var line = new dojo.lfx.Line(startCoords, endCoords);
+				var anim = new dojo.lfx.Animation(500, line, dojo.lfx.easeOut);
+				var dragObject = this;
+				dojo.event.connect(anim, "onAnimate", function(e) {
+					dragObject.dragClone.style.left = e[0] + "px";
+					dragObject.dragClone.style.top = e[1] + "px";
+				});
+				dojo.event.connect(anim, "onEnd", function (e) {
+					// pause for a second (not literally) and disappear
+					dojo.lang.setTimeout(dojo.dom.removeNode, 200,
+						dragObject.dragClone);
+				});
+				anim.play();
+				break;
+		}
+
+		// 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");
+	},
+
+	squelchOnClick: function(e){
+		// squelch this onClick() event because it's the result of a drag (it's not a real click)
+		e.preventDefault();
+
+		// but if a real click comes along, allow it
+		dojo.event.disconnect(this.domNode, "onclick", this, "squelchOnClick");
+	},
+
+	constrainTo: function(container) {
+		this.constrainToContainer=true;
+		if (container) {
+			this.constrainingContainer = container;
+		} else {
+			this.constrainingContainer = this.domNode.parentNode;
+		}
+	}
+});
+
+dojo.dnd.HtmlDropTarget = 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.inherits(dojo.dnd.HtmlDropTarget, dojo.dnd.DropTarget);
+
+dojo.lang.extend(dojo.dnd.HtmlDropTarget, {
+	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.dom.ELEMENT_NODE) { continue; }
+			var pos = dojo.style.getAbsolutePosition(child, true);
+			var height = dojo.style.getInnerHeight(child);
+			var width = dojo.style.getInnerWidth(child);
+			this.childBoxes.push({top: pos.y, bottom: pos.y+height,
+				left: pos.x, right: pos.x+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;
+			borderTopWidth = "1px";
+			borderTopColor = "black";
+			borderTopStyle = "solid";
+			width = dojo.style.getInnerWidth(this.domNode) + "px";
+			left = dojo.style.getAbsoluteX(this.domNode, true) + "px";
+		}
+	},
+
+	onDragMove: function(e, dragObjects){
+		var i = this._getNodeUnderMouse(e);
+
+		if(!this.dropIndicator){
+			this.createDropIndicator();
+		}
+
+		if(i < 0) {
+			if(this.childBoxes.length) {
+				var before = (dojo.html.gravity(this.childBoxes[0].node, e) & dojo.html.gravity.NORTH);
+			} else {
+				var before = true;
+			}
+		} else {
+			var child = this.childBoxes[i];
+			var before = (dojo.html.gravity(child.node, e) & dojo.html.gravity.NORTH);
+		}
+		this.placeIndicator(e, dragObjects, i, before);
+
+		if(!dojo.html.hasParent(this.dropIndicator)) {
+			document.body.appendChild(this.dropIndicator);
+		}
+	},
+
+	/**
+	 * Position the horizontal line that indicates "insert between these two items"
+	 */
+	placeIndicator: function(e, dragObjects, boxIndex, before) {
+		with(this.dropIndicator.style){
+			if (boxIndex < 0) {
+				if (this.childBoxes.length) {
+					top = (before ? this.childBoxes[0].top
+						: this.childBoxes[this.childBoxes.length - 1].bottom) + "px";
+				} else {
+					top = dojo.style.getAbsoluteY(this.domNode, true) + "px";
+				}
+			} else {
+				var child = this.childBoxes[boxIndex];
+				top = (before ? child.top : child.bottom) + "px";
+			}
+		}
+	},
+
+	onDragOut: function(e) {
+		if(this.dropIndicator) {
+			dojo.dom.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);
+
+		if (i < 0) {
+			if (this.childBoxes.length) {
+				if (dojo.html.gravity(this.childBoxes[0].node, e) & dojo.html.gravity.NORTH) {
+					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) & dojo.html.gravity.NORTH) {
+			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;
+	}
+});

Propchange: incubator/xap/trunk/src/dojo/src/dnd/HtmlDragAndDrop.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/xap/trunk/src/dojo/src/dnd/HtmlDragManager.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/dojo/src/dnd/HtmlDragManager.js?rev=417609&view=auto
==============================================================================
--- incubator/xap/trunk/src/dojo/src/dnd/HtmlDragManager.js (added)
+++ incubator/xap/trunk/src/dojo/src/dnd/HtmlDragManager.js Tue Jun 27 15:35:12 2006
@@ -0,0 +1,442 @@
+/*
+	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");
+dojo.require("dojo.style");
+
+// NOTE: there will only ever be a single instance of HTMLDragManager, so it's
+// safe to use prototype properties for book-keeping.
+dojo.dnd.HtmlDragManager = function(){
+}
+
+dojo.inherits(dojo.dnd.HtmlDragManager, dojo.dnd.DragManager);
+
+dojo.lang.extend(dojo.dnd.HtmlDragManager, {
+	/**
+	 * 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: [],
+
+	// 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){
+		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.
+			var dp = this.dsPrefix;
+			var dpIdx = dp+"Idx_"+(this.dsCounter++);
+			ds.dragSourceId = dpIdx;
+			this.dragSources[dpIdx] = ds;
+			ds.domNode.setAttribute(dp, dpIdx);
+
+			// so we can drag links
+			if(dojo.render.html.ie){
+				dojo.event.connect(ds.domNode, "ondragstart", this.cancelEvent);
+			}
+		}
+	},
+
+	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.disconnect(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);
+		}
+	},
+
+	getDragSource: function(e){
+		var tn = e.target;
+		if(tn === document.body){ return; }
+		var ta = dojo.html.getAttribute(tn, this.dsPrefix);
+		while((!ta)&&(tn)){
+			tn = tn.parentNode;
+			if((!tn)||(tn === document.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.dom.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);
+		}
+
+ 		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;
+		if((!e.shiftKey)&&(!e.ctrlKey)){
+			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";
+				tempDragObj.dragSource.onDragEnd(e);
+				tempDragObj.onDragEnd(e);
+			}, this);
+
+			this.selectedSources = [];
+			this.dragObjects = [];
+			this.dragSource = null;
+			if(this.currentDropTarget) {
+				this.currentDropTarget.onDropEnd();
+			}
+		}
+
+		dojo.event.disconnect(document, "onmousemove", this, "onMouseMove");
+		this.currentDropTarget = null;
+	},
+
+	onScroll: function(){
+		for(var i = 0; i < this.dragObjects.length; i++) {
+			if(this.dragObjects[i].updateDragOffset) {
+				this.dragObjects[i].updateDragOffset();
+			}
+		}
+		// TODO: do not recalculate, only adjust coordinates
+		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(){
+		this.dropTargetDimensions = [];
+		dojo.lang.forEach(this.dropTargets, function(tempTarget){
+			var tn = tempTarget.domNode;
+			if(!tn){ return; }
+			var ttx = dojo.style.getAbsoluteX(tn, true);
+			var tty = dojo.style.getAbsoluteY(tn, true);
+			this.dropTargetDimensions.push([
+				[ttx, tty],	// upper-left
+				// lower-right
+				[ ttx+dojo.style.getInnerWidth(tn), tty+dojo.style.getInnerHeight(tn) ],
+				tempTarget
+			]);
+			//dojo.debug("Cached for "+tempTarget)
+		}, this);
+		//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;
+			}
+
+			if (this.selectedSources.length == 1) {
+				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.top += dy;
+					tdo.dragOffset.left += 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.dom.hasParent(this.currentDropTarget.domNode))
+			var c = dojo.style.toCoordinateArray(this.currentDropTarget.domNode, true);
+			//		var dtp = this.currentDropTargetPoints;
+			var dtp = [
+				[c[0],c[1]], [c[0]+c[2], c[1]+c[3]]
+			];
+		}
+
+		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;
+	// set up event handlers on the document
+	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
+	dojo.event.connect(window, "onscroll",	dm, "onScroll");
+})();

Propchange: incubator/xap/trunk/src/dojo/src/dnd/HtmlDragManager.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/xap/trunk/src/dojo/src/dnd/HtmlDragMove.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/dojo/src/dnd/HtmlDragMove.js?rev=417609&view=auto
==============================================================================
--- incubator/xap/trunk/src/dojo/src/dnd/HtmlDragMove.js (added)
+++ incubator/xap/trunk/src/dojo/src/dnd/HtmlDragMove.js Tue Jun 27 15:35:12 2006
@@ -0,0 +1,71 @@
+/*
+	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.provide("dojo.dnd.HtmlDragMoveSource");
+dojo.provide("dojo.dnd.HtmlDragMoveObject");
+dojo.require("dojo.dnd.*");
+
+dojo.dnd.HtmlDragMoveSource = function(node, type){
+	dojo.dnd.HtmlDragSource.call(this, node, type);
+}
+
+dojo.inherits(dojo.dnd.HtmlDragMoveSource, dojo.dnd.HtmlDragSource);
+
+dojo.lang.extend(dojo.dnd.HtmlDragMoveSource, {
+	onDragStart: function(){
+		var dragObj =  new dojo.dnd.HtmlDragMoveObject(this.dragObject, this.type);
+
+		if (this.constrainToContainer) {
+			dragObj.constrainTo(this.constrainingContainer);
+		}
+		return dragObj;
+	}
+});
+
+dojo.dnd.HtmlDragMoveObject = function(node, type){
+	dojo.dnd.HtmlDragObject.call(this, node, type);
+}
+
+dojo.inherits(dojo.dnd.HtmlDragMoveObject, dojo.dnd.HtmlDragObject);
+
+dojo.lang.extend(dojo.dnd.HtmlDragMoveObject, {
+	onDragEnd: function(e){
+		// 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");
+	},
+	
+	onDragStart: function(e){
+
+		dojo.html.clearSelection();
+
+		this.dragClone = this.domNode;
+
+		this.scrollOffset = dojo.html.getScrollOffset();
+		this.dragStartPosition = dojo.style.getAbsolutePosition(this.domNode, true);
+		
+		this.dragOffset = {y: this.dragStartPosition.y - e.pageY,
+			x: this.dragStartPosition.x - e.pageX};
+
+		if (this.domNode.parentNode.nodeName.toLowerCase() == 'body') {
+			this.parentPosition = {y: 0, x: 0};
+		} else {
+			this.parentPosition = dojo.style.getAbsolutePosition(this.domNode.parentNode, true);
+		}
+
+		this.dragClone.style.position = "absolute";
+
+		if (this.constrainToContainer) {
+			this.constraints = this.getConstraints();
+		}
+	}
+
+});

Propchange: incubator/xap/trunk/src/dojo/src/dnd/HtmlDragMove.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/xap/trunk/src/dojo/src/dnd/Sortable.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/dojo/src/dnd/Sortable.js?rev=417609&view=auto
==============================================================================
--- incubator/xap/trunk/src/dojo/src/dnd/Sortable.js (added)
+++ incubator/xap/trunk/src/dojo/src/dnd/Sortable.js Tue Jun 27 15:35:12 2006
@@ -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;
+	}
+
+});

Propchange: incubator/xap/trunk/src/dojo/src/dnd/Sortable.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/xap/trunk/src/dojo/src/dnd/TreeDragAndDrop.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/dojo/src/dnd/TreeDragAndDrop.js?rev=417609&view=auto
==============================================================================
--- incubator/xap/trunk/src/dojo/src/dnd/TreeDragAndDrop.js (added)
+++ incubator/xap/trunk/src/dojo/src/dnd/TreeDragAndDrop.js Tue Jun 27 15:35:12 2006
@@ -0,0 +1,473 @@
+/*
+	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
+*/
+
+/**
+ * TreeDrag* specialized on managing subtree drags
+ * It selects nodes and visualises what's going on,
+ * but delegates real actions upon tree to the controller
+ *
+ * This code is considered a part of controller
+*/
+
+dojo.provide("dojo.dnd.TreeDragAndDrop");
+dojo.provide("dojo.dnd.TreeDragSource");
+dojo.provide("dojo.dnd.TreeDropTarget");
+dojo.provide("dojo.dnd.TreeDNDController");
+
+dojo.require("dojo.dnd.HtmlDragAndDrop");
+dojo.require("dojo.lang.func");
+dojo.require("dojo.lang.array");
+dojo.require("dojo.lang.extras");
+
+dojo.dnd.TreeDragSource = function(node, syncController, type, treeNode){
+	this.controller = syncController;
+	this.treeNode = treeNode;
+
+	dojo.dnd.HtmlDragSource.call(this, node, type);
+}
+
+dojo.inherits(dojo.dnd.TreeDragSource, dojo.dnd.HtmlDragSource);
+
+dojo.lang.extend(dojo.dnd.TreeDragSource, {
+	onDragStart: function(){
+		/* extend adds functions to prototype */
+		var dragObject = dojo.dnd.HtmlDragSource.prototype.onDragStart.call(this);
+		//dojo.debugShallow(dragObject)
+
+		dragObject.treeNode = this.treeNode;
+
+		dragObject.onDragStart = dojo.lang.hitch(dragObject, function(e) {
+
+			/* save selection */
+			this.savedSelectedNode = this.treeNode.tree.selector.selectedNode;
+			if (this.savedSelectedNode) {
+				this.savedSelectedNode.unMarkSelected();
+			}
+
+			var result = dojo.dnd.HtmlDragObject.prototype.onDragStart.apply(this, arguments);
+
+
+			/* remove background grid from cloned object */
+			var cloneGrid = this.dragClone.getElementsByTagName('img');
+			for(var i=0; i<cloneGrid.length; i++) {
+				cloneGrid.item(i).style.backgroundImage='url()';
+			}
+
+			return result;
+
+
+		});
+
+		dragObject.onDragEnd = function(e) {
+
+			/* restore selection */
+			if (this.savedSelectedNode) {
+				this.savedSelectedNode.markSelected();
+			}
+			//dojo.debug(e.dragStatus);
+
+			return dojo.dnd.HtmlDragObject.prototype.onDragEnd.apply(this, arguments);
+		}
+		//dojo.debug(dragObject.domNode.outerHTML)
+
+
+		return dragObject;
+	},
+
+	onDragEnd: function(e){
+
+
+		 var res = dojo.dnd.HtmlDragSource.prototype.onDragEnd.call(this, e);
+
+
+		 return res;
+	}
+});
+
+// .......................................
+
+dojo.dnd.TreeDropTarget = function(domNode, controller, type, treeNode, DNDMode){
+
+	this.treeNode = treeNode;
+	this.controller = controller; // I will sync-ly process drops
+	this.DNDMode = DNDMode;
+
+	dojo.dnd.HtmlDropTarget.apply(this, [domNode, type]);
+}
+
+dojo.inherits(dojo.dnd.TreeDropTarget, dojo.dnd.HtmlDropTarget);
+
+dojo.lang.extend(dojo.dnd.TreeDropTarget, {
+
+	autoExpandDelay: 1500,
+	autoExpandTimer: null,
+
+
+	position: null,
+
+	indicatorStyle: "2px black solid",
+
+	showIndicator: function(position) {
+
+		// do not change style too often, cause of blinking possible
+		if (this.position == position) {
+			return;
+		}
+
+		//dojo.debug(position)
+
+		this.hideIndicator();
+
+		this.position = position;
+
+		if (position == "before") {
+			this.treeNode.labelNode.style.borderTop = this.indicatorStyle;
+		} else if (position == "after") {
+			this.treeNode.labelNode.style.borderBottom = this.indicatorStyle;
+		} else if (position == "onto") {
+			this.treeNode.markSelected();
+		}
+
+
+	},
+
+	hideIndicator: function() {
+		this.treeNode.labelNode.style.borderBottom="";
+		this.treeNode.labelNode.style.borderTop="";
+		this.treeNode.unMarkSelected();
+		this.position = null;
+	},
+
+
+
+	// is the target possibly ok ?
+	// This function is run on dragOver, but drop possibility is also determined by position over node
+	// that's why acceptsWithPosition is called
+	// doesnt take index into account ( can change while moving mouse w/o changing target )
+
+
+	/**
+	 * Coarse (tree-level) access check.
+	 * We can't determine real accepts status w/o position
+	*/
+	onDragOver: function(e){
+//dojo.debug("onDragOver for "+e);
+
+
+		var accepts = dojo.dnd.HtmlDropTarget.prototype.onDragOver.apply(this, arguments);
+
+		//dojo.debug("TreeDropTarget.onDragOver accepts:"+accepts)
+
+		if (accepts && this.treeNode.isFolder && !this.treeNode.isExpanded) {
+			this.setAutoExpandTimer();
+		}
+
+		return accepts;
+	},
+
+	/* Parent.onDragOver calls this function to get accepts status */
+	accepts: function(dragObjects) {
+
+		var accepts = dojo.dnd.HtmlDropTarget.prototype.accepts.apply(this, arguments);
+
+		if (!accepts) return false;
+
+		var sourceTreeNode = dragObjects[0].treeNode;
+
+		if (dojo.lang.isUndefined(sourceTreeNode) || !sourceTreeNode || !sourceTreeNode.isTreeNode) {
+			dojo.raise("Source is not TreeNode or not found");
+		}
+
+		if (sourceTreeNode === this.treeNode) return false;
+
+		return true;
+	},
+
+
+
+	setAutoExpandTimer: function() {
+		// set up autoexpand timer
+		var _this = this;
+
+		var autoExpand = function () {
+			if (dojo.dnd.dragManager.currentDropTarget === _this) {
+				_this.controller.expand(_this.treeNode);
+			}
+		}
+
+		this.autoExpandTimer = dojo.lang.setTimeout(autoExpand, _this.autoExpandDelay);
+	},
+
+
+	getAcceptPosition: function(e, sourceTreeNode) {
+
+		var DNDMode = this.DNDMode;
+
+		if (DNDMode & dojo.widget.Tree.prototype.DNDModes.ONTO &&
+			// check if ONTO is allowed localy
+			!(
+			  !this.treeNode.actionIsDisabled(dojo.widget.TreeNode.prototype.actions.ADDCHILD) // check dynamically cause may change w/o regeneration of dropTarget
+			  && sourceTreeNode.parent !== this.treeNode
+			  && this.controller.canMove(sourceTreeNode, this.treeNode)
+			 )
+		) {
+			// disable ONTO if can't move
+			DNDMode &= ~dojo.widget.Tree.prototype.DNDModes.ONTO;
+		}
+
+
+		var position = this.getPosition(e, DNDMode);
+
+		//dojo.debug(DNDMode & +" : "+position);
+
+
+		// if onto is here => it was allowed before, no accept check is needed
+		if (position=="onto" ||
+			(!this.isAdjacentNode(sourceTreeNode, position)
+			 && this.controller.canMove(sourceTreeNode, this.treeNode.parent)
+			)
+		) {
+			return position;
+		} else {
+			return false;
+		}
+
+	},
+
+	onDragOut: function(e) {
+		this.clearAutoExpandTimer();
+
+		this.hideIndicator();
+	},
+
+
+	clearAutoExpandTimer: function() {
+		if (this.autoExpandTimer) {
+			clearTimeout(this.autoExpandTimer);
+			this.autoExpandTimer = null;
+		}
+	},
+
+
+
+	onDragMove: function(e, dragObjects){
+
+		var sourceTreeNode = dragObjects[0].treeNode;
+
+		var position = this.getAcceptPosition(e, sourceTreeNode);
+
+		if (position) {
+			this.showIndicator(position);
+		}
+
+	},
+
+	isAdjacentNode: function(sourceNode, position) {
+
+		if (sourceNode === this.treeNode) return true;
+		if (sourceNode.getNextSibling() === this.treeNode && position=="before") return true;
+		if (sourceNode.getPreviousSibling() === this.treeNode && position=="after") return true;
+
+		return false;
+	},
+
+
+	/* get DNDMode and see which position e fits */
+	getPosition: function(e, DNDMode) {
+		node = dojo.byId(this.treeNode.labelNode);
+		var mousey = e.pageY || e.clientY + document.body.scrollTop;
+		var nodey = dojo.html.getAbsoluteY(node);
+		var height = dojo.html.getInnerHeight(node);
+
+		var relY = mousey - nodey;
+		var p = relY / height;
+
+		var position = ""; // "" <=> forbidden
+		if (DNDMode & dojo.widget.Tree.prototype.DNDModes.ONTO
+		  && DNDMode & dojo.widget.Tree.prototype.DNDModes.BETWEEN) {
+			if (p<=0.3) {
+				position = "before";
+			} else if (p<=0.7) {
+				position = "onto";
+			} else {
+				position = "after";
+			}
+		} else if (DNDMode & dojo.widget.Tree.prototype.DNDModes.BETWEEN) {
+			if (p<=0.5) {
+				position = "before";
+			} else {
+				position = "after";
+			}
+		}
+		else if (DNDMode & dojo.widget.Tree.prototype.DNDModes.ONTO) {
+			position = "onto";
+		}
+
+
+		return position;
+	},
+
+
+
+	getTargetParentIndex: function(sourceTreeNode, position) {
+
+		var index = position == "before" ? this.treeNode.getParentIndex() : this.treeNode.getParentIndex()+1;
+		if (this.treeNode.parent === sourceTreeNode.parent
+		  && this.treeNode.getParentIndex() > sourceTreeNode.getParentIndex()) {
+		  	index--;  // dragging a node is different for simple move bacause of before-after issues
+		}
+
+		return index;
+	},
+
+
+	onDrop: function(e){
+		// onDragOut will clean position
+
+
+		var position = this.position;
+
+//dojo.debug(position);
+
+		this.onDragOut(e);
+
+		var sourceTreeNode = e.dragObject.treeNode;
+
+		if (!dojo.lang.isObject(sourceTreeNode)) {
+			dojo.raise("TreeNode not found in dragObject")
+		}
+
+		if (position == "onto") {
+			return this.controller.move(sourceTreeNode, this.treeNode, 0);
+		} else {
+			var index = this.getTargetParentIndex(sourceTreeNode, position);
+			return this.controller.move(sourceTreeNode, this.treeNode.parent, index);
+		}
+
+		//dojo.debug('drop2');
+
+
+
+	}
+
+
+});
+
+
+
+dojo.dnd.TreeDNDController = function(treeController) {
+
+	// I use this controller to perform actions
+	this.treeController = treeController;
+
+	this.dragSources = {};
+
+	this.dropTargets = {};
+
+}
+
+dojo.lang.extend(dojo.dnd.TreeDNDController, {
+
+
+	listenTree: function(tree) {
+		//dojo.debug("Listen tree "+tree);
+		dojo.event.topic.subscribe(tree.eventNames.createDOMNode, this, "onCreateDOMNode");
+		dojo.event.topic.subscribe(tree.eventNames.moveFrom, this, "onMoveFrom");
+		dojo.event.topic.subscribe(tree.eventNames.moveTo, this, "onMoveTo");
+		dojo.event.topic.subscribe(tree.eventNames.addChild, this, "onAddChild");
+		dojo.event.topic.subscribe(tree.eventNames.removeNode, this, "onRemoveNode");
+		dojo.event.topic.subscribe(tree.eventNames.treeDestroy, this, "onTreeDestroy");
+	},
+
+
+	unlistenTree: function(tree) {
+		//dojo.debug("Listen tree "+tree);
+		dojo.event.topic.unsubscribe(tree.eventNames.createDOMNode, this, "onCreateDOMNode");
+		dojo.event.topic.unsubscribe(tree.eventNames.moveFrom, this, "onMoveFrom");
+		dojo.event.topic.unsubscribe(tree.eventNames.moveTo, this, "onMoveTo");
+		dojo.event.topic.unsubscribe(tree.eventNames.addChild, this, "onAddChild");
+		dojo.event.topic.unsubscribe(tree.eventNames.removeNode, this, "onRemoveNode");
+		dojo.event.topic.unsubscribe(tree.eventNames.treeDestroy, this, "onTreeDestroy");
+	},
+
+	onTreeDestroy: function(message) {
+		this.unlistenTree(message.source);
+		// I'm not widget so don't use destroy() call and dieWithTree
+	},
+
+	onCreateDOMNode: function(message) {
+		this.registerDNDNode(message.source);
+	},
+
+	onAddChild: function(message) {
+		this.registerDNDNode(message.child);
+	},
+
+	onMoveFrom: function(message) {
+		var _this = this;
+		dojo.lang.forEach(
+			message.child.getDescendants(),
+			function(node) { _this.unregisterDNDNode(node); }
+		);
+	},
+
+	onMoveTo: function(message) {
+		var _this = this;
+		dojo.lang.forEach(
+			message.child.getDescendants(),
+			function(node) { _this.registerDNDNode(node); }
+		);
+	},
+
+	/**
+	 * Controller(node model) creates DNDNodes because it passes itself to node for synchroneous drops processing
+	 * I can't process DnD with events cause an event can't return result success/false
+	*/
+	registerDNDNode: function(node) {
+		if (!node.tree.DNDMode) return;
+
+//dojo.debug("registerDNDNode "+node);
+
+		/* I drag label, not domNode, because large domNodes are very slow to copy and large to drag */
+
+		var source = null;
+		var target = null;
+
+		if (!node.actionIsDisabled(node.actions.MOVE)) {
+			//dojo.debug("reg source")
+			var source = new dojo.dnd.TreeDragSource(node.labelNode, this, node.tree.widgetId, node);
+			this.dragSources[node.widgetId] = source;
+		}
+
+		var target = new dojo.dnd.TreeDropTarget(node.labelNode, this.treeController, node.tree.DNDAcceptTypes, node, node.tree.DNDMode);
+
+		this.dropTargets[node.widgetId] = target;
+
+	},
+
+
+	unregisterDNDNode: function(node) {
+
+		if (this.dragSources[node.widgetId]) {
+			dojo.dnd.dragManager.unregisterDragSource(this.dragSources[node.widgetId]);
+			delete this.dragSources[node.widgetId];
+		}
+
+		if (this.dropTargets[node.widgetId]) {
+			dojo.dnd.dragManager.unregisterDropTarget(this.dropTargets[node.widgetId]);
+			delete this.dropTargets[node.widgetId];
+		}
+	}
+
+
+
+
+
+});

Propchange: incubator/xap/trunk/src/dojo/src/dnd/TreeDragAndDrop.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/xap/trunk/src/dojo/src/dnd/__package__.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/dojo/src/dnd/__package__.js?rev=417609&view=auto
==============================================================================
--- incubator/xap/trunk/src/dojo/src/dnd/__package__.js (added)
+++ incubator/xap/trunk/src/dojo/src/dnd/__package__.js Tue Jun 27 15:35:12 2006
@@ -0,0 +1,16 @@
+/*
+	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.kwCompoundRequire({
+	common: ["dojo.dnd.DragAndDrop"],
+	browser: ["dojo.dnd.HtmlDragAndDrop"],
+	dashboard: ["dojo.dnd.HtmlDragAndDrop"]
+});
+dojo.provide("dojo.dnd.*");

Propchange: incubator/xap/trunk/src/dojo/src/dnd/__package__.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/xap/trunk/src/dojo/src/event/__package__.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/dojo/src/event/__package__.js?rev=417609&view=auto
==============================================================================
--- incubator/xap/trunk/src/dojo/src/event/__package__.js (added)
+++ incubator/xap/trunk/src/dojo/src/event/__package__.js Tue Jun 27 15:35:12 2006
@@ -0,0 +1,16 @@
+/*
+	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.kwCompoundRequire({
+	common: ["dojo.event", "dojo.event.topic"],
+	browser: ["dojo.event.browser"],
+	dashboard: ["dojo.event.browser"]
+});
+dojo.provide("dojo.event.*");

Propchange: incubator/xap/trunk/src/dojo/src/event/__package__.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/xap/trunk/src/dojo/src/event/browser.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/dojo/src/event/browser.js?rev=417609&view=auto
==============================================================================
--- incubator/xap/trunk/src/dojo/src/event/browser.js (added)
+++ incubator/xap/trunk/src/dojo/src/event/browser.js Tue Jun 27 15:35:12 2006
@@ -0,0 +1,269 @@
+/*
+	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.event.browser");
+dojo.require("dojo.event");
+
+dojo_ie_clobber = new function(){
+	this.clobberNodes = [];
+
+	function nukeProp(node, prop){
+		// try{ node.removeAttribute(prop); 	}catch(e){ /* squelch */ }
+		try{ node[prop] = null; 			}catch(e){ /* squelch */ }
+		try{ delete node[prop]; 			}catch(e){ /* squelch */ }
+		// FIXME: JotLive needs this, but I'm not sure if it's too slow or not
+		try{ node.removeAttribute(prop);	}catch(e){ /* squelch */ }
+	}
+
+	this.clobber = function(nodeRef){
+		var na;
+		var tna;
+		if(nodeRef){
+			tna = nodeRef.all || nodeRef.getElementsByTagName("*");
+			na = [nodeRef];
+			for(var x=0; x<tna.length; x++){
+				// if we're gonna be clobbering the thing, at least make sure
+				// we aren't trying to do it twice
+				if(tna[x]["__doClobber__"]){
+					na.push(tna[x]);
+				}
+			}
+		}else{
+			try{ window.onload = null; }catch(e){}
+			na = (this.clobberNodes.length) ? this.clobberNodes : document.all;
+		}
+		tna = null;
+		var basis = {};
+		for(var i = na.length-1; i>=0; i=i-1){
+			var el = na[i];
+			if(el["__clobberAttrs__"]){
+				for(var j=0; j<el.__clobberAttrs__.length; j++){
+					nukeProp(el, el.__clobberAttrs__[j]);
+				}
+				nukeProp(el, "__clobberAttrs__");
+				nukeProp(el, "__doClobber__");
+			}
+		}
+		na = null;
+	}
+}
+
+if(dojo.render.html.ie){
+	window.onunload = function(){
+		dojo_ie_clobber.clobber();
+		try{
+			if((dojo["widget"])&&(dojo.widget["manager"])){
+				dojo.widget.manager.destroyAll();
+			}
+		}catch(e){}
+		try{ window.onload = null; }catch(e){}
+		try{ window.onunload = null; }catch(e){}
+		dojo_ie_clobber.clobberNodes = [];
+		// CollectGarbage();
+	}
+}
+
+dojo.event.browser = new function(){
+
+	var clobberIdx = 0;
+
+	this.clean = function(node){
+		if(dojo.render.html.ie){ 
+			dojo_ie_clobber.clobber(node);
+		}
+	}
+
+	this.addClobberNode = function(node){
+		if(!node["__doClobber__"]){
+			node.__doClobber__ = true;
+			dojo_ie_clobber.clobberNodes.push(node);
+			// this might not be the most efficient thing to do, but it's
+			// much less error prone than other approaches which were
+			// previously tried and failed
+			node.__clobberAttrs__ = [];
+		}
+	}
+
+	this.addClobberNodeAttrs = function(node, props){
+		this.addClobberNode(node);
+		for(var x=0; x<props.length; x++){
+			node.__clobberAttrs__.push(props[x]);
+		}
+	}
+
+	this.removeListener = function(node, evtName, fp, capture){
+		if(!capture){ var capture = false; }
+		evtName = evtName.toLowerCase();
+		if(evtName.substr(0,2)=="on"){ evtName = evtName.substr(2); }
+		// FIXME: this is mostly a punt, we aren't actually doing anything on IE
+		if(node.removeEventListener){
+			node.removeEventListener(evtName, fp, capture);
+		}
+	}
+
+	this.addListener = function(node, evtName, fp, capture, dontFix){
+		if(!node){ return; } // FIXME: log and/or bail?
+		if(!capture){ var capture = false; }
+		evtName = evtName.toLowerCase();
+		if(evtName.substr(0,2)!="on"){ evtName = "on"+evtName; }
+
+		if(!dontFix){
+			// build yet another closure around fp in order to inject fixEvent
+			// around the resulting event
+			var newfp = function(evt){
+				if(!evt){ evt = window.event; }
+				var ret = fp(dojo.event.browser.fixEvent(evt, this));
+				if(capture){
+					dojo.event.browser.stopEvent(evt);
+				}
+				return ret;
+			}
+		}else{
+			newfp = fp;
+		}
+
+		if(node.addEventListener){ 
+			node.addEventListener(evtName.substr(2), newfp, capture);
+			return newfp;
+		}else{
+			if(typeof node[evtName] == "function" ){
+				var oldEvt = node[evtName];
+				node[evtName] = function(e){
+					oldEvt(e);
+					return newfp(e);
+				}
+			}else{
+				node[evtName]=newfp;
+			}
+			if(dojo.render.html.ie){
+				this.addClobberNodeAttrs(node, [evtName]);
+			}
+			return newfp;
+		}
+	}
+
+	this.isEvent = function(obj){
+		// FIXME: event detection hack ... could test for additional attributes
+		// if necessary
+		return (typeof obj != "undefined")&&(typeof Event != "undefined")&&(obj.eventPhase);
+		// Event does not support instanceof in Opera, otherwise:
+		//return (typeof Event != "undefined")&&(obj instanceof Event);
+	}
+
+	this.currentEvent = null;
+	
+	this.callListener = function(listener, curTarget){
+		if(typeof listener != 'function'){
+			dojo.raise("listener not a function: " + listener);
+		}
+		dojo.event.browser.currentEvent.currentTarget = curTarget;
+		return listener.call(curTarget, dojo.event.browser.currentEvent);
+	}
+
+	this.stopPropagation = function(){
+		dojo.event.browser.currentEvent.cancelBubble = true;
+	}
+
+	this.preventDefault = function(){
+	  dojo.event.browser.currentEvent.returnValue = false;
+	}
+
+	this.keys = {
+		KEY_BACKSPACE: 8,
+		KEY_TAB: 9,
+		KEY_ENTER: 13,
+		KEY_SHIFT: 16,
+		KEY_CTRL: 17,
+		KEY_ALT: 18,
+		KEY_PAUSE: 19,
+		KEY_CAPS_LOCK: 20,
+		KEY_ESCAPE: 27,
+		KEY_SPACE: 32,
+		KEY_PAGE_UP: 33,
+		KEY_PAGE_DOWN: 34,
+		KEY_END: 35,
+		KEY_HOME: 36,
+		KEY_LEFT_ARROW: 37,
+		KEY_UP_ARROW: 38,
+		KEY_RIGHT_ARROW: 39,
+		KEY_DOWN_ARROW: 40,
+		KEY_INSERT: 45,
+		KEY_DELETE: 46,
+		KEY_LEFT_WINDOW: 91,
+		KEY_RIGHT_WINDOW: 92,
+		KEY_SELECT: 93,
+		KEY_F1: 112,
+		KEY_F2: 113,
+		KEY_F3: 114,
+		KEY_F4: 115,
+		KEY_F5: 116,
+		KEY_F6: 117,
+		KEY_F7: 118,
+		KEY_F8: 119,
+		KEY_F9: 120,
+		KEY_F10: 121,
+		KEY_F11: 122,
+		KEY_F12: 123,
+		KEY_NUM_LOCK: 144,
+		KEY_SCROLL_LOCK: 145
+	};
+
+	// reverse lookup
+	this.revKeys = [];
+	for(var key in this.keys){
+		this.revKeys[this.keys[key]] = key;
+	}
+
+	this.fixEvent = function(evt, sender){
+		if((!evt)&&(window["event"])){
+			var evt = window.event;
+		}
+		
+		if((evt["type"])&&(evt["type"].indexOf("key") == 0)){ // key events
+			evt.keys = this.revKeys;
+			// FIXME: how can we eliminate this iteration?
+			for(var key in this.keys) {
+				evt[key] = this.keys[key];
+			}
+			if((dojo.render.html.ie)&&(evt["type"] == "keypress")){
+				evt.charCode = evt.keyCode;
+			}
+		}
+	
+		if(dojo.render.html.ie){
+			if(!evt.target){ evt.target = evt.srcElement; }
+			if(!evt.currentTarget){ evt.currentTarget = (sender ? sender : evt.srcElement); }
+			if(!evt.layerX){ evt.layerX = evt.offsetX; }
+			if(!evt.layerY){ evt.layerY = evt.offsetY; }
+			// FIXME: scroll position query is duped from dojo.html to avoid dependency on that entire module
+			if(!evt.pageX){ evt.pageX = evt.clientX + (window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0) }
+			if(!evt.pageY){ evt.pageY = evt.clientY + (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0) }
+			// mouseover
+			if(evt.type == "mouseover"){ evt.relatedTarget = evt.fromElement; }
+			// mouseout
+			if(evt.type == "mouseout"){ evt.relatedTarget = evt.toElement; }
+			this.currentEvent = evt;
+			evt.callListener = this.callListener;
+			evt.stopPropagation = this.stopPropagation;
+			evt.preventDefault = this.preventDefault;
+		}
+		return evt;
+	}
+
+	this.stopEvent = function(ev) {
+		if(window.event){
+			ev.returnValue = false;
+			ev.cancelBubble = true;
+		}else{
+			ev.preventDefault();
+			ev.stopPropagation();
+		}
+	}
+}

Propchange: incubator/xap/trunk/src/dojo/src/event/browser.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/xap/trunk/src/dojo/src/event/topic.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/dojo/src/event/topic.js?rev=417609&view=auto
==============================================================================
--- incubator/xap/trunk/src/dojo/src/event/topic.js (added)
+++ incubator/xap/trunk/src/dojo/src/event/topic.js Tue Jun 27 15:35:12 2006
@@ -0,0 +1,98 @@
+/*
+	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.event");
+dojo.provide("dojo.event.topic");
+
+dojo.event.topic = new function(){
+	this.topics = {};
+
+	this.getTopic = function(topicName){
+		if(!this.topics[topicName]){
+			this.topics[topicName] = new this.TopicImpl(topicName);
+		}
+		return this.topics[topicName];
+	}
+
+	this.registerPublisher = function(topic, obj, funcName){
+		var topic = this.getTopic(topic);
+		topic.registerPublisher(obj, funcName);
+	}
+
+	this.subscribe = function(topic, obj, funcName){
+		var topic = this.getTopic(topic);
+		topic.subscribe(obj, funcName);
+	}
+
+	this.unsubscribe = function(topic, obj, funcName){
+		var topic = this.getTopic(topic);
+		topic.unsubscribe(obj, funcName);
+	}
+
+	this.destroy = function(topic){
+		this.getTopic(topic).destroy();
+		delete this.topics[topic];
+	}
+
+	this.publish = function(topic, message){
+		var topic = this.getTopic(topic);
+		// if message is an array, we treat it as a set of arguments,
+		// otherwise, we just pass on the arguments passed in as-is
+		var args = [];
+		if(arguments.length == 2 && (dojo.lang.isArray(message) || message.callee)){
+			args = message;
+		}else{
+			var args = [];
+			for(var x=1; x<arguments.length; x++){
+				args.push(arguments[x]);
+			}
+		}
+		topic.sendMessage.apply(topic, args);
+	}
+}
+
+dojo.event.topic.TopicImpl = function(topicName){
+	this.topicName = topicName;
+
+	this.subscribe = function(listenerObject, listenerMethod){
+		var tf = listenerMethod||listenerObject;
+		var to = (!listenerMethod) ? dj_global : listenerObject;
+		dojo.event.kwConnect({
+			srcObj:		this, 
+			srcFunc:	"sendMessage", 
+			adviceObj:	to,
+			adviceFunc: tf
+		});
+	}
+
+	this.unsubscribe = function(listenerObject, listenerMethod){
+		var tf = (!listenerMethod) ? listenerObject : listenerMethod;
+		var to = (!listenerMethod) ? null : listenerObject;
+		dojo.event.kwDisconnect({
+			srcObj:		this, 
+			srcFunc:	"sendMessage", 
+			adviceObj:	to,
+			adviceFunc: tf
+		});
+	}
+
+	this.destroy = function(){
+		dojo.event.MethodJoinPoint.getForMethod(this, "sendMessage").disconnect();
+	}
+
+	this.registerPublisher = function(publisherObject, publisherMethod){
+		dojo.event.connect(publisherObject, publisherMethod, this, "sendMessage");
+	}
+
+	this.sendMessage = function(message){
+		// The message has been propagated
+	}
+}
+

Propchange: incubator/xap/trunk/src/dojo/src/event/topic.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/xap/trunk/src/dojo/src/flash/flash6/DojoExternalInterface.as
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/dojo/src/flash/flash6/DojoExternalInterface.as?rev=417609&view=auto
==============================================================================
--- incubator/xap/trunk/src/dojo/src/flash/flash6/DojoExternalInterface.as (added)
+++ incubator/xap/trunk/src/dojo/src/flash/flash6/DojoExternalInterface.as Tue Jun 27 15:35:12 2006
@@ -0,0 +1,201 @@
+/*
+	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
+*/
+
+/** 
+		An implementation of Flash 8's ExternalInterface that works with Flash 6
+		and which is source-compatible with Flash 8. 
+		
+		@author Brad Neuberg, bkn3@columbia.edu 
+*/
+
+class DojoExternalInterface{
+	public static var available:Boolean;
+	public static var _fscommandReady = false;
+	public static var _callbacks = new Array();
+
+	public static function initialize(){ 
+		//getURL("javascript:dojo.debug('FLASH:DojoExternalInterface initialize')");
+		// FIXME: Set available variable by testing for capabilities
+		DojoExternalInterface.available = true;
+		
+		// Sometimes, on IE, the fscommand infrastructure can take a few hundred
+		// milliseconds the first time a page loads. Set a timer to keep checking
+		// to make sure we can issue fscommands; otherwise, our calls to fscommand
+		// for setCallback() and loaded() will just "disappear"
+		_root.fscommandReady = false;
+		var fsChecker = function(){
+			// issue a test fscommand
+			fscommand("fscommandReady");
+			
+			// JavaScript should set _root.fscommandReady if it got the call
+			if(_root.fscommandReady == "true"){
+				DojoExternalInterface._fscommandReady = true;
+				clearInterval(_root.fsTimer);
+			}
+		};
+		_root.fsTimer = setInterval(fsChecker, 100);
+	}
+	
+	public static function addCallback(methodName:String, instance:Object, 
+											method:Function) : Boolean{
+		// A variable that indicates whether the call below succeeded
+		_root._succeeded = null;
+		
+		// Callbacks are registered with the JavaScript side as follows.
+		// On the Flash side, we maintain a lookup table that associates
+		// the methodName with the actual instance and method that are
+		// associated with this method.
+		// Using fscommand, we send over the action "addCallback", with the
+		// argument being the methodName to add, such as "foobar".
+		// The JavaScript takes these values and registers the existence of
+		// this callback point.
+		
+		// precede the method name with a _ character in case it starts
+		// with a number
+		_callbacks["_" + methodName] = {_instance: instance, _method: method};
+		_callbacks[_callbacks.length] = methodName;
+		
+		// The API for ExternalInterface says we have to make sure the call
+		// succeeded; check to see if there is a value 
+		// for _succeeded, which is set by the JavaScript side
+		if(_root._succeeded == null){
+			return false;
+		}else{
+			return true;
+		}
+	}
+	
+	public static function call(methodName:String, 
+								resultsCallback:Function) : Void{
+		// FIXME: support full JSON serialization
+		
+		// First, we pack up all of the arguments to this call and set them
+		// as Flash variables, which the JavaScript side will unpack using
+		// plugin.GetVariable(). We set the number of arguments as "_numArgs",
+		// and add each argument as a variable, such as "_1", "_2", etc., starting
+		// from 0.
+		// We then execute an fscommand with the action "call" and the
+		// argument being the method name. JavaScript takes the method name,
+		// retrieves the arguments using GetVariable, executes the method,
+		// and then places the return result in a Flash variable
+		// named "_returnResult".
+		_root._numArgs = arguments.length - 2;
+		for(var i = 2; i < arguments.length; i++){
+			var argIndex = i - 2;
+			_root["_" + argIndex] = arguments[i];
+		}
+		
+		_root._returnResult = undefined;
+		fscommand("call", methodName);
+		
+		// immediately return if the caller is not waiting for return results
+		if(resultsCallback == undefined || resultsCallback == null){
+			return;
+		}
+		
+		// check at regular intervals for return results	
+		var resultsChecker = function(){
+			if(_root._returnResult != undefined){
+				clearInterval(_root._callbackID);
+				resultsCallback.call(null, _root._returnResult);
+			}
+		};	
+		_root._callbackID = setInterval(resultsChecker, 100);
+	}
+	
+	/** 
+			Called by Flash to indicate to JavaScript that we are ready to have
+			our Flash functions called. Calling loaded()
+			will fire the dojo.flash.loaded() event, so that JavaScript can know that
+			Flash has finished loading and adding its callbacks, and can begin to
+			interact with the Flash file.
+	*/
+	public static function loaded(){
+		//getURL("javascript:dojo.debug('FLASH:loaded')");
+		
+		// one more step: see if fscommands are ready to be executed; if not,
+		// set an interval that will keep running until fscommands are ready;
+		// make sure the gateway is loaded as well
+		var execLoaded = function(){
+			if(DojoExternalInterface._fscommandReady == true){
+				clearInterval(_root.loadedInterval);
+				
+				// initialize the small Flash file that helps gateway JS to Flash
+				// calls
+				DojoExternalInterface._initializeFlashRunner();
+			}	
+		};
+		
+		if(_fscommandReady == true){
+			execLoaded();
+		}else{
+			_root.loadedInterval = setInterval(execLoaded, 50);
+		}
+	}
+	
+	/** 
+			Handles and executes a JavaScript to Flash method call. Used by
+			initializeFlashRunner. 
+	*/
+	public static function _handleJSCall(){
+		// get our parameters
+		var numArgs = parseInt(_root._numArgs);
+		var jsArgs = new Array();
+		for(var i = 0; i < numArgs; i++){
+			var currentValue = _root["_" + i];
+			jsArgs.push(currentValue);
+		}
+		
+		// get our function name
+		var functionName = _root._functionName;
+		
+		// now get the actual instance and method object to execute on,
+		// using our lookup table that was constructed by calls to
+		// addCallback on initialization
+		var instance = _callbacks["_" + functionName]._instance;
+		var method = _callbacks["_" + functionName]._method;
+		
+		// execute it
+		var results = method.apply(instance, jsArgs);
+		
+		// return the results
+		_root._returnResult = results;
+	}
+	
+	/** Called by the flash6_gateway.swf to indicate that it is loaded. */
+	public static function _gatewayReady(){
+		for(var i = 0; i < _callbacks.length; i++){
+			fscommand("addCallback", _callbacks[i]);
+		}
+		call("dojo.flash.loaded");
+	}
+	
+	/** 
+			When JavaScript wants to communicate with Flash it simply sets
+			the Flash variable "_execute" to true; this method creates the
+			internal Movie Clip, called the Flash Runner, that makes this
+			magic happen.
+	*/
+	public static function _initializeFlashRunner(){
+		// figure out where our Flash movie is
+		var swfLoc = "../..";
+		if(swfLoc.charAt(swfLoc.length - 1) != '/'){
+			swfLoc = swfLoc + "/";
+		}
+		swfLoc = swfLoc + "flash6_gateway.swf";
+		
+		// load our gateway helper file
+		_root.createEmptyMovieClip("_flashRunner", 5000);
+		_root._flashRunner._lockroot = true;
+		_root._flashRunner.loadMovie(swfLoc);
+	}
+}
+
+// vim:ts=4:noet:tw=0:

Added: incubator/xap/trunk/src/dojo/src/flash/flash6/flash6_gateway.fla
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/dojo/src/flash/flash6/flash6_gateway.fla?rev=417609&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/xap/trunk/src/dojo/src/flash/flash6/flash6_gateway.fla
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream