tvheadend/vendor/ext-3.4.1/docs/source/DDCore.html
Adam Sutton bafcfff42d webui: restructure webui/extjs source files
I want to keep the 3rd-party packages away from the main source
where possible.
2013-06-03 17:11:01 +01:00

3194 lines
112 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The source code</title>
<link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../resources/prettify/prettify.js"></script>
<style type="text/css">
.highlight { display: block; background-color: #ddd; }
</style>
<script type="text/javascript">
function highlight() {
document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
}
</script>
</head>
<body onload="prettyPrint(); highlight();">
<pre class="prettyprint lang-js">/*
* These classes are derivatives of the similarly named classes in the YUI Library.
* The original license:
* Copyright (c) 2006, Yahoo! Inc. All rights reserved.
* Code licensed under the BSD License:
* http://developer.yahoo.net/yui/license.txt
*/
(function() {
var Event=Ext.EventManager;
var Dom=Ext.lib.Dom;
<span id='Ext-dd-DragDrop-method-constructor'><span id='Ext-dd-DragDrop'>/**
</span></span> * @class Ext.dd.DragDrop
* 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 and onDragOut.
* Up to three html elements can be associated with a DragDrop instance:
* &lt;ul&gt;
* &lt;li&gt;linked element: the element that is passed into the constructor.
* This is the element which defines the boundaries for interaction with
* other DragDrop objects.&lt;/li&gt;
* &lt;li&gt;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.&lt;/li&gt;
* &lt;li&gt;drag element: this represents 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 Ext.dd.DD}. setDragElId() lets you define
* a separate element that would be moved, as in {@link Ext.dd.DDProxy}.
* &lt;/li&gt;
* &lt;/ul&gt;
* 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 &quot;group1&quot; group:
* &lt;pre&gt;
* dd = new Ext.dd.DragDrop(&quot;div1&quot;, &quot;group1&quot;);
* &lt;/pre&gt;
* 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...
* &lt;pre&gt;
* dd.onDragDrop = function(e, id) {
* &amp;nbsp;&amp;nbsp;alert(&quot;dd was dropped on &quot; + id);
* }
* &lt;/pre&gt;
* @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
*/
Ext.dd.DragDrop = function(id, sGroup, config) {
if(id) {
this.init(id, sGroup, config);
}
};
Ext.dd.DragDrop.prototype = {
<span id='Ext-dd-DragDrop-property-ignoreSelf'> /**
</span> * 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.
* @property ignoreSelf
* @type Boolean
*/
<span id='Ext-dd-DragDrop-property-id'> /**
</span> * The id of the element associated with this object. This is what we
* refer to as the &quot;linked element&quot; 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,
<span id='Ext-dd-DragDrop-property-config'> /**
</span> * Configuration attributes passed into the constructor
* @property config
* @type object
*/
config: null,
<span id='Ext-dd-DragDrop-property-dragElId'> /**
</span> * 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
* @property dragElId
* @type String
* @private
*/
dragElId: null,
<span id='Ext-dd-DragDrop-property-handleElId'> /**
</span> * 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,
<span id='Ext-dd-DragDrop-property-invalidHandleTypes'> /**
</span> * 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 &amp;lt;a&gt; elements:&lt;pre&gt;&lt;code&gt;
{
A: &quot;A&quot;
}&lt;/code&gt;&lt;/pre&gt;
* @property invalidHandleTypes
* @type Object
*/
invalidHandleTypes: null,
<span id='Ext-dd-DragDrop-property-invalidHandleIds'> /**
</span> * 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 &quot;foo&quot;, use:&lt;pre&gt;&lt;code&gt;
{
foo: true
}&lt;/code&gt;&lt;/pre&gt;
* @property invalidHandleIds
* @type Object
*/
invalidHandleIds: null,
<span id='Ext-dd-DragDrop-property-invalidHandleClasses'> /**
</span> * An Array of CSS class names for elements to be considered in valid as drag handles.
* @property invalidHandleClasses
* @type Array
*/
invalidHandleClasses: null,
<span id='Ext-dd-DragDrop-property-startPageX'> /**
</span> * The linked element's absolute X position at the time the drag was
* started
* @property startPageX
* @type int
* @private
*/
startPageX: 0,
<span id='Ext-dd-DragDrop-property-startPageY'> /**
</span> * The linked element's absolute X position at the time the drag was
* started
* @property startPageY
* @type int
* @private
*/
startPageY: 0,
<span id='Ext-dd-DragDrop-property-groups'> /**
</span> * 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 object An object in the format {'group1':true, 'group2':true}
*/
groups: null,
<span id='Ext-dd-DragDrop-property-locked'> /**
</span> * Individual drag/drop instances can be locked. This will prevent
* onmousedown start drag.
* @property locked
* @type boolean
* @private
*/
locked: false,
<span id='Ext-dd-DragDrop-method-lock'> /**
</span> * Lock this instance
* @method lock
*/
lock: function() {
this.locked = true;
},
<span id='Ext-dd-DragDrop-property-moveOnly'> /**
</span> * 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.
* @property moveOnly
* @type boolean
*/
moveOnly: false,
<span id='Ext-dd-DragDrop-method-unlock'> /**
</span> * Unlock this instace
* @method unlock
*/
unlock: function() {
this.locked = false;
},
<span id='Ext-dd-DragDrop-property-isTarget'> /**
</span> * By default, all instances can be a drop target. This can be disabled by
* setting isTarget to false.
* @property isTarget
* @type boolean
*/
isTarget: true,
<span id='Ext-dd-DragDrop-property-padding'> /**
</span> * The padding configured for this drag and drop object for calculating
* the drop zone intersection with this object.
* @property padding
* @type int[] An array containing the 4 padding values: [top, right, bottom, left]
*/
padding: null,
<span id='Ext-dd-DragDrop-property-_domRef'> /**
</span> * Cached reference to the linked element
* @property _domRef
* @private
*/
_domRef: null,
<span id='Ext-dd-DragDrop-property-__ygDragDrop'> /**
</span> * Internal typeof flag
* @property __ygDragDrop
* @private
*/
__ygDragDrop: true,
<span id='Ext-dd-DragDrop-property-constrainX'> /**
</span> * Set to true when horizontal contraints are applied
* @property constrainX
* @type boolean
* @private
*/
constrainX: false,
<span id='Ext-dd-DragDrop-property-constrainY'> /**
</span> * Set to true when vertical contraints are applied
* @property constrainY
* @type boolean
* @private
*/
constrainY: false,
<span id='Ext-dd-DragDrop-property-minX'> /**
</span> * The left constraint
* @property minX
* @type int
* @private
*/
minX: 0,
<span id='Ext-dd-DragDrop-property-maxX'> /**
</span> * The right constraint
* @property maxX
* @type int
* @private
*/
maxX: 0,
<span id='Ext-dd-DragDrop-property-minY'> /**
</span> * The up constraint
* @property minY
* @type int
* @private
*/
minY: 0,
<span id='Ext-dd-DragDrop-property-maxY'> /**
</span> * The down constraint
* @property maxY
* @type int
* @private
*/
maxY: 0,
<span id='Ext-dd-DragDrop-property-maintainOffset'> /**
</span> * 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,
<span id='Ext-dd-DragDrop-property-xTicks'> /**
</span> * 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,
<span id='Ext-dd-DragDrop-property-yTicks'> /**
</span> * 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,
<span id='Ext-dd-DragDrop-property-primaryButtonOnly'> /**
</span> * 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,
<span id='Ext-dd-DragDrop-property-available'> /**
</span> * The available property is false until the linked dom element is accessible.
* @property available
* @type boolean
*/
available: false,
<span id='Ext-dd-DragDrop-property-hasOuterHandles'> /**
</span> * 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,
<span id='Ext-dd-DragDrop-method-b4StartDrag'> /**
</span> * Code that executes immediately before the startDrag event
* @method b4StartDrag
* @private
*/
b4StartDrag: function(x, y) { },
<span id='Ext-dd-DragDrop-method-startDrag'> /**
</span> * Abstract method called after a drag/drop object is clicked
* 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 */ },
<span id='Ext-dd-DragDrop-method-b4Drag'> /**
</span> * Code that executes immediately before the onDrag event
* @method b4Drag
* @private
*/
b4Drag: function(e) { },
<span id='Ext-dd-DragDrop-method-onDrag'> /**
</span> * Abstract method called during the onMouseMove event while dragging an
* object.
* @method onDrag
* @param {Event} e the mousemove event
*/
onDrag: function(e) { /* override this */ },
<span id='Ext-dd-DragDrop-method-onDragEnter'> /**
</span> * 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.
*/
onDragEnter: function(e, id) { /* override this */ },
<span id='Ext-dd-DragDrop-method-b4DragOver'> /**
</span> * Code that executes immediately before the onDragOver event
* @method b4DragOver
* @private
*/
b4DragOver: function(e) { },
<span id='Ext-dd-DragDrop-method-onDragOver'> /**
</span> * 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.
*/
onDragOver: function(e, id) { /* override this */ },
<span id='Ext-dd-DragDrop-method-b4DragOut'> /**
</span> * Code that executes immediately before the onDragOut event
* @method b4DragOut
* @private
*/
b4DragOut: function(e) { },
<span id='Ext-dd-DragDrop-method-onDragOut'> /**
</span> * 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.
*/
onDragOut: function(e, id) { /* override this */ },
<span id='Ext-dd-DragDrop-method-b4DragDrop'> /**
</span> * Code that executes immediately before the onDragDrop event
* @method b4DragDrop
* @private
*/
b4DragDrop: function(e) { },
<span id='Ext-dd-DragDrop-method-onDragDrop'> /**
</span> * 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.
*/
onDragDrop: function(e, id) { /* override this */ },
<span id='Ext-dd-DragDrop-method-onInvalidDrop'> /**
</span> * 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 */ },
<span id='Ext-dd-DragDrop-method-b4EndDrag'> /**
</span> * Code that executes immediately before the endDrag event
* @method b4EndDrag
* @private
*/
b4EndDrag: function(e) { },
<span id='Ext-dd-DragDrop-method-endDrag'> /**
</span> * Fired when we are done dragging the object
* @method endDrag
* @param {Event} e the mouseup event
*/
endDrag: function(e) { /* override this */ },
<span id='Ext-dd-DragDrop-method-b4MouseDown'> /**
</span> * Code executed immediately before the onMouseDown event
* @method b4MouseDown
* @param {Event} e the mousedown event
* @private
*/
b4MouseDown: function(e) { },
<span id='Ext-dd-DragDrop-method-onMouseDown'> /**
</span> * Event handler that fires when a drag/drop obj gets a mousedown
* @method onMouseDown
* @param {Event} e the mousedown event
*/
onMouseDown: function(e) { /* override this */ },
<span id='Ext-dd-DragDrop-method-onMouseUp'> /**
</span> * Event handler that fires when a drag/drop obj gets a mouseup
* @method onMouseUp
* @param {Event} e the mouseup event
*/
onMouseUp: function(e) { /* override this */ },
<span id='Ext-dd-DragDrop-method-onAvailable'> /**
</span> * Override the onAvailable method to do what is needed after the initial
* position was determined.
* @method onAvailable
*/
onAvailable: function () {
},
<span id='Ext-dd-DragDrop-property-defaultPadding'> /**
</span> * Provides default constraint padding to &quot;constrainTo&quot; elements (defaults to {left: 0, right:0, top:0, bottom:0}).
* @type Object
*/
defaultPadding : {left:0, right:0, top:0, bottom:0},
<span id='Ext-dd-DragDrop-method-constrainTo'> /**
</span> * Initializes the drag drop object's constraints to restrict movement to a certain element.
*
* Usage:
&lt;pre&gt;&lt;code&gt;
var dd = new Ext.dd.DDProxy(&quot;dragDiv1&quot;, &quot;proxytest&quot;,
{ dragElId: &quot;existingProxyDiv&quot; });
dd.startDrag = function(){
this.constrainTo(&quot;parent-id&quot;);
};
&lt;/code&gt;&lt;/pre&gt;
* Or you can initalize it using the {@link Ext.Element} object:
&lt;pre&gt;&lt;code&gt;
Ext.get(&quot;dragDiv1&quot;).initDDProxy(&quot;proxytest&quot;, {dragElId: &quot;existingProxyDiv&quot;}, {
startDrag : function(){
this.constrainTo(&quot;parent-id&quot;);
}
});
&lt;/code&gt;&lt;/pre&gt;
* @param {Mixed} constrainTo The element to constrain to.
* @param {Object/Number} pad (optional) Pad provides a way to specify &quot;padding&quot; 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}
* @param {Boolean} inContent (optional) Constrain the draggable in the content box of the element (inside padding and borders)
*/
constrainTo : function(constrainTo, pad, inContent){
if(Ext.isNumber(pad)){
pad = {left: pad, right:pad, top:pad, bottom:pad};
}
pad = pad || this.defaultPadding;
var b = Ext.get(this.getEl()).getBox(),
ce = Ext.get(constrainTo),
s = ce.getScroll(),
c,
cd = ce.dom;
if(cd == document.body){
c = { x: s.left, y: s.top, width: Ext.lib.Dom.getViewWidth(), height: Ext.lib.Dom.getViewHeight()};
}else{
var xy = ce.getXY();
c = {x : xy[0], y: xy[1], width: cd.clientWidth, height: cd.clientHeight};
}
var topSpace = b.y - c.y,
leftSpace = b.x - c.x;
this.resetConstraints();
this.setXConstraint(leftSpace - (pad.left||0), // left
c.width - leftSpace - b.width - (pad.right||0), //right
this.xTickSize
);
this.setYConstraint(topSpace - (pad.top||0), //top
c.height - topSpace - b.height - (pad.bottom||0), //bottom
this.yTickSize
);
},
<span id='Ext-dd-DragDrop-method-getEl'> /**
</span> * Returns a reference to the linked element
* @method getEl
* @return {HTMLElement} the html element
*/
getEl: function() {
if (!this._domRef) {
this._domRef = Ext.getDom(this.id);
}
return this._domRef;
},
<span id='Ext-dd-DragDrop-method-getDragEl'> /**
</span> * 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 Ext.dd.DDProxy
* @method getDragEl
* @return {HTMLElement} the html element
*/
getDragEl: function() {
return Ext.getDom(this.dragElId);
},
<span id='Ext-dd-DragDrop-method-init'> /**
</span> * Sets up the DragDrop object. Must be called in the constructor of any
* Ext.dd.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
*/
init: function(id, sGroup, config) {
this.initTarget(id, sGroup, config);
Event.on(this.id, &quot;mousedown&quot;, this.handleMouseDown, this);
// Event.on(this.id, &quot;selectstart&quot;, Event.preventDefault);
},
<span id='Ext-dd-DragDrop-method-initTarget'> /**
</span> * 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
*/
initTarget: function(id, sGroup, config) {
// configuration attributes
this.config = config || {};
// create a local reference to the drag and drop manager
this.DDM = Ext.dd.DDM;
// initialize the groups array
this.groups = {};
// assume that we have an element reference instead of an id if the
// parameter is not a string
if (typeof id !== &quot;string&quot;) {
id = Ext.id(id);
}
// set the id
this.id = id;
// add to an interaction group
this.addToGroup((sGroup) ? sGroup : &quot;default&quot;);
// 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;
// the linked element is the element that gets dragged by default
this.setDragElId(id);
// by default, clicked anchors will not start drag operations.
this.invalidHandleTypes = { A: &quot;A&quot; };
this.invalidHandleIds = {};
this.invalidHandleClasses = [];
this.applyConfig();
this.handleOnAvailable();
},
<span id='Ext-dd-DragDrop-method-applyConfig'> /**
</span> * 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
this.padding = this.config.padding || [0, 0, 0, 0];
this.isTarget = (this.config.isTarget !== false);
this.maintainOffset = (this.config.maintainOffset);
this.primaryButtonOnly = (this.config.primaryButtonOnly !== false);
},
<span id='Ext-dd-DragDrop-method-handleOnAvailable'> /**
</span> * Executed when the linked element is available
* @method handleOnAvailable
* @private
*/
handleOnAvailable: function() {
this.available = true;
this.resetConstraints();
this.onAvailable();
},
<span id='Ext-dd-DragDrop-method-setPadding'> /**
</span> * 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
*/
setPadding: function(iTop, iRight, iBot, iLeft) {
// this.padding = [iLeft, iRight, iTop, iBot];
if (!iRight &amp;&amp; 0 !== iRight) {
this.padding = [iTop, iTop, iTop, iTop];
} else if (!iBot &amp;&amp; 0 !== iBot) {
this.padding = [iTop, iRight, iTop, iRight];
} else {
this.padding = [iTop, iRight, iBot, iLeft];
}
},
<span id='Ext-dd-DragDrop-method-setInitPosition'> /**
</span> * Stores the initial placement of the linked element.
* @method setInitPosition
* @param {int} diffX the X offset, default 0
* @param {int} diffY the Y offset, default 0
*/
setInitPosition: function(diffX, diffY) {
var el = this.getEl();
if (!this.DDM.verifyEl(el)) {
return;
}
var dx = diffX || 0;
var dy = diffY || 0;
var p = Dom.getXY( el );
this.initPageX = p[0] - dx;
this.initPageY = p[1] - dy;
this.lastPageX = p[0];
this.lastPageY = p[1];
this.setStartPosition(p);
},
<span id='Ext-dd-DragDrop-method-setStartPosition'> /**
</span> * 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) {
var p = pos || Dom.getXY( this.getEl() );
this.deltaSetXY = null;
this.startPageX = p[0];
this.startPageY = p[1];
},
<span id='Ext-dd-DragDrop-method-addToGroup'> /**
</span> * 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.
* @method addToGroup
* @param sGroup {string} the name of the group
*/
addToGroup: function(sGroup) {
this.groups[sGroup] = true;
this.DDM.regDragDrop(this, sGroup);
},
<span id='Ext-dd-DragDrop-method-removeFromGroup'> /**
</span> * Remove's this instance from the supplied interaction group
* @method removeFromGroup
* @param {string} sGroup The group to drop
*/
removeFromGroup: function(sGroup) {
if (this.groups[sGroup]) {
delete this.groups[sGroup];
}
this.DDM.removeDDFromGroup(this, sGroup);
},
<span id='Ext-dd-DragDrop-method-setDragElId'> /**
</span> * 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) {
this.dragElId = id;
},
<span id='Ext-dd-DragDrop-method-setHandleElId'> /**
</span> * 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 !== &quot;string&quot;) {
id = Ext.id(id);
}
this.handleElId = id;
this.DDM.regHandle(this.id, id);
},
<span id='Ext-dd-DragDrop-method-setOuterHandleElId'> /**
</span> * 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 !== &quot;string&quot;) {
id = Ext.id(id);
}
Event.on(id, &quot;mousedown&quot;,
this.handleMouseDown, this);
this.setHandleElId(id);
this.hasOuterHandles = true;
},
<span id='Ext-dd-DragDrop-method-unreg'> /**
</span> * Remove all drag and drop hooks for this element
* @method unreg
*/
unreg: function() {
Event.un(this.id, &quot;mousedown&quot;,
this.handleMouseDown);
this._domRef = null;
this.DDM._remove(this);
},
destroy : function(){
this.unreg();
},
<span id='Ext-dd-DragDrop-method-isLocked'> /**
</span> * Returns true if this instance is locked, or the drag drop mgr is locked
* (meaning that all drag/drop is disabled on the page.)
* @method isLocked
* @return {boolean} true if this obj or all drag/drop is locked, else
* false
*/
isLocked: function() {
return (this.DDM.isLocked() || this.locked);
},
<span id='Ext-dd-DragDrop-method-handleMouseDown'> /**
</span> * Fired when this object is clicked
* @method handleMouseDown
* @param {Event} e
* @param {Ext.dd.DragDrop} oDD the clicked dd object (this dd obj)
* @private
*/
handleMouseDown: function(e, oDD){
if (this.primaryButtonOnly &amp;&amp; e.button != 0) {
return;
}
if (this.isLocked()) {
return;
}
this.DDM.refreshCache(this.groups);
var pt = new Ext.lib.Point(Ext.lib.Event.getPageX(e), Ext.lib.Event.getPageY(e));
if (!this.hasOuterHandles &amp;&amp; !this.DDM.isOverTarget(pt, this) ) {
} else {
if (this.clickValidator(e)) {
// set the initial element position
this.setStartPosition();
this.b4MouseDown(e);
this.onMouseDown(e);
this.DDM.handleMouseDown(e, this);
if (this.preventDefault || this.stopPropagation) {
if (this.preventDefault) {
e.preventDefault();
}
if (this.stopPropagation) {
e.stopPropagation();
}
} else {
this.DDM.stopEvent(e);
}
} else {
}
}
},
clickValidator: function(e) {
var target = e.getTarget();
return ( this.isValidHandleChild(target) &amp;&amp;
(this.id == this.handleElId ||
this.DDM.handleWasClicked(target, this.id)) );
},
<span id='Ext-dd-DragDrop-method-addInvalidHandleType'> /**
</span> * 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) {
var type = tagName.toUpperCase();
this.invalidHandleTypes[type] = type;
},
<span id='Ext-dd-DragDrop-method-addInvalidHandleId'> /**
</span> * 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 !== &quot;string&quot;) {
id = Ext.id(id);
}
this.invalidHandleIds[id] = id;
},
<span id='Ext-dd-DragDrop-method-addInvalidHandleClass'> /**
</span> * 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) {
this.invalidHandleClasses.push(cssClass);
},
<span id='Ext-dd-DragDrop-method-removeInvalidHandleType'> /**
</span> * Unsets an excluded tag name set by addInvalidHandleType
* @method removeInvalidHandleType
* @param {string} tagName the type of element to unexclude
*/
removeInvalidHandleType: function(tagName) {
var type = tagName.toUpperCase();
// this.invalidHandleTypes[type] = null;
delete this.invalidHandleTypes[type];
},
<span id='Ext-dd-DragDrop-method-removeInvalidHandleId'> /**
</span> * Unsets an invalid handle id
* @method removeInvalidHandleId
* @param {string} id the id of the element to re-enable
*/
removeInvalidHandleId: function(id) {
if (typeof id !== &quot;string&quot;) {
id = Ext.id(id);
}
delete this.invalidHandleIds[id];
},
<span id='Ext-dd-DragDrop-method-removeInvalidHandleClass'> /**
</span> * Unsets an invalid css class
* @method removeInvalidHandleClass
* @param {string} cssClass the class of the element(s) you wish to
* re-enable
*/
removeInvalidHandleClass: function(cssClass) {
for (var i=0, len=this.invalidHandleClasses.length; i&lt;len; ++i) {
if (this.invalidHandleClasses[i] == cssClass) {
delete this.invalidHandleClasses[i];
}
}
},
<span id='Ext-dd-DragDrop-method-isValidHandleChild'> /**
</span> * 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 == &quot;#text&quot;) ? node.parentNode : node;
var nodeName;
try {
nodeName = node.nodeName.toUpperCase();
} catch(e) {
nodeName = node.nodeName;
}
valid = valid &amp;&amp; !this.invalidHandleTypes[nodeName];
valid = valid &amp;&amp; !this.invalidHandleIds[node.id];
for (var i=0, len=this.invalidHandleClasses.length; valid &amp;&amp; i&lt;len; ++i) {
valid = !Ext.fly(node).hasClass(this.invalidHandleClasses[i]);
}
return valid;
},
<span id='Ext-dd-DragDrop-method-setXTicks'> /**
</span> * Create the array of horizontal tick marks if an interval was specified
* in setXConstraint().
* @method setXTicks
* @private
*/
setXTicks: function(iStartX, iTickSize) {
this.xTicks = [];
this.xTickSize = iTickSize;
var tickMap = {};
for (var i = this.initPageX; i &gt;= this.minX; i = i - iTickSize) {
if (!tickMap[i]) {
this.xTicks[this.xTicks.length] = i;
tickMap[i] = true;
}
}
for (i = this.initPageX; i &lt;= this.maxX; i = i + iTickSize) {
if (!tickMap[i]) {
this.xTicks[this.xTicks.length] = i;
tickMap[i] = true;
}
}
this.xTicks.sort(this.DDM.numericSort) ;
},
<span id='Ext-dd-DragDrop-method-setYTicks'> /**
</span> * Create the array of vertical tick marks if an interval was specified in
* setYConstraint().
* @method setYTicks
* @private
*/
setYTicks: function(iStartY, iTickSize) {
this.yTicks = [];
this.yTickSize = iTickSize;
var tickMap = {};
for (var i = this.initPageY; i &gt;= this.minY; i = i - iTickSize) {
if (!tickMap[i]) {
this.yTicks[this.yTicks.length] = i;
tickMap[i] = true;
}
}
for (i = this.initPageY; i &lt;= this.maxY; i = i + iTickSize) {
if (!tickMap[i]) {
this.yTicks[this.yTicks.length] = i;
tickMap[i] = true;
}
}
this.yTicks.sort(this.DDM.numericSort) ;
},
<span id='Ext-dd-DragDrop-method-setXConstraint'> /**
</span> * 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.
*/
setXConstraint: function(iLeft, iRight, iTickSize) {
this.leftConstraint = iLeft;
this.rightConstraint = iRight;
this.minX = this.initPageX - iLeft;
this.maxX = this.initPageX + iRight;
if (iTickSize) { this.setXTicks(this.initPageX, iTickSize); }
this.constrainX = true;
},
<span id='Ext-dd-DragDrop-method-clearConstraints'> /**
</span> * 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();
},
<span id='Ext-dd-DragDrop-method-clearTicks'> /**
</span> * Clears any tick interval defined for this instance
* @method clearTicks
*/
clearTicks: function() {
this.xTicks = null;
this.yTicks = null;
this.xTickSize = 0;
this.yTickSize = 0;
},
<span id='Ext-dd-DragDrop-method-setYConstraint'> /**
</span> * 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.
*/
setYConstraint: function(iUp, iDown, iTickSize) {
this.topConstraint = iUp;
this.bottomConstraint = iDown;
this.minY = this.initPageY - iUp;
this.maxY = this.initPageY + iDown;
if (iTickSize) { this.setYTicks(this.initPageY, iTickSize); }
this.constrainY = true;
},
<span id='Ext-dd-DragDrop-method-resetConstraints'> /**
</span> * resetConstraints must be called if you manually reposition a dd element.
* @method resetConstraints
* @param {boolean} maintainOffset
*/
resetConstraints: function() {
// Maintain offsets if necessary
if (this.initPageX || this.initPageX === 0) {
// figure out how much this thing has moved
var dx = (this.maintainOffset) ? this.lastPageX - this.initPageX : 0;
var dy = (this.maintainOffset) ? this.lastPageY - this.initPageY : 0;
this.setInitPosition(dx, dy);
// 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 );
}
},
<span id='Ext-dd-DragDrop-method-getTick'> /**
</span> * 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
*/
getTick: function(val, tickArray) {
if (!tickArray) {
// If tick interval is not defined, it is effectively 1 pixel,
// so we return the value passed to us.
return val;
} else if (tickArray[0] &gt;= val) {
// The value is lower than the first tick, so we return the first
// tick.
return tickArray[0];
} else {
for (var i=0, len=tickArray.length; i&lt;len; ++i) {
var next = i + 1;
if (tickArray[next] &amp;&amp; tickArray[next] &gt;= val) {
var diff1 = val - tickArray[i];
var diff2 = tickArray[next] - val;
return (diff2 &gt; diff1) ? tickArray[i] : tickArray[next];
}
}
// The value is larger than the last tick, so we return the last
// tick.
return tickArray[tickArray.length - 1];
}
},
<span id='Ext-dd-DragDrop-method-toString'> /**
</span> * toString method
* @method toString
* @return {string} string representation of the dd obj
*/
toString: function() {
return (&quot;DragDrop &quot; + this.id);
}
};
})();
/*
* 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.
*/
// Only load the library once. Rewriting the manager class would orphan
// existing drag and drop instances.
if (!Ext.dd.DragDropMgr) {
<span id='Ext-dd-DragDropMgr'>/**
</span> * @class Ext.dd.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.
* @singleton
*/
Ext.dd.DragDropMgr = function() {
var Event = Ext.EventManager;
return {
<span id='Ext-dd-DragDropMgr-property-ids'> /**
</span> * Two dimensional Array of registered DragDrop objects. The first
* dimension is the DragDrop item group, the second the DragDrop
* object.
* @property ids
* @type String[]
* @private
*/
ids: {},
<span id='Ext-dd-DragDropMgr-property-handleIds'> /**
</span> * 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[]
* @private
*/
handleIds: {},
<span id='Ext-dd-DragDropMgr-property-dragCurrent'> /**
</span> * the DragDrop object that is currently being dragged
* @property dragCurrent
* @type DragDrop
* @private
**/
dragCurrent: null,
<span id='Ext-dd-DragDropMgr-property-dragOvers'> /**
</span> * the DragDrop object(s) that are being hovered over
* @property dragOvers
* @type Array
* @private
*/
dragOvers: {},
<span id='Ext-dd-DragDropMgr-property-deltaX'> /**
</span> * the X distance between the cursor and the object being dragged
* @property deltaX
* @type int
* @private
*/
deltaX: 0,
<span id='Ext-dd-DragDropMgr-property-deltaY'> /**
</span> * the Y distance between the cursor and the object being dragged
* @property deltaY
* @type int
* @private
*/
deltaY: 0,
<span id='Ext-dd-DragDropMgr-property-preventDefault'> /**
</span> * 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
*/
preventDefault: true,
<span id='Ext-dd-DragDropMgr-property-stopPropagation'> /**
</span> * 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
*/
stopPropagation: true,
<span id='Ext-dd-DragDropMgr-property-initialized'> /**
</span> * Internal flag that is set to true when drag and drop has been
* intialized
* @property initialized
* @private
*/
initialized: false,
<span id='Ext-dd-DragDropMgr-property-locked'> /**
</span> * All drag and drop can be disabled.
* @property locked
* @private
*/
locked: false,
<span id='Ext-dd-DragDropMgr-method-init'> /**
</span> * Called the first time an element is registered.
* @method init
* @private
*/
init: function() {
this.initialized = true;
},
<span id='Ext-dd-DragDropMgr-property-POINT'> /**
</span> * In point mode, drag and drop interaction is defined by the
* location of the cursor during the drag/drop
* @property POINT
* @type int
*/
POINT: 0,
<span id='Ext-dd-DragDropMgr-property-INTERSECT'> /**
</span> * In intersect mode, drag and drop interaction is defined by the
* overlap of two or more drag and drop objects.
* @property INTERSECT
* @type int
*/
INTERSECT: 1,
<span id='Ext-dd-DragDropMgr-property-mode'> /**
</span> * The current drag and drop mode. Default: POINT
* @property mode
* @type int
*/
mode: 0,
<span id='Ext-dd-DragDropMgr-property-notifyOccluded'> /**
</span> * @property {Boolean} [notifyOccluded=false]
* This config is only provided to provide old, usually unwanted drag/drop behaviour.
*
* From ExtJS 4.1.0 onwards, when drop targets are contained in floating, absolutely positioned elements
* such as in {@link Ext.window.Window Windows}, which may overlap each other, `over` and `drop` events
* are only delivered to the topmost drop target at the mouse position.
*
* If all targets below that in zIndex order should also receive notifications, set
* `notifyOccluded` to `true`.
*/
notifyOccluded: false,
<span id='Ext-dd-DragDropMgr-method-_execOnAll'> /**
</span> * Runs method on all drag and drop objects
* @method _execOnAll
* @private
*/
_execOnAll: function(sMethod, args) {
for (var i in this.ids) {
for (var j in this.ids[i]) {
var oDD = this.ids[i][j];
if (! this.isTypeOfDD(oDD)) {
continue;
}
oDD[sMethod].apply(oDD, args);
}
}
},
<span id='Ext-dd-DragDropMgr-method-_onLoad'> /**
</span> * Drag and drop initialization. Sets up the global event handlers
* @method _onLoad
* @private
*/
_onLoad: function() {
this.init();
Event.on(document, &quot;mouseup&quot;, this.handleMouseUp, this, true);
Event.on(document, &quot;mousemove&quot;, this.handleMouseMove, this, true);
Event.on(window, &quot;unload&quot;, this._onUnload, this, true);
Event.on(window, &quot;resize&quot;, this._onResize, this, true);
// Event.on(window, &quot;mouseout&quot;, this._test);
},
<span id='Ext-dd-DragDropMgr-method-_onResize'> /**
</span> * Reset constraints on all drag and drop objs
* @method _onResize
* @private
*/
_onResize: function(e) {
this._execOnAll(&quot;resetConstraints&quot;, []);
},
<span id='Ext-dd-DragDropMgr-method-lock'> /**
</span> * Lock all drag and drop functionality
* @method lock
*/
lock: function() { this.locked = true; },
<span id='Ext-dd-DragDropMgr-method-unlock'> /**
</span> * Unlock all drag and drop functionality
* @method unlock
*/
unlock: function() { this.locked = false; },
<span id='Ext-dd-DragDropMgr-method-isLocked'> /**
</span> * Is drag and drop locked?
* @method isLocked
* @return {boolean} True if drag and drop is locked, false otherwise.
*/
isLocked: function() { return this.locked; },
<span id='Ext-dd-DragDropMgr-property-locationCache'> /**
</span> * Location cache that is set for all drag drop objects when a drag is
* initiated, cleared when the drag is finished.
* @property locationCache
* @private
*/
locationCache: {},
<span id='Ext-dd-DragDropMgr-property-useCache'> /**
</span> * 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
*/
useCache: true,
<span id='Ext-dd-DragDropMgr-property-clickPixelThresh'> /**
</span> * The number of pixels that the mouse needs to move after the
* mousedown before the drag is initiated. Default=3;
* @property clickPixelThresh
* @type int
*/
clickPixelThresh: 3,
<span id='Ext-dd-DragDropMgr-property-clickTimeThresh'> /**
</span> * The number of milliseconds after the mousedown event to initiate the
* drag if we don't get a mouseup event. Default=350
* @property clickTimeThresh
* @type int
*/
clickTimeThresh: 350,
<span id='Ext-dd-DragDropMgr-property-dragThreshMet'> /**
</span> * Flag that indicates that either the drag pixel threshold or the
* mousdown time threshold has been met
* @property dragThreshMet
* @type boolean
* @private
*/
dragThreshMet: false,
<span id='Ext-dd-DragDropMgr-property-clickTimeout'> /**
</span> * Timeout used for the click time threshold
* @property clickTimeout
* @type Object
* @private
*/
clickTimeout: null,
<span id='Ext-dd-DragDropMgr-property-startX'> /**
</span> * The X position of the mousedown event stored for later use when a
* drag threshold is met.
* @property startX
* @type int
* @private
*/
startX: 0,
<span id='Ext-dd-DragDropMgr-property-startY'> /**
</span> * The Y position of the mousedown event stored for later use when a
* drag threshold is met.
* @property startY
* @type int
* @private
*/
startY: 0,
<span id='Ext-dd-DragDropMgr-method-regDragDrop'> /**
</span> * 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
*/
regDragDrop: function(oDD, sGroup) {
if (!this.initialized) { this.init(); }
if (!this.ids[sGroup]) {
this.ids[sGroup] = {};
}
this.ids[sGroup][oDD.id] = oDD;
},
<span id='Ext-dd-DragDropMgr-method-removeDDFromGroup'> /**
</span> * Removes the supplied dd instance from the supplied group. Executed
* by DragDrop.removeFromGroup, so don't call this function directly.
* @method removeDDFromGroup
* @private
*/
removeDDFromGroup: function(oDD, sGroup) {
if (!this.ids[sGroup]) {
this.ids[sGroup] = {};
}
var obj = this.ids[sGroup];
if (obj &amp;&amp; obj[oDD.id]) {
delete obj[oDD.id];
}
},
<span id='Ext-dd-DragDropMgr-method-_remove'> /**
</span> * Unregisters a drag and drop item. This is executed in
* DragDrop.unreg, use that method instead of calling this directly.
* @method _remove
* @private
*/
_remove: function(oDD) {
for (var g in oDD.groups) {
if (g &amp;&amp; this.ids[g] &amp;&amp; this.ids[g][oDD.id]) {
delete this.ids[g][oDD.id];
}
}
delete this.handleIds[oDD.id];
},
<span id='Ext-dd-DragDropMgr-method-regHandle'> /**
</span> * 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
*/
regHandle: function(sDDId, sHandleId) {
if (!this.handleIds[sDDId]) {
this.handleIds[sDDId] = {};
}
this.handleIds[sDDId][sHandleId] = sHandleId;
},
<span id='Ext-dd-DragDropMgr-method-isDragDrop'> /**
</span> * 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
*/
isDragDrop: function(id) {
return ( this.getDDById(id) ) ? true : false;
},
<span id='Ext-dd-DragDropMgr-method-getRelated'> /**
</span> * 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
*/
getRelated: function(p_oDD, bTargetsOnly) {
var oDDs = [];
for (var i in p_oDD.groups) {
for (var j in this.ids[i]) {
var dd = this.ids[i][j];
if (! this.isTypeOfDD(dd)) {
continue;
}
if (!bTargetsOnly || dd.isTarget) {
oDDs[oDDs.length] = dd;
}
}
}
return oDDs;
},
<span id='Ext-dd-DragDropMgr-method-isLegalTarget'> /**
</span> * Returns true if the specified dd target is a legal target for
* the specifice drag obj
* @method isLegalTarget
* @param {DragDrop} oDD the drag obj
* @param {DragDrop} oTargetDD the target
* @return {boolean} true if the target is a legal target for the
* dd obj
*/
isLegalTarget: function (oDD, oTargetDD) {
var targets = this.getRelated(oDD, true);
for (var i=0, len=targets.length;i&lt;len;++i) {
if (targets[i].id == oTargetDD.id) {
return true;
}
}
return false;
},
<span id='Ext-dd-DragDropMgr-method-isTypeOfDD'> /**
</span> * My goal is to be able to transparently determine if an object is
* typeof DragDrop, and the exact subclass of DragDrop. typeof
* returns &quot;object&quot;, oDD.constructor.toString() always returns
* &quot;DragDrop&quot; 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
*/
isTypeOfDD: function (oDD) {
return (oDD &amp;&amp; oDD.__ygDragDrop);
},
<span id='Ext-dd-DragDropMgr-method-isHandle'> /**
</span> * 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
*/
isHandle: function(sDDId, sHandleId) {
return ( this.handleIds[sDDId] &amp;&amp;
this.handleIds[sDDId][sHandleId] );
},
<span id='Ext-dd-DragDropMgr-method-getDDById'> /**
</span> * 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
*/
getDDById: function(id) {
for (var i in this.ids) {
if (this.ids[i][id]) {
return this.ids[i][id];
}
}
return null;
},
<span id='Ext-dd-DragDropMgr-method-handleMouseDown'> /**
</span> * 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
*/
handleMouseDown: function(e, oDD) {
if(Ext.QuickTips){
Ext.QuickTips.ddDisable();
}
if(this.dragCurrent){
// the original browser mouseup wasn't handled (e.g. outside FF browser window)
// so clean up first to avoid breaking the next drag
this.handleMouseUp(e);
}
this.currentTarget = e.getTarget();
this.dragCurrent = oDD;
var el = oDD.getEl();
// track start position
this.startX = e.getPageX();
this.startY = e.getPageY();
this.deltaX = this.startX - el.offsetLeft;
this.deltaY = this.startY - el.offsetTop;
this.dragThreshMet = false;
this.clickTimeout = setTimeout(
function() {
var DDM = Ext.dd.DDM;
DDM.startDrag(DDM.startX, DDM.startY);
},
this.clickTimeThresh );
},
<span id='Ext-dd-DragDropMgr-method-startDrag'> /**
</span> * 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
*/
startDrag: function(x, y) {
clearTimeout(this.clickTimeout);
if (this.dragCurrent) {
this.dragCurrent.b4StartDrag(x, y);
this.dragCurrent.startDrag(x, y);
}
this.dragThreshMet = true;
},
<span id='Ext-dd-DragDropMgr-method-handleMouseUp'> /**
</span> * Internal function to handle the mouseup event. Will be invoked
* from the context of the document.
* @method handleMouseUp
* @param {Event} e the event
* @private
*/
handleMouseUp: function(e) {
if(Ext.QuickTips){
Ext.QuickTips.ddEnable();
}
if (! this.dragCurrent) {
return;
}
clearTimeout(this.clickTimeout);
if (this.dragThreshMet) {
this.fireEvents(e, true);
} else {
}
this.stopDrag(e);
this.stopEvent(e);
},
<span id='Ext-dd-DragDropMgr-method-stopEvent'> /**
</span> * 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()
*/
stopEvent: function(e){
if(this.stopPropagation) {
e.stopPropagation();
}
if (this.preventDefault) {
e.preventDefault();
}
},
<span id='Ext-dd-DragDropMgr-method-stopDrag'> /**
</span> * Internal function to clean up event handlers after the drag
* operation is complete
* @method stopDrag
* @param {Event} e the event
* @private
*/
stopDrag: function(e) {
// Fire the drag end event for the item that was dragged
if (this.dragCurrent) {
if (this.dragThreshMet) {
this.dragCurrent.b4EndDrag(e);
this.dragCurrent.endDrag(e);
}
this.dragCurrent.onMouseUp(e);
}
this.dragCurrent = null;
this.dragOvers = {};
},
<span id='Ext-dd-DragDropMgr-method-handleMouseMove'> /**
</span> * 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
*/
handleMouseMove: function(e) {
if (! this.dragCurrent) {
return true;
}
// var button = e.which || e.button;
// check for IE mouseup outside of page boundary
if (Ext.isIE &amp;&amp; (e.button !== 0 &amp;&amp; e.button !== 1 &amp;&amp; e.button !== 2)) {
this.stopEvent(e);
return this.handleMouseUp(e);
}
if (!this.dragThreshMet) {
var diffX = Math.abs(this.startX - e.getPageX());
var diffY = Math.abs(this.startY - e.getPageY());
if (diffX &gt; this.clickPixelThresh ||
diffY &gt; this.clickPixelThresh) {
this.startDrag(this.startX, this.startY);
}
}
if (this.dragThreshMet) {
this.dragCurrent.b4Drag(e);
this.dragCurrent.onDrag(e);
if(!this.dragCurrent.moveOnly){
this.fireEvents(e, false);
}
}
this.stopEvent(e);
return true;
},
<span id='Ext-dd-DragDropMgr-method-fireEvents'> /**
</span> * 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
*/
fireEvents: function(e, isDrop) {
var me = this,
dragCurrent = me.dragCurrent,
mousePoint = e.getPoint(),
overTarget,
overTargetEl,
allTargets = [],
oldOvers = [], // cache the previous dragOver array
outEvts = [],
overEvts = [],
dropEvts = [],
enterEvts = [],
needsSort,
i,
len,
sGroup;
// If the user did the mouse up outside of the window, we could
// get here even though we have ended the drag.
if (!dragCurrent || dragCurrent.isLocked()) {
return;
}
// 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 (i in me.dragOvers) {
overTarget = me.dragOvers[i];
if (! me.isTypeOfDD(overTarget)) {
continue;
}
if (! this.isOverTarget(mousePoint, overTarget, me.mode)) {
outEvts.push( overTarget );
}
oldOvers[i] = true;
delete me.dragOvers[i];
}
// Collect all targets which are members of the same ddGoups that the dragCurrent is a member of, and which may recieve mouseover and drop notifications.
// This is preparatory to seeing which one(s) we are currently over
// Begin by iterating through the ddGroups of which the dragCurrent is a member
for (sGroup in dragCurrent.groups) {
if (&quot;string&quot; != typeof sGroup) {
continue;
}
// Loop over the registered members of each group, testing each as a potential target
for (i in me.ids[sGroup]) {
overTarget = me.ids[sGroup][i];
// The target is valid if it is a DD type
// And it's got a DOM element
// And it's configured to be a drop target
// And it's not locked
// And it's either not the dragCurrent, or, if it is, tha dragCurrent is configured to not ignore itself.
if (me.isTypeOfDD(overTarget) &amp;&amp;
(overTargetEl = overTarget.getEl()) &amp;&amp;
(overTarget.isTarget) &amp;&amp;
(!overTarget.isLocked()) &amp;&amp;
((overTarget != dragCurrent) || (dragCurrent.ignoreSelf === false))) {
// Only sort by zIndex if there were some which had a floating zIndex value
if ((overTarget.zIndex = me.getZIndex(overTargetEl)) !== -1) {
needsSort = true;
}
allTargets.push(overTarget);
}
}
}
// If there were floating targets, sort the highest zIndex to the top
if (needsSort) {
allTargets.sort(me.byZIndex);
}
// Loop through possible targets, notifying the one(s) we are over.
// Usually we only deliver events to the topmost.
for (i = 0, len = allTargets.length; i &lt; len; i++) {
overTarget = allTargets[i];
// If we are over the overTarget, queue it up to recieve an event of whatever type we are handling
if (me.isOverTarget(mousePoint, overTarget, me.mode)) {
// look for drop interactions
if (isDrop) {
dropEvts.push( overTarget );
// look for drag enter and drag over interactions
} else {
// initial drag over: dragEnter fires
if (!oldOvers[overTarget.id]) {
enterEvts.push( overTarget );
// subsequent drag overs: dragOver fires
} else {
overEvts.push( overTarget );
}
me.dragOvers[overTarget.id] = overTarget;
}
// Unless this DragDropManager has been explicitly configured to deliver events to multiple targets, then we are done.
if (!me.notifyOccluded) {
break;
}
}
}
if (me.mode) {
if (outEvts.length) {
dragCurrent.b4DragOut(e, outEvts);
dragCurrent.onDragOut(e, outEvts);
}
if (enterEvts.length) {
dragCurrent.onDragEnter(e, enterEvts);
}
if (overEvts.length) {
dragCurrent.b4DragOver(e, overEvts);
dragCurrent.onDragOver(e, overEvts);
}
if (dropEvts.length) {
dragCurrent.b4DragDrop(e, dropEvts);
dragCurrent.onDragDrop(e, dropEvts);
}
} else {
// fire dragout events
for (i=0, len=outEvts.length; i&lt;len; ++i) {
dragCurrent.b4DragOut(e, outEvts[i].id);
dragCurrent.onDragOut(e, outEvts[i].id);
}
// fire enter events
for (i=0,len=enterEvts.length; i&lt;len; ++i) {
// dc.b4DragEnter(e, oDD.id);
dragCurrent.onDragEnter(e, enterEvts[i].id);
}
// fire over events
for (i=0,len=overEvts.length; i&lt;len; ++i) {
dragCurrent.b4DragOver(e, overEvts[i].id);
dragCurrent.onDragOver(e, overEvts[i].id);
}
// fire drop events
for (i=0, len=dropEvts.length; i&lt;len; ++i) {
dragCurrent.b4DragDrop(e, dropEvts[i].id);
dragCurrent.onDragDrop(e, dropEvts[i].id);
}
}
// notify about a drop that did not find a target
if (isDrop &amp;&amp; !dropEvts.length) {
dragCurrent.onInvalidDrop(e);
}
},
<span id='Ext-dd-DragDropMgr-method-getZIndex'> /**
</span> * @private
* Collects the z-index of the passed element, looking up the parentNode axis to find an absolutely positioned ancestor
* which is able to yield a z-index. If found to be not absolutely positionedm returns -1.
*
* This is used when sorting potential drop targets into z-index order so that only the topmost receives `over` and `drop` events.
*
* @return {Number} The z-index of the element, or of its topmost absolutely positioned ancestor. Returns -1 if the element is not
* absolutely positioned.
*/
getZIndex: function(element) {
var body = document.body,
z,
zIndex = -1;
element = Ext.getDom(element);
while (element !== body) {
if (!isNaN(z = Number(Ext.fly(element).getStyle('zIndex')))) {
zIndex = z;
}
element = element.parentNode;
}
return zIndex;
},
<span id='Ext-dd-DragDropMgr-method-byZIndex'> /**
</span> * @private
* Utility method to pass to {@link Ext.Array#sort} when sorting potential drop targets by z-index.
*/
byZIndex: function(d1, d2) {
return d1.zIndex &lt; d2.zIndex;
},
<span id='Ext-dd-DragDropMgr-method-getBestMatch'> /**
</span> * 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
*/
getBestMatch: function(dds) {
var winner = null;
// Return null if the input is not what we expect
//if (!dds || !dds.length || dds.length == 0) {
// winner = null;
// If there is only one item, it wins
//} else if (dds.length == 1) {
var len = dds.length;
if (len == 1) {
winner = dds[0];
} else {
// Loop through the targeted items
for (var i=0; i&lt;len; ++i) {
var dd = dds[i];
// If the cursor is over the object, it wins. If the
// cursor is over multiple matches, the first one we come
// to wins.
if (dd.cursorIsOver) {
winner = dd;
break;
// Otherwise the object with the most overlap wins
} else {
if (!winner ||
winner.overlap.getArea() &lt; dd.overlap.getArea()) {
winner = dd;
}
}
}
}
return winner;
},
<span id='Ext-dd-DragDropMgr-method-refreshCache'> /**
</span> * 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:
* &lt;code&gt;
* Ext.dd.DragDropMgr.refreshCache(ddinstance.groups);
* &lt;/code&gt;
* Alternatively:
* &lt;code&gt;
* Ext.dd.DragDropMgr.refreshCache({group1:true, group2:true});
* &lt;/code&gt;
* @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
*/
refreshCache: function(groups) {
for (var sGroup in groups) {
if (&quot;string&quot; != typeof sGroup) {
continue;
}
for (var i in this.ids[sGroup]) {
var oDD = this.ids[sGroup][i];
if (this.isTypeOfDD(oDD)) {
// if (this.isTypeOfDD(oDD) &amp;&amp; oDD.isTarget) {
var loc = this.getLocation(oDD);
if (loc) {
this.locationCache[oDD.id] = loc;
} else {
delete this.locationCache[oDD.id];
// this will unregister the drag and drop object if
// the element is not in a usable state
// oDD.unreg();
}
}
}
}
},
<span id='Ext-dd-DragDropMgr-method-verifyEl'> /**
</span> * 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
*/
verifyEl: function(el) {
if (el) {
var parent;
if(Ext.isIE){
try{
parent = el.offsetParent;
}catch(e){}
}else{
parent = el.offsetParent;
}
if (parent) {
return true;
}
}
return false;
},
<span id='Ext-dd-DragDropMgr-method-getLocation'> /**
</span> * 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 {Ext.lib.Region} a Region object representing the total area
* the element occupies, including any padding
* the instance is configured for.
*/
getLocation: function(oDD) {
if (! this.isTypeOfDD(oDD)) {
return null;
}
var el = oDD.getEl(), pos, x1, x2, y1, y2, t, r, b, l, region;
try {
pos= Ext.lib.Dom.getXY(el);
} catch (e) { }
if (!pos) {
return null;
}
x1 = pos[0];
x2 = x1 + el.offsetWidth;
y1 = pos[1];
y2 = y1 + el.offsetHeight;
t = y1 - oDD.padding[0];
r = x2 + oDD.padding[1];
b = y2 + oDD.padding[2];
l = x1 - oDD.padding[3];
return new Ext.lib.Region( t, r, b, l );
},
<span id='Ext-dd-DragDropMgr-method-isOverTarget'> /**
</span> * Checks the cursor location to see if it over the target
* @method isOverTarget
* @param {Ext.lib.Point} pt The point to evaluate
* @param {DragDrop} oTarget the DragDrop object we are inspecting
* @return {boolean} true if the mouse is over the target
* @private
*/
isOverTarget: function(pt, oTarget, intersect) {
// use cache if available
var loc = this.locationCache[oTarget.id];
if (!loc || !this.useCache) {
loc = this.getLocation(oTarget);
this.locationCache[oTarget.id] = loc;
}
if (!loc) {
return false;
}
oTarget.cursorIsOver = loc.contains( 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 also done. Otherwise we need to evaluate the
// location of the target as related to the actual location of the
// dragged element.
var dc = this.dragCurrent;
if (!dc || !dc.getTargetCoord ||
(!intersect &amp;&amp; !dc.constrainX &amp;&amp; !dc.constrainY)) {
return oTarget.cursorIsOver;
}
oTarget.overlap = null;
// 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.
var pos = dc.getTargetCoord(pt.x, pt.y);
var el = dc.getDragEl();
var curRegion = new Ext.lib.Region( pos.y,
pos.x + el.offsetWidth,
pos.y + el.offsetHeight,
pos.x );
var overlap = curRegion.intersect(loc);
if (overlap) {
oTarget.overlap = overlap;
return (intersect) ? true : oTarget.cursorIsOver;
} else {
return false;
}
},
<span id='Ext-dd-DragDropMgr-method-_onUnload'> /**
</span> * unload event handler
* @method _onUnload
* @private
*/
_onUnload: function(e, me) {
Event.removeListener(document, &quot;mouseup&quot;, this.handleMouseUp, this);
Event.removeListener(document, &quot;mousemove&quot;, this.handleMouseMove, this);
Event.removeListener(window, &quot;resize&quot;, this._onResize, this);
Ext.dd.DragDropMgr.unregAll();
},
<span id='Ext-dd-DragDropMgr-method-unregAll'> /**
</span> * Cleans up the drag and drop events and objects.
* @method unregAll
* @private
*/
unregAll: function() {
if (this.dragCurrent) {
this.stopDrag();
this.dragCurrent = null;
}
this._execOnAll(&quot;unreg&quot;, []);
for (var i in this.elementCache) {
delete this.elementCache[i];
}
this.elementCache = {};
this.ids = {};
},
<span id='Ext-dd-DragDropMgr-property-elementCache'> /**
</span> * A cache of DOM elements
* @property elementCache
* @private
*/
elementCache: {},
<span id='Ext-dd-DragDropMgr-method-getElWrapper'> /**
</span> * Get the wrapper for the DOM element specified
* @method getElWrapper
* @param {String} id the id of the element to get
* @return {Ext.dd.DDM.ElementWrapper} the wrapped element
* @private
* @deprecated This wrapper isn't that useful
*/
getElWrapper: function(id) {
var oWrapper = this.elementCache[id];
if (!oWrapper || !oWrapper.el) {
oWrapper = this.elementCache[id] =
new this.ElementWrapper(Ext.getDom(id));
}
return oWrapper;
},
<span id='Ext-dd-DragDropMgr-method-getElement'> /**
</span> * Returns the actual DOM element
* @method getElement
* @param {String} id the id of the elment to get
* @return {Object} The element
* @deprecated use Ext.lib.Ext.getDom instead
*/
getElement: function(id) {
return Ext.getDom(id);
},
<span id='Ext-dd-DragDropMgr-method-getCss'> /**
</span> * 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 Ext.lib.Dom instead
*/
getCss: function(id) {
var el = Ext.getDom(id);
return (el) ? el.style : null;
},
<span id='Ext-dd-DragDropMgr-ElementWrapper'> /**
</span> * Inner class for cached elements
* @class Ext.dd.DragDropMgr.ElementWrapper
* @for DragDropMgr
* @private
* @deprecated
*/
ElementWrapper: function(el) {
<span id='Ext-dd-DragDropMgr-ElementWrapper-property-el'> /**
</span> * The element
* @property el
*/
this.el = el || null;
<span id='Ext-dd-DragDropMgr-ElementWrapper-property-id'> /**
</span> * The element id
* @property id
*/
this.id = this.el &amp;&amp; el.id;
<span id='Ext-dd-DragDropMgr-ElementWrapper-property-css'> /**
</span> * A reference to the style property
* @property css
*/
this.css = this.el &amp;&amp; el.style;
},
<span id='Ext-dd-DragDropMgr-ElementWrapper-method-getPosX'> /**
</span> * 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 Ext.lib.Dom.getX instead
*/
getPosX: function(el) {
return Ext.lib.Dom.getX(el);
},
<span id='Ext-dd-DragDropMgr-ElementWrapper-method-getPosY'> /**
</span> * 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 Ext.lib.Dom.getY instead
*/
getPosY: function(el) {
return Ext.lib.Dom.getY(el);
},
<span id='Ext-dd-DragDropMgr-ElementWrapper-method-swapNode'> /**
</span> * 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
*/
swapNode: function(n1, n2) {
if (n1.swapNode) {
n1.swapNode(n2);
} else {
var p = n2.parentNode;
var s = n2.nextSibling;
if (s == n1) {
p.insertBefore(n1, n2);
} else if (n2 == n1.nextSibling) {
p.insertBefore(n2, n1);
} else {
n1.parentNode.replaceChild(n2, n1);
p.insertBefore(n1, s);
}
}
},
<span id='Ext-dd-DragDropMgr-ElementWrapper-method-getScroll'> /**
</span> * Returns the current scroll position
* @method getScroll
* @private
*/
getScroll: function () {
var t, l, dde=document.documentElement, db=document.body;
if (dde &amp;&amp; (dde.scrollTop || dde.scrollLeft)) {
t = dde.scrollTop;
l = dde.scrollLeft;
} else if (db) {
t = db.scrollTop;
l = db.scrollLeft;
} else {
}
return { top: t, left: l };
},
<span id='Ext-dd-DragDropMgr-ElementWrapper-method-getStyle'> /**
</span> * 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 Ext.lib.Dom.getStyle
*/
getStyle: function(el, styleProp) {
return Ext.fly(el).getStyle(styleProp);
},
<span id='Ext-dd-DragDropMgr-ElementWrapper-method-getScrollTop'> /**
</span> * Gets the scrollTop
* @method getScrollTop
* @return {int} the document's scrollTop
*/
getScrollTop: function () {
return this.getScroll().top;
},
<span id='Ext-dd-DragDropMgr-ElementWrapper-method-getScrollLeft'> /**
</span> * Gets the scrollLeft
* @method getScrollLeft
* @return {int} the document's scrollTop
*/
getScrollLeft: function () {
return this.getScroll().left;
},
<span id='Ext-dd-DragDropMgr-ElementWrapper-method-moveToEl'> /**
</span> * 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
*/
moveToEl: function (moveEl, targetEl) {
var aCoord = Ext.lib.Dom.getXY(targetEl);
Ext.lib.Dom.setXY(moveEl, aCoord);
},
<span id='Ext-dd-DragDropMgr-ElementWrapper-method-numericSort'> /**
</span> * Numeric array sort function
* @method numericSort
*/
numericSort: function(a, b) {
return (a - b);
},
<span id='Ext-dd-DragDropMgr-ElementWrapper-property-_timeoutCount'> /**
</span> * Internal counter
* @property _timeoutCount
* @private
*/
_timeoutCount: 0,
<span id='Ext-dd-DragDropMgr-ElementWrapper-method-_addListeners'> /**
</span> * 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
*/
_addListeners: function() {
var DDM = Ext.dd.DDM;
if ( Ext.lib.Event &amp;&amp; document ) {
DDM._onLoad();
} else {
if (DDM._timeoutCount &gt; 2000) {
} else {
setTimeout(DDM._addListeners, 10);
if (document &amp;&amp; document.body) {
DDM._timeoutCount += 1;
}
}
}
},
<span id='Ext-dd-DragDropMgr-ElementWrapper-method-handleWasClicked'> /**
</span> * 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
*/
handleWasClicked: function(node, id) {
if (this.isHandle(id, node.id)) {
return true;
} else {
// check to see if this is a text node child of the one we want
var p = node.parentNode;
while (p) {
if (this.isHandle(id, p.id)) {
return true;
} else {
p = p.parentNode;
}
}
}
return false;
}
};
}();
// shorter alias, save a few bytes
Ext.dd.DDM = Ext.dd.DragDropMgr;
Ext.dd.DDM._addListeners();
}
<span id='Ext-dd-DD-method-constructor'><span id='Ext-dd-DD'>/**
</span></span> * @class Ext.dd.DD
* A DragDrop implementation where the linked element follows the
* mouse cursor during a drag.
* @extends Ext.dd.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
*/
Ext.dd.DD = function(id, sGroup, config) {
if (id) {
this.init(id, sGroup, config);
}
};
Ext.extend(Ext.dd.DD, Ext.dd.DragDrop, {
<span id='Ext-dd-DD-property-scroll'> /**
</span> * When set to true, the utility automatically tries to scroll the browser
* window when a drag and drop element is dragged near the viewport boundary.
* Defaults to true.
* @property scroll
* @type boolean
*/
scroll: true,
<span id='Ext-dd-DD-method-autoOffset'> /**
</span> * 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
*/
autoOffset: function(iPageX, iPageY) {
var x = iPageX - this.startPageX;
var y = iPageY - this.startPageY;
this.setDelta(x, y);
},
<span id='Ext-dd-DD-method-setDelta'> /**
</span> * 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)
* @method setDelta
* @param {int} iDeltaX the distance from the left
* @param {int} iDeltaY the distance from the top
*/
setDelta: function(iDeltaX, iDeltaY) {
this.deltaX = iDeltaX;
this.deltaY = iDeltaY;
},
<span id='Ext-dd-DD-method-setDragElPos'> /**
</span> * 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
*/
setDragElPos: function(iPageX, iPageY) {
// the first time we do this, we are going to check to make sure
// the element has css positioning
var el = this.getDragEl();
this.alignElWithMouse(el, iPageX, iPageY);
},
<span id='Ext-dd-DD-method-alignElWithMouse'> /**
</span> * 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
*/
alignElWithMouse: function(el, iPageX, iPageY) {
var oCoord = this.getTargetCoord(iPageX, iPageY);
var fly = el.dom ? el : Ext.fly(el, '_dd');
if (!this.deltaSetXY) {
var aCoord = [oCoord.x, oCoord.y];
fly.setXY(aCoord);
var newLeft = fly.getLeft(true);
var newTop = fly.getTop(true);
this.deltaSetXY = [ newLeft - oCoord.x, newTop - oCoord.y ];
} else {
fly.setLeftTop(oCoord.x + this.deltaSetXY[0], oCoord.y + this.deltaSetXY[1]);
}
this.cachePosition(oCoord.x, oCoord.y);
this.autoScroll(oCoord.x, oCoord.y, el.offsetHeight, el.offsetWidth);
return oCoord;
},
<span id='Ext-dd-DD-method-cachePosition'> /**
</span> * 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)
*/
cachePosition: function(iPageX, iPageY) {
if (iPageX) {
this.lastPageX = iPageX;
this.lastPageY = iPageY;
} else {
var aCoord = Ext.lib.Dom.getXY(this.getEl());
this.lastPageX = aCoord[0];
this.lastPageY = aCoord[1];
}
},
<span id='Ext-dd-DD-method-autoScroll'> /**
</span> * 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
var clientH = Ext.lib.Dom.getViewHeight();
// The client width
var clientW = Ext.lib.Dom.getViewWidth();
// The amt scrolled down
var st = this.DDM.getScrollTop();
// The amt scrolled right
var sl = this.DDM.getScrollLeft();
// 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
var toBot = (clientH + st - y - this.deltaY);
// The distance from the cursor to the right of the visible area
var toRight = (clientW + sl - x - this.deltaX);
// 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.
var scrAmt = (document.all) ? 80 : 30;
// Scroll down if we are near the bottom of the visible page and the
// obj extends below the crease
if ( bot &gt; clientH &amp;&amp; toBot &lt; thresh ) {
window.scrollTo(sl, st + scrAmt);
}
// Scroll up if the window is scrolled down and the top of the object
// goes above the top border
if ( y &lt; st &amp;&amp; st &gt; 0 &amp;&amp; y - st &lt; thresh ) {
window.scrollTo(sl, st - scrAmt);
}
// Scroll right if the obj is beyond the right border and the cursor is
// near the border.
if ( right &gt; clientW &amp;&amp; toRight &lt; thresh ) {
window.scrollTo(sl + scrAmt, st);
}
// Scroll left if the window has been scrolled to the right and the obj
// extends past the left border
if ( x &lt; sl &amp;&amp; sl &gt; 0 &amp;&amp; x - sl &lt; thresh ) {
window.scrollTo(sl - scrAmt, st);
}
}
},
<span id='Ext-dd-DD-method-getTargetCoord'> /**
</span> * 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
*/
getTargetCoord: function(iPageX, iPageY) {
var x = iPageX - this.deltaX;
var y = iPageY - this.deltaY;
if (this.constrainX) {
if (x &lt; this.minX) { x = this.minX; }
if (x &gt; this.maxX) { x = this.maxX; }
}
if (this.constrainY) {
if (y &lt; this.minY) { y = this.minY; }
if (y &gt; this.maxY) { y = this.maxY; }
}
x = this.getTick(x, this.xTicks);
y = this.getTick(y, this.yTicks);
return {x:x, y:y};
},
<span id='Ext-dd-DD-method-applyConfig'> /**
</span> * Sets up config options specific to this class. Overrides
* Ext.dd.DragDrop, but all versions of this method through the
* inheritance chain are called
*/
applyConfig: function() {
Ext.dd.DD.superclass.applyConfig.call(this);
this.scroll = (this.config.scroll !== false);
},
<span id='Ext-dd-DD-method-b4MouseDown'> /**
</span> * Event that fires prior to the onMouseDown event. Overrides
* Ext.dd.DragDrop.
*/
b4MouseDown: function(e) {
// this.resetConstraints();
this.autoOffset(e.getPageX(),
e.getPageY());
},
<span id='Ext-dd-DD-method-b4Drag'> /**
</span> * Event that fires prior to the onDrag event. Overrides
* Ext.dd.DragDrop.
*/
b4Drag: function(e) {
this.setDragElPos(e.getPageX(),
e.getPageY());
},
toString: function() {
return (&quot;DD &quot; + this.id);
}
//////////////////////////////////////////////////////////////////////////
// Debugging ygDragDrop events that can be overridden
//////////////////////////////////////////////////////////////////////////
/*
startDrag: function(x, y) {
},
onDrag: function(e) {
},
onDragEnter: function(e, id) {
},
onDragOver: function(e, id) {
},
onDragOut: function(e, id) {
},
onDragDrop: function(e, id) {
},
endDrag: function(e) {
}
*/
});
<span id='Ext-dd-DDProxy-method-constructor'><span id='Ext-dd-DDProxy'>/**
</span></span> * @class Ext.dd.DDProxy
* 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 &quot;frame&quot; element refer to the single proxy element that
* was created to be dragged in place of all DDProxy elements on the
* page.
*
* @extends Ext.dd.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
*/
Ext.dd.DDProxy = function(id, sGroup, config) {
if (id) {
this.init(id, sGroup, config);
this.initFrame();
}
};
<span id='Ext-dd-DDProxy-static-property-Ext.dd.DDProxy.dragElId'>/**
</span> * The default drag frame div id
* @property Ext.dd.DDProxy.dragElId
* @type String
* @static
*/
Ext.dd.DDProxy.dragElId = &quot;ygddfdiv&quot;;
Ext.extend(Ext.dd.DDProxy, Ext.dd.DD, {
<span id='Ext-dd-DDProxy-property-resizeFrame'> /**
</span> * 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,
<span id='Ext-dd-DDProxy-property-centerFrame'> /**
</span> * By default the frame is positioned exactly where the drag element is, so
* we use the cursor offset provided by Ext.dd.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,
<span id='Ext-dd-DDProxy-method-createFrame'> /**
</span> * Creates the proxy element if it does not yet exist
* @method createFrame
*/
createFrame: function() {
var self = this;
var body = document.body;
if (!body || !body.firstChild) {
setTimeout( function() { self.createFrame(); }, 50 );
return;
}
var div = this.getDragEl();
if (!div) {
div = document.createElement(&quot;div&quot;);
div.id = this.dragElId;
var s = div.style;
s.position = &quot;absolute&quot;;
s.visibility = &quot;hidden&quot;;
s.cursor = &quot;move&quot;;
s.border = &quot;2px solid #aaa&quot;;
s.zIndex = 999;
// 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.
body.insertBefore(div, body.firstChild);
}
},
<span id='Ext-dd-DDProxy-method-initFrame'> /**
</span> * Initialization for the drag frame element. Must be called in the
* constructor of all subclasses
* @method initFrame
*/
initFrame: function() {
this.createFrame();
},
applyConfig: function() {
Ext.dd.DDProxy.superclass.applyConfig.call(this);
this.resizeFrame = (this.config.resizeFrame !== false);
this.centerFrame = (this.config.centerFrame);
this.setDragElId(this.config.dragElId || Ext.dd.DDProxy.dragElId);
},
<span id='Ext-dd-DDProxy-method-showFrame'> /**
</span> * 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
*/
showFrame: function(iPageX, iPageY) {
var el = this.getEl();
var dragEl = this.getDragEl();
var s = dragEl.style;
this._resizeProxy();
if (this.centerFrame) {
this.setDelta( Math.round(parseInt(s.width, 10)/2),
Math.round(parseInt(s.height, 10)/2) );
}
this.setDragElPos(iPageX, iPageY);
Ext.fly(dragEl).show();
},
<span id='Ext-dd-DDProxy-method-_resizeProxy'> /**
</span> * 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) {
var el = this.getEl();
Ext.fly(this.getDragEl()).setSize(el.offsetWidth, el.offsetHeight);
}
},
// overrides Ext.dd.DragDrop
b4MouseDown: function(e) {
var x = e.getPageX();
var y = e.getPageY();
this.autoOffset(x, y);
this.setDragElPos(x, y);
},
// overrides Ext.dd.DragDrop
b4StartDrag: function(x, y) {
// show the drag frame
this.showFrame(x, y);
},
// overrides Ext.dd.DragDrop
b4EndDrag: function(e) {
Ext.fly(this.getDragEl()).hide();
},
// overrides Ext.dd.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 Ext.dd.DD.
endDrag: function(e) {
var lel = this.getEl();
var del = this.getDragEl();
// Show the drag frame briefly so we can get its position
del.style.visibility = &quot;&quot;;
this.beforeMove();
// Hide the linked element before the move to get around a Safari
// rendering bug.
lel.style.visibility = &quot;hidden&quot;;
Ext.dd.DDM.moveToEl(lel, del);
del.style.visibility = &quot;hidden&quot;;
lel.style.visibility = &quot;&quot;;
this.afterDrag();
},
beforeMove : function(){
},
afterDrag : function(){
},
toString: function() {
return (&quot;DDProxy &quot; + this.id);
}
});
<span id='Ext-dd-DDTarget-method-constructor'><span id='Ext-dd-DDTarget'>/**
</span></span> * @class Ext.dd.DDTarget
* 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.
* @extends Ext.dd.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
*/
Ext.dd.DDTarget = function(id, sGroup, config) {
if (id) {
this.initTarget(id, sGroup, config);
}
};
// Ext.dd.DDTarget.prototype = new Ext.dd.DragDrop();
Ext.extend(Ext.dd.DDTarget, Ext.dd.DragDrop, {
<span id='Ext-dd-DDTarget-method-getDragEl'> /**
</span> * @hide
* Overridden and disabled. A DDTarget does not support being dragged.
* @method
*/
getDragEl: Ext.emptyFn,
<span id='Ext-dd-DDTarget-method-isValidHandleChild'> /**
</span> * @hide
* Overridden and disabled. A DDTarget does not support being dragged.
* @method
*/
isValidHandleChild: Ext.emptyFn,
<span id='Ext-dd-DDTarget-method-startDrag'> /**
</span> * @hide
* Overridden and disabled. A DDTarget does not support being dragged.
* @method
*/
startDrag: Ext.emptyFn,
<span id='Ext-dd-DDTarget-method-endDrag'> /**
</span> * @hide
* Overridden and disabled. A DDTarget does not support being dragged.
* @method
*/
endDrag: Ext.emptyFn,
<span id='Ext-dd-DDTarget-method-onDrag'> /**
</span> * @hide
* Overridden and disabled. A DDTarget does not support being dragged.
* @method
*/
onDrag: Ext.emptyFn,
<span id='Ext-dd-DDTarget-method-onDragDrop'> /**
</span> * @hide
* Overridden and disabled. A DDTarget does not support being dragged.
* @method
*/
onDragDrop: Ext.emptyFn,
<span id='Ext-dd-DDTarget-method-onDragEnter'> /**
</span> * @hide
* Overridden and disabled. A DDTarget does not support being dragged.
* @method
*/
onDragEnter: Ext.emptyFn,
<span id='Ext-dd-DDTarget-method-onDragOut'> /**
</span> * @hide
* Overridden and disabled. A DDTarget does not support being dragged.
* @method
*/
onDragOut: Ext.emptyFn,
<span id='Ext-dd-DDTarget-method-onDragOver'> /**
</span> * @hide
* Overridden and disabled. A DDTarget does not support being dragged.
* @method
*/
onDragOver: Ext.emptyFn,
<span id='Ext-dd-DDTarget-method-onInvalidDrop'> /**
</span> * @hide
* Overridden and disabled. A DDTarget does not support being dragged.
* @method
*/
onInvalidDrop: Ext.emptyFn,
<span id='Ext-dd-DDTarget-method-onMouseDown'> /**
</span> * @hide
* Overridden and disabled. A DDTarget does not support being dragged.
* @method
*/
onMouseDown: Ext.emptyFn,
<span id='Ext-dd-DDTarget-method-onMouseUp'> /**
</span> * @hide
* Overridden and disabled. A DDTarget does not support being dragged.
* @method
*/
onMouseUp: Ext.emptyFn,
<span id='Ext-dd-DDTarget-method-setXConstraint'> /**
</span> * @hide
* Overridden and disabled. A DDTarget does not support being dragged.
* @method
*/
setXConstraint: Ext.emptyFn,
<span id='Ext-dd-DDTarget-method-setYConstraint'> /**
</span> * @hide
* Overridden and disabled. A DDTarget does not support being dragged.
* @method
*/
setYConstraint: Ext.emptyFn,
<span id='Ext-dd-DDTarget-method-resetConstraints'> /**
</span> * @hide
* Overridden and disabled. A DDTarget does not support being dragged.
* @method
*/
resetConstraints: Ext.emptyFn,
<span id='Ext-dd-DDTarget-method-clearConstraints'> /**
</span> * @hide
* Overridden and disabled. A DDTarget does not support being dragged.
* @method
*/
clearConstraints: Ext.emptyFn,
<span id='Ext-dd-DDTarget-method-clearTicks'> /**
</span> * @hide
* Overridden and disabled. A DDTarget does not support being dragged.
* @method
*/
clearTicks: Ext.emptyFn,
<span id='Ext-dd-DDTarget-method-setInitPosition'> /**
</span> * @hide
* Overridden and disabled. A DDTarget does not support being dragged.
* @method
*/
setInitPosition: Ext.emptyFn,
<span id='Ext-dd-DDTarget-method-setDragElId'> /**
</span> * @hide
* Overridden and disabled. A DDTarget does not support being dragged.
* @method
*/
setDragElId: Ext.emptyFn,
<span id='Ext-dd-DDTarget-method-setHandleElId'> /**
</span> * @hide
* Overridden and disabled. A DDTarget does not support being dragged.
* @method
*/
setHandleElId: Ext.emptyFn,
<span id='Ext-dd-DDTarget-method-setOuterHandleElId'> /**
</span> * @hide
* Overridden and disabled. A DDTarget does not support being dragged.
* @method
*/
setOuterHandleElId: Ext.emptyFn,
<span id='Ext-dd-DDTarget-method-addInvalidHandleClass'> /**
</span> * @hide
* Overridden and disabled. A DDTarget does not support being dragged.
* @method
*/
addInvalidHandleClass: Ext.emptyFn,
<span id='Ext-dd-DDTarget-method-addInvalidHandleId'> /**
</span> * @hide
* Overridden and disabled. A DDTarget does not support being dragged.
* @method
*/
addInvalidHandleId: Ext.emptyFn,
<span id='Ext-dd-DDTarget-method-addInvalidHandleType'> /**
</span> * @hide
* Overridden and disabled. A DDTarget does not support being dragged.
* @method
*/
addInvalidHandleType: Ext.emptyFn,
<span id='Ext-dd-DDTarget-method-removeInvalidHandleClass'> /**
</span> * @hide
* Overridden and disabled. A DDTarget does not support being dragged.
* @method
*/
removeInvalidHandleClass: Ext.emptyFn,
<span id='Ext-dd-DDTarget-method-removeInvalidHandleId'> /**
</span> * @hide
* Overridden and disabled. A DDTarget does not support being dragged.
* @method
*/
removeInvalidHandleId: Ext.emptyFn,
<span id='Ext-dd-DDTarget-method-removeInvalidHandleType'> /**
</span> * @hide
* Overridden and disabled. A DDTarget does not support being dragged.
* @method
*/
removeInvalidHandleType: Ext.emptyFn,
toString: function() {
return (&quot;DDTarget &quot; + this.id);
}
});</pre>
</body>
</html>