<!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:
* <ul>
* <li>linked element: the element that is passed into the constructor.
* This is the element which defines the boundaries for interaction with
* other DragDrop objects.</li>
* <li>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.</li>
* <li>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}.
* </li>
* </ul>
* This class should not be instantiated until the onload event to ensure that
* the associated elements are available.
* The following would define a DragDrop obj that would interact with any
* other DragDrop obj in the "group1" group:
* <pre>
* dd = new Ext.dd.DragDrop("div1", "group1");
* </pre>
* 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...
* <pre>
* dd.onDragDrop = function(e, id) {
* &nbsp;&nbsp;alert("dd was dropped on " + id);
* }
* </pre>
* @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 "linked element" 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 &lt;a> elements:<pre><code>
{
A: "A"
}</code></pre>
* @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 "foo", use:<pre><code>
{
foo: true
}</code></pre>
* @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
* notificati