4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js">/*
19 * This is a derivative of the similarly named class in the YUI Library.
20 * The original license:
21 * Copyright (c) 2006, Yahoo! Inc. All rights reserved.
22 * Code licensed under the BSD License:
23 * http://developer.yahoo.net/yui/license.txt
27 <span id='Ext-dd-DragDropManager'>/**
28 </span> * @class Ext.dd.DragDropManager
29 * DragDropManager is a singleton that tracks the element interaction for
30 * all DragDrop items in the window. Generally, you will not call
31 * this class directly, but it does have helper methods that could
32 * be useful in your DragDrop implementations.
35 Ext.define('Ext.dd.DragDropManager', {
38 requires: ['Ext.util.Region'],
40 uses: ['Ext.tip.QuickTipManager'],
42 // shorter ClassName, to save bytes and use internally
43 alternateClassName: ['Ext.dd.DragDropMgr', 'Ext.dd.DDM'],
45 <span id='Ext-dd-DragDropManager-property-ids'> /**
46 </span> * Two dimensional Array of registered DragDrop objects. The first
47 * dimension is the DragDrop item group, the second the DragDrop
55 <span id='Ext-dd-DragDropManager-property-handleIds'> /**
56 </span> * Array of element ids defined as drag handles. Used to determine
57 * if the element that generated the mousedown event is actually the
58 * handle and not the html element itself.
65 <span id='Ext-dd-DragDropManager-property-dragCurrent'> /**
66 </span> * the DragDrop object that is currently being dragged
67 * @property {Ext.dd.DragDrop} dragCurrent
72 <span id='Ext-dd-DragDropManager-property-dragOvers'> /**
73 </span> * the DragDrop object(s) that are being hovered over
74 * @property {Ext.dd.DragDrop[]} dragOvers
79 <span id='Ext-dd-DragDropManager-property-deltaX'> /**
80 </span> * the X distance between the cursor and the object being dragged
87 <span id='Ext-dd-DragDropManager-property-deltaY'> /**
88 </span> * the Y distance between the cursor and the object being dragged
95 <span id='Ext-dd-DragDropManager-property-preventDefault'> /**
96 </span> * Flag to determine if we should prevent the default behavior of the
97 * events we define. By default this is true, but this can be set to
98 * false if you need the default behavior (not recommended)
99 * @property preventDefault
102 preventDefault: true,
104 <span id='Ext-dd-DragDropManager-property-stopPropagation'> /**
105 </span> * Flag to determine if we should stop the propagation of the events
106 * we generate. This is true by default but you may want to set it to
107 * false if the html element contains other features that require the
109 * @property stopPropagation
112 stopPropagation: true,
114 <span id='Ext-dd-DragDropManager-property-initialized'> /**
115 </span> * Internal flag that is set to true when drag and drop has been
117 * @property initialized
122 <span id='Ext-dd-DragDropManager-property-locked'> /**
123 </span> * All drag and drop can be disabled.
129 <span id='Ext-dd-DragDropManager-method-init'> /**
130 </span> * Called the first time an element is registered.
135 this.initialized = true;
138 <span id='Ext-dd-DragDropManager-property-POINT'> /**
139 </span> * In point mode, drag and drop interaction is defined by the
140 * location of the cursor during the drag/drop
146 <span id='Ext-dd-DragDropManager-property-INTERSECT'> /**
147 </span> * In intersect mode, drag and drop interaction is defined by the
148 * overlap of two or more drag and drop objects.
149 * @property INTERSECT
154 <span id='Ext-dd-DragDropManager-property-mode'> /**
155 </span> * The current drag and drop mode. Default: POINT
161 <span id='Ext-dd-DragDropManager-method-_execOnAll'> /**
162 </span> * Runs method on all drag and drop objects
166 _execOnAll: function(sMethod, args) {
167 for (var i in this.ids) {
168 for (var j in this.ids[i]) {
169 var oDD = this.ids[i][j];
170 if (! this.isTypeOfDD(oDD)) {
173 oDD[sMethod].apply(oDD, args);
178 <span id='Ext-dd-DragDropManager-method-_onLoad'> /**
179 </span> * Drag and drop initialization. Sets up the global event handlers
183 _onLoad: function() {
187 var Event = Ext.EventManager;
188 Event.on(document, "mouseup", this.handleMouseUp, this, true);
189 Event.on(document, "mousemove", this.handleMouseMove, this, true);
190 Event.on(window, "unload", this._onUnload, this, true);
191 Event.on(window, "resize", this._onResize, this, true);
192 // Event.on(window, "mouseout", this._test);
196 <span id='Ext-dd-DragDropManager-method-_onResize'> /**
197 </span> * Reset constraints on all drag and drop objs
201 _onResize: function(e) {
202 this._execOnAll("resetConstraints", []);
205 <span id='Ext-dd-DragDropManager-method-lock'> /**
206 </span> * Lock all drag and drop functionality
209 lock: function() { this.locked = true; },
211 <span id='Ext-dd-DragDropManager-method-unlock'> /**
212 </span> * Unlock all drag and drop functionality
215 unlock: function() { this.locked = false; },
217 <span id='Ext-dd-DragDropManager-method-isLocked'> /**
218 </span> * Is drag and drop locked?
220 * @return {Boolean} True if drag and drop is locked, false otherwise.
222 isLocked: function() { return this.locked; },
224 <span id='Ext-dd-DragDropManager-property-locationCache'> /**
225 </span> * Location cache that is set for all drag drop objects when a drag is
226 * initiated, cleared when the drag is finished.
227 * @property locationCache
232 <span id='Ext-dd-DragDropManager-property-useCache'> /**
233 </span> * Set useCache to false if you want to force object the lookup of each
234 * drag and drop linked element constantly during a drag.
240 <span id='Ext-dd-DragDropManager-property-clickPixelThresh'> /**
241 </span> * The number of pixels that the mouse needs to move after the
242 * mousedown before the drag is initiated. Default=3;
243 * @property clickPixelThresh
248 <span id='Ext-dd-DragDropManager-property-clickTimeThresh'> /**
249 </span> * The number of milliseconds after the mousedown event to initiate the
250 * drag if we don't get a mouseup event. Default=350
251 * @property clickTimeThresh
254 clickTimeThresh: 350,
256 <span id='Ext-dd-DragDropManager-property-dragThreshMet'> /**
257 </span> * Flag that indicates that either the drag pixel threshold or the
258 * mousdown time threshold has been met
259 * @property dragThreshMet
263 dragThreshMet: false,
265 <span id='Ext-dd-DragDropManager-property-clickTimeout'> /**
266 </span> * Timeout used for the click time threshold
267 * @property clickTimeout
273 <span id='Ext-dd-DragDropManager-property-startX'> /**
274 </span> * The X position of the mousedown event stored for later use when a
275 * drag threshold is met.
282 <span id='Ext-dd-DragDropManager-property-startY'> /**
283 </span> * The Y position of the mousedown event stored for later use when a
284 * drag threshold is met.
291 <span id='Ext-dd-DragDropManager-method-regDragDrop'> /**
292 </span> * Each DragDrop instance must be registered with the DragDropManager.
293 * This is executed in DragDrop.init()
294 * @method regDragDrop
295 * @param {Ext.dd.DragDrop} oDD the DragDrop object to register
296 * @param {String} sGroup the name of the group this element belongs to
298 regDragDrop: function(oDD, sGroup) {
299 if (!this.initialized) { this.init(); }
301 if (!this.ids[sGroup]) {
302 this.ids[sGroup] = {};
304 this.ids[sGroup][oDD.id] = oDD;
307 <span id='Ext-dd-DragDropManager-method-removeDDFromGroup'> /**
308 </span> * Removes the supplied dd instance from the supplied group. Executed
309 * by DragDrop.removeFromGroup, so don't call this function directly.
310 * @method removeDDFromGroup
313 removeDDFromGroup: function(oDD, sGroup) {
314 if (!this.ids[sGroup]) {
315 this.ids[sGroup] = {};
318 var obj = this.ids[sGroup];
319 if (obj && obj[oDD.id]) {
324 <span id='Ext-dd-DragDropManager-method-_remove'> /**
325 </span> * Unregisters a drag and drop item. This is executed in
326 * DragDrop.unreg, use that method instead of calling this directly.
330 _remove: function(oDD) {
331 for (var g in oDD.groups) {
332 if (g && this.ids[g] && this.ids[g][oDD.id]) {
333 delete this.ids[g][oDD.id];
336 delete this.handleIds[oDD.id];
339 <span id='Ext-dd-DragDropManager-method-regHandle'> /**
340 </span> * Each DragDrop handle element must be registered. This is done
341 * automatically when executing DragDrop.setHandleElId()
343 * @param {String} sDDId the DragDrop id this element is a handle for
344 * @param {String} sHandleId the id of the element that is the drag
347 regHandle: function(sDDId, sHandleId) {
348 if (!this.handleIds[sDDId]) {
349 this.handleIds[sDDId] = {};
351 this.handleIds[sDDId][sHandleId] = sHandleId;
354 <span id='Ext-dd-DragDropManager-method-isDragDrop'> /**
355 </span> * Utility function to determine if a given element has been
356 * registered as a drag drop item.
358 * @param {String} id the element id to check
359 * @return {Boolean} true if this element is a DragDrop item,
362 isDragDrop: function(id) {
363 return ( this.getDDById(id) ) ? true : false;
366 <span id='Ext-dd-DragDropManager-method-getRelated'> /**
367 </span> * Returns the drag and drop instances that are in all groups the
368 * passed in instance belongs to.
370 * @param {Ext.dd.DragDrop} p_oDD the obj to get related data for
371 * @param {Boolean} bTargetsOnly if true, only return targetable objs
372 * @return {Ext.dd.DragDrop[]} the related instances
374 getRelated: function(p_oDD, bTargetsOnly) {
376 for (var i in p_oDD.groups) {
377 for (var j in this.ids[i]) {
378 var dd = this.ids[i][j];
379 if (! this.isTypeOfDD(dd)) {
382 if (!bTargetsOnly || dd.isTarget) {
383 oDDs[oDDs.length] = dd;
391 <span id='Ext-dd-DragDropManager-method-isLegalTarget'> /**
392 </span> * Returns true if the specified dd target is a legal target for
393 * the specifice drag obj
394 * @method isLegalTarget
395 * @param {Ext.dd.DragDrop} oDD the drag obj
396 * @param {Ext.dd.DragDrop} oTargetDD the target
397 * @return {Boolean} true if the target is a legal target for the
400 isLegalTarget: function (oDD, oTargetDD) {
401 var targets = this.getRelated(oDD, true);
402 for (var i=0, len=targets.length;i<len;++i) {
403 if (targets[i].id == oTargetDD.id) {
411 <span id='Ext-dd-DragDropManager-method-isTypeOfDD'> /**
412 </span> * My goal is to be able to transparently determine if an object is
413 * typeof DragDrop, and the exact subclass of DragDrop. typeof
414 * returns "object", oDD.constructor.toString() always returns
415 * "DragDrop" and not the name of the subclass. So for now it just
416 * evaluates a well-known variable in DragDrop.
418 * @param {Object} the object to evaluate
419 * @return {Boolean} true if typeof oDD = DragDrop
421 isTypeOfDD: function (oDD) {
422 return (oDD && oDD.__ygDragDrop);
425 <span id='Ext-dd-DragDropManager-method-isHandle'> /**
426 </span> * Utility function to determine if a given element has been
427 * registered as a drag drop handle for the given Drag Drop object.
429 * @param {String} id the element id to check
430 * @return {Boolean} true if this element is a DragDrop handle, false
433 isHandle: function(sDDId, sHandleId) {
434 return ( this.handleIds[sDDId] &&
435 this.handleIds[sDDId][sHandleId] );
438 <span id='Ext-dd-DragDropManager-method-getDDById'> /**
439 </span> * Returns the DragDrop instance for a given id
441 * @param {String} id the id of the DragDrop object
442 * @return {Ext.dd.DragDrop} the drag drop object, null if it is not found
444 getDDById: function(id) {
445 for (var i in this.ids) {
446 if (this.ids[i][id]) {
447 return this.ids[i][id];
453 <span id='Ext-dd-DragDropManager-method-handleMouseDown'> /**
454 </span> * Fired after a registered DragDrop object gets the mousedown event.
455 * Sets up the events required to track the object being dragged
456 * @method handleMouseDown
457 * @param {Event} e the event
458 * @param {Ext.dd.DragDrop} oDD the DragDrop object being dragged
461 handleMouseDown: function(e, oDD) {
462 if(Ext.tip.QuickTipManager){
463 Ext.tip.QuickTipManager.ddDisable();
465 if(this.dragCurrent){
466 // the original browser mouseup wasn't handled (e.g. outside FF browser window)
467 // so clean up first to avoid breaking the next drag
468 this.handleMouseUp(e);
471 this.currentTarget = e.getTarget();
472 this.dragCurrent = oDD;
474 var el = oDD.getEl();
476 // track start position
477 this.startX = e.getPageX();
478 this.startY = e.getPageY();
480 this.deltaX = this.startX - el.offsetLeft;
481 this.deltaY = this.startY - el.offsetTop;
483 this.dragThreshMet = false;
485 this.clickTimeout = setTimeout(
487 var DDM = Ext.dd.DragDropManager;
488 DDM.startDrag(DDM.startX, DDM.startY);
490 this.clickTimeThresh );
493 <span id='Ext-dd-DragDropManager-method-startDrag'> /**
494 </span> * Fired when either the drag pixel threshol or the mousedown hold
495 * time threshold has been met.
497 * @param {Number} x the X position of the original mousedown
498 * @param {Number} y the Y position of the original mousedown
500 startDrag: function(x, y) {
501 clearTimeout(this.clickTimeout);
502 if (this.dragCurrent) {
503 this.dragCurrent.b4StartDrag(x, y);
504 this.dragCurrent.startDrag(x, y);
506 this.dragThreshMet = true;
509 <span id='Ext-dd-DragDropManager-method-handleMouseUp'> /**
510 </span> * Internal function to handle the mouseup event. Will be invoked
511 * from the context of the document.
512 * @method handleMouseUp
513 * @param {Event} e the event
516 handleMouseUp: function(e) {
518 if(Ext.tip && Ext.tip.QuickTipManager){
519 Ext.tip.QuickTipManager.ddEnable();
521 if (! this.dragCurrent) {
525 clearTimeout(this.clickTimeout);
527 if (this.dragThreshMet) {
528 this.fireEvents(e, true);
537 <span id='Ext-dd-DragDropManager-method-stopEvent'> /**
538 </span> * Utility to stop event propagation and event default, if these
539 * features are turned on.
541 * @param {Event} e the event as returned by this.getEvent()
543 stopEvent: function(e){
544 if(this.stopPropagation) {
548 if (this.preventDefault) {
553 <span id='Ext-dd-DragDropManager-method-stopDrag'> /**
554 </span> * Internal function to clean up event handlers after the drag
555 * operation is complete
557 * @param {Event} e the event
560 stopDrag: function(e) {
561 // Fire the drag end event for the item that was dragged
562 if (this.dragCurrent) {
563 if (this.dragThreshMet) {
564 this.dragCurrent.b4EndDrag(e);
565 this.dragCurrent.endDrag(e);
568 this.dragCurrent.onMouseUp(e);
571 this.dragCurrent = null;
575 <span id='Ext-dd-DragDropManager-method-handleMouseMove'> /**
576 </span> * Internal function to handle the mousemove event. Will be invoked
577 * from the context of the html element.
579 * @TODO figure out what we can do about mouse events lost when the
580 * user drags objects beyond the window boundary. Currently we can
581 * detect this in internet explorer by verifying that the mouse is
582 * down during the mousemove event. Firefox doesn't give us the
583 * button state on the mousemove event.
584 * @method handleMouseMove
585 * @param {Event} e the event
588 handleMouseMove: function(e) {
589 if (! this.dragCurrent) {
592 // var button = e.which || e.button;
594 // check for IE mouseup outside of page boundary
595 if (Ext.isIE && (e.button !== 0 && e.button !== 1 && e.button !== 2)) {
597 return this.handleMouseUp(e);
600 if (!this.dragThreshMet) {
601 var diffX = Math.abs(this.startX - e.getPageX());
602 var diffY = Math.abs(this.startY - e.getPageY());
603 if (diffX > this.clickPixelThresh ||
604 diffY > this.clickPixelThresh) {
605 this.startDrag(this.startX, this.startY);
609 if (this.dragThreshMet) {
610 this.dragCurrent.b4Drag(e);
611 this.dragCurrent.onDrag(e);
612 if(!this.dragCurrent.moveOnly){
613 this.fireEvents(e, false);
622 <span id='Ext-dd-DragDropManager-method-fireEvents'> /**
623 </span> * Iterates over all of the DragDrop elements to find ones we are
624 * hovering over or dropping on
626 * @param {Event} e the event
627 * @param {Boolean} isDrop is this a drop op or a mouseover op?
630 fireEvents: function(e, isDrop) {
631 var dc = this.dragCurrent;
633 // If the user did the mouse up outside of the window, we could
634 // get here even though we have ended the drag.
635 if (!dc || dc.isLocked()) {
639 var pt = e.getPoint();
641 // cache the previous dragOver array
649 // Check to see if the object(s) we were hovering over is no longer
650 // being hovered over so we can fire the onDragOut event
651 for (var i in this.dragOvers) {
653 var ddo = this.dragOvers[i];
655 if (! this.isTypeOfDD(ddo)) {
659 if (! this.isOverTarget(pt, ddo, this.mode)) {
664 delete this.dragOvers[i];
667 for (var sGroup in dc.groups) {
669 if ("string" != typeof sGroup) {
673 for (i in this.ids[sGroup]) {
674 var oDD = this.ids[sGroup][i];
675 if (! this.isTypeOfDD(oDD)) {
679 if (oDD.isTarget && !oDD.isLocked() && ((oDD != dc) || (dc.ignoreSelf === false))) {
680 if (this.isOverTarget(pt, oDD, this.mode)) {
681 // look for drop interactions
683 dropEvts.push( oDD );
684 // look for drag enter and drag over interactions
687 // initial drag over: dragEnter fires
688 if (!oldOvers[oDD.id]) {
689 enterEvts.push( oDD );
690 // subsequent drag overs: dragOver fires
692 overEvts.push( oDD );
695 this.dragOvers[oDD.id] = oDD;
703 if (outEvts.length) {
704 dc.b4DragOut(e, outEvts);
705 dc.onDragOut(e, outEvts);
708 if (enterEvts.length) {
709 dc.onDragEnter(e, enterEvts);
712 if (overEvts.length) {
713 dc.b4DragOver(e, overEvts);
714 dc.onDragOver(e, overEvts);
717 if (dropEvts.length) {
718 dc.b4DragDrop(e, dropEvts);
719 dc.onDragDrop(e, dropEvts);
723 // fire dragout events
725 for (i=0, len=outEvts.length; i<len; ++i) {
726 dc.b4DragOut(e, outEvts[i].id);
727 dc.onDragOut(e, outEvts[i].id);
731 for (i=0,len=enterEvts.length; i<len; ++i) {
732 // dc.b4DragEnter(e, oDD.id);
733 dc.onDragEnter(e, enterEvts[i].id);
737 for (i=0,len=overEvts.length; i<len; ++i) {
738 dc.b4DragOver(e, overEvts[i].id);
739 dc.onDragOver(e, overEvts[i].id);
743 for (i=0, len=dropEvts.length; i<len; ++i) {
744 dc.b4DragDrop(e, dropEvts[i].id);
745 dc.onDragDrop(e, dropEvts[i].id);
750 // notify about a drop that did not find a target
751 if (isDrop && !dropEvts.length) {
757 <span id='Ext-dd-DragDropManager-method-getBestMatch'> /**
758 </span> * Helper function for getting the best match from the list of drag
759 * and drop objects returned by the drag and drop events when we are
760 * in INTERSECT mode. It returns either the first object that the
761 * cursor is over, or the object that has the greatest overlap with
762 * the dragged element.
763 * @method getBestMatch
764 * @param {Ext.dd.DragDrop[]} dds The array of drag and drop objects
766 * @return {Ext.dd.DragDrop} The best single match
768 getBestMatch: function(dds) {
770 // Return null if the input is not what we expect
771 //if (!dds || !dds.length || dds.length == 0) {
773 // If there is only one item, it wins
774 //} else if (dds.length == 1) {
776 var len = dds.length;
781 // Loop through the targeted items
782 for (var i=0; i<len; ++i) {
784 // If the cursor is over the object, it wins. If the
785 // cursor is over multiple matches, the first one we come
787 if (dd.cursorIsOver) {
790 // Otherwise the object with the most overlap wins
793 winner.overlap.getArea() < dd.overlap.getArea()) {
803 <span id='Ext-dd-DragDropManager-method-refreshCache'> /**
804 </span> * Refreshes the cache of the top-left and bottom-right points of the
805 * drag and drop objects in the specified group(s). This is in the
806 * format that is stored in the drag and drop instance, so typical
809 * Ext.dd.DragDropManager.refreshCache(ddinstance.groups);
813 * Ext.dd.DragDropManager.refreshCache({group1:true, group2:true});
815 * @TODO this really should be an indexed array. Alternatively this
816 * method could accept both.
817 * @method refreshCache
818 * @param {Object} groups an associative array of groups to refresh
820 refreshCache: function(groups) {
821 for (var sGroup in groups) {
822 if ("string" != typeof sGroup) {
825 for (var i in this.ids[sGroup]) {
826 var oDD = this.ids[sGroup][i];
828 if (this.isTypeOfDD(oDD)) {
829 // if (this.isTypeOfDD(oDD) && oDD.isTarget) {
830 var loc = this.getLocation(oDD);
832 this.locationCache[oDD.id] = loc;
834 delete this.locationCache[oDD.id];
835 // this will unregister the drag and drop object if
836 // the element is not in a usable state
844 <span id='Ext-dd-DragDropManager-method-verifyEl'> /**
845 </span> * This checks to make sure an element exists and is in the DOM. The
846 * main purpose is to handle cases where innerHTML is used to remove
847 * drag and drop objects from the DOM. IE provides an 'unspecified
848 * error' when trying to access the offsetParent of such an element
850 * @param {HTMLElement} el the element to check
851 * @return {Boolean} true if the element looks usable
853 verifyEl: function(el) {
858 parent = el.offsetParent;
861 parent = el.offsetParent;
871 <span id='Ext-dd-DragDropManager-method-getLocation'> /**
872 </span> * Returns a Region object containing the drag and drop element's position
873 * and size, including the padding configured for it
874 * @method getLocation
875 * @param {Ext.dd.DragDrop} oDD the drag and drop object to get the location for.
876 * @return {Ext.util.Region} a Region object representing the total area
877 * the element occupies, including any padding
878 * the instance is configured for.
880 getLocation: function(oDD) {
881 if (! this.isTypeOfDD(oDD)) {
885 //delegate getLocation method to the
886 //drag and drop target.
888 return oDD.getRegion();
891 var el = oDD.getEl(), pos, x1, x2, y1, y2, t, r, b, l;
894 pos= Ext.Element.getXY(el);
902 x2 = x1 + el.offsetWidth;
904 y2 = y1 + el.offsetHeight;
906 t = y1 - oDD.padding[0];
907 r = x2 + oDD.padding[1];
908 b = y2 + oDD.padding[2];
909 l = x1 - oDD.padding[3];
911 return Ext.create('Ext.util.Region', t, r, b, l);
914 <span id='Ext-dd-DragDropManager-method-isOverTarget'> /**
915 </span> * Checks the cursor location to see if it over the target
916 * @method isOverTarget
917 * @param {Ext.util.Point} pt The point to evaluate
918 * @param {Ext.dd.DragDrop} oTarget the DragDrop object we are inspecting
919 * @return {Boolean} true if the mouse is over the target
922 isOverTarget: function(pt, oTarget, intersect) {
923 // use cache if available
924 var loc = this.locationCache[oTarget.id];
925 if (!loc || !this.useCache) {
926 loc = this.getLocation(oTarget);
927 this.locationCache[oTarget.id] = loc;
935 oTarget.cursorIsOver = loc.contains( pt );
937 // DragDrop is using this as a sanity check for the initial mousedown
938 // in this case we are done. In POINT mode, if the drag obj has no
939 // contraints, we are also done. Otherwise we need to evaluate the
940 // location of the target as related to the actual location of the
942 var dc = this.dragCurrent;
943 if (!dc || !dc.getTargetCoord ||
944 (!intersect && !dc.constrainX && !dc.constrainY)) {
945 return oTarget.cursorIsOver;
948 oTarget.overlap = null;
950 // Get the current location of the drag element, this is the
951 // location of the mouse event less the delta that represents
952 // where the original mousedown happened on the element. We
953 // need to consider constraints and ticks as well.
954 var pos = dc.getTargetCoord(pt.x, pt.y);
956 var el = dc.getDragEl();
957 var curRegion = Ext.create('Ext.util.Region', pos.y,
958 pos.x + el.offsetWidth,
959 pos.y + el.offsetHeight,
962 var overlap = curRegion.intersect(loc);
965 oTarget.overlap = overlap;
966 return (intersect) ? true : oTarget.cursorIsOver;
972 <span id='Ext-dd-DragDropManager-method-_onUnload'> /**
973 </span> * unload event handler
977 _onUnload: function(e, me) {
978 Ext.dd.DragDropManager.unregAll();
981 <span id='Ext-dd-DragDropManager-method-unregAll'> /**
982 </span> * Cleans up the drag and drop events and objects.
986 unregAll: function() {
988 if (this.dragCurrent) {
990 this.dragCurrent = null;
993 this._execOnAll("unreg", []);
995 for (var i in this.elementCache) {
996 delete this.elementCache[i];
999 this.elementCache = {};
1003 <span id='Ext-dd-DragDropManager-property-elementCache'> /**
1004 </span> * A cache of DOM elements
1005 * @property elementCache
1010 <span id='Ext-dd-DragDropManager-method-getElWrapper'> /**
1011 </span> * Get the wrapper for the DOM element specified
1012 * @method getElWrapper
1013 * @param {String} id the id of the element to get
1014 * @return {Ext.dd.DragDropManager.ElementWrapper} the wrapped element
1016 * @deprecated This wrapper isn't that useful
1018 getElWrapper: function(id) {
1019 var oWrapper = this.elementCache[id];
1020 if (!oWrapper || !oWrapper.el) {
1021 oWrapper = this.elementCache[id] =
1022 new this.ElementWrapper(Ext.getDom(id));
1027 <span id='Ext-dd-DragDropManager-method-getElement'> /**
1028 </span> * Returns the actual DOM element
1029 * @method getElement
1030 * @param {String} id the id of the elment to get
1031 * @return {Object} The element
1032 * @deprecated use Ext.lib.Ext.getDom instead
1034 getElement: function(id) {
1035 return Ext.getDom(id);
1038 <span id='Ext-dd-DragDropManager-method-getCss'> /**
1039 </span> * Returns the style property for the DOM element (i.e.,
1040 * document.getElById(id).style)
1042 * @param {String} id the id of the elment to get
1043 * @return {Object} The style property of the element
1045 getCss: function(id) {
1046 var el = Ext.getDom(id);
1047 return (el) ? el.style : null;
1050 <span id='Ext-dd-DragDropManager-ElementWrapper'> /**
1051 </span> * @class Ext.dd.DragDropManager.ElementWrapper
1052 * Inner class for cached elements
1056 ElementWrapper: function(el) {
1057 <span id='Ext-dd-DragDropManager-ElementWrapper-property-el'> /**
1058 </span> * The element
1061 this.el = el || null;
1062 <span id='Ext-dd-DragDropManager-ElementWrapper-property-id'> /**
1063 </span> * The element id
1066 this.id = this.el && el.id;
1067 <span id='Ext-dd-DragDropManager-ElementWrapper-property-css'> /**
1068 </span> * A reference to the style property
1071 this.css = this.el && el.style;
1074 // The DragDropManager class continues
1075 <span id='Ext-dd-DragDropManager'> /** @class Ext.dd.DragDropManager */
1077 <span id='Ext-dd-DragDropManager-method-getPosX'> /**
1078 </span> * Returns the X position of an html element
1079 * @param {HTMLElement} el the element for which to get the position
1080 * @return {Number} the X coordinate
1082 getPosX: function(el) {
1083 return Ext.Element.getX(el);
1086 <span id='Ext-dd-DragDropManager-method-getPosY'> /**
1087 </span> * Returns the Y position of an html element
1088 * @param {HTMLElement} el the element for which to get the position
1089 * @return {Number} the Y coordinate
1091 getPosY: function(el) {
1092 return Ext.Element.getY(el);
1095 <span id='Ext-dd-DragDropManager-method-swapNode'> /**
1096 </span> * Swap two nodes. In IE, we use the native method, for others we
1097 * emulate the IE behavior
1098 * @param {HTMLElement} n1 the first node to swap
1099 * @param {HTMLElement} n2 the other node to swap
1101 swapNode: function(n1, n2) {
1105 var p = n2.parentNode;
1106 var s = n2.nextSibling;
1109 p.insertBefore(n1, n2);
1110 } else if (n2 == n1.nextSibling) {
1111 p.insertBefore(n2, n1);
1113 n1.parentNode.replaceChild(n2, n1);
1114 p.insertBefore(n1, s);
1119 <span id='Ext-dd-DragDropManager-method-getScroll'> /**
1120 </span> * Returns the current scroll position
1123 getScroll: function () {
1124 var doc = window.document,
1125 docEl = doc.documentElement,
1131 top = window.scrollYOffset;
1132 left = window.scrollXOffset;
1134 if (docEl && (docEl.scrollTop || docEl.scrollLeft)) {
1135 top = docEl.scrollTop;
1136 left = docEl.scrollLeft;
1138 top = body.scrollTop;
1139 left = body.scrollLeft;
1148 <span id='Ext-dd-DragDropManager-method-getStyle'> /**
1149 </span> * Returns the specified element style property
1150 * @param {HTMLElement} el the element
1151 * @param {String} styleProp the style property
1152 * @return {String} The value of the style property
1154 getStyle: function(el, styleProp) {
1155 return Ext.fly(el).getStyle(styleProp);
1158 <span id='Ext-dd-DragDropManager-method-getScrollTop'> /**
1159 </span> * Gets the scrollTop
1160 * @return {Number} the document's scrollTop
1162 getScrollTop: function () {
1163 return this.getScroll().top;
1166 <span id='Ext-dd-DragDropManager-method-getScrollLeft'> /**
1167 </span> * Gets the scrollLeft
1168 * @return {Number} the document's scrollTop
1170 getScrollLeft: function () {
1171 return this.getScroll().left;
1174 <span id='Ext-dd-DragDropManager-method-moveToEl'> /**
1175 </span> * Sets the x/y position of an element to the location of the
1177 * @param {HTMLElement} moveEl The element to move
1178 * @param {HTMLElement} targetEl The position reference element
1180 moveToEl: function (moveEl, targetEl) {
1181 var aCoord = Ext.Element.getXY(targetEl);
1182 Ext.Element.setXY(moveEl, aCoord);
1185 <span id='Ext-dd-DragDropManager-method-numericSort'> /**
1186 </span> * Numeric array sort function
1189 * @returns {Number} positive, negative or 0
1191 numericSort: function(a, b) {
1195 <span id='Ext-dd-DragDropManager-property-_timeoutCount'> /**
1196 </span> * Internal counter
1197 * @property {Number} _timeoutCount
1202 <span id='Ext-dd-DragDropManager-method-_addListeners'> /**
1203 </span> * Trying to make the load order less important. Without this we get
1204 * an error if this file is loaded before the Event Utility.
1207 _addListeners: function() {
1211 if (this._timeoutCount > 2000) {
1213 setTimeout(this._addListeners, 10);
1214 if (document && document.body) {
1215 this._timeoutCount += 1;
1221 <span id='Ext-dd-DragDropManager-method-handleWasClicked'> /**
1222 </span> * Recursively searches the immediate parent and all child nodes for
1223 * the handle element in order to determine wheter or not it was
1225 * @param {HTMLElement} node the html element to inspect
1227 handleWasClicked: function(node, id) {
1228 if (this.isHandle(id, node.id)) {
1231 // check to see if this is a text node child of the one we want
1232 var p = node.parentNode;
1235 if (this.isHandle(id, p.id)) {
1246 this._addListeners();