Ext.dd.DropZone
Hierarchy
Ext.BaseExt.dd.DragDropExt.dd.DDTargetExt.dd.DropTargetExt.dd.DropZoneRequires
Subclasses
Files
This class provides a container DD instance that allows dropping on multiple child target nodes.
By default, this class requires that child nodes accepting drop are registered with Ext.dd.Registry. However a simpler way to allow a DropZone to manage any number of target elements is to configure the DropZone with an implementation of getTargetFromEvent which interrogates the passed mouse event to see if it has taken place within an element, or class of elements. This is easily done by using the event's getTarget method to identify a node based on a Ext.DomQuery selector.
Once the DropZone has detected through calling getTargetFromEvent, that the mouse is over a drop target, that target is passed as the first parameter to onNodeEnter, onNodeOver, onNodeOut, onNodeDrop. You may configure the instance of DropZone with implementations of these methods to provide application-specific behaviour for these events to update both application state, and UI state.
For example to make a GridPanel a cooperating target with the example illustrated in DragZone, the following technique might be used:
myGridPanel.on('render', function() {
myGridPanel.dropZone = new Ext.dd.DropZone(myGridPanel.getView().scroller, {
// If the mouse is over a grid row, return that node. This is
// provided as the "target" parameter in all "onNodeXXXX" node event handling functions
getTargetFromEvent: function(e) {
return e.getTarget(myGridPanel.getView().rowSelector);
},
// On entry into a target node, highlight that node.
onNodeEnter : function(target, dd, e, data){
Ext.fly(target).addCls('my-row-highlight-class');
},
// On exit from a target node, unhighlight that node.
onNodeOut : function(target, dd, e, data){
Ext.fly(target).removeCls('my-row-highlight-class');
},
// While over a target node, return the default drop allowed class which
// places a "tick" icon into the drag proxy.
onNodeOver : function(target, dd, e, data){
return Ext.dd.DropZone.prototype.dropAllowed;
},
// On node drop we can interrogate the target to find the underlying
// application object that is the real target of the dragged data.
// In this case, it is a Record in the GridPanel's Store.
// We can use the data set up by the DragZone's getDragData method to read
// any data we decided to attach in the DragZone's getDragData method.
onNodeDrop : function(target, dd, e, data){
var rowIndex = myGridPanel.getView().findRowIndex(target);
var r = myGridPanel.getStore().getAt(rowIndex);
Ext.Msg.alert('Drop gesture', 'Dropped Record id ' + data.draggedRecord.id +
' on Record id ' + r.id);
return true;
}
});
}
See the DragZone documentation for details about building a DragZone which cooperates with this DropZone.
Available since: 1.1.0
Config options
A named drag drop group to which this object belongs. If a group is specified, then this object will only interact with other drag drop objects in the same group.
Available since: 1.1.0
The CSS class returned to the drag source when drop is allowed.
Defaults to: "x-dd-drop-ok"
Available since: 1.1.0
Properties
Internal typeof flag
Defaults to: true
Available since: 1.1.0
Cached reference to the linked element
Cached reference to the linked element
Available since: 1.1.0
The available property is false until the linked dom element is accessible.
Defaults to: false
Available since: 1.1.0
Configuration attributes passed into the constructor
Configuration attributes passed into the constructor
Available since: 1.1.0
Set to true when horizontal contraints are applied
Defaults to: false
Available since: 1.1.0
Set to true when vertical contraints are applied
Defaults to: false
Available since: 1.1.0
Provides default constraint padding to "constrainTo" elements.
Defaults to: {left: 0, right: 0, top: 0, bottom: 0}
Available since: 2.3.0
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: Ext.dd.DDProxy
Available since: 1.1.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. An object in the format {'group1':true, 'group2':true}
Available since: 1.1.0
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.
Available since: 1.1.0
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. Defaults to false.
Defaults to: false
Available since: 1.1.0
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.
Available since: 1.1.0
Set to false to enable a DragDrop object to fire drag events while dragging over its own Element. Defaults to true - DragDrop objects do not by default fire drag events to themselves.
Available since: 3.4.0
An Array of CSS class names for elements to be considered in valid as drag handles.
An Array of CSS class names for elements to be considered in valid as drag handles.
Available since: 1.1.0
An object who's property names identify the IDs of elements to be considered invalid as drag handles. A non-null property value identifies the ID as invalid. For example, to prevent dragging from being initiated on element ID "foo", use:
{
foo: true
}
Available since: 1.1.0
An object who's property names identify HTML tags to be considered invalid as drag handles. A non-null property value identifies the tag as invalid. Defaults to the following value which prevents drag operations from being initiated by <a> elements:
{
A: "A"
}
Available since: 1.1.0
private
By default, all instances can be a drop target. This can be disabled by setting isTarget to false.
Defaults to: true
Available since: 1.1.0
Overrides: Ext.dd.DragDrop.isTarget
Individual drag/drop instances can be locked. This will prevent onmousedown start drag.
Defaults to: false
Available since: 1.1.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
Defaults to: false
Available since: 1.1.0
When set to true, other DD objects in cooperating DDGroups do not receive notification events when this DD object is dragged over them. Defaults to false.
Defaults to: false
Available since: 2.3.0
The padding configured for this drag and drop object for calculating the drop zone intersection with this object. An array containing the 4 padding values: [top, right, bottom, left]
Available since: 1.1.0
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
Defaults to: true
Available since: 1.1.0
Get the reference to the current class from which this object was instantiated. Unlike statics,
this.self is scope-dependent and it's meant to be used for dynamic inheritance. See statics
for a detailed comparison
Ext.define('My.Cat', {
statics: {
speciesName: 'Cat' // My.Cat.speciesName = 'Cat'
},
constructor: function() {
alert(this.self.speciesName); / dependent on 'this'
return this;
},
clone: function() {
return new this.self();
}
});
Ext.define('My.SnowLeopard', {
extend: 'My.Cat',
statics: {
speciesName: 'Snow Leopard' // My.SnowLeopard.speciesName = 'Snow Leopard'
}
});
var cat = new My.Cat(); // alerts 'Cat'
var snowLeopard = new My.SnowLeopard(); // alerts 'Snow Leopard'
var clone = snowLeopard.clone();
alert(Ext.getClassName(clone)); // alerts 'My.SnowLeopard'
Available since: 4.0.0
The linked element's absolute X position at the time the drag was started
Defaults to: 0
Available since: 1.1.0
The linked element's absolute X position at the time the drag was started
Defaults to: 0
Available since: 1.1.0
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.
Available since: 1.1.0
Methods
Instance Methods Creates new DropTarget. ...Creates new DropTarget.
Available since: 1.1.0
Parameters
- el : String/HTMLElement/Ext.Element
The container element or ID of it.
- config : Object
Returns
Overrides: Ext.dd.DDTarget.constructor
addToGroup( sGroup )Adds this instance to a group of related drag/drop objects. ...Adds 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.
Available since: 1.1.0
Parameters
- sGroup : String
the name of the group
applyConfig( )Applies the configuration parameters that were passed into the constructor. ...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.
Available since: 1.1.0
b4DragDrop( e )privateCode that executes immediately before the onDragDrop event ...Code that executes immediately before the onDragDrop event
Available since: 1.1.0
Parameters
- e : Object
b4DragOut( e )privateCode that executes immediately before the onDragOut event ...Code that executes immediately before the onDragOut event
Available since: 1.1.0
Parameters
- e : Object
b4DragOver( e )privateCode that executes immediately before the onDragOver event ...Code that executes immediately before the onDragOver event
Available since: 1.1.0
Parameters
- e : Object
b4MouseDown( e )privateCode executed immediately before the onMouseDown event ...Code executed immediately before the onMouseDown event
Available since: 1.1.0
Parameters
- e : Event
the mousedown event
b4StartDrag( x, y )private Call the original method that was previously overridden with override
Ext.define('My.Cat', {
constructor: functi...Call the original method that was previously overridden with override
Ext.define('My.Cat', {
constructor: function() {
alert("I'm a cat!");
return this;
}
});
My.Cat.override({
constructor: function() {
alert("I'm going to be a cat!");
var instance = this.callOverridden();
alert("Meeeeoooowwww");
return instance;
}
});
var kitty = new My.Cat(); // alerts "I'm going to be a cat!"
// alerts "I'm a cat!"
// alerts "Meeeeoooowwww"
Available since: 4.0.0
Parameters
- args : Array/Arguments
The arguments, either an array or the arguments object
Returns
- Object
Returns the result after calling the overridden method
Call the parent's overridden method. ...Call the parent's overridden method. For example:
Ext.define('My.own.A', {
constructor: function(test) {
alert(test);
}
});
Ext.define('My.own.B', {
extend: 'My.own.A',
constructor: function(test) {
alert(test);
this.callParent([test + 1]);
}
});
Ext.define('My.own.C', {
extend: 'My.own.B',
constructor: function() {
alert("Going to call parent's overriden constructor...");
this.callParent(arguments);
}
});
var a = new My.own.A(1); // alerts '1'
var b = new My.own.B(1); // alerts '1', then alerts '2'
var c = new My.own.C(2); // alerts "Going to call parent's overriden constructor..."
// alerts '2', then alerts '3'
Available since: 4.0.0
Parameters
- args : Array/Arguments
The arguments, either an array or the arguments object
from the current method, for example: this.callParent(arguments)
Returns
- Object
Returns the result from the superclass' method
constrainTo( constrainTo, [pad], [inContent] )Initializes the drag drop object's constraints to restrict movement to a certain element. ...Initializes the drag drop object's constraints to restrict movement to a certain element.
Usage:
var dd = new Ext.dd.DDProxy("dragDiv1", "proxytest",
{ dragElId: "existingProxyDiv" });
dd.startDrag = function(){
this.constrainTo("parent-id");
};
Or you can initalize it using the Ext.Element object:
Ext.get("dragDiv1").initDDProxy("proxytest", {dragElId: "existingProxyDiv"}, {
startDrag : function(){
this.constrainTo("parent-id");
}
});
Available since: 2.3.0
Parameters
- constrainTo : String/HTMLElement/Ext.Element
The element or element ID to constrain to.
- pad : Object/Number (optional)
Pad provides a way to specify "padding" of the constraints,
and can be either a number for symmetrical padding (4 would be equal to {left:4, right:4, top:4, bottom:4}) or
an object containing the sides to pad. For example: {right:10, bottom:10}
- inContent : Boolean (optional)
Constrain the draggable in the content box of the element (inside padding and borders)
getEl( ) : HTMLElementReturns a reference to the linked element ...Returns a reference to the linked element
Available since: 1.1.0
Returns
- HTMLElement
the html element
Returns a custom data object associated with the DOM node that is the target of the event. ...Returns a custom data object associated with the DOM node that is the target of the event. By default
this looks up the event target in the Ext.dd.Registry, although you can override this method to
provide your own custom lookup.
Available since: 1.1.0
Parameters
- e : Event
The event
Returns
- Object
data The custom data
Normally the drag element is moved pixel by pixel, but we can specify
that it move a number of pixels at a time. ...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.
Available since: 1.1.0
Parameters
Returns
- Number
the closest tick
handleMouseDown( e, oDD )privateCalled when this object is clicked ...Called when this object is clicked
Available since: 1.1.0
Parameters
- e : Event
- oDD : Ext.dd.DragDrop
the clicked dd object (this dd obj)
handleOnAvailable( )privateExecuted when the linked element is available ...Executed when the linked element is available
Available since: 1.1.0
init( id, sGroup, config )Sets up the DragDrop object. ...Sets up the DragDrop object. Must be called in the constructor of any
Ext.dd.DragDrop subclass
Available since: 1.1.0
Parameters
Initialize configuration for this class. ...Initialize configuration for this class. a typical example:
Ext.define('My.awesome.Class', {
// The default config
config: {
name: 'Awesome',
isAwesome: true
},
constructor: function(config) {
this.initConfig(config);
return this;
}
});
var awesome = new My.awesome.Class({
name: 'Super Awesome'
});
alert(awesome.getName()); // 'Super Awesome'
Available since: 4.0.0
Parameters
- config : Object
Returns
- Object
mixins The mixin prototypes as key - value pairs
initTarget( id, sGroup, config ) Returns true if this instance is locked, or the drag drop mgr is locked
(meaning that all drag/drop is disabled on th...Returns true if this instance is locked, or the drag drop mgr is locked
(meaning that all drag/drop is disabled on the page.)
Available since: 1.1.0
Returns
- Boolean
true if this obj or all drag/drop is locked, else
false
mixin( name, cls )private The function a Ext.dd.DragSource calls once to notify this drop zone that the dragged item has
been dropped on it. ...The function a Ext.dd.DragSource calls once to notify this drop zone that the dragged item has
been dropped on it. The drag zone will look up the target node based on the event passed in, and if there
is a node registered for that event, it will delegate to onNodeDrop for node-specific handling,
otherwise it will call onContainerDrop.
Available since: 1.1.0
Parameters
- source : Ext.dd.DragSource
The drag source that was dragged over this drop zone
- e : Event
The event
- data : Object
An object containing arbitrary data supplied by the drag source
Returns
- Boolean
False if the drop was invalid.
Overrides: Ext.dd.DropTarget.notifyDrop
The function a Ext.dd.DragSource calls once to notify this drop zone that the source is now over
the zone. ...The function a Ext.dd.DragSource calls once to notify this drop zone that the source is now over
the zone. The default implementation returns this.dropNotAllowed and expects that only registered drop
nodes can process drag drop operations, so if you need the drop zone itself to be able to process drops
you should override this method and provide a custom implementation.
Available since: 1.1.0
Parameters
- source : Ext.dd.DragSource
The drag source that was dragged over this drop zone
- e : Event
The event
- data : Object
An object containing arbitrary data supplied by the drag source
Returns
- String
status The CSS class that communicates the drop status back to the source so that the
underlying Ext.dd.StatusProxy can be updated
Overrides: Ext.dd.DropTarget.notifyEnter
notifyOut( source, e, data )The function a Ext.dd.DragSource calls once to notify this drop zone that the source has been dragged
out of the zone...The function a Ext.dd.DragSource calls once to notify this drop zone that the source has been dragged
out of the zone without dropping. If the drag source is currently over a registered node, the notification
will be delegated to onNodeOut for node-specific handling, otherwise it will be ignored.
Available since: 1.1.0
Parameters
- source : Ext.dd.DragSource
The drag source that was dragged over this drop target
- e : Event
The event
- data : Object
An object containing arbitrary data supplied by the drag zone
Overrides: Ext.dd.DropTarget.notifyOut
The function a Ext.dd.DragSource calls continuously while it is being dragged over the drop zone. ...The function a Ext.dd.DragSource calls continuously while it is being dragged over the drop zone.
This method will be called on every mouse movement while the drag source is over the drop zone.
It will call onNodeOver while the drag source is over a registered node, and will also automatically
delegate to the appropriate node-specific methods as necessary when the drag source enters and exits
registered nodes (onNodeEnter, onNodeOut). If the drag source is not currently over a
registered node, it will call onContainerOver.
Available since: 1.1.0
Parameters
- source : Ext.dd.DragSource
The drag source that was dragged over this drop zone
- e : Event
The event
- data : Object
An object containing arbitrary data supplied by the drag source
Returns
- String
status The CSS class that communicates the drop status back to the source so that the
underlying Ext.dd.StatusProxy can be updated
Overrides: Ext.dd.DropTarget.notifyOver
onAvailable( )Override the onAvailable method to do what is needed after the initial
position was determined. ...Override the onAvailable method to do what is needed after the initial
position was determined.
Available since: 1.1.0
Called when the DropZone determines that a Ext.dd.DragSource has been dropped on it,
but not on any of its registered...Called when the DropZone determines that a Ext.dd.DragSource has been dropped on it,
but not on any of its registered drop nodes. The default implementation returns false, so it should be
overridden to provide the appropriate processing of the drop event if you need the drop zone itself to
be able to accept drops. It should return true when valid so that the drag source's repair action does not run.
Available since: 1.1.0
Parameters
- source : Ext.dd.DragSource
The drag source that was dragged over this drop zone
- e : Event
The event
- data : Object
An object containing arbitrary data supplied by the drag source
Returns
- Boolean
True if the drop was valid, else false
Called while the DropZone determines that a Ext.dd.DragSource is being dragged over it,
but not over any of its regis...Called while the DropZone determines that a Ext.dd.DragSource is being dragged over it,
but not over any of its registered drop nodes. The default implementation returns this.dropNotAllowed, so
it should be overridden to provide the proper feedback if necessary.
Available since: 1.1.0
Parameters
- source : Ext.dd.DragSource
The drag source that was dragged over this drop zone
- e : Event
The event
- data : Object
An object containing arbitrary data supplied by the drag source
Returns
- String
status The CSS class that communicates the drop status back to the source so that the
underlying Ext.dd.StatusProxy can be updated
Called when the DropZone determines that a Ext.dd.DragSource has been dropped onto
the drop node. ...Called when the DropZone determines that a Ext.dd.DragSource has been dropped onto
the drop node. The default implementation returns false, so it should be overridden to provide the
appropriate processing of the drop event and return true so that the drag source's repair action does not run.
Available since: 1.1.0
Parameters
- nodeData : Object
The custom data associated with the drop node (this is the same value returned from
getTargetFromEvent for this node)
- source : Ext.dd.DragSource
The drag source that was dragged over this drop zone
- e : Event
The event
- data : Object
An object containing arbitrary data supplied by the drag source
Returns
- Boolean
True if the drop was valid, else false
onNodeEnter( nodeData, source, e, data )Called when the DropZone determines that a Ext.dd.DragSource has entered a drop node
that has either been registered ...Called when the DropZone determines that a Ext.dd.DragSource has entered a drop node
that has either been registered or detected by a configured implementation of getTargetFromEvent.
This method has no default implementation and should be overridden to provide
node-specific processing if necessary.
Available since: 1.1.0
Parameters
- nodeData : Object
The custom data associated with the drop node (this is the same value returned from
getTargetFromEvent for this node)
- source : Ext.dd.DragSource
The drag source that was dragged over this drop zone
- e : Event
The event
- data : Object
An object containing arbitrary data supplied by the drag source
onNodeOut( nodeData, source, e, data )Called when the DropZone determines that a Ext.dd.DragSource has been dragged out of
the drop node without dropping. ...Called when the DropZone determines that a Ext.dd.DragSource has been dragged out of
the drop node without dropping. This method has no default implementation and should be overridden to provide
node-specific processing if necessary.
Available since: 1.1.0
Parameters
- nodeData : Object
The custom data associated with the drop node (this is the same value returned from
getTargetFromEvent for this node)
- source : Ext.dd.DragSource
The drag source that was dragged over this drop zone
- e : Event
The event
- data : Object
An object containing arbitrary data supplied by the drag source
Called while the DropZone determines that a Ext.dd.DragSource is over a drop node
that has either been registered or ...Called while the DropZone determines that a Ext.dd.DragSource is over a drop node
that has either been registered or detected by a configured implementation of getTargetFromEvent.
The default implementation returns this.dropNotAllowed, so it should be
overridden to provide the proper feedback.
Available since: 1.1.0
Parameters
- nodeData : Object
The custom data associated with the drop node (this is the same value returned from
getTargetFromEvent for this node)
- source : Ext.dd.DragSource
The drag source that was dragged over this drop zone
- e : Event
The event
- data : Object
An object containing arbitrary data supplied by the drag source
Returns
- String
status The CSS class that communicates the drop status back to the source so that the
underlying Ext.dd.StatusProxy can be updated
removeFromGroup( sGroup )Removes this instance from the supplied interaction group ...Removes this instance from the supplied interaction group
Available since: 1.1.0
Parameters
- sGroup : String
The group to drop
setPadding( iTop, iRight, iBot, iLeft )Configures the padding for the target zone in px. ...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.
Available since: 1.1.0
Parameters
setStartPosition( pos )privateSets the start position of the element. ...Sets the start position of the element. This is set when the obj
is initialized, the reset when a drag is started.
Available since: 1.1.0
Parameters
- pos : Object
current position (from previous lookup)
setXTicks( iStartX, iTickSize )private setYTicks( iStartY, iTickSize )private Get the reference to the class from which this object was instantiated. ...Get the reference to the class from which this object was instantiated. Note that unlike self,
this.statics() is scope-independent and it always returns the class from which it was called, regardless of what
this points to during run-time
Ext.define('My.Cat', {
statics: {
totalCreated: 0,
speciesName: 'Cat' // My.Cat.speciesName = 'Cat'
},
constructor: function() {
var statics = this.statics();
alert(statics.speciesName); // always equals to 'Cat' no matter what 'this' refers to
// equivalent to: My.Cat.speciesName
alert(this.self.speciesName); // dependent on 'this'
statics.totalCreated++;
return this;
},
clone: function() {
var cloned = new this.self; // dependent on 'this'
cloned.groupName = this.statics().speciesName; // equivalent to: My.Cat.speciesName
return cloned;
}
});
Ext.define('My.SnowLeopard', {
extend: 'My.Cat',
statics: {
speciesName: 'Snow Leopard' // My.SnowLeopard.speciesName = 'Snow Leopard'
},
constructor: function() {
this.callParent();
}
});
var cat = new My.Cat(); // alerts 'Cat', then alerts 'Cat'
var snowLeopard = new My.SnowLeopard(); // alerts 'Cat', then alerts 'Snow Leopard'
var clone = snowLeopard.clone();
alert(Ext.getClassName(clone)); // alerts 'My.SnowLeopard'
alert(clone.groupName); // alerts 'Cat'
alert(My.Cat.totalCreated); // alerts 3
Available since: 4.0.0
Returns
toString method ...toString method
Available since: 1.1.0
Returns
- String
string representation of the dd obj
Overrides: Ext.dd.DragDrop.toString
unreg( )Removes all drag and drop hooks for this element ...Removes all drag and drop hooks for this element
Available since: 1.1.0
Creates new DropTarget.
Available since: 1.1.0
Parameters
- el : String/HTMLElement/Ext.Element
The container element or ID of it.
- config : Object
Returns
Overrides: Ext.dd.DDTarget.constructor
Adds 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.
Available since: 1.1.0
Parameters
- sGroup : String
the name of the group
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.
Available since: 1.1.0
Code that executes immediately before the onDragDrop event
Available since: 1.1.0
Parameters
- e : Object
Code that executes immediately before the onDragOut event
Available since: 1.1.0
Parameters
- e : Object
Code that executes immediately before the onDragOver event
Available since: 1.1.0
Parameters
- e : Object
Code executed immediately before the onMouseDown event
Available since: 1.1.0
Parameters
- e : Event
the mousedown event
Call the original method that was previously overridden with override
Ext.define('My.Cat', {
constructor: function() {
alert("I'm a cat!");
return this;
}
});
My.Cat.override({
constructor: function() {
alert("I'm going to be a cat!");
var instance = this.callOverridden();
alert("Meeeeoooowwww");
return instance;
}
});
var kitty = new My.Cat(); // alerts "I'm going to be a cat!"
// alerts "I'm a cat!"
// alerts "Meeeeoooowwww"
Available since: 4.0.0
Parameters
- args : Array/Arguments
The arguments, either an array or the
argumentsobject
Returns
- Object
Returns the result after calling the overridden method
Call the parent's overridden method. For example:
Ext.define('My.own.A', {
constructor: function(test) {
alert(test);
}
});
Ext.define('My.own.B', {
extend: 'My.own.A',
constructor: function(test) {
alert(test);
this.callParent([test + 1]);
}
});
Ext.define('My.own.C', {
extend: 'My.own.B',
constructor: function() {
alert("Going to call parent's overriden constructor...");
this.callParent(arguments);
}
});
var a = new My.own.A(1); // alerts '1'
var b = new My.own.B(1); // alerts '1', then alerts '2'
var c = new My.own.C(2); // alerts "Going to call parent's overriden constructor..."
// alerts '2', then alerts '3'
Available since: 4.0.0
Parameters
- args : Array/Arguments
The arguments, either an array or the
argumentsobject from the current method, for example:this.callParent(arguments)
Returns
- Object
Returns the result from the superclass' method
Initializes the drag drop object's constraints to restrict movement to a certain element.
Usage:
var dd = new Ext.dd.DDProxy("dragDiv1", "proxytest",
{ dragElId: "existingProxyDiv" });
dd.startDrag = function(){
this.constrainTo("parent-id");
};
Or you can initalize it using the Ext.Element object:
Ext.get("dragDiv1").initDDProxy("proxytest", {dragElId: "existingProxyDiv"}, {
startDrag : function(){
this.constrainTo("parent-id");
}
});
Available since: 2.3.0
Parameters
- constrainTo : String/HTMLElement/Ext.Element
The element or element ID to constrain to.
- pad : Object/Number (optional)
Pad provides a way to specify "padding" of the constraints, and can be either a number for symmetrical padding (4 would be equal to
{left:4, right:4, top:4, bottom:4}) or an object containing the sides to pad. For example:{right:10, bottom:10} - inContent : Boolean (optional)
Constrain the draggable in the content box of the element (inside padding and borders)
Returns a reference to the linked element
Available since: 1.1.0
Returns
- HTMLElement
the html element
Returns a custom data object associated with the DOM node that is the target of the event. By default this looks up the event target in the Ext.dd.Registry, although you can override this method to provide your own custom lookup.
Available since: 1.1.0
Parameters
- e : Event
The event
Returns
- Object
data The custom data
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.
Available since: 1.1.0
Parameters
Returns
- Number
the closest tick
Called when this object is clicked
Available since: 1.1.0
Parameters
- e : Event
- oDD : Ext.dd.DragDrop
the clicked dd object (this dd obj)
Executed when the linked element is available
Available since: 1.1.0
Sets up the DragDrop object. Must be called in the constructor of any Ext.dd.DragDrop subclass
Available since: 1.1.0
Parameters
Initialize configuration for this class. a typical example:
Ext.define('My.awesome.Class', {
// The default config
config: {
name: 'Awesome',
isAwesome: true
},
constructor: function(config) {
this.initConfig(config);
return this;
}
});
var awesome = new My.awesome.Class({
name: 'Super Awesome'
});
alert(awesome.getName()); // 'Super Awesome'
Available since: 4.0.0
Parameters
- config : Object
Returns
- Object
mixins The mixin prototypes as key - value pairs
Returns true if this instance is locked, or the drag drop mgr is locked (meaning that all drag/drop is disabled on the page.)
Available since: 1.1.0
Returns
- Boolean
true if this obj or all drag/drop is locked, else false
The function a Ext.dd.DragSource calls once to notify this drop zone that the dragged item has been dropped on it. The drag zone will look up the target node based on the event passed in, and if there is a node registered for that event, it will delegate to onNodeDrop for node-specific handling, otherwise it will call onContainerDrop.
Available since: 1.1.0
Parameters
- source : Ext.dd.DragSource
The drag source that was dragged over this drop zone
- e : Event
The event
- data : Object
An object containing arbitrary data supplied by the drag source
Returns
- Boolean
False if the drop was invalid.
Overrides: Ext.dd.DropTarget.notifyDrop
The function a Ext.dd.DragSource calls once to notify this drop zone that the source is now over the zone. The default implementation returns this.dropNotAllowed and expects that only registered drop nodes can process drag drop operations, so if you need the drop zone itself to be able to process drops you should override this method and provide a custom implementation.
Available since: 1.1.0
Parameters
- source : Ext.dd.DragSource
The drag source that was dragged over this drop zone
- e : Event
The event
- data : Object
An object containing arbitrary data supplied by the drag source
Returns
- String
status The CSS class that communicates the drop status back to the source so that the underlying Ext.dd.StatusProxy can be updated
Overrides: Ext.dd.DropTarget.notifyEnter
The function a Ext.dd.DragSource calls once to notify this drop zone that the source has been dragged out of the zone without dropping. If the drag source is currently over a registered node, the notification will be delegated to onNodeOut for node-specific handling, otherwise it will be ignored.
Available since: 1.1.0
Parameters
- source : Ext.dd.DragSource
The drag source that was dragged over this drop target
- e : Event
The event
- data : Object
An object containing arbitrary data supplied by the drag zone
Overrides: Ext.dd.DropTarget.notifyOut
The function a Ext.dd.DragSource calls continuously while it is being dragged over the drop zone. This method will be called on every mouse movement while the drag source is over the drop zone. It will call onNodeOver while the drag source is over a registered node, and will also automatically delegate to the appropriate node-specific methods as necessary when the drag source enters and exits registered nodes (onNodeEnter, onNodeOut). If the drag source is not currently over a registered node, it will call onContainerOver.
Available since: 1.1.0
Parameters
- source : Ext.dd.DragSource
The drag source that was dragged over this drop zone
- e : Event
The event
- data : Object
An object containing arbitrary data supplied by the drag source
Returns
- String
status The CSS class that communicates the drop status back to the source so that the underlying Ext.dd.StatusProxy can be updated
Overrides: Ext.dd.DropTarget.notifyOver
Override the onAvailable method to do what is needed after the initial position was determined.
Available since: 1.1.0
Called when the DropZone determines that a Ext.dd.DragSource has been dropped on it, but not on any of its registered drop nodes. The default implementation returns false, so it should be overridden to provide the appropriate processing of the drop event if you need the drop zone itself to be able to accept drops. It should return true when valid so that the drag source's repair action does not run.
Available since: 1.1.0
Parameters
- source : Ext.dd.DragSource
The drag source that was dragged over this drop zone
- e : Event
The event
- data : Object
An object containing arbitrary data supplied by the drag source
Returns
- Boolean
True if the drop was valid, else false
Called while the DropZone determines that a Ext.dd.DragSource is being dragged over it, but not over any of its registered drop nodes. The default implementation returns this.dropNotAllowed, so it should be overridden to provide the proper feedback if necessary.
Available since: 1.1.0
Parameters
- source : Ext.dd.DragSource
The drag source that was dragged over this drop zone
- e : Event
The event
- data : Object
An object containing arbitrary data supplied by the drag source
Returns
- String
status The CSS class that communicates the drop status back to the source so that the underlying Ext.dd.StatusProxy can be updated
Called when the DropZone determines that a Ext.dd.DragSource has been dropped onto the drop node. The default implementation returns false, so it should be overridden to provide the appropriate processing of the drop event and return true so that the drag source's repair action does not run.
Available since: 1.1.0
Parameters
- nodeData : Object
The custom data associated with the drop node (this is the same value returned from getTargetFromEvent for this node)
- source : Ext.dd.DragSource
The drag source that was dragged over this drop zone
- e : Event
The event
- data : Object
An object containing arbitrary data supplied by the drag source
Returns
- Boolean
True if the drop was valid, else false
Called when the DropZone determines that a Ext.dd.DragSource has entered a drop node that has either been registered or detected by a configured implementation of getTargetFromEvent. This method has no default implementation and should be overridden to provide node-specific processing if necessary.
Available since: 1.1.0
Parameters
- nodeData : Object
The custom data associated with the drop node (this is the same value returned from getTargetFromEvent for this node)
- source : Ext.dd.DragSource
The drag source that was dragged over this drop zone
- e : Event
The event
- data : Object
An object containing arbitrary data supplied by the drag source
Called when the DropZone determines that a Ext.dd.DragSource has been dragged out of the drop node without dropping. This method has no default implementation and should be overridden to provide node-specific processing if necessary.
Available since: 1.1.0
Parameters
- nodeData : Object
The custom data associated with the drop node (this is the same value returned from getTargetFromEvent for this node)
- source : Ext.dd.DragSource
The drag source that was dragged over this drop zone
- e : Event
The event
- data : Object
An object containing arbitrary data supplied by the drag source
Called while the DropZone determines that a Ext.dd.DragSource is over a drop node that has either been registered or detected by a configured implementation of getTargetFromEvent. The default implementation returns this.dropNotAllowed, so it should be overridden to provide the proper feedback.
Available since: 1.1.0
Parameters
- nodeData : Object
The custom data associated with the drop node (this is the same value returned from getTargetFromEvent for this node)
- source : Ext.dd.DragSource
The drag source that was dragged over this drop zone
- e : Event
The event
- data : Object
An object containing arbitrary data supplied by the drag source
Returns
- String
status The CSS class that communicates the drop status back to the source so that the underlying Ext.dd.StatusProxy can be updated
Removes this instance from the supplied interaction group
Available since: 1.1.0
Parameters
- sGroup : String
The group to drop
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.
Available since: 1.1.0
Parameters
Sets the start position of the element. This is set when the obj is initialized, the reset when a drag is started.
Available since: 1.1.0
Parameters
- pos : Object
current position (from previous lookup)
Get the reference to the class from which this object was instantiated. Note that unlike self,
this.statics() is scope-independent and it always returns the class from which it was called, regardless of what
this points to during run-time
Ext.define('My.Cat', {
statics: {
totalCreated: 0,
speciesName: 'Cat' // My.Cat.speciesName = 'Cat'
},
constructor: function() {
var statics = this.statics();
alert(statics.speciesName); // always equals to 'Cat' no matter what 'this' refers to
// equivalent to: My.Cat.speciesName
alert(this.self.speciesName); // dependent on 'this'
statics.totalCreated++;
return this;
},
clone: function() {
var cloned = new this.self; // dependent on 'this'
cloned.groupName = this.statics().speciesName; // equivalent to: My.Cat.speciesName
return cloned;
}
});
Ext.define('My.SnowLeopard', {
extend: 'My.Cat',
statics: {
speciesName: 'Snow Leopard' // My.SnowLeopard.speciesName = 'Snow Leopard'
},
constructor: function() {
this.callParent();
}
});
var cat = new My.Cat(); // alerts 'Cat', then alerts 'Cat'
var snowLeopard = new My.SnowLeopard(); // alerts 'Cat', then alerts 'Snow Leopard'
var clone = snowLeopard.clone();
alert(Ext.getClassName(clone)); // alerts 'My.SnowLeopard'
alert(clone.groupName); // alerts 'Cat'
alert(My.Cat.totalCreated); // alerts 3
Available since: 4.0.0
Returns
toString method
Available since: 1.1.0
Returns
- String
string representation of the dd obj
Overrides: Ext.dd.DragDrop.toString
Removes all drag and drop hooks for this element
Available since: 1.1.0
Static Methods Add / override static properties of this class. ...Add / override static properties of this class.
Ext.define('My.cool.Class', {
...
});
My.cool.Class.addStatics({
someProperty: 'someValue', // My.cool.Class.someProperty = 'someValue'
method1: function() { ... }, // My.cool.Class.method1 = function() { ... };
method2: function() { ... } // My.cool.Class.method2 = function() { ... };
});
Available since: 4.0.2
Parameters
- members : Object
Returns
- Ext.Base
this
Borrow another class' members to the prototype of this class. ...Borrow another class' members to the prototype of this class.
Ext.define('Bank', {
money: '$$$',
printMoney: function() {
alert('$$$$$$$');
}
});
Ext.define('Thief', {
...
});
Thief.borrow(Bank, ['money', 'printMoney']);
var steve = new Thief();
alert(steve.money); // alerts '$$$'
steve.printMoney(); // alerts '$$$$$$$'
Available since: 4.0.2
Parameters
- fromClass : Ext.Base
The class to borrow members from
- members : String/String[]
The names of the members to borrow
Returns
- Ext.Base
this
Create a new instance of this Class. ...Create a new instance of this Class.
Ext.define('My.cool.Class', {
...
});
My.cool.Class.create({
someConfig: true
});
All parameters are passed to the constructor of the class.
Available since: 4.0.2
Returns
- Object
the created instance.
createAlias( alias, origin )staticCreate aliases for existing prototype methods. ...Create aliases for existing prototype methods. Example:
Ext.define('My.cool.Class', {
method1: function() { ... },
method2: function() { ... }
});
var test = new My.cool.Class();
My.cool.Class.createAlias({
method3: 'method1',
method4: 'method2'
});
test.method3(); // test.method1()
My.cool.Class.createAlias('method5', 'method3');
test.method5(); // test.method3() -> test.method1()
Available since: 4.0.2
Parameters
- alias : String/Object
The new method name, or an object to set multiple aliases. See
flexSetter
- origin : String/Object
The original method name
Get the current class' name in string format. ...Get the current class' name in string format.
Ext.define('My.cool.Class', {
constructor: function() {
alert(this.self.getName()); // alerts 'My.cool.Class'
}
});
My.cool.Class.getName(); // 'My.cool.Class'
Available since: 4.0.4
Returns
- String
className
implement( members )staticAdd methods / properties to the prototype of this class. ...Add methods / properties to the prototype of this class.
Ext.define('My.awesome.Cat', {
constructor: function() {
...
}
});
My.awesome.Cat.implement({
meow: function() {
alert('Meowww...');
}
});
var kitty = new My.awesome.Cat;
kitty.meow();
Available since: 4.0.2
Parameters
- members : Object
Override prototype members of this class. ...Override prototype members of this class. Overridden methods can be invoked via
callOverridden
Ext.define('My.Cat', {
constructor: function() {
alert("I'm a cat!");
return this;
}
});
My.Cat.override({
constructor: function() {
alert("I'm going to be a cat!");
var instance = this.callOverridden();
alert("Meeeeoooowwww");
return instance;
}
});
var kitty = new My.Cat(); // alerts "I'm going to be a cat!"
// alerts "I'm a cat!"
// alerts "Meeeeoooowwww"
Available since: 4.0.2
Parameters
- members : Object
Returns
- Ext.Base
this
Add / override static properties of this class.
Ext.define('My.cool.Class', {
...
});
My.cool.Class.addStatics({
someProperty: 'someValue', // My.cool.Class.someProperty = 'someValue'
method1: function() { ... }, // My.cool.Class.method1 = function() { ... };
method2: function() { ... } // My.cool.Class.method2 = function() { ... };
});
Available since: 4.0.2
Parameters
- members : Object
Returns
- Ext.Base
this
Borrow another class' members to the prototype of this class.
Ext.define('Bank', {
money: '$$$',
printMoney: function() {
alert('$$$$$$$');
}
});
Ext.define('Thief', {
...
});
Thief.borrow(Bank, ['money', 'printMoney']);
var steve = new Thief();
alert(steve.money); // alerts '$$$'
steve.printMoney(); // alerts '$$$$$$$'
Available since: 4.0.2
Parameters
- fromClass : Ext.Base
The class to borrow members from
- members : String/String[]
The names of the members to borrow
Returns
- Ext.Base
this
Create a new instance of this Class.
Ext.define('My.cool.Class', {
...
});
My.cool.Class.create({
someConfig: true
});
All parameters are passed to the constructor of the class.
Available since: 4.0.2
Returns
- Object
the created instance.
Create aliases for existing prototype methods. Example:
Ext.define('My.cool.Class', {
method1: function() { ... },
method2: function() { ... }
});
var test = new My.cool.Class();
My.cool.Class.createAlias({
method3: 'method1',
method4: 'method2'
});
test.method3(); // test.method1()
My.cool.Class.createAlias('method5', 'method3');
test.method5(); // test.method3() -> test.method1()
Available since: 4.0.2
Parameters
- alias : String/Object
The new method name, or an object to set multiple aliases. See flexSetter
- origin : String/Object
The original method name
Get the current class' name in string format.
Ext.define('My.cool.Class', {
constructor: function() {
alert(this.self.getName()); // alerts 'My.cool.Class'
}
});
My.cool.Class.getName(); // 'My.cool.Class'
Available since: 4.0.4
Returns
- String
className
Add methods / properties to the prototype of this class.
Ext.define('My.awesome.Cat', {
constructor: function() {
...
}
});
My.awesome.Cat.implement({
meow: function() {
alert('Meowww...');
}
});
var kitty = new My.awesome.Cat;
kitty.meow();
Available since: 4.0.2
Parameters
- members : Object
Override prototype members of this class. Overridden methods can be invoked via callOverridden
Ext.define('My.Cat', {
constructor: function() {
alert("I'm a cat!");
return this;
}
});
My.Cat.override({
constructor: function() {
alert("I'm going to be a cat!");
var instance = this.callOverridden();
alert("Meeeeoooowwww");
return instance;
}
});
var kitty = new My.Cat(); // alerts "I'm going to be a cat!"
// alerts "I'm a cat!"
// alerts "Meeeeoooowwww"
Available since: 4.0.2
Parameters
- members : Object
Returns
- Ext.Base
this