Class YAHOO.util.DragDropMgr

Object
   |
   +--YAHOO.util.DragDropMgr

class YAHOO.util.DragDropMgr

Field Summary [top]

int clickPixelThresh
The number of pixels that the mouse needs to move after the mousedown before the drag is initiated. 
int clickTimeThresh
The number of milliseconds after the mousedown event to initiate the drag if we don't get a mouseup event. 
int INTERSECT
In intersect mode, drag and drop interactio nis defined by the overlap of two or more drag and drop objects. 
boolean locked
Is drag and drop locked? 
int mode
The current drag and drop mode. 
int POINT
In point mode, drag and drop interaction is defined by the location of the cursor during the drag/drop 
boolean preventDefault
Flag to determine if we should prevent the default behavior of the events we define. 
boolean stopPropagation
Flag to determine if we should stop the propagation of the events we generate. 
boolean useCache
Set useCache to false if you want to force object the lookup of each drag and drop linked element constantly during a drag. 

Method Summary [top]

ygDragDrop getBestMatch (dds)
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. 
int getClientHeight ()
Gets the client height 
int getClientWidth ()
Gets the client width 
Object getCss (<String> id)
Returns the style property for the DOM element (i.e., document.getElById(id).style) 
DragDrop getDDById (<String> id)
Returns the DragDrop instance for a given id 
Object getElement (<String> id)
Returns the actual DOM element 
Object getLocation (<ygDragDrop> oDD)
Returns the an array containing the drag and drop element's position and size, including the ygDragDrop.padding configured for it 
int getPosX (el)
Returns the X position of an html element 
int getPosY (el)
Returns the Y position of an html element 
Object getRelated (<ygDragDrop> p_oDD, <boolean> bTargetsOnly)
Returns the drag and drop instances that are in all groups the passed in instance belongs to. 
int getScrollLeft ()
Gets the scrollLeft 
int getScrollTop ()
Gets the scrollTop 
string getStyle (<HTMLElement> el, <string> styleProp)
Returns the specified element style property 
Object handleWasClicked (node, id)
Recursively searches the immediate parent and all child nodes for the handle element in order to determine wheter or not it was clicked. 
boolean isDragDrop (<String> id)
Utility function to determine if a given element has been registered as a drag drop item. 
boolean isHandle (sDDId, sHandleId)
Utility function to determine if a given element has been registered as a drag drop handle for the given Drag Drop object. 
boolean isLegalTarget (oDD, oTargetDD)
Returns true if the specified dd target is a legal target for the specifice drag obj 
boolean isLocked ()
Is drag and drop locked? 
boolean isTypeOfDD (oDD)
My goal is to be able to transparently determine if an object is typeof ygDragDrop, and the exact subclass of ygDragDrop. 
void lock ()
Lock all drag and drop functionality 
void moveToEl (moveEl, targetEl)
 
Object numericSort (a, b)
numeric array sort function 
void refreshCache (<Array> aGroups)
Refreshes the cache of the top-left and bottom-right points of the drag and drop objects in the specified groups 
void regDragDrop (<DragDrop> oDD, <String> sGroup)
Each DragDrop instance must be registered with the DragDropMgr. 
void regHandle (<String> sDDId, <String> sHandleId)
Each DragDrop handle element must be registered. 
void startDrag (x, y)
Fired when either the drag pixel threshol or the mousedown hold time threshold has been met. 
void stopEvent (<Event> e)
Utility to stop event propagation and event default, if these features are turned on. 
void swapNode (n1, n2)
Swap two nodes. 
void unlock ()
Unlock all drag and drop functionality 
boolean verifyEl (<HTMLElement> el)
This checks to make sure an element exists and is in the DOM. 

Field Detail [top]

clickPixelThresh

int   clickPixelThresh
The number of pixels that the mouse needs to move after the mousedown before the drag is initiated. Default=3;

clickTimeThresh

int   clickTimeThresh
The number of milliseconds after the mousedown event to initiate the drag if we don't get a mouseup event. Default=1000

INTERSECT

int   INTERSECT
In intersect mode, drag and drop interactio nis defined by the overlap of two or more drag and drop objects.

locked

boolean   locked
Is drag and drop locked?

mode

int   mode
The current drag and drop mode. Default it point mode

POINT

int   POINT
In point mode, drag and drop interaction is defined by the location of the cursor during the drag/drop

preventDefault

boolean   preventDefault
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)

stopPropagation

boolean   stopPropagation
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.

useCache

boolean   useCache
Set useCache to false if you want to force object the lookup of each drag and drop linked element constantly during a drag.

Constructor Detail [top]

YAHOO.util.DragDropMgr

YAHOO.util.DragDropMgr

Method Detail [top]

getBestMatch

ygDragDrop getBestMatch (dds)
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.
Parameters:
ygDragDrop - []} dds The array of drag and drop objects targeted
Returns:
The best single match

getClientHeight

int getClientHeight ()
Gets the client height
Returns:
client height in px

getClientWidth

int getClientWidth ()
Gets the client width
Returns:
client width in px

getCss

