Class Index | File Index

Classes


Class YAHOO.util.DragDrop


Defined in: dragdrop.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
YAHOO.util.DragDrop(id, sGroup, config)
Defines the interface and base operation of items that that can be dragged or can be drop targets.
Field Summary
Field Attributes Field Name and Description
<private>  
Internal typeof flag
<private>  
 
The availabe property is false until the linked dom element is accessible.
 
Configuration attributes passed into the constructor
<private>  
Set to true when horizontal contraints are applied
<private>  
Set to true when vertical contraints are applied
<private>  
The id of the element that will be dragged.
 
The group defines a logical collection of DragDrop objects that are related.
<private>  
the id of the element that initiates the drag operation.
 
id
The id of the element associated with this object.
 
An indexted array of css class names for elements that will be ignored if clicked.
 
An associative array of ids for elements that will be ignored if clicked
 
An associative array of HTML tags that will be ignored if clicked.
 
By default, all insances can be a drop target.
<private>  
Individual drag/drop instances can be locked.
 
Maintain offsets when we resetconstraints.
<private>  
The right constraint
<private>  
The down constraint
<private>  
The left constraint
<private>  
The up constraint
 
The padding configured for this drag and drop object for calculating the drop zone intersection with this object.
 
By default the drag and drop instance will only respond to the primary button click (left button for a right-handed mouse).
<private>  
The linked element's absolute X position at the time the drag was started
<private>  
The linked element's absolute X position at the time the drag was started
 
Array of pixel locations the element will snap to if we specified a horizontal graduation/interval.
 
Array of pixel locations the element will snap to if we specified a vertical graduation/interval.
Method Summary
Method Attributes Method Name and Description
 
Lets you specify a css class of elements that will not initiate a drag
 
Lets you to specify an element id for a child of a drag handle that should not initiate a drag
 
Allows you to specify a tag name that should not start a drag operation when clicked.
 
addToGroup(sGroup)
Add this instance to a group of related drag/drop objects.
 
Applies the configuration parameters that were passed into the constructor.
<private>  
b4Drag(e)
Code that executes immediately before the onDrag event
<private>  
Code that executes immediately before the onDragDrop event
<private>  
Code that executes immediately before the onDragOut event
<private>  
Code that executes immediately before the onDragOver event
<private>  
Code that executes immediately before the endDrag event
<private>  
Code executed immediately before the onMouseDown event
<private>  
Code that executes immediately before the startDrag event
 
Clears any constraints applied to this instance.
 
Clears any tick interval defined for this instance
 
Fired when we are done dragging the object
 
Returns a reference to the actual element to drag.
 
Returns a reference to the linked element
<private>  
getTick(val, tickArray)
Normally the drag element is moved pixel by pixel, but we can specify that it move a number of pixels at a time.
<private>  
Fired when this object is clicked
<private>  
Executed when the linked element is available
 
init(id, sGroup, config)
Sets up the DragDrop object.
 
initTarget(id, sGroup, config)
Initializes Targeting functionality only.
 
