You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ca...@apache.org on 2007/01/11 23:36:18 UTC
svn commit: r495409 [12/47] - in
/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource:
./ src/ src/animation/ src/cal/ src/charting/ src/charting/svg/
src/charting/vml/ src/collections/ src/crypto/ src/data/ src/data/...
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/HtmlDragCopy.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/HtmlDragCopy.js?view=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/HtmlDragCopy.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/HtmlDragCopy.js Thu Jan 11 14:35:53 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: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/HtmlDragManager.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/HtmlDragManager.js?view=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/HtmlDragManager.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/HtmlDragManager.js Thu Jan 11 14:35:53 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: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/HtmlDragMove.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/HtmlDragMove.js?view=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/HtmlDragMove.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/HtmlDragMove.js Thu Jan 11 14:35:53 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: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/Sortable.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/Sortable.js?view=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/Sortable.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/Sortable.js Thu Jan 11 14:35:53 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;
+ }
+
+});
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/TreeDragAndDrop.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/TreeDragAndDrop.js?view=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/TreeDragAndDrop.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/TreeDragAndDrop.js Thu Jan 11 14:35:53 2007
@@ -0,0 +1,475 @@
+/*
+ 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.require("dojo.dnd.HtmlDragAndDrop");
+dojo.require("dojo.lang.func");
+dojo.require("dojo.lang.array");
+dojo.require("dojo.lang.extras");
+dojo.require("dojo.html.layout");
+
+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){
+
+ this.treeNode = treeNode;
+ this.controller = controller; // I will sync-ly process drops
+
+ 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);
+ },
+
+
+ getDNDMode: function() {
+ return this.treeNode.tree.DNDMode;
+ },
+
+
+ getAcceptPosition: function(e, sourceTreeNode) {
+
+ var DNDMode = this.getDNDMode();
+
+ 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) {
+ var node = dojo.byId(this.treeNode.labelNode);
+ var mousey = e.pageY || e.clientY + dojo.body().scrollTop;
+ var nodey = dojo.html.getAbsolutePosition(node).y;
+ var height = dojo.html.getBorderBox(node).height;
+
+ 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);
+
+ 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];
+ }
+ }
+
+
+
+
+
+});
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/TreeDragAndDropV3.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/TreeDragAndDropV3.js?view=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/TreeDragAndDropV3.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/TreeDragAndDropV3.js Thu Jan 11 14:35:53 2007
@@ -0,0 +1,403 @@
+/*
+ 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.TreeDragAndDropV3");
+
+dojo.require("dojo.dnd.HtmlDragAndDrop");
+dojo.require("dojo.lang.func");
+dojo.require("dojo.lang.array");
+dojo.require("dojo.lang.extras");
+dojo.require("dojo.Deferred");
+dojo.require("dojo.html.layout");
+
+// FIXME: if controller can't move then skip node on move start
+dojo.dnd.TreeDragSourceV3 = function(node, syncController, type, treeNode){
+ //dojo.profile.start("TreeDragSourceV3 "+treeNode);
+ this.controller = syncController;
+ this.treeNode = treeNode;
+
+ dojo.dnd.HtmlDragSource.call(this, node, type);
+ //dojo.profile.end("TreeDragSourceV3 "+treeNode);
+}
+
+dojo.inherits(dojo.dnd.TreeDragSourceV3, dojo.dnd.HtmlDragSource);
+
+
+// .......................................
+
+dojo.dnd.TreeDropTargetV3 = function(domNode, controller, type, treeNode){
+
+ this.treeNode = treeNode;
+ this.controller = controller; // I will sync-ly process drops
+
+ dojo.dnd.HtmlDropTarget.call(this, domNode, type);
+}
+
+dojo.inherits(dojo.dnd.TreeDropTargetV3, dojo.dnd.HtmlDropTarget);
+
+dojo.lang.extend(dojo.dnd.TreeDropTargetV3, {
+
+ autoExpandDelay: 1500,
+ autoExpandTimer: null,
+
+
+ position: null,
+
+ indicatorStyle: "2px black groove",
+
+ showIndicator: function(position) {
+
+ // do not change style too often, cause of blinking possible
+ if (this.position == position) {
+ return;
+ }
+
+ //dojo.debug("set position for "+this.treeNode)
+
+ this.hideIndicator();
+
+ this.position = position;
+
+ var node = this.treeNode;
+
+
+ node.contentNode.style.width = dojo.html.getBorderBox(node.labelNode).width + "px";
+
+ if (position == "onto") {
+ node.contentNode.style.border = this.indicatorStyle;
+ } else {
+ // FIXME: bottom-top or highlight should cover ONLY top/bottom or div itself,
+ // not span whole line (try Dnd)
+ // FAILURE: Can't put span inside div: multiline bottom-top will span multiple lines
+ if (position == "before") {
+ node.contentNode.style.borderTop = this.indicatorStyle;
+ } else if (position == "after") {
+ node.contentNode.style.borderBottom = this.indicatorStyle;
+ }
+ }
+ },
+
+ hideIndicator: function() {
+ this.treeNode.contentNode.style.borderBottom = "";
+ this.treeNode.contentNode.style.borderTop = "";
+ this.treeNode.contentNode.style.border = "";
+ this.treeNode.contentNode.style.width=""
+ 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();
+ }
+
+ if (accepts) {
+ this.cacheNodeCoords();
+ }
+
+
+ return accepts;
+ },
+
+ /* Parent.onDragOver calls this function to get accepts status */
+ accepts: function(dragObjects) {
+
+ var accepts = dojo.dnd.HtmlDropTarget.prototype.accepts.apply(this, arguments);
+
+ //dojo.debug("accepts "+accepts);
+
+ if (!accepts) return false;
+
+ for(var i=0; i<dragObjects.length; i++) {
+ // there may be NO treeNode
+ var sourceTreeNode = dragObjects[i].treeNode;
+
+ 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);
+ // SLOW. Coordinates will not be recalculated if collapse occurs, or
+ // other (generic) resize. So that's a kind of hack.
+ dojo.dnd.dragManager.cacheTargetLocations();
+ }
+ }
+
+ this.autoExpandTimer = dojo.lang.setTimeout(autoExpand, _this.autoExpandDelay);
+ },
+
+
+
+ getAcceptPosition: function(e, dragObjects) {
+
+
+ var DndMode = this.treeNode.tree.DndMode;
+
+ // disable ONTO mode possibility if impossible
+ if (DndMode & dojo.widget.TreeV3.prototype.DndModes.ONTO &&
+ // check if ONTO is allowed localy
+ // check dynamically cause may change w/o regeneration of dropTarget
+ this.treeNode.actionIsDisabledNow(this.treeNode.actions.ADDCHILD)
+ ) {
+ // disable ONTO if can't move
+ DndMode &= ~dojo.widget.TreeV3.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") {
+ return position;
+ }
+
+ for(var i=0; i<dragObjects.length; i++) {
+ var source = dragObjects[i].dragSource;
+ if (source.treeNode && this.isAdjacentNode(source.treeNode, position)) { // skip check if same parent
+ continue;
+ }
+
+ if (!this.controller.canMove(source.treeNode ? source.treeNode : source, this.treeNode.parent)) {
+ return false;
+ }
+ }
+
+ return position;
+
+ },
+
+
+
+ onDropEnd: function(e) {
+ this.clearAutoExpandTimer();
+
+ this.hideIndicator();
+ },
+
+
+ onDragOut: function(e) {
+ this.clearAutoExpandTimer();
+
+ this.hideIndicator();
+ },
+
+ clearAutoExpandTimer: function() {
+ if (this.autoExpandTimer) {
+ clearTimeout(this.autoExpandTimer);
+ this.autoExpandTimer = null;
+ }
+ },
+
+
+
+ onDragMove: function(e, dragObjects){
+
+ var position = this.getAcceptPosition(e, dragObjects);
+
+ 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;
+ },
+
+
+ /**
+ * cache node coordinates to speed up onDragMove
+ */
+ cacheNodeCoords: function() {
+ var node = this.treeNode.contentNode;
+
+ this.cachedNodeY = dojo.html.getAbsolutePosition(node).y;
+ this.cachedNodeHeight = dojo.html.getBorderBox(node).height;
+ },
+
+
+
+ /* get DndMode and see which position e fits */
+ getPosition: function(e, DndMode) {
+ var mousey = e.pageY || e.clientY + dojo.body().scrollTop;
+
+ var relY = mousey - this.cachedNodeY;
+ var p = relY / this.cachedNodeHeight;
+
+ var position = ""; // "" <=> forbidden
+ if (DndMode & dojo.widget.TreeV3.prototype.DndModes.ONTO
+ && DndMode & dojo.widget.TreeV3.prototype.DndModes.BETWEEN) {
+ //dojo.debug("BOTH");
+ if (p<=0.33) {
+ position = "before";
+ // if children are expanded then I ignore understrike, cause it is confusing with firstChild
+ // but for last nodes I put understrike there
+ } else if (p<=0.66 || this.treeNode.isExpanded && this.treeNode.children.length && !this.treeNode.isLastChild()) {
+ position = "onto";
+ } else {
+ position = "after";
+ }
+ } else if (DndMode & dojo.widget.TreeV3.prototype.DndModes.BETWEEN) {
+ //dojo.debug("BETWEEN");
+ if (p<=0.5 || this.treeNode.isExpanded && this.treeNode.children.length && !this.treeNode.isLastChild()) {
+ position = "before";
+ } else {
+ position = "after";
+ }
+ }
+ else if (DndMode & dojo.widget.TreeV3.prototype.DndModes.ONTO) {
+ //dojo.debug("ONTO");
+ position = "onto";
+ }
+
+ //dojo.debug(position);
+
+ return position;
+ },
+
+
+
+ getTargetParentIndex: function(source, position) {
+
+ var index = position == "before" ? this.treeNode.getParentIndex() : this.treeNode.getParentIndex()+1;
+ if (source.treeNode
+ && this.treeNode.parent === source.treeNode.parent
+ && this.treeNode.getParentIndex() > source.treeNode.getParentIndex()) {
+ index--; // dragging a node is different for simple move bacause of before-after issues
+ }
+
+ return index;
+ },
+
+
+ onDrop: function(e) {
+ // onDropEnd will clean position
+
+
+ var position = this.position;
+
+//dojo.debug(position);
+ var source = e.dragObject.dragSource;
+
+ //dojo.debug("onDrop "+source.treeNode+" " + position + " "+this.treeNode);
+
+
+ var targetParent, targetIndex;
+ if (position == "onto") {
+ targetParent = this.treeNode;
+ targetIndex = 0;
+ } else {
+ targetIndex = this.getTargetParentIndex(source, position);
+ targetParent = this.treeNode.parent;
+ }
+
+ //dojo.profile.start("onDrop "+sourceTreeNode);
+ var r = this.getDropHandler(e, source, targetParent, targetIndex)();
+
+ //dojo.profile.end("onDrop "+sourceTreeNode);
+
+ return r;
+
+ },
+
+ /**
+ * determine, which action I should perform with nodes
+ * e.g move, clone..
+ */
+ getDropHandler: function(e, source, targetParent, targetIndex) {
+ var handler;
+ var _this = this;
+ handler = function () {
+ var result;
+
+ //dojo.debug("Move "+source.treeNode+" to parent "+targetParent+":"+targetIndex);
+ if (source.treeNode) {
+ result = _this.controller.move(source.treeNode, targetParent, targetIndex, true);
+ //dojo.debug("moved "+result);
+ } else {
+ if (dojo.lang.isFunction(source.onDrop)) {
+ source.onDrop(targetParent, targetIndex);
+ }
+
+ var treeNode = source.getTreeNode();
+ if (treeNode) {
+ result = _this.controller.createChild(targetParent, targetIndex, treeNode, true);
+ } else {
+ result = true;
+ }
+ }
+
+ if (result instanceof dojo.Deferred) {
+ // this Deferred is always sync
+ var isSuccess = result.fired == 0;
+ if (!isSuccess) {
+ _this.handleDropError(source, targetParent, targetIndex, result);
+ }
+
+ return isSuccess;
+
+ } else {
+ return result;
+ }
+ }
+
+ return handler;
+ },
+
+
+ handleDropError: function(source, parent, index, result) {
+ dojo.debug("TreeDropTargetV3.handleDropError: DND error occured");
+ dojo.debugShallow(result);
+ }
+
+
+});
+
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/__package__.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/__package__.js?view=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/__package__.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dnd/__package__.js Thu Jan 11 14:35:53 2007
@@ -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.*");
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/docs.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/docs.js?view=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/docs.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/docs.js Thu Jan 11 14:35:53 2007
@@ -0,0 +1,671 @@
+/*
+ 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.docs");
+dojo.require("dojo.io.*");
+dojo.require("dojo.event.topic");
+dojo.require("dojo.rpc.JotService");
+dojo.require("dojo.dom");
+dojo.require("dojo.uri.Uri");
+dojo.require("dojo.Deferred");
+dojo.require("dojo.DeferredList");
+
+/*
+ * TODO:
+ *
+ * Package summary needs to compensate for "is"
+ * Handle host environments
+ * Deal with dojo.widget weirdness
+ * Parse parameters
+ * Limit function parameters to only the valid ones (Involves packing parameters onto meta during rewriting)
+ *
+ */
+
+dojo.docs = new function() {
+ this._url = dojo.uri.dojoUri("docscripts");
+ this._rpc = new dojo.rpc.JotService;
+ this._rpc.serviceUrl = dojo.uri.dojoUri("docscripts/jsonrpc.php");
+};
+dojo.lang.mixin(dojo.docs, {
+ _count: 0,
+ _callbacks: {function_names: []},
+ _cache: {}, // Saves the JSON objects in cache
+ require: function(/*String*/ require, /*bool*/ sync) {
+ dojo.debug("require(): " + require);
+ var parts = require.split("/");
+
+ var size = parts.length;
+ var deferred = new dojo.Deferred;
+ var args = {
+ mimetype: "text/json",
+ load: function(type, data){
+ dojo.debug("require(): loaded for " + require);
+
+ if(parts[0] != "function_names") {
+ for(var i = 0, part; part = parts[i]; i++){
+ data = data[part];
+ }
+ }
+ deferred.callback(data);
+ },
+ error: function(){
+ deferred.errback();
+ }
+ };
+
+ if(location.protocol == "file:"){
+ if(size){
+ if(parts[parts.length - 1] == "documentation"){
+ parts[parts.length - 1] = "meta";
+ }
+
+ if(parts[0] == "function_names"){
+ args.url = [this._url, "local_json", "function_names"].join("/");
+ }else{
+ var dirs = parts[0].split(".");
+ args.url = [this._url, "local_json", dirs[0]].join("/");
+ if(dirs.length > 1){
+ args.url = [args.url, dirs[1]].join(".");
+ }
+ }
+ }
+ }
+
+ dojo.io.bind(args);
+ return deferred;
+ },
+ getFunctionNames: function(){
+ return this.require("function_names"); // dojo.Deferred
+ },
+ unFormat: function(/*String*/ string){
+ var fString = string;
+ if(string.charAt(string.length - 1) == "_"){
+ fString = [string.substring(0, string.length - 1), "*"].join("");
+ }
+ return fString;
+ },
+ getMeta: function(/*String*/ pkg, /*String*/ name, /*Function*/ callback, /*String?*/ id){
+ // summary: Gets information about a function in regards to its meta data
+ if(typeof name == "function"){
+ // pId: a
+ // pkg: ignore
+ id = callback;
+ callback = name;
+ name = pkg;
+ pkg = null;
+ dojo.debug("getMeta(" + name + ")");
+ }else{
+ dojo.debug("getMeta(" + pkg + "/" + name + ")");
+ }
+
+ if(!id){
+ id = "_";
+ }
+ },
+ _withPkg: function(/*String*/ type, /*Object*/ data, /*Object*/ evt, /*Object*/ input, /*String*/ newType){
+ dojo.debug("_withPkg(" + evt.name + ") has package: " + data[0]);
+ evt.pkg = data[0];
+ if("load" == type && evt.pkg){
+ evt.type = newType;
+ }else{
+ if(evt.callbacks && evt.callbacks.length){
+ evt.callbacks.shift()("error", {}, evt, evt.input);
+ }
+ }
+ },
+ _gotMeta: function(/*String*/ type, /*Object*/ data, /*Object*/ evt){
+ dojo.debug("_gotMeta(" + evt.name + ")");
+
+ var cached = dojo.docs._getCache(evt.pkg, evt.name, "meta", "functions", evt.id);
+ if(cached.summary){
+ data.summary = cached.summary;
+ }
+ if(evt.callbacks && evt.callbacks.length){
+ evt.callbacks.shift()(type, data, evt, evt.input);
+ }
+ },
+ getSrc: function(/*String*/ name, /*Function*/ callback, /*String?*/ id){
+ // summary: Gets src file (created by the doc parser)
+ dojo.debug("getSrc(" + name + ")");
+ if(!id){
+ id = "_";
+ }
+ },
+ getDoc: function(/*String*/ name, /*Function*/ callback, /*String?*/ id){
+ // summary: Gets external documentation stored on Jot for a given function
+ dojo.debug("getDoc(" + name + ")");
+
+ if(!id){
+ id = "_";
+ }
+
+ var input = {};
+
+ input.type = "doc";
+ input.name = name;
+ input.callbacks = [callback];
+ },
+ _gotDoc: function(/*String*/ type, /*Array*/ data, /*Object*/ evt, /*Object*/ input){
+ dojo.debug("_gotDoc(" + evt.type + ")");
+
+ evt[evt.type] = data;
+ if(evt.expects && evt.expects.doc){
+ for(var i = 0, expect; expect = evt.expects.doc[i]; i++){
+ if(!(expect in evt)){
+ dojo.debug("_gotDoc() waiting for more data");
+ return;
+ }
+ }
+ }
+
+ var cache = dojo.docs._getCache(evt.pkg, "meta", "functions", evt.name, evt.id, "meta");
+
+ var description = evt.fn.description;
+ cache.description = description;
+ data = {
+ returns: evt.fn.returns,
+ id: evt.id,
+ variables: []
+ }
+ if(!cache.parameters){
+ cache.parameters = {};
+ }
+ for(var i = 0, param; param = evt.param[i]; i++){
+ var fName = param["DocParamForm/name"];
+ if(!cache.parameters[fName]){
+ cache.parameters[fName] = {};
+ }
+ cache.parameters[fName].description = param["DocParamForm/desc"]
+ }
+
+ data.description = cache.description;
+ data.parameters = cache.parameters;
+
+ evt.type = "doc";
+
+ if(evt.callbacks && evt.callbacks.length){
+ evt.callbacks.shift()("load", data, evt, input);
+ }
+ },
+ getPkgDoc: function(/*String*/ name, /*Function*/ callback){
+ // summary: Gets external documentation stored on Jot for a given package
+ dojo.debug("getPkgDoc(" + name + ")");
+ var input = {};
+ },
+ getPkgInfo: function(/*String*/ name, /*Function*/ callback){
+ // summary: Gets a combination of the metadata and external documentation for a given package
+ dojo.debug("getPkgInfo(" + name + ")");
+
+ var input = {
+ expects: {
+ pkginfo: ["pkgmeta", "pkgdoc"]
+ },
+ callback: callback
+ };
+ dojo.docs.getPkgMeta(input, name, dojo.docs._getPkgInfo);
+ dojo.docs.getPkgDoc(input, name, dojo.docs._getPkgInfo);
+ },
+ _getPkgInfo: function(/*String*/ type, /*Object*/ data, /*Object*/ evt){
+ dojo.debug("_getPkgInfo() for " + evt.type);
+ var input = {};
+ var results = {};
+ if(typeof key == "object"){
+ input = key;
+ input[evt.type] = data;
+ if(input.expects && input.expects.pkginfo){
+ for(var i = 0, expect; expect = input.expects.pkginfo[i]; i++){
+ if(!(expect in input)){
+ dojo.debug("_getPkgInfo() waiting for more data");
+ return;
+ }
+ }
+ }
+ results = input.pkgmeta;
+ results.description = input.pkgdoc;
+ }
+
+ if(input.callback){
+ input.callback("load", results, evt);
+ }
+ },
+ getInfo: function(/*String*/ name, /*Function*/ callback){
+ dojo.debug("getInfo(" + name + ")");
+ var input = {
+ expects: {
+ "info": ["meta", "doc"]
+ },
+ callback: callback
+ }
+ dojo.docs.getMeta(input, name, dojo.docs._getInfo);
+ dojo.docs.getDoc(input, name, dojo.docs._getInfo);
+ },
+ _getInfo: function(/*String*/ type, /*String*/ data, /*Object*/ evt, /*Object*/ input){
+ dojo.debug("_getInfo(" + evt.type + ")");
+ if(input && input.expects && input.expects.info){
+ input[evt.type] = data;
+ for(var i = 0, expect; expect = input.expects.info[i]; i++){
+ if(!(expect in input)){
+ dojo.debug("_getInfo() waiting for more data");
+ return;
+ }
+ }
+ }
+
+ if(input.callback){
+ input.callback("load", dojo.docs._getCache(evt.pkg, "meta", "functions", evt.name, evt.id, "meta"), evt, input);
+ }
+ },
+ _getMainText: function(/*String*/ text){
+ // summary: Grabs the innerHTML from a Jot Rech Text node
+ dojo.debug("_getMainText()");
+ return text.replace(/^<html[^<]*>/, "").replace(/<\/html>$/, "").replace(/<\w+\s*\/>/g, "");
+ },
+ getPackageMeta: function(/*Object*/ input){
+ dojo.debug("getPackageMeta(): " + input.package);
+ return this.require(input.package + "/meta", input.sync);
+ },
+ getFunctionMeta: function(/*Object*/ input){
+ var package = input.package || "";
+ var name = input.name;
+ var id = input.id || "_";
+ dojo.debug("getFunctionMeta(): " + name);
+
+ if(!name) return;
+
+ if(package){
+ return this.require(package + "/meta/functions/" + name + "/" + id + "/meta");
+ }else{
+ this.getFunctionNames();
+ }
+ },
+ getFunctionDocumentation: function(/*Object*/ input){
+ var package = input.package || "";
+ var name = input.name;
+ var id = input.id || "_";
+ dojo.debug("getFunctionDocumentation(): " + name);
+
+ if(!name) return;
+
+ if(package){
+ return this.require(package + "/meta/functions/" + name + "/" + id + "/documentation");
+ }
+ },
+ _onDocSearch: function(/*Object*/ input){
+ var _this = this;
+ var name = input.name.toLowerCase();
+ if(!name) return;
+
+ this.getFunctionNames().addCallback(function(data){
+ dojo.debug("_onDocSearch(): function names loaded for " + name);
+
+ var output = [];
+ var list = [];
+ var closure = function(pkg, fn) {
+ return function(data){
+ dojo.debug("_onDocSearch(): package meta loaded for: " + pkg);
+ if(data.functions){
+ var functions = data.functions;
+ for(var key in functions){
+ if(fn == key){
+ var ids = functions[key];
+ for(var id in ids){
+ var fnMeta = ids[id];
+ output.push({
+ package: pkg,
+ name: fn,
+ id: id,
+ summary: fnMeta.summary
+ });
+ }
+ }
+ }
+ }
+ return output;
+ }
+ }
+
+ pkgLoop:
+ for(var pkg in data){
+ if(pkg.toLowerCase() == name){
+ name = pkg;
+ dojo.debug("_onDocSearch found a package");
+ //dojo.docs._onDocSelectPackage(input);
+ return;
+ }
+ for(var i = 0, fn; fn = data[pkg][i]; i++){
+ if(fn.toLowerCase().indexOf(name) != -1){
+ dojo.debug("_onDocSearch(): Search matched " + fn);
+ var meta = _this.getPackageMeta({package: pkg});
+ meta.addCallback(closure(pkg, fn));
+ list.push(meta);
+
+ // Build a list of all packages that need to be loaded and their loaded state.
+ continue pkgLoop;
+ }
+ }
+ }
+
+ list = new dojo.DeferredList(list);
+ list.addCallback(function(results){
+ dojo.debug("_onDocSearch(): All packages loaded");
+ _this._printFunctionResults(results[0][1]);
+ });
+ });
+ },
+ _onDocSearchFn: function(/*String*/ type, /*Array*/ data, /*Object*/ evt){
+ dojo.debug("_onDocSearchFn(" + evt.name + ")");
+
+ var name = evt.name || evt.pkg;
+
+ dojo.debug("_onDocSearchFn found a function");
+
+ evt.pkgs = packages;
+ evt.pkg = name;
+ evt.loaded = 0;
+ for(var i = 0, pkg; pkg = packages[i]; i++){
+ dojo.docs.getPkgMeta(evt, pkg, dojo.docs._onDocResults);
+ }
+ },
+ _onPkgResults: function(/*String*/ type, /*Object*/ data, /*Object*/ evt, /*Object*/ input){
+ dojo.debug("_onPkgResults(" + evt.type + ")");
+ var description = "";
+ var path = "";
+ var methods = {};
+ var requires = {};
+ if(input){
+ input[evt.type] = data;
+ if(input.expects && input.expects.pkgresults){
+ for(var i = 0, expect; expect = input.expects.pkgresults[i]; i++){
+ if(!(expect in input)){
+ dojo.debug("_onPkgResults() waiting for more data");
+ return;
+ }
+ }
+ }
+ path = input.pkgdoc.path;
+ description = input.pkgdoc.description;
+ methods = input.pkgmeta.methods;
+ requires = input.pkgmeta.requires;
+ }
+ var pkg = evt.name.replace("_", "*");
+ var results = {
+ path: path,
+ description: description,
+ size: 0,
+ methods: [],
+ pkg: pkg,
+ requires: requires
+ }
+ var rePrivate = /_[^.]+$/;
+ for(var method in methods){
+ if(!rePrivate.test(method)){
+ for(var pId in methods[method]){
+ results.methods.push({
+ pkg: pkg,
+ name: method,
+ id: pId,
+ summary: methods[method][pId].summary
+ })
+ }
+ }
+ }
+ results.size = results.methods.length;
+ dojo.docs._printPkgResult(results);
+ },
+ _onDocResults: function(/*String*/ type, /*Object*/ data, /*Object*/ evt, /*Object*/ input){
+ dojo.debug("_onDocResults(" + evt.name + "/" + input.pkg + ") " + type);
+ ++input.loaded;
+
+ if(input.loaded == input.pkgs.length){
+ var pkgs = input.pkgs;
+ var name = input.pkg;
+ var results = {methods: []};
+ var rePrivate = /_[^.]+$/;
+ data = dojo.docs._cache;
+
+ for(var i = 0, pkg; pkg = pkgs[i]; i++){
+ var methods = dojo.docs._getCache(pkg, "meta", "methods");
+ for(var fn in methods){
+ if(fn.toLowerCase().indexOf(name) == -1){
+ continue;
+ }
+ if(fn != "requires" && !rePrivate.test(fn)){
+ for(var pId in methods[fn]){
+ var result = {
+ pkg: pkg,
+ name: fn,
+ id: "_",
+ summary: ""
+ }
+ if(methods[fn][pId].summary){
+ result.summary = methods[fn][pId].summary;
+ }
+ results.methods.push(result);
+ }
+ }
+ }
+ }
+
+ dojo.debug("Publishing docResults");
+ dojo.docs._printFnResults(results);
+ }
+ },
+ _printFunctionResults: function(results){
+ dojo.debug("_printFnResults(): called");
+ // summary: Call this function to send the /docs/function/results topic
+ },
+ _printPkgResult: function(results){
+ dojo.debug("_printPkgResult(): called");
+ },
+ _onDocSelectFunction: function(/*Object*/ input){
+ // summary: Get doc, meta, and src
+ var name = input.name;
+ var package = input.package || "";
+ var id = input.id || "_";
+ dojo.debug("_onDocSelectFunction(" + name + ")");
+ if(!name || !package) return false;
+
+ var pkgMeta = this.getPackageMeta({package: package});
+ var meta = this.getFunctionMeta({package: package, name: name, id: id});
+ var doc = this.getFunctionDocumentation({package: package, name: name, id: id});
+
+ var list = new dojo.DeferredList([pkgMeta, meta, doc]);
+ list.addCallback(function(results){
+ dojo.debug("_onDocSelectFunction() loaded");
+ for(var i = 0, result; result = results[i]; i++){
+ dojo.debugShallow(result[1]);
+ }
+ });
+
+ return list;
+ },
+ _onDocSelectPackage: function(/*Object*/ input){
+ dojo.debug("_onDocSelectPackage(" + input.name + ")")
+ input.expects = {
+ "pkgresults": ["pkgmeta", "pkgdoc"]
+ };
+ dojo.docs.getPkgMeta(input, input.name, dojo.docs._onPkgResults);
+ dojo.docs.getPkgDoc(input, input.name, dojo.docs._onPkgResults);
+ },
+ _onDocSelectResults: function(/*String*/ type, /*Object*/ data, /*Object*/ evt, /*Object*/ input){
+ dojo.debug("_onDocSelectResults(" + evt.type + ", " + evt.name + ")");
+ if(evt.type == "meta"){
+ dojo.docs.getPkgMeta(input, evt.pkg, dojo.docs._onDocSelectResults);
+ }
+ if(input){
+ input[evt.type] = data;
+ if(input.expects && input.expects.docresults){
+ for(var i = 0, expect; expect = input.expects.docresults[i]; i++){
+ if(!(expect in input)){
+ dojo.debug("_onDocSelectResults() waiting for more data");
+ return;
+ }
+ }
+ }
+ }
+
+ dojo.docs._printFunctionDetail(input);
+ },
+
+ _printFunctionDetail: function(results) {
+ // summary: Call this function to send the /docs/function/detail topic event
+ },
+
+ selectFunction: function(/*String*/ name, /*String?*/ id){
+ // summary: The combined information
+ },
+ savePackage: function(/*Object*/ callbackObject, /*String*/ callback, /*Object*/ parameters){
+ dojo.event.kwConnect({
+ srcObj: dojo.docs,
+ srcFunc: "_savedPkgRpc",
+ targetObj: callbackObject,
+ targetFunc: callback,
+ once: true
+ });
+
+ var props = {};
+ var cache = dojo.docs._getCache(parameters.pkg, "meta");
+
+ var i = 1;
+
+ if(!cache.path){
+ var path = "id";
+ props[["pname", i].join("")] = "DocPkgForm/require";
+ props[["pvalue", i++].join("")] = parameters.pkg;
+ }else{
+ var path = cache.path;
+ }
+
+ props.form = "//DocPkgForm";
+ props.path = ["/WikiHome/DojoDotDoc/", path].join("");
+
+ if(parameters.description){
+ props[["pname", i].join("")] = "main/text";
+ props[["pvalue", i++].join("")] = parameters.description;
+ }
+
+ dojo.docs._rpc.callRemote("saveForm", props).addCallbacks(dojo.docs._pkgRpc, dojo.docs._pkgRpc);
+ },
+ _pkgRpc: function(data){
+ if(data.name){
+ dojo.docs._getCache(data["DocPkgForm/require"], "meta").path = data.name;
+ dojo.docs._savedPkgRpc("load");
+ }else{
+ dojo.docs._savedPkgRpc("error");
+ }
+ },
+ _savedPkgRpc: function(type){
+ },
+ functionPackages: function(/*String*/ name, /*Function*/ callback, /*Object*/ input){
+ // summary: Gets the package associated with a function and stores it in the .pkg value of input
+ dojo.debug("functionPackages() name: " + name);
+
+ if(!input){
+ input = {};
+ }
+ if(!input.callbacks){
+ input.callbacks = [];
+ }
+
+ input.type = "function_names";
+ input.name = name;
+ input.callbacks.unshift(callback);
+ input.callbacks.unshift(dojo.docs._functionPackages);
+ },
+ _functionPackages: function(/*String*/ type, /*Array*/ data, /*Object*/ evt){
+ dojo.debug("_functionPackages() name: " + evt.name);
+ evt.pkg = '';
+
+ var results = [];
+ var data = dojo.docs._cache['function_names'];
+ for(var key in data){
+ if(dojo.lang.inArray(data[key], evt.name)){
+ dojo.debug("_functionPackages() package: " + key);
+ results.push(key);
+ }
+ }
+
+ if(evt.callbacks && evt.callbacks.length){
+ evt.callbacks.shift()(type, results, evt, evt.input);
+ }
+ },
+ setUserName: function(/*String*/ name){
+ dojo.docs._userName = name;
+ if(name && dojo.docs._password){
+ dojo.docs._logIn();
+ }
+ },
+ setPassword: function(/*String*/ password){
+ dojo.docs._password = password;
+ if(password && dojo.docs._userName){
+ dojo.docs._logIn();
+ }
+ },
+ _logIn: function(){
+ dojo.io.bind({
+ url: dojo.docs._rpc.serviceUrl.toString(),
+ method: "post",
+ mimetype: "text/json",
+ content: {
+ username: dojo.docs._userName,
+ password: dojo.docs._password
+ },
+ load: function(type, data){
+ if(data.error){
+ dojo.docs.logInSuccess();
+ }else{
+ dojo.docs.logInFailure();
+ }
+ },
+ error: function(){
+ dojo.docs.logInFailure();
+ }
+ });
+ },
+ logInSuccess: function(){},
+ logInFailure: function(){},
+ _set: function(/*Object*/ base, /*String...*/ keys, /*String*/ value){
+ var args = [];
+ for(var i = 0, arg; arg = arguments[i]; i++){
+ args.push(arg);
+ }
+
+ if(args.length < 3) return;
+ base = args.shift();
+ value = args.pop();
+ var key = args.pop();
+ for(var i = 0, arg; arg = args[i]; i++){
+ if(typeof base[arg] != "object"){
+ base[arg] = {};
+ }
+ base = base[arg];
+ }
+ base[key] = value;
+ },
+ _getCache: function(/*String...*/ keys){
+ var obj = dojo.docs._cache;
+ for(var i = 0; i < arguments.length; i++){
+ var arg = arguments[i];
+ if(!obj[arg]){
+ obj[arg] = {};
+ }
+ obj = obj[arg];
+ }
+ return obj;
+ }
+});
+
+dojo.event.topic.subscribe("/docs/search", dojo.docs, "_onDocSearch");
+dojo.event.topic.subscribe("/docs/function/select", dojo.docs, "_onDocSelectFunction");
+dojo.event.topic.subscribe("/docs/package/select", dojo.docs, "_onDocSelectPackage");
+
+dojo.event.topic.registerPublisher("/docs/function/results", dojo.docs, "_printFunctionResults");
+dojo.event.topic.registerPublisher("/docs/function/detail", dojo.docs, "_printFunctionDetail");
+dojo.event.topic.registerPublisher("/docs/package/detail", dojo.docs, "_printPkgResult");
\ No newline at end of file
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dom.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dom.js?view=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dom.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/dom.js Thu Jan 11 14:35:53 2007
@@ -0,0 +1,560 @@
+/*
+ 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.dom");
+
+dojo.dom.ELEMENT_NODE = 1;
+dojo.dom.ATTRIBUTE_NODE = 2;
+dojo.dom.TEXT_NODE = 3;
+dojo.dom.CDATA_SECTION_NODE = 4;
+dojo.dom.ENTITY_REFERENCE_NODE = 5;
+dojo.dom.ENTITY_NODE = 6;
+dojo.dom.PROCESSING_INSTRUCTION_NODE = 7;
+dojo.dom.COMMENT_NODE = 8;
+dojo.dom.DOCUMENT_NODE = 9;
+dojo.dom.DOCUMENT_TYPE_NODE = 10;
+dojo.dom.DOCUMENT_FRAGMENT_NODE = 11;
+dojo.dom.NOTATION_NODE = 12;
+
+dojo.dom.dojoml = "http://www.dojotoolkit.org/2004/dojoml";
+
+/**
+ * comprehensive list of XML namespaces
+**/
+dojo.dom.xmlns = {
+ // summary
+ // aliases for various common XML namespaces
+ svg : "http://www.w3.org/2000/svg",
+ smil : "http://www.w3.org/2001/SMIL20/",
+ mml : "http://www.w3.org/1998/Math/MathML",
+ cml : "http://www.xml-cml.org",
+ xlink : "http://www.w3.org/1999/xlink",
+ xhtml : "http://www.w3.org/1999/xhtml",
+ xul : "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
+ xbl : "http://www.mozilla.org/xbl",
+ fo : "http://www.w3.org/1999/XSL/Format",
+ xsl : "http://www.w3.org/1999/XSL/Transform",
+ xslt : "http://www.w3.org/1999/XSL/Transform",
+ xi : "http://www.w3.org/2001/XInclude",
+ xforms : "http://www.w3.org/2002/01/xforms",
+ saxon : "http://icl.com/saxon",
+ xalan : "http://xml.apache.org/xslt",
+ xsd : "http://www.w3.org/2001/XMLSchema",
+ dt: "http://www.w3.org/2001/XMLSchema-datatypes",
+ xsi : "http://www.w3.org/2001/XMLSchema-instance",
+ rdf : "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
+ rdfs : "http://www.w3.org/2000/01/rdf-schema#",
+ dc : "http://purl.org/dc/elements/1.1/",
+ dcq: "http://purl.org/dc/qualifiers/1.0",
+ "soap-env" : "http://schemas.xmlsoap.org/soap/envelope/",
+ wsdl : "http://schemas.xmlsoap.org/wsdl/",
+ AdobeExtensions : "http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
+};
+
+dojo.dom.isNode = function(/* object */wh){
+ // summary:
+ // checks to see if wh is actually a node.
+ if(typeof Element == "function") {
+ try {
+ return wh instanceof Element; // boolean
+ } catch(e) {}
+ } else {
+ // best-guess
+ return wh && !isNaN(wh.nodeType); // boolean
+ }
+}
+
+dojo.dom.getUniqueId = function(){
+ // summary:
+ // returns a unique string for use with any DOM element
+ var _document = dojo.doc();
+ do {
+ var id = "dj_unique_" + (++arguments.callee._idIncrement);
+ }while(_document.getElementById(id));
+ return id; // string
+}
+dojo.dom.getUniqueId._idIncrement = 0;
+
+dojo.dom.firstElement = dojo.dom.getFirstChildElement = function(/* Element */parentNode, /* string? */tagName){
+ // summary:
+ // returns the first child element matching tagName
+ var node = parentNode.firstChild;
+ while(node && node.nodeType != dojo.dom.ELEMENT_NODE){
+ node = node.nextSibling;
+ }
+ if(tagName && node && node.tagName && node.tagName.toLowerCase() != tagName.toLowerCase()) {
+ node = dojo.dom.nextElement(node, tagName);
+ }
+ return node; // Element
+}
+
+dojo.dom.lastElement = dojo.dom.getLastChildElement = function(/* Element */parentNode, /* string? */tagName){
+ // summary:
+ // returns the last child element matching tagName
+ var node = parentNode.lastChild;
+ while(node && node.nodeType != dojo.dom.ELEMENT_NODE) {
+ node = node.previousSibling;
+ }
+ if(tagName && node && node.tagName && node.tagName.toLowerCase() != tagName.toLowerCase()) {
+ node = dojo.dom.prevElement(node, tagName);
+ }
+ return node; // Element
+}
+
+dojo.dom.nextElement = dojo.dom.getNextSiblingElement = function(/* Node */node, /* string? */tagName){
+ // summary:
+ // returns the next sibling element matching tagName
+ if(!node) { return null; }
+ do {
+ node = node.nextSibling;
+ } while(node && node.nodeType != dojo.dom.ELEMENT_NODE);
+
+ if(node && tagName && tagName.toLowerCase() != node.tagName.toLowerCase()) {
+ return dojo.dom.nextElement(node, tagName);
+ }
+ return node; // Element
+}
+
+dojo.dom.prevElement = dojo.dom.getPreviousSiblingElement = function(/* Node */node, /* string? */tagName){
+ // summary:
+ // returns the previous sibling element matching tagName
+ if(!node) { return null; }
+ if(tagName) { tagName = tagName.toLowerCase(); }
+ do {
+ node = node.previousSibling;
+ } while(node && node.nodeType != dojo.dom.ELEMENT_NODE);
+
+ if(node && tagName && tagName.toLowerCase() != node.tagName.toLowerCase()) {
+ return dojo.dom.prevElement(node, tagName);
+ }
+ return node; // Element
+}
+
+// TODO: hmph
+/*this.forEachChildTag = function(node, unaryFunc) {
+ var child = this.getFirstChildTag(node);
+ while(child) {
+ if(unaryFunc(child) == "break") { break; }
+ child = this.getNextSiblingTag(child);
+ }
+}*/
+
+dojo.dom.moveChildren = function(/*Element*/srcNode, /*Element*/destNode, /*boolean?*/trim){
+ // summary:
+ // Moves children from srcNode to destNode and returns the count of
+ // children moved; will trim off text nodes if trim == true
+ var count = 0;
+ if(trim) {
+ while(srcNode.hasChildNodes() &&
+ srcNode.firstChild.nodeType == dojo.dom.TEXT_NODE) {
+ srcNode.removeChild(srcNode.firstChild);
+ }
+ while(srcNode.hasChildNodes() &&
+ srcNode.lastChild.nodeType == dojo.dom.TEXT_NODE) {
+ srcNode.removeChild(srcNode.lastChild);
+ }
+ }
+ while(srcNode.hasChildNodes()){
+ destNode.appendChild(srcNode.firstChild);
+ count++;
+ }
+ return count; // number
+}
+
+dojo.dom.copyChildren = function(/*Element*/srcNode, /*Element*/destNode, /*boolean?*/trim){
+ // summary:
+ // Copies children from srcNde to destNode and returns the count of
+ // children copied; will trim off text nodes if trim == true
+ var clonedNode = srcNode.cloneNode(true);
+ return this.moveChildren(clonedNode, destNode, trim); // number
+}
+
+dojo.dom.replaceChildren = function(/*Element*/node, /*Node*/newChild){
+ // summary:
+ // Removes all children of node and appends newChild. All the existing
+ // children will be destroyed.
+ // FIXME: what if newChild is an array-like object?
+ var nodes = [];
+ if(dojo.render.html.ie){
+ for(var i=0;i<node.childNodes.length;i++){
+ nodes.push(node.childNodes[i]);
+ }
+ }
+ dojo.dom.removeChildren(node);
+ node.appendChild(newChild);
+ for(var i=0;i<nodes.length;i++){
+ dojo.dom.destroyNode(nodes[i]);
+ }
+}
+
+dojo.dom.removeChildren = function(/*Element*/node){
+ // summary:
+ // removes all children from node and returns the count of children removed.
+ // The children nodes are not destroyed. Be sure to call destroyNode on them
+ // after they are not used anymore.
+ var count = node.childNodes.length;
+ while(node.hasChildNodes()){ dojo.dom.removeNode(node.firstChild); }
+ return count; // int
+}
+
+dojo.dom.replaceNode = function(/*Element*/node, /*Element*/newNode){
+ // summary:
+ // replaces node with newNode and returns a reference to the removed node.
+ // To prevent IE memory leak, call destroyNode on the returned node when
+ // it is no longer needed.
+ return node.parentNode.replaceChild(newNode, node); // Node
+}
+
+dojo.dom.destroyNode = function(/*Node*/node){
+ // summary:
+ // destroy a node (it can not be used any more). For IE, this is the
+ // right function to call to prevent memory leaks. While for other
+ // browsers, this is identical to dojo.dom.removeNode
+ if(node.parentNode){
+ node = dojo.dom.removeNode(node);
+ }
+ if(node.nodeType != 3){ // ingore TEXT_NODE
+ if(dojo.evalObjPath("dojo.event.browser.clean", false)){
+ dojo.event.browser.clean(node);
+ }
+ if(dojo.render.html.ie){
+ node.outerHTML=''; //prevent ugly IE mem leak associated with Node.removeChild (ticket #1727)
+ }
+ }
+}
+
+dojo.dom.removeNode = function(/*Node*/node){
+ // summary:
+ // if node has a parent, removes node from parent and returns a
+ // reference to the removed child.
+ // To prevent IE memory leak, call destroyNode on the returned node when
+ // it is no longer needed.
+ // node:
+ // the node to remove from its parent.
+
+ if(node && node.parentNode){
+ // return a ref to the removed child
+ return node.parentNode.removeChild(node); //Node
+ }
+}
+
+dojo.dom.getAncestors = function(/*Node*/node, /*function?*/filterFunction, /*boolean?*/returnFirstHit){
+ // summary:
+ // returns all ancestors matching optional filterFunction; will return
+ // only the first if returnFirstHit
+ var ancestors = [];
+ var isFunction = (filterFunction && (filterFunction instanceof Function || typeof filterFunction == "function"));
+ while(node){
+ if(!isFunction || filterFunction(node)){
+ ancestors.push(node);
+ }
+ if(returnFirstHit && ancestors.length > 0){
+ return ancestors[0]; // Node
+ }
+
+ node = node.parentNode;
+ }
+ if(returnFirstHit){ return null; }
+ return ancestors; // array
+}
+
+dojo.dom.getAncestorsByTag = function(/*Node*/node, /*String*/tag, /*boolean?*/returnFirstHit){
+ // summary:
+ // returns all ancestors matching tag (as tagName), will only return
+ // first one if returnFirstHit
+ tag = tag.toLowerCase();
+ return dojo.dom.getAncestors(node, function(el){
+ return ((el.tagName)&&(el.tagName.toLowerCase() == tag));
+ }, returnFirstHit); // Node || array
+}
+
+dojo.dom.getFirstAncestorByTag = function(/*Node*/node, /*string*/tag){
+ // summary:
+ // Returns first ancestor of node with tag tagName
+ return dojo.dom.getAncestorsByTag(node, tag, true); // Node
+}
+
+dojo.dom.isDescendantOf = function(/* Node */node, /* Node */ancestor, /* boolean? */guaranteeDescendant){
+ // summary
+ // Returns boolean if node is a descendant of ancestor
+ // guaranteeDescendant allows us to be a "true" isDescendantOf function
+ if(guaranteeDescendant && node) { node = node.parentNode; }
+ while(node) {
+ if(node == ancestor){
+ return true; // boolean
+ }
+ node = node.parentNode;
+ }
+ return false; // boolean
+}
+
+dojo.dom.innerXML = function(/*Node*/node){
+ // summary:
+ // Implementation of MS's innerXML function.
+ if(node.innerXML){
+ return node.innerXML; // string
+ }else if (node.xml){
+ return node.xml; // string
+ }else if(typeof XMLSerializer != "undefined"){
+ return (new XMLSerializer()).serializeToString(node); // string
+ }
+}
+
+dojo.dom.createDocument = function(){
+ // summary:
+ // cross-browser implementation of creating an XML document object.
+ var doc = null;
+ var _document = dojo.doc();
+
+ if(!dj_undef("ActiveXObject")){
+ var prefixes = [ "MSXML2", "Microsoft", "MSXML", "MSXML3" ];
+ for(var i = 0; i<prefixes.length; i++){
+ try{
+ doc = new ActiveXObject(prefixes[i]+".XMLDOM");
+ }catch(e){ /* squelch */ };
+
+ if(doc){ break; }
+ }
+ }else if((_document.implementation)&&
+ (_document.implementation.createDocument)){
+ doc = _document.implementation.createDocument("", "", null);
+ }
+
+ return doc; // DOMDocument
+}
+
+dojo.dom.createDocumentFromText = function(/*string*/str, /*string?*/mimetype){
+ // summary:
+ // attempts to create a Document object based on optional mime-type,
+ // using str as the contents of the document
+ if(!mimetype){ mimetype = "text/xml"; }
+ if(!dj_undef("DOMParser")){
+ var parser = new DOMParser();
+ return parser.parseFromString(str, mimetype); // DOMDocument
+ }else if(!dj_undef("ActiveXObject")){
+ var domDoc = dojo.dom.createDocument();
+ if(domDoc){
+ domDoc.async = false;
+ domDoc.loadXML(str);
+ return domDoc; // DOMDocument
+ }else{
+ dojo.debug("toXml didn't work?");
+ }
+ /*
+ }else if((dojo.render.html.capable)&&(dojo.render.html.safari)){
+ // FIXME: this doesn't appear to work!
+ // from: http://web-graphics.com/mtarchive/001606.php
+ // var xml = '<?xml version="1.0"?>'+str;
+ var mtype = "text/xml";
+ var xml = '<?xml version="1.0"?>'+str;
+ var url = "data:"+mtype+";charset=utf-8,"+encodeURIComponent(xml);
+ var req = new XMLHttpRequest();
+ req.open("GET", url, false);
+ req.overrideMimeType(mtype);
+ req.send(null);
+ return req.responseXML;
+ */
+ }else{
+ var _document = dojo.doc();
+ if(_document.createElement){
+ // FIXME: this may change all tags to uppercase!
+ var tmp = _document.createElement("xml");
+ tmp.innerHTML = str;
+ if(_document.implementation && _document.implementation.createDocument){
+ var xmlDoc = _document.implementation.createDocument("foo", "", null);
+ for(var i = 0; i < tmp.childNodes.length; i++) {
+ xmlDoc.importNode(tmp.childNodes.item(i), true);
+ }
+ return xmlDoc; // DOMDocument
+ }
+ // FIXME: probably not a good idea to have to return an HTML fragment
+ // FIXME: the tmp.doc.firstChild is as tested from IE, so it may not
+ // work that way across the board
+ return ((tmp.document)&&
+ (tmp.document.firstChild ? tmp.document.firstChild : tmp)); // DOMDocument
+ }
+ }
+ return null;
+}
+
+dojo.dom.prependChild = function(/*Element*/node, /*Element*/parent){
+ // summary:
+ // prepends node to parent's children nodes
+ if(parent.firstChild) {
+ parent.insertBefore(node, parent.firstChild);
+ } else {
+ parent.appendChild(node);
+ }
+ return true; // boolean
+}
+
+dojo.dom.insertBefore = function(/*Node*/node, /*Node*/ref, /*boolean?*/force){
+ // summary:
+ // Try to insert node before ref
+ if( (force != true)&&
+ (node === ref || node.nextSibling === ref)){ return false; }
+ var parent = ref.parentNode;
+ parent.insertBefore(node, ref);
+ return true; // boolean
+}
+
+dojo.dom.insertAfter = function(/*Node*/node, /*Node*/ref, /*boolean?*/force){
+ // summary:
+ // Try to insert node after ref
+ var pn = ref.parentNode;
+ if(ref == pn.lastChild){
+ if((force != true)&&(node === ref)){
+ return false; // boolean
+ }
+ pn.appendChild(node);
+ }else{
+ return this.insertBefore(node, ref.nextSibling, force); // boolean
+ }
+ return true; // boolean
+}
+
+dojo.dom.insertAtPosition = function(/*Node*/node, /*Node*/ref, /*string*/position){
+ // summary:
+ // attempt to insert node in relation to ref based on position
+ if((!node)||(!ref)||(!position)){
+ return false; // boolean
+ }
+ switch(position.toLowerCase()){
+ case "before":
+ return dojo.dom.insertBefore(node, ref); // boolean
+ case "after":
+ return dojo.dom.insertAfter(node, ref); // boolean
+ case "first":
+ if(ref.firstChild){
+ return dojo.dom.insertBefore(node, ref.firstChild); // boolean
+ }else{
+ ref.appendChild(node);
+ return true; // boolean
+ }
+ break;
+ default: // aka: last
+ ref.appendChild(node);
+ return true; // boolean
+ }
+}
+
+dojo.dom.insertAtIndex = function(/*Node*/node, /*Element*/containingNode, /*number*/insertionIndex){
+ // summary:
+ // insert node into child nodes nodelist of containingNode at
+ // insertionIndex. insertionIndex should be between 0 and
+ // the number of the childNodes in containingNode. insertionIndex
+ // specifys after how many childNodes in containingNode the node
+ // shall be inserted. If 0 is given, node will be appended to
+ // containingNode.
+ var siblingNodes = containingNode.childNodes;
+
+ // if there aren't any kids yet, just add it to the beginning
+
+ if (!siblingNodes.length || siblingNodes.length == insertionIndex){
+ containingNode.appendChild(node);
+ return true; // boolean
+ }
+
+ if(insertionIndex == 0){
+ return dojo.dom.prependChild(node, containingNode); // boolean
+ }
+ // otherwise we need to walk the childNodes
+ // and find our spot
+
+ return dojo.dom.insertAfter(node, siblingNodes[insertionIndex-1]); // boolean
+}
+
+dojo.dom.textContent = function(/*Node*/node, /*string*/text){
+ // summary:
+ // implementation of the DOM Level 3 attribute; scan node for text
+ if (arguments.length>1) {
+ var _document = dojo.doc();
+ dojo.dom.replaceChildren(node, _document.createTextNode(text));
+ return text; // string
+ } else {
+ if(node.textContent != undefined){ //FF 1.5
+ return node.textContent; // string
+ }
+ var _result = "";
+ if (node == null) { return _result; }
+ for (var i = 0; i < node.childNodes.length; i++) {
+ switch (node.childNodes[i].nodeType) {
+ case 1: // ELEMENT_NODE
+ case 5: // ENTITY_REFERENCE_NODE
+ _result += dojo.dom.textContent(node.childNodes[i]);
+ break;
+ case 3: // TEXT_NODE
+ case 2: // ATTRIBUTE_NODE
+ case 4: // CDATA_SECTION_NODE
+ _result += node.childNodes[i].nodeValue;
+ break;
+ default:
+ break;
+ }
+ }
+ return _result; // string
+ }
+}
+
+dojo.dom.hasParent = function(/*Node*/node){
+ // summary:
+ // returns whether or not node is a child of another node.
+ return Boolean(node && node.parentNode && dojo.dom.isNode(node.parentNode)); // boolean
+}
+
+/**
+ * Examples:
+ *
+ * myFooNode = <foo />
+ * isTag(myFooNode, "foo"); // returns "foo"
+ * isTag(myFooNode, "bar"); // returns ""
+ * isTag(myFooNode, "FOO"); // returns ""
+ * isTag(myFooNode, "hey", "foo", "bar"); // returns "foo"
+**/
+dojo.dom.isTag = function(/* Node */node /* ... */){
+ // summary:
+ // determines if node has any of the provided tag names and returns
+ // the tag name that matches, empty string otherwise.
+ if(node && node.tagName) {
+ for(var i=1; i<arguments.length; i++){
+ if(node.tagName==String(arguments[i])){
+ return String(arguments[i]); // string
+ }
+ }
+ }
+ return ""; // string
+}
+
+dojo.dom.setAttributeNS = function( /*Element*/elem, /*string*/namespaceURI,
+ /*string*/attrName, /*string*/attrValue){
+ // summary:
+ // implementation of DOM2 setAttributeNS that works cross browser.
+ if(elem == null || ((elem == undefined)&&(typeof elem == "undefined"))){
+ dojo.raise("No element given to dojo.dom.setAttributeNS");
+ }
+
+ if(!((elem.setAttributeNS == undefined)&&(typeof elem.setAttributeNS == "undefined"))){ // w3c
+ elem.setAttributeNS(namespaceURI, attrName, attrValue);
+ }else{ // IE
+ // get a root XML document
+ var ownerDoc = elem.ownerDocument;
+ var attribute = ownerDoc.createNode(
+ 2, // node type
+ attrName,
+ namespaceURI
+ );
+
+ // set value
+ attribute.nodeValue = attrValue;
+
+ // attach to element
+ elem.setAttributeNode(attribute);
+ }
+}
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/event.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/event.js?view=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/event.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/event.js Thu Jan 11 14:35:53 2007
@@ -0,0 +1,14 @@
+/*
+ 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");
+
+dojo.require("dojo.event.*");
+dojo.deprecated("dojo.event", "replaced by dojo.event.*", "0.5");