Object getCss (<String> id)
Returns the style property for the DOM element (i.e., document.getElById(id).style)
Parameters:
id - the id of the elment to get
Returns:
The style property of the element

getDDById

DragDrop getDDById (<String> id)
Returns the DragDrop instance for a given id
Parameters:
id - the id of the DragDrop object
Returns:
the drag drop object, null if it is not found

getElement

Object getElement (<String> id)
Returns the actual DOM element
Parameters:
id - the id of the elment to get
Returns:
The element

getLocation

Object getLocation (<ygDragDrop> oDD)
Returns the an array containing the drag and drop element's position and size, including the ygDragDrop.padding configured for it
Parameters:
oDD - the drag and drop object to get the location for
Returns:
array containing the top left and bottom right points of the element

getPosX

int getPosX (el)
Returns the X position of an html element
Parameters:
el - the element for which to get the position
Returns:
the X coordinate

getPosY

int getPosY (el)
Returns the Y position of an html element
Parameters:
el - the element for which to get the position
Returns:
the Y coordinate

getRelated

Object getRelated (<ygDragDrop> p_oDD, <boolean> bTargetsOnly)
Returns the drag and drop instances that are in all groups the passed in instance belongs to.
Parameters:
p_oDD - the obj to get related data for
bTargetsOnly - if true, only return targetable objs
Returns:
{ygDragDrop[]} the related instances

getScrollLeft

int getScrollLeft ()
Gets the scrollLeft
Returns:
the document's scrollTop

getScrollTop

int getScrollTop ()
Gets the scrollTop
Returns:
the document's scrollTop

getStyle

string getStyle (<HTMLElement> el, <string> styleProp)
Returns the specified element style property
Parameters:
el - the element
styleProp - the style property
Returns:
The value of the style property
, use YAHOO.util.Dom.getStyle

handleWasClicked

Object handleWasClicked (node, id)
Recursively searches the immediate parent and all child nodes for the handle element in order to determine wheter or not it was clicked.
Parameters:
node - the html element to inspect

isDragDrop

boolean isDragDrop (<String> id)
Utility function to determine if a given element has been registered as a drag drop item.
Parameters:
id - the element id to check
Returns:
true if this element is a DragDrop item, false otherwise

isHandle

boolean isHandle (sDDId, sHandleId)
Utility function to determine if a given element has been registered as a drag drop handle for the given Drag Drop object.
Parameters:
id - the element id to check
Returns:
true if this element is a DragDrop handle, false otherwise

isLegalTarget

boolean isLegalTarget (oDD, oTargetDD)
Returns true if the specified dd target is a legal target for the specifice drag obj
Parameters:
the - drag obj
ygDragDrop - ) the target
Returns:
true if the target is a legal target for the dd obj

isLocked

boolean isLocked ()
Is drag and drop locked?
Returns:
True if drag and drop is locked, false otherwise.

isTypeOfDD

boolean isTypeOfDD (oDD)
My goal is to be able to transparently determine if an object is typeof ygDragDrop, and the exact subclass of ygDragDrop. typeof returns "object", oDD.constructor.toString() always returns "ygDragDrop" and not the name of the subclass. So for now it just evaluates a well-known variable in ygDragDrop.
Parameters:
the - object to evaluate
Returns:
true if typeof oDD = ygDragDrop

lock

void lock ()
Lock all drag and drop functionality

moveToEl

void moveToEl (moveEl, targetEl)

numericSort

Object numericSort (a, b)
numeric array sort function

refreshCache

void refreshCache (<Array> aGroups)
Refreshes the cache of the top-left and bottom-right points of the drag and drop objects in the specified groups
Parameters:
aGroups - an associative array of groups to refresh

regDragDrop

void regDragDrop (<DragDrop> oDD, <String> sGroup)
Each DragDrop instance must be registered with the DragDropMgr. This is executed in ygDragDrop.init()
Parameters:
oDD - the DragDrop object to register
sGroup - the name of the group this element belongs to

regHandle

void regHandle (<String> sDDId, <String> sHandleId)
Each DragDrop handle element must be registered. This is done automatically when executing ygDragDrop.setHandleElId()
Parameters:
sDDId - the DragDrop id this element is a handle for
sHandleId - the id of the element that is the drag handle

startDrag

void startDrag (x, y)
Fired when either the drag pixel threshol or the mousedown hold time threshold has been met.
Parameters:
x - {int} the X position of the original mousedown
y - {int} the Y position of the original mousedown

stopEvent

void stopEvent (<Event> e)
Utility to stop event propagation and event default, if these features are turned on.
Parameters:
e - the event as returned by YAHOO.util.DragDropMgr.prototype.getEvent()

swapNode

void swapNode (n1, n2)
Swap two nodes. In IE, we use the native method, for others we emulate the IE behavior
Parameters:
n1 - the first node to swap
n2 - the other node to swap

unlock

void unlock ()
Unlock all drag and drop functionality

verifyEl

boolean verifyEl (<HTMLElement> el)
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
Parameters:
el - the element to check
Returns:
true if the element looks usable