Yahoo! UI Library

Drag and Drop  2.5.2

Yahoo! UI Library > dragdrop > YAHOO.util.DragDropMgr

Show Private Show Protected

static Class YAHOO.util.DragDropMgr

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.

Properties

clickPixelThresh - static int

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

clickTimeThresh - static int

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

interactionInfo - static object

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

INTERSECT - static final int

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.

mode - static int

The current drag and drop mode. Default: POINT

POINT - static final int

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

preventDefault - static boolean

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 - static boolean

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.

STRICT_INTERSECT - static final int

In intersect mode, drag and drop interaction is defined only by the overlap of two or more drag and drop objects.

useCache - static boolean

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

Methods

getBestMatch

static DragDrop 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:
dds <DragDrop[]> The array of drag and drop objects targeted
Returns: DragDrop
The best single match

getClientHeight

static int getClientHeight ( )
Gets the client height
Returns: int
client height in px
Deprecated use YAHOO.util.Dom.getViewportHeight instead

getClientWidth

static int getClientWidth ( )
Gets the client width
Returns: int
client width in px
Deprecated use YAHOO.util.Dom.getViewportWidth instead

getCss

static Object getCss ( id )
Returns the style property for the DOM element (i.e., document.getElById(id).style)
Parameters:
id <String> the id of the elment to get
Returns: Object
The style property of the element
Deprecated use YAHOO.util.Dom instead

getDDById

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

getElement

static Object getElement ( id )
Returns the actual DOM element
Parameters:
id <String> the id of the elment to get
Returns: Object
The element
Deprecated use YAHOO.util.Dom.get instead

getLocation

static YAHOO.util.Region getLocation ( oDD )
Returns a Region object containing the drag and drop element's position and size, including the padding configured for it
Parameters:
oDD <DragDrop> the drag and drop object to get the location for
Returns: YAHOO.util.Region
a Region object representing the total area the element occupies, including any padding the instance is configured for.

getPosX

static int getPosX ( el )
Returns the X position of an html element
Parameters:
el <object> the element for which to get the position
Returns: int
the X coordinate
Deprecated use YAHOO.util.Dom.getX instead

getPosY

static int getPosY ( el )
Returns the Y position of an html element
Parameters:
el <object> the element for which to get the position
Returns: int
the Y coordinate
Deprecated use YAHOO.util.Dom.getY instead

getRelated

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

getScrollLeft

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

getScrollTop

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

getStyle

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

handleWasClicked

static void handleWasClicked ( node )
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 <object> the html element to inspect
Returns: void

isDragDrop

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

isHandle

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

isLegalTarget

static boolean isLegalTarget ( the )
Returns true if the specified dd target is a legal target for the specifice drag obj
Parameters:
the <DragDrop> drag obj
the <DragDrop> target
Returns: boolean
true if the target is a legal target for the dd obj

isLocked

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

isTypeOfDD

static boolean isTypeOfDD ( the )
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.
Parameters:
the <Object> object to evaluate
Returns: boolean
true if typeof oDD = DragDrop

lock

static void lock ( )
Lock all drag and drop functionality
Returns: void

moveToEl

static void moveToEl ( moveEl , targetEl )
Sets the x/y position of an element to the location of the target element.
Parameters:
moveEl <HTMLElement> The element to move
targetEl <HTMLElement> The position reference element
Returns: void

numericSort

static void numericSort ( )
Numeric array sort function
Returns: void

refreshCache

static void refreshCache ( groups )
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: YAHOO.util.DragDropMgr.refreshCache(ddinstance.groups); Alternatively: YAHOO.util.DragDropMgr.refreshCache({group1:true, group2:true});
Parameters:
groups <Object> an associative array of groups to refresh
Returns: void

regDragDrop

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

regHandle

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

startDrag

static 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
Returns: void

stopDrag

static void stopDrag ( e , silent )
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.)
Parameters:
e <Event> the mouseup event, another event (or a fake event) with pageX and pageY defined, or nothing if the silent parameter is true
silent <boolean> skips the enddrag and mouseup events if true
Returns: void

stopEvent

static void stopEvent ( e )
Utility to stop event propagation and event default, if these features are turned on.
Parameters:
e <Event> the event as returned by this.getEvent()
Returns: void

swapNode

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

unlock

static void unlock ( )
Unlock all drag and drop functionality
Returns: void

verifyEl

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


Copyright © 2007 Yahoo! Inc. All rights reserved.