/*
Copyright (c) 2007, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
version: 2.3.0
*/
/**
* The drag and drop utility provides a framework for building drag and drop
* applications. In addition to enabling drag and drop for specific elements,
* the drag and drop elements are tracked by the manager class, and the
* interactions between the various elements are tracked during the drag and
* the implementing code is notified about these important moments.
* @module dragdrop
* @title Drag and Drop
* @requires yahoo,dom,event
* @namespace YAHOO.util
*/
// Only load the library once. Rewriting the manager class would orphan
// existing drag and drop instances.
/**
* DragDropMgr is a singleton that tracks the element interaction for
* all DragDrop items in the window. Generally, you will not call
* this class directly, but it does have helper methods that could
* be useful in your DragDrop implementations.
* @class DragDropMgr
* @static
*/
return {
/**
* Two dimensional Array of registered DragDrop objects. The first
* dimension is the DragDrop item group, the second the DragDrop
* object.
* @property ids
* @type {string: string}
* @private
* @static
*/
ids: {},
/**
* Array of element ids defined as drag handles. Used to determine
* if the element that generated the mousedown event is actually the
* handle and not the html element itself.
* @property handleIds
* @type {string: string}
* @private
* @static
*/
handleIds: {},
/**
* the DragDrop object that is currently being dragged
* @property dragCurrent
* @type DragDrop
* @private
* @static
**/
dragCurrent: null,
/**
* the DragDrop object(s) that are being hovered over
* @property dragOvers
* @type Array
* @private
* @static
*/
dragOvers: {},
/**
* the X distance between the cursor and the object being dragged
* @property deltaX
* @type int
* @private
* @static
*/
deltaX: 0,
/**
* the Y distance between the cursor and the object being dragged
* @property deltaY
* @type int
* @private
* @static
*/
deltaY: 0,
/**
* Flag to determine if we should prevent the default behavior of the
* events we define. By default this is true, but this can be set to
* false if you need the default behavior (not recommended)
* @property preventDefault
* @type boolean
* @static
*/
preventDefault: true,
/**
* Flag to determine if we should stop the propagation of the events
* we generate. This is true by default but you may want to set it to
* false if the html element contains other features that require the
* mouse click.
* @property stopPropagation
* @type boolean
* @static
*/
stopPropagation: true,
/**
* Internal flag that is set to true when drag and drop has been
* initialized
* @property initialized
* @private
* @static
*/
initialized: false,
/**
* All drag and drop can be disabled.
* @property locked
* @private
* @static
*/
locked: false,
/**
* Provides additional information about the the current set of
* interactions. Can be accessed from the event handlers. It
* contains the following properties:
*
* out: onDragOut interactions
* enter: onDragEnter interactions
* over: onDragOver interactions
* drop: onDragDrop interactions
* point: The location of the cursor
* draggedRegion: The location of dragged element at the time
* of the interaction
* sourceRegion: The location of the source elemtn at the time
* of the interaction
* validDrop: boolean
* @property interactionInfo
* @type object
* @static
*/
interactionInfo: null,
/**
* Called the first time an element is registered.
* @method init
* @private
* @static
*/
init: function() {
this.initialized = true;
},
/**
* In point mode, drag and drop interaction is defined by the
* @property POINT
* @type int
* @static
* @final
*/
POINT: 0,
/**
* In intersect mode, drag and drop interaction is defined by the
* cursor position or the amount of overlap of two or more drag and
* drop objects.
* @property INTERSECT
* @type int
* @static
* @final
*/
INTERSECT: 1,
/**
* In intersect mode, drag and drop interaction is defined only by the
* overlap of two or more drag and drop objects.
* @property STRICT_INTERSECT
* @type int
* @static
* @final
*/
STRICT_INTERSECT: 2,
/**
* The current drag and drop mode. Default: POINT
* @property mode
* @type int
* @static
*/
mode: 0,
/**
* Runs method on all drag and drop objects
* @method _execOnAll
* @private
* @static
*/
for (var i in this.ids) {
for (var j in this.ids[i]) {
if (! this.isTypeOfDD(oDD)) {
continue;
}
}
}
},
/**
* Drag and drop initialization. Sets up the global event handlers
* @method _onLoad
* @private
* @static
*/
_onLoad: function() {
this.init();
// Event.on(window, "mouseout", this._test);
},
/**
* Reset constraints on all drag and drop objs
* @method _onResize
* @private
* @static
*/
_onResize: function(e) {
this._execOnAll("resetConstraints", []);
},
/**
* Lock all drag and drop functionality
* @method lock
* @static
*/
/**
* Unlock all drag and drop functionality
* @method unlock
* @static
*/
/**
* Is drag and drop locked?
* @method isLocked
* @return {boolean} True if drag and drop is locked, false otherwise.
* @static
*/
/**
* Location cache that is set for all drag drop objects when a drag is
* initiated, cleared when the drag is finished.
* @property locationCache
* @private
* @static
*/
locationCache: {},
/**
* Set useCache to false if you want to force object the lookup of each
* drag and drop linked element constantly during a drag.
* @property useCache
* @type boolean
* @static
*/
useCache: true,
/**
* The number of pixels that the mouse needs to move after the
* mousedown before the drag is initiated. Default=3;
* @property clickPixelThresh
* @type int
* @static
*/
clickPixelThresh: 3,
/**
* The number of milliseconds after the mousedown event to initiate the
* drag if we don't get a mouseup event. Default=1000
* @property clickTimeThresh
* @type int
* @static
*/
clickTimeThresh: 1000,
/**
* Flag that indicates that either the drag pixel threshold or the
* mousdown time threshold has been met
* @property dragThreshMet
* @type boolean
* @private
* @static
*/
dragThreshMet: false,
/**
* Timeout used for the click time threshold
* @property clickTimeout
* @type Object
* @private
* @static
*/
clickTimeout: null,
/**
* The X position of the mousedown event stored for later use when a
* drag threshold is met.
* @property startX
* @type int
* @private
* @static
*/
startX: 0,
/**
* The Y position of the mousedown event stored for later use when a
* drag threshold is met.
* @property startY
* @type int
* @private
* @static
*/
startY: 0,
/**
* Each DragDrop instance must be registered with the DragDropMgr.
* This is executed in DragDrop.init()
* @method regDragDrop
* @param {DragDrop} oDD the DragDrop object to register
* @param {String} sGroup the name of the group this element belongs to
* @static
*/
if (!this.initialized) { this.init(); }
}
},
/**
* Removes the supplied dd instance from the supplied group. Executed
* by DragDrop.removeFromGroup, so don't call this function directly.
* @method removeDDFromGroup
* @private
* @static
*/
}
}
},
/**
* Unregisters a drag and drop item. This is executed in
* DragDrop.unreg, use that method instead of calling this directly.
* @method _remove
* @private
* @static
*/
//YAHOO.log("NEW LEN " + this.ids.length, "warn");
}
}
},
/**
* Each DragDrop handle element must be registered. This is done
* automatically when executing DragDrop.setHandleElId()
* @method regHandle
* @param {String} sDDId the DragDrop id this element is a handle for
* @param {String} sHandleId the id of the element that is the drag
* handle
* @static
*/
}
},
/**
* Utility function to determine if a given element has been
* registered as a drag drop item.
* @method isDragDrop
* @param {String} id the element id to check
* @return {boolean} true if this element is a DragDrop item,
* false otherwise
* @static
*/
isDragDrop: function(id) {
},
/**
* Returns the drag and drop instances that are in all groups the
* passed in instance belongs to.
* @method getRelated
* @param {DragDrop} p_oDD the obj to get related data for
* @param {boolean} bTargetsOnly if true, only return targetable objs
* @return {DragDrop[]} the related instances
* @static
*/
var oDDs = [];
for (j in this.ids[i]) {
if (! this.isTypeOfDD(dd)) {
continue;
}
}
}
}
return oDDs;
},
/**
* Returns true if the specified dd target is a legal target for
* the specifice drag obj
* @method isLegalTarget
* @param {DragDrop} the drag obj
* @param {DragDrop} the target
* @return {boolean} true if the target is a legal target for the
* dd obj
* @static
*/
return true;
}
}
return false;
},
/**
* My goal is to be able to transparently determine if an object is
* typeof DragDrop, and the exact subclass of DragDrop. typeof
* returns "object", oDD.constructor.toString() always returns
* "DragDrop" and not the name of the subclass. So for now it just
* evaluates a well-known variable in DragDrop.
* @method isTypeOfDD
* @param {Object} the object to evaluate
* @return {boolean} true if typeof oDD = DragDrop
* @static
*/
isTypeOfDD: function (oDD) {
},
/**
* Utility function to determine if a given element has been
* registered as a drag drop handle for the given Drag Drop object.
* @method isHandle
* @param {String} id the element id to check
* @return {boolean} true if this element is a DragDrop handle, false
* otherwise
* @static
*/
},
/**
* Returns the DragDrop instance for a given id
* @method getDDById
* @param {String} id the id of the DragDrop object
* @return {DragDrop} the drag drop object, null if it is not found
* @static
*/
for (var i in this.ids) {
}
}
return null;
},
/**
* Fired after a registered DragDrop object gets the mousedown event.
* Sets up the events required to track the object being dragged
* @method handleMouseDown
* @param {Event} e the event
* @param oDD the DragDrop object being dragged
* @private
* @static
*/
handleMouseDown: function(e, oDD) {
this.dragCurrent = oDD;
// track start position
this.dragThreshMet = false;
this.clickTimeout = setTimeout(
function() {
},
this.clickTimeThresh );
},
/**
* Fired when either the drag pixel threshol or the mousedown hold
* time threshold has been met.
* @method startDrag
* @param x {int} the X position of the original mousedown
* @param y {int} the Y position of the original mousedown
* @static
*/
startDrag: function(x, y) {
clearTimeout(this.clickTimeout);
var dc = this.dragCurrent;
if (dc) {
dc.b4StartDrag(x, y);
}
if (dc) {
}
this.dragThreshMet = true;
},
/**
* Internal function to handle the mouseup event. Will be invoked
* from the context of the document.
* @method handleMouseUp
* @param {Event} e the event
* @private
* @static
*/
handleMouseUp: function(e) {
if (this.dragCurrent) {
clearTimeout(this.clickTimeout);
if (this.dragThreshMet) {
this.fireEvents(e, true);
} else {
}
this.stopDrag(e);
this.stopEvent(e);
}
},
/**
* Utility to stop event propagation and event default, if these
* features are turned on.
* @method stopEvent
* @param {Event} e the event as returned by this.getEvent()
* @static
*/
stopEvent: function(e) {
if (this.stopPropagation) {
}
if (this.preventDefault) {
}
},
/**
* Ends the current drag, cleans up the state, and fires the endDrag
* and mouseUp events. Called internally when a mouseup is detected
* during the drag. Can be fired manually during the drag by passing
* either another event (such as the mousemove event received in onDrag)
* or a fake event with pageX and pageY defined (so that endDrag and
* onMouseUp have usable position data.). Alternatively, pass true
* for the silent parameter so that the endDrag and onMouseUp events
* are skipped (so no event data is needed.)
*
* @method stopDrag
* @param {Event} e the mouseup event, another event (or a fake event)
* with pageX and pageY defined, or nothing if the
* silent parameter is true
* @param {boolean} silent skips the enddrag and mouseup events if true
* @static
*/
// YAHOO.log("mouseup - removing event handlers");
// Fire the drag end event for the item that was dragged
if (this.dragCurrent && !silent) {
if (this.dragThreshMet) {
this.dragCurrent.b4EndDrag(e);
this.dragCurrent.endDrag(e);
}
this.dragCurrent.onMouseUp(e);
}
this.dragCurrent = null;
this.dragOvers = {};
},
/**
* Internal function to handle the mousemove event. Will be invoked
* from the context of the html element.
*
* @TODO figure out what we can do about mouse events lost when the
* user drags objects beyond the window boundary. Currently we can
* detect this in internet explorer by verifying that the mouse is
* down during the mousemove event. Firefox doesn't give us the
* button state on the mousemove event.
* @method handleMouseMove
* @param {Event} e the event
* @private
* @static
*/
handleMouseMove: function(e) {
//YAHOO.log("handlemousemove");
var dc = this.dragCurrent;
if (dc) {
// YAHOO.log("no current drag obj");
// var button = e.which || e.button;
// YAHOO.log("which: " + e.which + ", button: "+ e.button);
// check for IE mouseup outside of page boundary
this.stopEvent(e);
return this.handleMouseUp(e);
}
if (!this.dragThreshMet) {
// YAHOO.log("diffX: " + diffX + "diffY: " + diffY);
if (diffX > this.clickPixelThresh ||
diffY > this.clickPixelThresh) {
}
}
if (this.dragThreshMet) {
if (dc) {
}
if (dc) {
this.fireEvents(e, false);
}
}
this.stopEvent(e);
}
},
/**
* Iterates over all of the DragDrop elements to find ones we are
* hovering over or dropping on
* @method fireEvents
* @param {Event} e the event
* @param {boolean} isDrop is this a drop op or a mouseover op?
* @private
* @static
*/
fireEvents: function(e, isDrop) {
var dc = this.dragCurrent;
// If the user did the mouse up outside of the window, we could
// get here even though we have ended the drag.
return;
}
pos.x );
// cache the previous dragOver array
var oldOvers = [];
var outEvts = [];
var overEvts = [];
var dropEvts = [];
var enterEvts = [];
// Check to see if the object(s) we were hovering over is no longer
// being hovered over so we can fire the onDragOut event
for (var i in this.dragOvers) {
if (! this.isTypeOfDD(ddo)) {
continue;
}
}
oldOvers[i] = true;
delete this.dragOvers[i];
}
// YAHOO.log("Processing group " + sGroup);
if ("string" != typeof sGroup) {
continue;
}
if (! this.isTypeOfDD(oDD)) {
continue;
}
// look for drop interactions
if (isDrop) {
// look for drag enter and drag over interactions
} else {
// initial drag over: dragEnter fires
// subsequent drag overs: dragOver fires
} else {
}
}
}
}
}
}
this.interactionInfo = {
};
// notify about a drop that did not find a target
this.interactionInfo.validDrop = false;
dc.onInvalidDrop(e);
}
if (this.mode) {
if (dc) {
}
}
if (dc) {
}
}
if (dc) {
}
if (dc) {
}
}
if (dc) {
}
if (dc) {
}
}
} else {
// fire dragout events
var len = 0;
if (dc) {
}
if (dc) {
}
}
// fire enter events
// dc.b4DragEnter(e, oDD.id);
if (dc) {
}
}
// fire over events
if (dc) {
}
if (dc) {
}
}
// fire drop events
if (dc) {
}
if (dc) {
}
}
}
},
/**
* Helper function for getting the best match from the list of drag
* and drop objects returned by the drag and drop events when we are
* in INTERSECT mode. It returns either the first object that the
* cursor is over, or the object that has the greatest overlap with
* the dragged element.
* @method getBestMatch
* @param {DragDrop[]} dds The array of drag and drop objects
* targeted
* @return {DragDrop} The best single match
* @static
*/
getBestMatch: function(dds) {
var winner = null;
if (len == 1) {
} else {
// Loop through the targeted items
for (var i=0; i<len; ++i) {
// If the cursor is over the object, it wins. If the
// cursor is over multiple matches, the first one we come
// to wins.
break;
// Otherwise the object with the most overlap wins
} else {
}
}
}
}
return winner;
},
/**
* Refreshes the cache of the top-left and bottom-right points of the
* drag and drop objects in the specified group(s). This is in the
* format that is stored in the drag and drop instance, so typical
* usage is:
* <code>
* YAHOO.util.DragDropMgr.refreshCache(ddinstance.groups);
* </code>
* Alternatively:
* <code>
* YAHOO.util.DragDropMgr.refreshCache({group1:true, group2:true});
* </code>
* @TODO this really should be an indexed array. Alternatively this
* method could accept both.
* @method refreshCache
* @param {Object} groups an associative array of groups to refresh
* @static
*/
refreshCache: function(groups) {
// refresh everything if group array is not provided
for (var sGroup in g) {
if ("string" != typeof sGroup) {
continue;
}
if (this.isTypeOfDD(oDD)) {
if (loc) {
} else {
}
}
}
}
},
/**
* This checks to make sure an element exists and is in the DOM. The
* main purpose is to handle cases where innerHTML is used to remove
* drag and drop objects from the DOM. IE provides an 'unspecified
* error' when trying to access the offsetParent of such an element
* @method verifyEl
* @param {HTMLElement} el the element to check
* @return {boolean} true if the element looks usable
* @static
*/
try {
if (el) {
if (parent) {
return true;
}
}
} catch(e) {
}
return false;
},
/**
* Returns a Region object containing the drag and drop element's position
* and size, including the padding configured for it
* @method getLocation
* @param {DragDrop} oDD the drag and drop object to get the
* location for
* @return {YAHOO.util.Region} a Region object representing the total area
* the element occupies, including any padding
* the instance is configured for.
* @static
*/
getLocation: function(oDD) {
if (! this.isTypeOfDD(oDD)) {
return null;
}
try {
} catch (e) { }
if (!pos) {
return null;
}
},
/**
* Checks the cursor location to see if it over the target
* @method isOverTarget
* @param {YAHOO.util.Point} pt The point to evaluate
* @param {DragDrop} oTarget the DragDrop object we are inspecting
* @param {boolean} intersect true if we are in intersect mode
* @param {YAHOO.util.Region} pre-cached location of the dragged element
* @return {boolean} true if the mouse is over the target
* @private
* @static
*/
// use cache if available
}
if (!loc) {
return false;
}
//YAHOO.log("loc: " + loc + ", pt: " + pt);
// DragDrop is using this as a sanity check for the initial mousedown
// in this case we are done. In POINT mode, if the drag obj has no
// contraints, we are done. Otherwise we need to evaluate the
// region the target as occupies to determine if the dragged element
// overlaps with it.
var dc = this.dragCurrent;
//if (oTarget.cursorIsOver) {
//YAHOO.log("over " + oTarget + ", " + loc + ", " + pt, "warn");
//}
return oTarget.cursorIsOver;
}
// Get the current location of the drag element, this is the
// location of the mouse event less the delta that represents
// where the original mousedown happened on the element. We
// need to consider constraints and ticks as well.
if (!curRegion) {
pos.x );
}
if (overlap) {
} else {
return false;
}
},
/**
* unload event handler
* @method _onUnload
* @private
* @static
*/
this.unregAll();
},
/**
* Cleans up the drag and drop events and objects.
* @method unregAll
* @private
* @static
*/
unregAll: function() {
if (this.dragCurrent) {
this.stopDrag();
this.dragCurrent = null;
}
this._execOnAll("unreg", []);
for (i in this.elementCache) {
delete this.elementCache[i];
}
this.elementCache = {};
this.ids = {};
},
/**
* A cache of DOM elements
* @property elementCache
* @private
* @static
*/
elementCache: {},
/**
* Get the wrapper for the DOM element specified
* @method getElWrapper
* @param {String} id the id of the element to get
* @return {YAHOO.util.DDM.ElementWrapper} the wrapped element
* @private
* @deprecated This wrapper isn't that useful
* @static
*/
getElWrapper: function(id) {
}
return oWrapper;
},
/**
* Returns the actual DOM element
* @method getElement
* @param {String} id the id of the elment to get
* @return {Object} The element
* @deprecated use YAHOO.util.Dom.get instead
* @static
*/
getElement: function(id) {
},
/**
* Returns the style property for the DOM element (i.e.,
* document.getElById(id).style)
* @method getCss
* @param {String} id the id of the elment to get
* @return {Object} The style property of the element
* @deprecated use YAHOO.util.Dom instead
* @static
*/
},
/**
* Inner class for cached elements
* @class DragDropMgr.ElementWrapper
* @for DragDropMgr
* @private
* @deprecated
*/
ElementWrapper: function(el) {
/**
* The element
* @property el
*/
/**
* The element id
* @property id
*/
/**
* A reference to the style property
* @property css
*/
},
/**
* Returns the X position of an html element
* @method getPosX
* @param el the element for which to get the position
* @return {int} the X coordinate
* @for DragDropMgr
* @deprecated use YAHOO.util.Dom.getX instead
* @static
*/
},
/**
* Returns the Y position of an html element
* @method getPosY
* @param el the element for which to get the position
* @return {int} the Y coordinate
* @deprecated use YAHOO.util.Dom.getY instead
* @static
*/
},
/**
* Swap two nodes. In IE, we use the native method, for others we
* emulate the IE behavior
* @method swapNode
* @param n1 the first node to swap
* @param n2 the other node to swap
* @static
*/
} else {
var p = n2.parentNode;
var s = n2.nextSibling;
if (s == n1) {
} else {
p.insertBefore(n1, s);
}
}
},
/**
* Returns the current scroll position
* @method getScroll
* @private
* @static
*/
getScroll: function () {
l = dde.scrollLeft;
} else if (db) {
l = db.scrollLeft;
} else {
}
},
/**
* Returns the specified element style property
* @method getStyle
* @param {HTMLElement} el the element
* @param {string} styleProp the style property
* @return {string} The value of the style property
* @deprecated use YAHOO.util.Dom.getStyle
* @static
*/
},
/**
* Gets the scrollTop
* @method getScrollTop
* @return {int} the document's scrollTop
* @static
*/
/**
* Gets the scrollLeft
* @method getScrollLeft
* @return {int} the document's scrollTop
* @static
*/
/**
* Sets the x/y position of an element to the location of the
* target element.
* @method moveToEl
* @param {HTMLElement} moveEl The element to move
* @param {HTMLElement} targetEl The position reference element
* @static
*/
},
/**
* Gets the client height
* @method getClientHeight
* @return {int} client height in px
* @deprecated use YAHOO.util.Dom.getViewportHeight instead
* @static
*/
getClientHeight: function() {
},
/**
* Gets the client width
* @method getClientWidth
* @return {int} client width in px
* @deprecated use YAHOO.util.Dom.getViewportWidth instead
* @static
*/
getClientWidth: function() {
},
/**
* Numeric array sort function
* @method numericSort
* @static
*/
numericSort: function(a, b) { return (a - b); },
/**
* Internal counter
* @property _timeoutCount
* @private
* @static
*/
_timeoutCount: 0,
/**
* Trying to make the load order less important. Without this we get
* an error if this file is loaded before the Event Utility.
* @method _addListeners
* @private
* @static
*/
_addListeners: function() {
} else {
} else {
}
}
}
},
/**
* Recursively searches the immediate parent and all child nodes for
* the handle element in order to determine wheter or not it was
* clicked.
* @method handleWasClicked
* @param node the html element to inspect
* @static
*/
return true;
} else {
// check to see if this is a text node child of the one we want
var p = node.parentNode;
// YAHOO.log("p: " + p);
while (p) {
return true;
} else {
p = p.parentNode;
}
}
}
return false;
}
};
}();
// shorter alias, save a few bytes
}
(function() {
/**
* Defines the interface and base operation of items that that can be
* dragged or can be drop targets. It was designed to be extended, overriding
* the event handlers for startDrag, onDrag, onDragOver, onDragOut.
* Up to three html elements can be associated with a DragDrop instance:
* <ul>
* <li>linked element: the element that is passed into the constructor.
* This is the element which defines the boundaries for interaction with
* other DragDrop objects.</li>
* <li>handle element(s): The drag operation only occurs if the element that
* was clicked matches a handle element. By default this is the linked
* element, but there are times that you will want only a portion of the
* linked element to initiate the drag operation, and the setHandleElId()
* method provides a way to define this.</li>
* <li>drag element: this represents an the element that would be moved along
* with the cursor during a drag operation. By default, this is the linked
* element itself as in {@link YAHOO.util.DD}. setDragElId() lets you define
* a separate element that would be moved, as in {@link YAHOO.util.DDProxy}
* </li>
* </ul>
* This class should not be instantiated until the onload event to ensure that
* the associated elements are available.
* The following would define a DragDrop obj that would interact with any
* other DragDrop obj in the "group1" group:
* <pre>
* dd = new YAHOO.util.DragDrop("div1", "group1");
* </pre>
* Since none of the event handlers have been implemented, nothing would
* actually happen if you were to run the code above. Normally you would
* override this class or one of the default implementations, but you can
* also override the methods you want on an instance of the class...
* <pre>
* dd.onDragDrop = function(e, id) {
* alert("dd was dropped on " + id);
* }
* </pre>
* @namespace YAHOO.util
* @class DragDrop
* @constructor
* @param {String} id of the element that is linked to this instance
* @param {String} sGroup the group of related DragDrop objects
* @param {object} config an object containing configurable attributes
* Valid properties for DragDrop:
* padding, isTarget, maintainOffset, primaryButtonOnly,
*/
if (id) {
}
};
/**
* The id of the element associated with this object. This is what we
* refer to as the "linked element" because the size and position of
* this element is used to determine when the drag and drop objects have
* interacted.
* @property id
* @type String
*/
id: null,
/**
* Configuration attributes passed into the constructor
* @property config
* @type object
*/
config: null,
/**
* The id of the element that will be dragged. By default this is same
* as the linked element , but could be changed to another element. Ex:
* YAHOO.util.DDProxy
* @property dragElId
* @type String
* @private
*/
dragElId: null,
/**
* the id of the element that initiates the drag operation. By default
* this is the linked element, but could be changed to be a child of this
* element. This lets us do things like only starting the drag when the
* header element within the linked html element is clicked.
* @property handleElId
* @type String
* @private
*/
handleElId: null,
/**
* An associative array of HTML tags that will be ignored if clicked.
* @property invalidHandleTypes
* @type {string: string}
*/
invalidHandleTypes: null,
/**
* An associative array of ids for elements that will be ignored if clicked
* @property invalidHandleIds
* @type {string: string}
*/
invalidHandleIds: null,
/**
* An indexted array of css class names for elements that will be ignored
* if clicked.
* @property invalidHandleClasses
* @type string[]
*/
invalidHandleClasses: null,
/**
* The linked element's absolute X position at the time the drag was
* started
* @property startPageX
* @type int
* @private
*/
startPageX: 0,
/**
* The linked element's absolute X position at the time the drag was
* started
* @property startPageY
* @type int
* @private
*/
startPageY: 0,
/**
* The group defines a logical collection of DragDrop objects that are
* related. Instances only get events when interacting with other
* DragDrop object in the same group. This lets us define multiple
* groups using a single DragDrop subclass if we want.
* @property groups
* @type {string: string}
*/
groups: null,
/**
* onmousedown start drag.
* @property locked
* @type boolean
* @private
*/
locked: false,
/**
* Lock this instance
* @method lock
*/
/**
* Unlock this instace
* @method unlock
*/
/**
* By default, all instances can be a drop target. This can be disabled by
* setting isTarget to false.
* @method isTarget
* @type boolean
*/
isTarget: true,
/**
* The padding configured for this drag and drop object for calculating
* the drop zone intersection with this object.
* @method padding
* @type int[]
*/
padding: null,
/**
* Cached reference to the linked element
* @property _domRef
* @private
*/
_domRef: null,
/**
* Internal typeof flag
* @property __ygDragDrop
* @private
*/
__ygDragDrop: true,
/**
* Set to true when horizontal contraints are applied
* @property constrainX
* @type boolean
* @private
*/
constrainX: false,
/**
* Set to true when vertical contraints are applied
* @property constrainY
* @type boolean
* @private
*/
constrainY: false,
/**
* The left constraint
* @property minX
* @type int
* @private
*/
minX: 0,
/**
* The right constraint
* @property maxX
* @type int
* @private
*/
maxX: 0,
/**
* The up constraint
* @property minY
* @type int
* @type int
* @private
*/
minY: 0,
/**
* The down constraint
* @property maxY
* @type int
* @private
*/
maxY: 0,
/**
* The difference between the click position and the source element's location
* @property deltaX
* @type int
* @private
*/
deltaX: 0,
/**
* The difference between the click position and the source element's location
* @property deltaY
* @type int
* @private
*/
deltaY: 0,
/**
* Maintain offsets when we resetconstraints. Set to true when you want
* the position of the element relative to its parent to stay the same
* when the page changes
*
* @property maintainOffset
* @type boolean
*/
maintainOffset: false,
/**
* Array of pixel locations the element will snap to if we specified a
* horizontal graduation/interval. This array is generated automatically
* when you define a tick interval.
* @property xTicks
* @type int[]
*/
xTicks: null,
/**
* Array of pixel locations the element will snap to if we specified a
* vertical graduation/interval. This array is generated automatically
* when you define a tick interval.
* @property yTicks
* @type int[]
*/
yTicks: null,
/**
* By default the drag and drop instance will only respond to the primary
* button click (left button for a right-handed mouse). Set to true to
* allow drag and drop to start with any mouse click that is propogated
* by the browser
* @property primaryButtonOnly
* @type boolean
*/
primaryButtonOnly: true,
/**
* The availabe property is false until the linked dom element is accessible.
* @property available
* @type boolean
*/
available: false,
/**
* By default, drags can only be initiated if the mousedown occurs in the
* region the linked element is. This is done in part to work around a
* bug in some browsers that mis-report the mousedown if the previous
* mouseup happened outside of the window. This property is set to true
* if outer handles are defined.
*
* @property hasOuterHandles
* @type boolean
* @default false
*/
hasOuterHandles: false,
/**
* Property that is assigned to a drag and drop object when testing to
* see if it is being targeted by another dd object. This property
* can be used in intersect mode to help determine the focus of
* the mouse interaction. DDM.getBestMatch uses this property first to
* determine the closest match in INTERSECT mode when multiple targets
* are part of the same interaction.
* @property cursorIsOver
* @type boolean
*/
cursorIsOver: false,
/**
* Property that is assigned to a drag and drop object when testing to
* see if it is being targeted by another dd object. This is a region
* that represents the area the draggable element overlaps this target.
* DDM.getBestMatch uses this property to compare the size of the overlap
* to that of other targets in order to determine the closest match in
* INTERSECT mode when multiple targets are part of the same interaction.
* @property overlap
* @type YAHOO.util.Region
*/
overlap: null,
/**
* Code that executes immediately before the startDrag event
* @method b4StartDrag
* @private
*/
b4StartDrag: function(x, y) { },
/**
* and the drag or mousedown time thresholds have beeen met.
* @method startDrag
* @param {int} X click location
* @param {int} Y click location
*/
startDrag: function(x, y) { /* override this */ },
/**
* Code that executes immediately before the onDrag event
* @method b4Drag
* @private
*/
b4Drag: function(e) { },
/**
* Abstract method called during the onMouseMove event while dragging an
* object.
* @method onDrag
* @param {Event} e the mousemove event
*/
onDrag: function(e) { /* override this */ },
/**
* Abstract method called when this element fist begins hovering over
* another DragDrop obj
* @method onDragEnter
* @param {Event} e the mousemove event
* @param {String|DragDrop[]} id In POINT mode, the element
* id this is hovering over. In INTERSECT mode, an array of one or more
* dragdrop items being hovered over.
*/
/**
* Code that executes immediately before the onDragOver event
* @method b4DragOver
* @private
*/
b4DragOver: function(e) { },
/**
* Abstract method called when this element is hovering over another
* DragDrop obj
* @method onDragOver
* @param {Event} e the mousemove event
* @param {String|DragDrop[]} id In POINT mode, the element
* id this is hovering over. In INTERSECT mode, an array of dd items
* being hovered over.
*/
/**
* Code that executes immediately before the onDragOut event
* @method b4DragOut
* @private
*/
b4DragOut: function(e) { },
/**
* Abstract method called when we are no longer hovering over an element
* @method onDragOut
* @param {Event} e the mousemove event
* @param {String|DragDrop[]} id In POINT mode, the element
* id this was hovering over. In INTERSECT mode, an array of dd items
* that the mouse is no longer over.
*/
/**
* Code that executes immediately before the onDragDrop event
* @method b4DragDrop
* @private
*/
b4DragDrop: function(e) { },
/**
* Abstract method called when this item is dropped on another DragDrop
* obj
* @method onDragDrop
* @param {Event} e the mouseup event
* @param {String|DragDrop[]} id In POINT mode, the element
* id this was dropped on. In INTERSECT mode, an array of dd items this
* was dropped on.
*/
/**
* Abstract method called when this item is dropped on an area with no
* drop target
* @method onInvalidDrop
* @param {Event} e the mouseup event
*/
onInvalidDrop: function(e) { /* override this */ },
/**
* Code that executes immediately before the endDrag event
* @method b4EndDrag
* @private
*/
b4EndDrag: function(e) { },
/**
* Fired when we are done dragging the object
* @method endDrag
* @param {Event} e the mouseup event
*/
endDrag: function(e) { /* override this */ },
/**
* Code executed immediately before the onMouseDown event
* @method b4MouseDown
* @param {Event} e the mousedown event
* @private
*/
b4MouseDown: function(e) { },
/**
* @method onMouseDown
* @param {Event} e the mousedown event
*/
onMouseDown: function(e) { /* override this */ },
/**
* @method onMouseUp
* @param {Event} e the mouseup event
*/
onMouseUp: function(e) { /* override this */ },
/**
* Override the onAvailable method to do what is needed after the initial
* position was determined.
* @method onAvailable
*/
onAvailable: function () {
//this.logger.log("onAvailable (base)");
},
/**
* Returns a reference to the linked element
* @method getEl
* @return {HTMLElement} the html element
*/
getEl: function() {
if (!this._domRef) {
}
return this._domRef;
},
/**
* Returns a reference to the actual element to drag. By default this is
* the same as the html element, but it can be assigned to another
* element. An example of this can be found in YAHOO.util.DDProxy
* @method getDragEl
* @return {HTMLElement} the html element
*/
getDragEl: function() {
},
/**
* Sets up the DragDrop object. Must be called in the constructor of any
* YAHOO.util.DragDrop subclass
* @method init
* @param id the id of the linked element
* @param {String} sGroup the group of related items
* @param {object} config configuration attributes
*/
this.handleMouseDown, this, true);
// Event.on(this.id, "selectstart", Event.preventDefault);
},
/**
* Initializes Targeting functionality only... the object does not
* get a mousedown handler.
* @method initTarget
* @param id the id of the linked element
* @param {String} sGroup the group of related items
* @param {object} config configuration attributes
*/
// configuration attributes
// create a local reference to the drag and drop manager
// initialize the groups object
this.groups = {};
// assume that we have an element reference instead of an id if the
// parameter is not a string
if (typeof id !== "string") {
}
// set the id
// add to an interaction group
// We don't want to register this as the handle with the manager
// so we just set the id rather than calling the setter.
this.handleElId = id;
// create a logger instance
// the linked element is the element that gets dragged by default
this.setDragElId(id);
// by default, clicked anchors will not start drag operations.
// @TODO what else should be here? Probably form fields.
this.invalidHandleTypes = { A: "A" };
this.invalidHandleIds = {};
this.invalidHandleClasses = [];
this.applyConfig();
},
/**
* Applies the configuration parameters that were passed into the constructor.
* This is supposed to happen at each level through the inheritance chain. So
* a DDProxy implentation will execute apply config on DDProxy, DD, and
* DragDrop in order to get all of the parameters that are available in
* each object.
* @method applyConfig
*/
applyConfig: function() {
// configurable properties:
// padding, isTarget, maintainOffset, primaryButtonOnly
},
/**
* Executed when the linked element is available
* @method handleOnAvailable
* @private
*/
handleOnAvailable: function() {
//this.logger.log("handleOnAvailable");
this.available = true;
this.resetConstraints();
this.onAvailable();
},
/**
* Configures the padding for the target zone in px. Effectively expands
* (or reduces) the virtual object size for targeting calculations.
* Supports css-style shorthand; if only one parameter is passed, all sides
* will have that padding, and if only two are passed, the top and bottom
* will have the first param, the left and right the second.
* @method setPadding
* @param {int} iTop Top pad
* @param {int} iRight Right pad
* @param {int} iBot Bot pad
* @param {int} iLeft Left pad
*/
// this.padding = [iLeft, iRight, iTop, iBot];
} else {
}
},
/**
* Stores the initial placement of the linked element.
* @method setInitialPosition
* @param {int} diffX the X offset, default 0
* @param {int} diffY the Y offset, default 0
* @private
*/
return;
}
this.lastPageX = p[0];
this.lastPageY = p[1];
", " + this.initPageY);
this.setStartPosition(p);
},
/**
* Sets the start position of the element. This is set when the obj
* is initialized, the reset when a drag is started.
* @method setStartPosition
* @param pos current position (from previous lookup)
* @private
*/
setStartPosition: function(pos) {
this.deltaSetXY = null;
this.startPageX = p[0];
this.startPageY = p[1];
},
/**
* instances belong to at least one group, and can belong to as many
* groups as needed.
* @method addToGroup
* @param sGroup {string} the name of the group
*/
addToGroup: function(sGroup) {
},
/**
* Remove's this instance from the supplied interaction group
* @method removeFromGroup
* @param {string} sGroup The group to drop
*/
removeFromGroup: function(sGroup) {
}
},
/**
* Allows you to specify that an element other than the linked element
* will be moved with the cursor during a drag
* @method setDragElId
* @param id {string} the id of the element that will be used to initiate the drag
*/
setDragElId: function(id) {
},
/**
* Allows you to specify a child of the linked element that should be
* used to initiate the drag operation. An example of this would be if
* you have a content div with text and links. Clicking anywhere in the
* content area would normally start the drag operation. Use this method
* to specify that an element inside of the content div is the element
* that starts the drag operation.
* @method setHandleElId
* @param id {string} the id of the element that will be used to
* initiate the drag.
*/
setHandleElId: function(id) {
if (typeof id !== "string") {
}
this.handleElId = id;
},
/**
* Allows you to set an element outside of the linked element as a drag
* handle
* @method setOuterHandleElId
* @param id the id of the element that will be used to initiate the drag
*/
setOuterHandleElId: function(id) {
if (typeof id !== "string") {
}
this.handleMouseDown, this, true);
this.setHandleElId(id);
this.hasOuterHandles = true;
},
/**
* Remove all drag and drop hooks for this element
* @method unreg
*/
unreg: function() {
this.handleMouseDown);
this._domRef = null;
},
/**
* Returns true if this instance is locked, or the drag drop mgr is locked
* @method isLocked
* false
*/
isLocked: function() {
},
/**
* Fired when this object is clicked
* @method handleMouseDown
* @param {Event} e
* @param {YAHOO.util.DragDrop} oDD the clicked dd object (this dd obj)
* @private
*/
handleMouseDown: function(e, oDD) {
return;
}
if (this.isLocked()) {
return;
}
// firing the mousedown events prior to calculating positions
this.b4MouseDown(e);
this.onMouseDown(e);
// var self = this;
// setTimeout( function() { self.DDM.refreshCache(self.groups); }, 0);
// Only process the event if we really clicked within the linked
// element. The reason we make this check is that in the case that
// another element was moved between the clicked element and the
// cursor in the time between the mousedown and mouseup events. When
// this happens, the element gets the next mousedown event
// regardless of where on the screen it happened.
} else {
if (this.clickValidator(e)) {
// set the initial element position
this.setStartPosition();
// start tracking mousemove distance and mousedown time to
// determine when to start the actual drag
this.DDM.handleMouseDown(e, this);
// this mousedown is mine
} else {
}
}
},
clickValidator: function(e) {
return ( this.isValidHandleChild(target) &&
(this.id == this.handleElId ||
},
/**
* Finds the location the element should be placed if we want to move
* it to where the mouse location less the click offset would place us.
* @method getTargetCoord
* @param {int} iPageX the X coordinate of the click
* @param {int} iPageY the Y coordinate of the click
* @return an object that contains the coordinates (Object.x and Object.y)
* @private
*/
// this.logger.log("getTargetCoord: " + iPageX + ", " + iPageY);
if (this.constrainX) {
}
if (this.constrainY) {
}
// this.logger.log("getTargetCoord " +
// " iPageX: " + iPageX +
// " iPageY: " + iPageY +
// " x: " + x + ", y: " + y);
return {x:x, y:y};
},
/**
* Allows you to specify a tag name that should not start a drag operation
* when clicked. This is designed to facilitate embedding links within a
* drag handle that do something other than start the drag.
* @method addInvalidHandleType
* @param {string} tagName the type of element to exclude
*/
addInvalidHandleType: function(tagName) {
},
/**
* Lets you to specify an element id for a child of a drag handle
* that should not initiate a drag
* @method addInvalidHandleId
* @param {string} id the element id of the element you wish to ignore
*/
addInvalidHandleId: function(id) {
if (typeof id !== "string") {
}
},
/**
* Lets you specify a css class of elements that will not initiate a drag
* @method addInvalidHandleClass
* @param {string} cssClass the class of the elements you wish to ignore
*/
addInvalidHandleClass: function(cssClass) {
},
/**
* Unsets an excluded tag name set by addInvalidHandleType
* @method removeInvalidHandleType
* @param {string} tagName the type of element to unexclude
*/
removeInvalidHandleType: function(tagName) {
// this.invalidHandleTypes[type] = null;
delete this.invalidHandleTypes[type];
},
/**
* Unsets an invalid handle id
* @method removeInvalidHandleId
* @param {string} id the id of the element to re-enable
*/
removeInvalidHandleId: function(id) {
if (typeof id !== "string") {
}
delete this.invalidHandleIds[id];
},
/**
* Unsets an invalid css class
* @method removeInvalidHandleClass
* @param {string} cssClass the class of the element(s) you wish to
* re-enable
*/
removeInvalidHandleClass: function(cssClass) {
if (this.invalidHandleClasses[i] == cssClass) {
delete this.invalidHandleClasses[i];
}
}
},
/**
* Checks the tag exclusion list to see if this click should be ignored
* @method isValidHandleChild
* @param {HTMLElement} node the HTMLElement to evaluate
* @return {boolean} true if this is a valid tag type, false if not
*/
isValidHandleChild: function(node) {
var valid = true;
// var n = (node.nodeName == "#text") ? node.parentNode : node;
var nodeName;
try {
} catch(e) {
}
}
return valid;
},
/**
* Create the array of horizontal tick marks if an interval was specified
* in setXConstraint().
* @method setXTicks
* @private
*/
this.xTicks = [];
var tickMap = {};
if (!tickMap[i]) {
tickMap[i] = true;
}
}
if (!tickMap[i]) {
tickMap[i] = true;
}
}
},
/**
* Create the array of vertical tick marks if an interval was specified in
* setYConstraint().
* @method setYTicks
* @private
*/
// this.logger.log("setYTicks: " + iStartY + ", " + iTickSize
// + ", " + this.initPageY + ", " + this.minY + ", " + this.maxY );
this.yTicks = [];
var tickMap = {};
if (!tickMap[i]) {
tickMap[i] = true;
}
}
if (!tickMap[i]) {
tickMap[i] = true;
}
}
},
/**
* By default, the element can be dragged any place on the screen. Use
* this method to limit the horizontal travel of the element. Pass in
* 0,0 for the parameters if you want to lock the drag to the y axis.
* @method setXConstraint
* @param {int} iLeft the number of pixels the element can move to the left
* @param {int} iRight the number of pixels the element can move to the
* right
* @param {int} iTickSize optional parameter for specifying that the
* element
* should move iTickSize pixels at a time.
*/
this.constrainX = true;
" maxX:" + this.maxX);
},
/**
* Clears any constraints applied to this instance. Also clears ticks
* since they can't exist independent of a constraint at this time.
* @method clearConstraints
*/
clearConstraints: function() {
this.constrainX = false;
this.constrainY = false;
this.clearTicks();
},
/**
* Clears any tick interval defined for this instance
* @method clearTicks
*/
clearTicks: function() {
this.xTicks = null;
this.yTicks = null;
this.xTickSize = 0;
this.yTickSize = 0;
},
/**
* By default, the element can be dragged any place on the screen. Set
* this to limit the vertical travel of the element. Pass in 0,0 for the
* parameters if you want to lock the drag to the x axis.
* @method setYConstraint
* @param {int} iUp the number of pixels the element can move up
* @param {int} iDown the number of pixels the element can move down
* @param {int} iTickSize optional parameter for specifying that the
* element should move iTickSize pixels at a time.
*/
this.constrainY = true;
" maxY:" + this.maxY);
},
/**
* resetConstraints must be called if you manually reposition a dd element.
* @method resetConstraints
*/
resetConstraints: function() {
//this.logger.log("resetConstraints");
// Maintain offsets if necessary
//this.logger.log("init pagexy: " + this.initPageX + ", " +
//this.initPageY);
//this.logger.log("last pagexy: " + this.lastPageX + ", " +
//this.lastPageY);
// figure out how much this thing has moved
// This is the first time we have detected the element's position
} else {
this.setInitPosition();
}
if (this.constrainX) {
this.setXConstraint( this.leftConstraint,
this.rightConstraint,
this.xTickSize );
}
if (this.constrainY) {
this.setYConstraint( this.topConstraint,
this.bottomConstraint,
this.yTickSize );
}
},
/**
* Normally the drag element is moved pixel by pixel, but we can specify
* that it move a number of pixels at a time. This method resolves the
* location when we have it set up like this.
* @method getTick
* @param {int} val where we want to place the object
* @param {int[]} tickArray sorted array of valid points
* @return {int} the closest tick
* @private
*/
if (!tickArray) {
// If tick interval is not defined, it is effectively 1 pixel,
// so we return the value passed to us.
return val;
// The value is lower than the first tick, so we return the first
// tick.
return tickArray[0];
} else {
var next = i + 1;
}
}
// The value is larger than the last tick, so we return the last
// tick.
}
},
/**
* toString method
* @method toString
* @return {string} string representation of the dd obj
*/
toString: function() {
return ("DragDrop " + this.id);
}
};
})();
/**
* A DragDrop implementation where the linked element follows the
* mouse cursor during a drag.
* @class DD
* @extends YAHOO.util.DragDrop
* @constructor
* @param {String} id the id of the linked element
* @param {String} sGroup the group of related DragDrop items
* @param {object} config an object containing configurable attributes
* Valid properties for DD:
* scroll
*/
if (id) {
}
};
/**
* When set to true, the utility automatically tries to scroll the browser
* window wehn a drag and drop element is dragged near the viewport boundary.
* Defaults to true.
* @property scroll
* @type boolean
*/
scroll: true,
/**
* Sets the pointer offset to the distance between the linked element's top
* left corner and the location the element was clicked
* @method autoOffset
* @param {int} iPageX the X coordinate of the click
* @param {int} iPageY the Y coordinate of the click
*/
var x = iPageX - this.startPageX;
var y = iPageY - this.startPageY;
this.setDelta(x, y);
// this.logger.log("autoOffset el pos: " + aCoord + ", delta: " + x + "," + y);
},
/**
* Sets the pointer offset. You can call this directly to force the
* offset to be in a particular location (e.g., pass in 0,0 to set it
* to the center of the object, as done in YAHOO.widget.Slider)
* @method setDelta
* @param {int} iDeltaX the distance from the left
* @param {int} iDeltaY the distance from the top
*/
},
/**
* Sets the drag element to the location of the mousedown or click event,
* maintaining the cursor location relative to the location on the element
* that was clicked. Override this if you want to place the element in a
* location other than where the cursor is.
* @method setDragElPos
* @param {int} iPageX the X coordinate of the mousedown or drag event
* @param {int} iPageY the Y coordinate of the mousedown or drag event
*/
// the first time we do this, we are going to check to make sure
// the element has css positioning
},
/**
* Sets the element to the location of the mousedown or click event,
* maintaining the cursor location relative to the location on the element
* that was clicked. Override this if you want to place the element in a
* location other than where the cursor is.
* @method alignElWithMouse
* @param {HTMLElement} el the element to move
* @param {int} iPageX the X coordinate of the mousedown or drag event
* @param {int} iPageY the Y coordinate of the mousedown or drag event
*/
// this.logger.log("****alignElWithMouse : " + el.id + ", " + aCoord + ", " + el.style.display);
if (!this.deltaSetXY) {
} else {
}
},
/**
* Saves the most recent position so that we can reset the constraints and
* tick marks on-demand. We need to know this so that we can calculate the
* number of pixels the element is offset from its original position.
* @method cachePosition
* @param iPageX the current x position (optional, this just makes it so we
* don't have to look it up again)
* @param iPageY the current y position (optional, this just makes it so we
* don't have to look it up again)
*/
if (iPageX) {
} else {
}
},
/**
* Auto-scroll the window if the dragged object has been moved beyond the
* visible window boundary.
* @method autoScroll
* @param {int} x the drag element's x position
* @param {int} y the drag element's y position
* @param {int} h the height of the drag element
* @param {int} w the width of the drag element
* @private
*/
autoScroll: function(x, y, h, w) {
if (this.scroll) {
// The client height
// The client width
// The amt scrolled down
// The amt scrolled right
// Location of the bottom of the element
var bot = h + y;
// Location of the right of the element
var right = w + x;
// The distance from the cursor to the bottom of the visible area,
// adjusted so that we don't scroll if the cursor is beyond the
// element drag constraints
// The distance from the cursor to the right of the visible area
// this.logger.log( " x: " + x + " y: " + y + " h: " + h +
// " clientH: " + clientH + " clientW: " + clientW +
// " st: " + st + " sl: " + sl + " bot: " + bot +
// " right: " + right + " toBot: " + toBot + " toRight: " + toRight);
// How close to the edge the cursor must be before we scroll
// var thresh = (document.all) ? 100 : 40;
var thresh = 40;
// How many pixels to scroll per autoscroll op. This helps to reduce
// clunky scrolling. IE is more sensitive about this ... it needs this
// value to be higher.
// Scroll down if we are near the bottom of the visible page and the
// obj extends below the crease
}
// Scroll up if the window is scrolled down and the top of the object
// goes above the top border
}
// Scroll right if the obj is beyond the right border and the cursor is
// near the border.
}
// Scroll left if the window has been scrolled to the right and the obj
// extends past the left border
}
}
},
/*
* Sets up config options specific to this class. Overrides
* YAHOO.util.DragDrop, but all versions of this method through the
* inheritance chain are called
*/
applyConfig: function() {
},
/*
* Event that fires prior to the onMouseDown event. Overrides
* YAHOO.util.DragDrop.
*/
b4MouseDown: function(e) {
this.setStartPosition();
// this.resetConstraints();
},
/*
* Event that fires prior to the onDrag event. Overrides
* YAHOO.util.DragDrop.
*/
b4Drag: function(e) {
},
toString: function() {
return ("DD " + this.id);
}
//////////////////////////////////////////////////////////////////////////
// Debugging ygDragDrop events that can be overridden
//////////////////////////////////////////////////////////////////////////
/*
startDrag: function(x, y) {
this.logger.log(this.id.toString() + " startDrag");
},
onDrag: function(e) {
this.logger.log(this.id.toString() + " onDrag");
},
onDragEnter: function(e, id) {
this.logger.log(this.id.toString() + " onDragEnter: " + id);
},
onDragOver: function(e, id) {
this.logger.log(this.id.toString() + " onDragOver: " + id);
},
onDragOut: function(e, id) {
this.logger.log(this.id.toString() + " onDragOut: " + id);
},
onDragDrop: function(e, id) {
this.logger.log(this.id.toString() + " onDragDrop: " + id);
},
endDrag: function(e) {
this.logger.log(this.id.toString() + " endDrag");
}
*/
});
/**
* A DragDrop implementation that inserts an empty, bordered div into
* the document that follows the cursor during drag operations. At the time of
* the click, the frame div is resized to the dimensions of the linked html
* element, and moved to the exact location of the linked element.
*
* References to the "frame" element refer to the single proxy element that
* was created to be dragged in place of all DDProxy elements on the
* page.
*
* @class DDProxy
* @extends YAHOO.util.DD
* @constructor
* @param {String} id the id of the linked html element
* @param {String} sGroup the group of related DragDrop objects
* @param {object} config an object containing configurable attributes
* Valid properties for DDProxy in addition to those in DragDrop:
* resizeFrame, centerFrame, dragElId
*/
if (id) {
this.initFrame();
}
};
/**
* The default drag frame div id
* @property YAHOO.util.DDProxy.dragElId
* @type String
* @static
*/
/**
* By default we resize the drag frame to be the same size as the element
* we want to drag (this is to get the frame effect). We can turn it off
* if we want a different behavior.
* @property resizeFrame
* @type boolean
*/
resizeFrame: true,
/**
* By default the frame is positioned exactly where the drag element is, so
* we use the cursor offset provided by YAHOO.util.DD. Another option that works only if
* you do not have constraints on the obj is to have the drag frame centered
* around the cursor. Set centerFrame to true for this effect.
* @property centerFrame
* @type boolean
*/
centerFrame: false,
/**
* Creates the proxy element if it does not yet exist
* @method createFrame
*/
createFrame: function() {
return;
}
if (!div) {
s.position = "absolute";
s.visibility = "hidden";
s.cursor = "move";
s.border = "2px solid #aaa";
s.zIndex = 999;
s.height = "25px";
s.width = "25px";
/**
* If the proxy element has no background-color, then it is considered to the "transparent" by Internet Explorer.
* Since it is "transparent" then the events pass through it to the iframe below.
* So creating a "fake" div inside the proxy element and giving it a background-color, then setting it to an
* opacity of 0, it appears to not be there, however IE still thinks that it is so the events never pass through.
*/
// appendChild can blow up IE if invoked prior to the window load event
// while rendering a table. It is possible there are other scenarios
// that would cause this to happen as well.
}
},
/**
* Initialization for the drag frame element. Must be called in the
* constructor of all subclasses
* @method initFrame
*/
initFrame: function() {
this.createFrame();
},
applyConfig: function() {
//this.logger.log("DDProxy applyConfig");
},
/**
* Resizes the drag frame to the dimensions of the clicked object, positions
* it over the object, and finally displays it
* @method showFrame
* @param {int} iPageX X click position
* @param {int} iPageY Y click position
* @private
*/
this._resizeProxy();
if (this.centerFrame) {
}
},
/**
* The proxy is automatically resized to the dimensions of the linked
* element when a drag is initiated, unless resizeFrame is set to false
* @method _resizeProxy
* @private
*/
_resizeProxy: function() {
if (this.resizeFrame) {
}
},
// overrides YAHOO.util.DragDrop
b4MouseDown: function(e) {
this.setStartPosition();
this.autoOffset(x, y);
// This causes the autoscroll code to kick off, which means autoscroll can
// happen prior to the check for a valid drag handle.
// this.setDragElPos(x, y);
},
// overrides YAHOO.util.DragDrop
b4StartDrag: function(x, y) {
// show the drag frame
this.showFrame(x, y);
},
// overrides YAHOO.util.DragDrop
b4EndDrag: function(e) {
},
// overrides YAHOO.util.DragDrop
// By default we try to move the element to the last location of the frame.
// This is so that the default behavior mirrors that of YAHOO.util.DD.
endDrag: function(e) {
// Show the drag frame briefly so we can get its position
// del.style.visibility = "";
// Hide the linked element before the move to get around a Safari
// rendering bug.
//lel.style.visibility = "hidden";
//del.style.visibility = "hidden";
//lel.style.visibility = "";
},
toString: function() {
return ("DDProxy " + this.id);
}
});
/**
* A DragDrop implementation that does not move, but can be a drop
* target. You would get the same result by simply omitting implementation
* for the event callbacks, but this way we reduce the processing cost of the
* event listener and the callbacks.
* @class DDTarget
* @extends YAHOO.util.DragDrop
* @constructor
* @param {String} id the id of the element that is a drop target
* @param {String} sGroup the group of related DragDrop objects
* @param {object} config an object containing configurable attributes
* Valid properties for DDTarget in addition to those in
* DragDrop:
* none
*/
if (id) {
}
};
// YAHOO.util.DDTarget.prototype = new YAHOO.util.DragDrop();
toString: function() {
return ("DDTarget " + this.id);
}
});