Returns true if this instance is locked, or the drag drop mgr is locked (meaning that all drag/drop is disabled on the page.
 
Checks the tag exclusion list to see if this click should be ignored
 
lock()
Lock this instance
 
Override the onAvailable method to do what is needed after the initial position was determined.
 
onDrag(e)
Abstract method called during the onMouseMove event while dragging an object.
 
onDragDrop(e, id)
Abstract method called when this item is dropped on another DragDrop obj
 
onDragEnter(e, id)
Abstract method called when this element fist begins hovering over another DragDrop obj
 
onDragOut(e, id)
Abstract method called when we are no longer hovering over an element
 
onDragOver(e, id)
Abstract method called when this element is hovering over another DragDrop obj
 
Event handler that fires when a drag/drop obj gets a mousedown
 
Event handler that fires when a drag/drop obj gets a mouseup
 
Remove's this instance from the supplied interaction group
 
Unsets an invalid css class
 
Unsets an invalid handle id
 
Unsets an excluded tag name set by addInvalidHandleType
 
resetConstraints(maintainOffset)
resetConstraints must be called if you manually reposition a dd element.
 
Allows you to specify that an element other than the linked element will be moved with the cursor during a drag
 
Allows you to specify a child of the linked element that should be used to initiate the drag operation.
 
setInitPosition(diffX, diffY)
Stores the initial placement of the dd element
 
Allows you to set an element outside of the linked element as a drag handle
 
setPadding(iTop, iRight, iBot, iLeft)
Configures the padding for the target zone in px.
<private>  
Sets the start position of the element.
 
setXConstraint(iLeft, iRight, iTickSize)
By default, the element can be dragged any place on the screen.
<private>  
setXTicks(iStartX, iTickSize)
Create the array of horizontal tick marks if an interval was specified in setXConstraint().
 
setYConstraint(iUp, iDown, iTickSize)
By default, the element can be dragged any place on the screen.
<private>  
setYTicks(iStartY, iTickSize)
Create the array of vertical tick marks if an interval was specified in setYConstraint().
 
startDrag(X, Y)
Abstract method called after a drag/drop object is clicked and the drag or mousedown time thresholds have beeen met.
 
toString method
 
Unlock this instace
 
Remove all drag and drop hooks for this element
Class Detail
YAHOO.util.DragDrop(id, sGroup, config)
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:
  • linked element: the element that is passed into the constructor. This is the element which defines the boundaries for interaction with other DragDrop objects.
  • 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.
  • 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 YAHOO.util.DD. setDragElId() lets you define a separate element that would be moved, as in YAHOO.util.DDProxy
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:
 dd = new YAHOO.util.DragDrop("div1", "group1");
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...
 dd.onDragDrop = function(e, id) {
  alert("dd was dropped on " + id);
 }
Parameters:
{String} id
of the element that is linked to this instance
{String} sGroup
the group of related DragDrop objects
{object} config
an object containing configurable attributes Valid properties for DragDrop: padding, isTarget, maintainOffset, primaryButtonOnly
Field Detail
<private> __ygDragDrop
Internal typeof flag

<private> _domRef

{boolean} available
The availabe property is false until the linked dom element is accessible.

{object} config
Configuration attributes passed into the constructor

<private> {boolean} constrainX
Set to true when horizontal contraints are applied

<private> {boolean} constrainY
Set to true when vertical contraints are applied

<private> {String} dragElId
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

groups
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.

<private> {String} handleElId
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.

{String} 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.

{string[]} invalidHandleClasses
An indexted array of css class names for elements that will be ignored if clicked.

invalidHandleIds
An associative array of ids for elements that will be ignored if clicked

invalidHandleTypes
An associative array of HTML tags that will be ignored if clicked.

{boolean} isTarget
By default, all insances can be a drop target. This can be disabled by setting isTarget to false.

<private> {boolean} locked
Individual drag/drop instances can be locked. This will prevent onmousedown start drag.

{boolean} maintainOffset
Maintain offsets when we resetconstraints. Used to maintain the slider thumb value, and this needs to be fixed.

<private> {int} maxX
The right constraint

<private> {int} maxY
The down constraint

<private> {int} minX
The left constraint

<private> {int} minY
The up constraint

{int[]} padding
The padding configured for this drag and drop object for calculating the drop zone intersection with this object.

{boolean} primaryButtonOnly
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

<private> {int} startPageX
The linked element's absolute X position at the time the drag was started

<private> {int} startPageY
The linked element's absolute X position at the time the drag was started

{int[]} xTicks
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.

{int[]} yTicks
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.
Method Detail
addInvalidHandleClass(cssClass)
Lets you specify a css class of elements that will not initiate a drag
Parameters:
{string} cssClass
the class of the elements you wish to ignore

addInvalidHandleId(id)
Lets you to specify an element id for a child of a drag handle that should not initiate a drag
Parameters:
{string} id
the element id of the element you wish to ignore

addInvalidHandleType(tagName)
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.
Parameters:
{string} tagName
the type of element to exclude

addToGroup(sGroup)
Add this instance to a group of related drag/drop objects. All instances belong to at least one group, and can belong to as many groups as needed.
Parameters:
sGroup
{string} the name of the group

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.

<private> b4Drag(e)
Code that executes immediately before the onDrag event
Parameters:
e

<private> b4DragDrop(e)
Code that executes immediately before the onDragDrop event
Parameters:
e

<private> b4DragOut(e)
Code that executes immediately before the onDragOut event
Parameters:
e

<private> b4DragOver(e)
Code that executes immediately before the onDragOver event
Parameters:
e

<private> b4EndDrag(e)
Code that executes immediately before the endDrag event
Parameters:
e

<private> b4MouseDown(e)
Code executed immediately before the onMouseDown event
Parameters:
{Event} e

<private> b4StartDrag(x, y)
Code that executes immediately before the startDrag event
Parameters:
x
y

clearConstraints()
Clears any constraints applied to this instance. Also clears ticks since they can't exist independent of a constraint at this time.

clearTicks()
Clears any tick interval defined for this instance

endDrag(e)
Fired when we are done dragging the object
Parameters:
{Event} e

{HTMLElement} getDragEl()
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
Returns:
{HTMLElement} the html element

{HTMLElement} getEl()
Returns a reference to the linked element
Returns:
{HTMLElement} the html element

<private> {int} getTick(val, tickArray)
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.
Parameters:
{int} val
where we want to place the object
{int[]} tickArray
sorted array of valid points
Returns:
{int} the closest tick

<private> handleMouseDown(e, oDD)
Fired when this object is clicked
Parameters:
{Event} e
{YAHOO.util.DragDrop} oDD
the clicked dd object (this dd obj)

<private> handleOnAvailable()
Executed when the linked element is available

init(id, sGroup, config)
Sets up the DragDrop object. Must be called in the constructor of any YAHOO.util.DragDrop subclass
Parameters:
id
the id of the linked element
{String} sGroup
the group of related items
{object} config
configuration attributes

initTarget(id, sGroup, config)
Initializes Targeting functionality only... the object does not get a mousedown handler.
Parameters:
id
the id of the linked element
{String} sGroup
the group of related items
{object} config
configuration attributes

{boolean} isLocked()
Returns true if this instance is locked, or the drag drop mgr is locked (meaning that all drag/drop is disabled on the page.)
Returns:
{boolean} true if this obj or all drag/drop is locked, else false

{boolean} isValidHandleChild(node)
Checks the tag exclusion list to see if this click should be ignored
Parameters:
{ygNode} node
Returns:
{boolean} true if this is a valid tag type, false if not

lock()
Lock this instance

onAvailable()
Override the onAvailable method to do what is needed after the initial position was determined.

onDrag(e)
Abstract method called during the onMouseMove event while dragging an object.
Parameters:
{Event} e

onDragDrop(e, id)
Abstract method called when this item is dropped on another DragDrop obj
Parameters:
{Event} e
{String || YAHOO.util.DragDrop[]} id
In POINT mode, the element id this was dropped on. In INTERSECT mode, an array of dd items this was dropped on.

onDragEnter(e, id)
Abstract method called when this element fist begins hovering over another DragDrop obj
Parameters:
{Event} e
{String || YAHOO.util.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.

onDragOut(e, id)
Abstract method called when we are no longer hovering over an element
Parameters:
{Event} e
{String || YAHOO.util.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.

onDragOver(e, id)
Abstract method called when this element is hovering over another DragDrop obj
Parameters:
{Event} e
{String || YAHOO.util.DragDrop[]} id
In POINT mode, the element id this is hovering over. In INTERSECT mode, an array of dd items being hovered over.

onMouseDown(e)
Event handler that fires when a drag/drop obj gets a mousedown
Parameters:
{Event} e

onMouseUp(e)
Event handler that fires when a drag/drop obj gets a mouseup
Parameters:
{Event} e

removeFromGroup(sGroup)
Remove's this instance from the supplied interaction group
Parameters:
{string} sGroup
The group to drop

removeInvalidHandleClass(the)
Unsets an invalid css class
Parameters:
{string} the
class of the element(s) you wish to re-enable

removeInvalidHandleId(the)
Unsets an invalid handle id
Parameters:
{string} the
id of the element to re-enable

removeInvalidHandleType(tagName)
Unsets an excluded tag name set by addInvalidHandleType
Parameters:
{string} tagName
the type of element to unexclude

resetConstraints(maintainOffset)
resetConstraints must be called if you manually reposition a dd element.
Parameters:
{boolean} maintainOffset

setDragElId(id)
Allows you to specify that an element other than the linked element will be moved with the cursor during a drag
Parameters:
id
the id of the element that will be used to initiate the drag

setHandleElId(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.
Parameters:
id
the id of the element that will be used to initiate the drag

setInitPosition(diffX, diffY)
Stores the initial placement of the dd element
Parameters:
diffX
diffY

setOuterHandleElId(id)
Allows you to set an element outside of the linked element as a drag handle
Parameters:
id

setPadding(iTop, iRight, iBot, iLeft)
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.
Parameters:
{int} iTop
Top pad
{int} iRight
Right pad
{int} iBot
Bot pad
{int} iLeft
Left pad

<private> setStartPosition(pos)
Sets the start position of the element. This is set when the obj is initialized, the reset when a drag is started.
Parameters:
pos
current position (from previous lookup)

setXConstraint(iLeft, iRight, iTickSize)
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.
Parameters:
{int} iLeft
the number of pixels the element can move to the left
{int} iRight
the number of pixels the element can move to the right
{int} iTickSize
optional parameter for specifying that the element should move iTickSize pixels at a time.

<private> setXTicks(iStartX, iTickSize)
Create the array of horizontal tick marks if an interval was specified in setXConstraint().
Parameters:
iStartX
iTickSize

setYConstraint(iUp, iDown, iTickSize)
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.
Parameters:
{int} iUp
the number of pixels the element can move up
{int} iDown
the number of pixels the element can move down
{int} iTickSize
optional parameter for specifying that the element should move iTickSize pixels at a time.

<private> setYTicks(iStartY, iTickSize)
Create the array of vertical tick marks if an interval was specified in setYConstraint().
Parameters:
iStartY
iTickSize

startDrag(X, Y)
Abstract method called after a drag/drop object is clicked and the drag or mousedown time thresholds have beeen met.
Parameters:
{int} X
click location
{int} Y
click location

{string} toString()
toString method
Returns:
{string} string representation of the dd obj

unlock()
Unlock this instace

unreg()
Remove all drag and drop hooks for this element

Documentation generated by JsDoc Toolkit 2.0.0 on Thu Dec 02 2010 15:18:58 GMT+0100 (CET)