3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
4 <title>The source code</title>
\r
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
8 <body onload="prettyPrint();">
\r
9 <pre class="prettyprint lang-js">/*
10 * These classes are derivatives of the similarly named classes in the YUI Library.
11 * The original license:
12 * Copyright (c) 2006, Yahoo! Inc. All rights reserved.
13 * Code licensed under the BSD License:
14 * http://developer.yahoo.net/yui/license.txt
19 var Event=Ext.EventManager;
22 <div id="cls-Ext.dd.DragDrop"></div>/**
23 * @class Ext.dd.DragDrop
24 * Defines the interface and base operation of items that that can be
25 * dragged or can be drop targets. It was designed to be extended, overriding
26 * the event handlers for startDrag, onDrag, onDragOver and onDragOut.
27 * Up to three html elements can be associated with a DragDrop instance:
29 * <li>linked element: the element that is passed into the constructor.
30 * This is the element which defines the boundaries for interaction with
31 * other DragDrop objects.</li>
32 * <li>handle element(s): The drag operation only occurs if the element that
33 * was clicked matches a handle element. By default this is the linked
34 * element, but there are times that you will want only a portion of the
35 * linked element to initiate the drag operation, and the setHandleElId()
36 * method provides a way to define this.</li>
37 * <li>drag element: this represents the element that would be moved along
38 * with the cursor during a drag operation. By default, this is the linked
39 * element itself as in {@link Ext.dd.DD}. setDragElId() lets you define
40 * a separate element that would be moved, as in {@link Ext.dd.DDProxy}.
43 * This class should not be instantiated until the onload event to ensure that
44 * the associated elements are available.
45 * The following would define a DragDrop obj that would interact with any
46 * other DragDrop obj in the "group1" group:
48 * dd = new Ext.dd.DragDrop("div1", "group1");
50 * Since none of the event handlers have been implemented, nothing would
51 * actually happen if you were to run the code above. Normally you would
52 * override this class or one of the default implementations, but you can
53 * also override the methods you want on an instance of the class...
55 * dd.onDragDrop = function(e, id) {
56 * alert("dd was dropped on " + id);
60 * @param {String} id of the element that is linked to this instance
61 * @param {String} sGroup the group of related DragDrop objects
62 * @param {object} config an object containing configurable attributes
63 * Valid properties for DragDrop:
64 * padding, isTarget, maintainOffset, primaryButtonOnly
66 Ext.dd.DragDrop = function(id, sGroup, config) {
68 this.init(id, sGroup, config);
72 Ext.dd.DragDrop.prototype = {
74 <div id="prop-Ext.dd.DragDrop-ignoreSelf"></div>/**
75 * Set to false to enable a DragDrop object to fire drag events while dragging
76 * over its own Element. Defaults to true - DragDrop objects do not by default
77 * fire drag events to themselves.
78 * @property ignoreSelf
82 <div id="prop-Ext.dd.DragDrop-id"></div>/**
83 * The id of the element associated with this object. This is what we
84 * refer to as the "linked element" because the size and position of
85 * this element is used to determine when the drag and drop objects have
92 <div id="prop-Ext.dd.DragDrop-config"></div>/**
93 * Configuration attributes passed into the constructor
100 * The id of the element that will be dragged. By default this is same
101 * as the linked element , but could be changed to another element. Ex:
110 * The ID of the element that initiates the drag operation. By default
111 * this is the linked element, but could be changed to be a child of this
112 * element. This lets us do things like only starting the drag when the
113 * header element within the linked html element is clicked.
114 * @property handleElId
120 <div id="prop-Ext.dd.DragDrop-invalidHandleTypes"></div>/**
121 * An object who's property names identify HTML tags to be considered invalid as drag handles.
122 * A non-null property value identifies the tag as invalid. Defaults to the
123 * following value which prevents drag operations from being initiated by <a> elements:<pre><code>
127 * @property invalidHandleTypes
130 invalidHandleTypes: null,
132 <div id="prop-Ext.dd.DragDrop-invalidHandleIds"></div>/**
133 * An object who's property names identify the IDs of elements to be considered invalid as drag handles.
134 * A non-null property value identifies the ID as invalid. For example, to prevent
135 * dragging from being initiated on element ID "foo", use:<pre><code>
139 * @property invalidHandleIds
142 invalidHandleIds: null,
144 <div id="prop-Ext.dd.DragDrop-invalidHandleClasses"></div>/**
145 * An Array of CSS class names for elements to be considered in valid as drag handles.
146 * @property invalidHandleClasses
149 invalidHandleClasses: null,
152 * The linked element's absolute X position at the time the drag was
154 * @property startPageX
161 * The linked element's absolute X position at the time the drag was
163 * @property startPageY
169 <div id="prop-Ext.dd.DragDrop-groups"></div>/**
170 * The group defines a logical collection of DragDrop objects that are
171 * related. Instances only get events when interacting with other
172 * DragDrop object in the same group. This lets us define multiple
173 * groups using a single DragDrop subclass if we want.
175 * @type object An object in the format {'group1':true, 'group2':true}
180 * Individual drag/drop instances can be locked. This will prevent
181 * onmousedown start drag.
188 <div id="method-Ext.dd.DragDrop-lock"></div>/**
192 lock: function() { this.locked = true; },
194 <div id="prop-Ext.dd.DragDrop-moveOnly"></div>/**
195 * When set to true, other DD objects in cooperating DDGroups do not receive
196 * notification events when this DD object is dragged over them. Defaults to false.
202 <div id="method-Ext.dd.DragDrop-unlock"></div>/**
203 * Unlock this instace
206 unlock: function() { this.locked = false; },
208 <div id="prop-Ext.dd.DragDrop-isTarget"></div>/**
209 * By default, all instances can be a drop target. This can be disabled by
210 * setting isTarget to false.
216 <div id="prop-Ext.dd.DragDrop-padding"></div>/**
217 * The padding configured for this drag and drop object for calculating
218 * the drop zone intersection with this object.
220 * @type int[] An array containing the 4 padding values: [top, right, bottom, left]
225 * Cached reference to the linked element
232 * Internal typeof flag
233 * @property __ygDragDrop
239 * Set to true when horizontal contraints are applied
240 * @property constrainX
247 * Set to true when vertical contraints are applied
248 * @property constrainY
255 * The left constraint
263 * The right constraint
280 * The down constraint
287 <div id="prop-Ext.dd.DragDrop-maintainOffset"></div>/**
288 * Maintain offsets when we resetconstraints. Set to true when you want
289 * the position of the element relative to its parent to stay the same
290 * when the page changes
292 * @property maintainOffset
295 maintainOffset: false,
297 <div id="prop-Ext.dd.DragDrop-xTicks"></div>/**
298 * Array of pixel locations the element will snap to if we specified a
299 * horizontal graduation/interval. This array is generated automatically
300 * when you define a tick interval.
306 <div id="prop-Ext.dd.DragDrop-yTicks"></div>/**
307 * Array of pixel locations the element will snap to if we specified a
308 * vertical graduation/interval. This array is generated automatically
309 * when you define a tick interval.
315 <div id="prop-Ext.dd.DragDrop-primaryButtonOnly"></div>/**
316 * By default the drag and drop instance will only respond to the primary
317 * button click (left button for a right-handed mouse). Set to true to
318 * allow drag and drop to start with any mouse click that is propogated
320 * @property primaryButtonOnly
323 primaryButtonOnly: true,
325 <div id="prop-Ext.dd.DragDrop-available"></div>/**
326 * The availabe property is false until the linked dom element is accessible.
327 * @property available
332 <div id="prop-Ext.dd.DragDrop-hasOuterHandles"></div>/**
333 * By default, drags can only be initiated if the mousedown occurs in the
334 * region the linked element is. This is done in part to work around a
335 * bug in some browsers that mis-report the mousedown if the previous
336 * mouseup happened outside of the window. This property is set to true
337 * if outer handles are defined.
339 * @property hasOuterHandles
343 hasOuterHandles: false,
346 * Code that executes immediately before the startDrag event
347 * @method b4StartDrag
350 b4StartDrag: function(x, y) { },
352 <div id="method-Ext.dd.DragDrop-startDrag"></div>/**
353 * Abstract method called after a drag/drop object is clicked
354 * and the drag or mousedown time thresholds have beeen met.
356 * @param {int} X click location
357 * @param {int} Y click location
359 startDrag: function(x, y) { /* override this */ },
362 * Code that executes immediately before the onDrag event
366 b4Drag: function(e) { },
368 <div id="method-Ext.dd.DragDrop-onDrag"></div>/**
369 * Abstract method called during the onMouseMove event while dragging an
372 * @param {Event} e the mousemove event
374 onDrag: function(e) { /* override this */ },
376 <div id="method-Ext.dd.DragDrop-onDragEnter"></div>/**
377 * Abstract method called when this element fist begins hovering over
378 * another DragDrop obj
379 * @method onDragEnter
380 * @param {Event} e the mousemove event
381 * @param {String|DragDrop[]} id In POINT mode, the element
382 * id this is hovering over. In INTERSECT mode, an array of one or more
383 * dragdrop items being hovered over.
385 onDragEnter: function(e, id) { /* override this */ },
388 * Code that executes immediately before the onDragOver event
392 b4DragOver: function(e) { },
394 <div id="method-Ext.dd.DragDrop-onDragOver"></div>/**
395 * Abstract method called when this element is hovering over another
398 * @param {Event} e the mousemove event
399 * @param {String|DragDrop[]} id In POINT mode, the element
400 * id this is hovering over. In INTERSECT mode, an array of dd items
401 * being hovered over.
403 onDragOver: function(e, id) { /* override this */ },
406 * Code that executes immediately before the onDragOut event
410 b4DragOut: function(e) { },
412 <div id="method-Ext.dd.DragDrop-onDragOut"></div>/**
413 * Abstract method called when we are no longer hovering over an element
415 * @param {Event} e the mousemove event
416 * @param {String|DragDrop[]} id In POINT mode, the element
417 * id this was hovering over. In INTERSECT mode, an array of dd items
418 * that the mouse is no longer over.
420 onDragOut: function(e, id) { /* override this */ },
423 * Code that executes immediately before the onDragDrop event
427 b4DragDrop: function(e) { },
429 <div id="method-Ext.dd.DragDrop-onDragDrop"></div>/**
430 * Abstract method called when this item is dropped on another DragDrop
433 * @param {Event} e the mouseup event
434 * @param {String|DragDrop[]} id In POINT mode, the element
435 * id this was dropped on. In INTERSECT mode, an array of dd items this
438 onDragDrop: function(e, id) { /* override this */ },
440 <div id="method-Ext.dd.DragDrop-onInvalidDrop"></div>/**
441 * Abstract method called when this item is dropped on an area with no
443 * @method onInvalidDrop
444 * @param {Event} e the mouseup event
446 onInvalidDrop: function(e) { /* override this */ },
449 * Code that executes immediately before the endDrag event
453 b4EndDrag: function(e) { },
455 <div id="method-Ext.dd.DragDrop-endDrag"></div>/**
456 * Fired when we are done dragging the object
458 * @param {Event} e the mouseup event
460 endDrag: function(e) { /* override this */ },
463 * Code executed immediately before the onMouseDown event
464 * @method b4MouseDown
465 * @param {Event} e the mousedown event
468 b4MouseDown: function(e) { },
470 <div id="method-Ext.dd.DragDrop-onMouseDown"></div>/**
471 * Event handler that fires when a drag/drop obj gets a mousedown
472 * @method onMouseDown
473 * @param {Event} e the mousedown event
475 onMouseDown: function(e) { /* override this */ },
477 <div id="method-Ext.dd.DragDrop-onMouseUp"></div>/**
478 * Event handler that fires when a drag/drop obj gets a mouseup
480 * @param {Event} e the mouseup event
482 onMouseUp: function(e) { /* override this */ },
484 <div id="method-Ext.dd.DragDrop-onAvailable"></div>/**
485 * Override the onAvailable method to do what is needed after the initial
486 * position was determined.
487 * @method onAvailable
489 onAvailable: function () {
492 <div id="prop-Ext.dd.DragDrop-defaultPadding"></div>/**
493 * Provides default constraint padding to "constrainTo" elements (defaults to {left: 0, right:0, top:0, bottom:0}).
496 defaultPadding : {left:0, right:0, top:0, bottom:0},
498 <div id="method-Ext.dd.DragDrop-constrainTo"></div>/**
499 * Initializes the drag drop object's constraints to restrict movement to a certain element.
503 var dd = new Ext.dd.DDProxy("dragDiv1", "proxytest",
504 { dragElId: "existingProxyDiv" });
505 dd.startDrag = function(){
506 this.constrainTo("parent-id");
509 * Or you can initalize it using the {@link Ext.Element} object:
511 Ext.get("dragDiv1").initDDProxy("proxytest", {dragElId: "existingProxyDiv"}, {
512 startDrag : function(){
513 this.constrainTo("parent-id");
517 * @param {Mixed} constrainTo The element to constrain to.
518 * @param {Object/Number} pad (optional) Pad provides a way to specify "padding" of the constraints,
519 * and can be either a number for symmetrical padding (4 would be equal to {left:4, right:4, top:4, bottom:4}) or
520 * an object containing the sides to pad. For example: {right:10, bottom:10}
521 * @param {Boolean} inContent (optional) Constrain the draggable in the content box of the element (inside padding and borders)
523 constrainTo : function(constrainTo, pad, inContent){
524 if(Ext.isNumber(pad)){
525 pad = {left: pad, right:pad, top:pad, bottom:pad};
527 pad = pad || this.defaultPadding;
528 var b = Ext.get(this.getEl()).getBox(),
529 ce = Ext.get(constrainTo),
533 if(cd == document.body){
534 c = { x: s.left, y: s.top, width: Ext.lib.Dom.getViewWidth(), height: Ext.lib.Dom.getViewHeight()};
537 c = {x : xy[0], y: xy[1], width: cd.clientWidth, height: cd.clientHeight};
541 var topSpace = b.y - c.y,
542 leftSpace = b.x - c.x;
544 this.resetConstraints();
545 this.setXConstraint(leftSpace - (pad.left||0), // left
546 c.width - leftSpace - b.width - (pad.right||0), //right
549 this.setYConstraint(topSpace - (pad.top||0), //top
550 c.height - topSpace - b.height - (pad.bottom||0), //bottom
555 <div id="method-Ext.dd.DragDrop-getEl"></div>/**
556 * Returns a reference to the linked element
558 * @return {HTMLElement} the html element
562 this._domRef = Ext.getDom(this.id);
568 <div id="method-Ext.dd.DragDrop-getDragEl"></div>/**
569 * Returns a reference to the actual element to drag. By default this is
570 * the same as the html element, but it can be assigned to another
571 * element. An example of this can be found in Ext.dd.DDProxy
573 * @return {HTMLElement} the html element
575 getDragEl: function() {
576 return Ext.getDom(this.dragElId);
579 <div id="method-Ext.dd.DragDrop-init"></div>/**
580 * Sets up the DragDrop object. Must be called in the constructor of any
581 * Ext.dd.DragDrop subclass
583 * @param id the id of the linked element
584 * @param {String} sGroup the group of related items
585 * @param {object} config configuration attributes
587 init: function(id, sGroup, config) {
588 this.initTarget(id, sGroup, config);
589 Event.on(this.id, "mousedown", this.handleMouseDown, this);
590 // Event.on(this.id, "selectstart", Event.preventDefault);
593 <div id="method-Ext.dd.DragDrop-initTarget"></div>/**
594 * Initializes Targeting functionality only... the object does not
595 * get a mousedown handler.
597 * @param id the id of the linked element
598 * @param {String} sGroup the group of related items
599 * @param {object} config configuration attributes
601 initTarget: function(id, sGroup, config) {
603 // configuration attributes
604 this.config = config || {};
606 // create a local reference to the drag and drop manager
607 this.DDM = Ext.dd.DDM;
608 // initialize the groups array
611 // assume that we have an element reference instead of an id if the
612 // parameter is not a string
613 if (typeof id !== "string") {
620 // add to an interaction group
621 this.addToGroup((sGroup) ? sGroup : "default");
623 // We don't want to register this as the handle with the manager
624 // so we just set the id rather than calling the setter.
625 this.handleElId = id;
627 // the linked element is the element that gets dragged by default
628 this.setDragElId(id);
630 // by default, clicked anchors will not start drag operations.
631 this.invalidHandleTypes = { A: "A" };
632 this.invalidHandleIds = {};
633 this.invalidHandleClasses = [];
637 this.handleOnAvailable();
640 <div id="method-Ext.dd.DragDrop-applyConfig"></div>/**
641 * Applies the configuration parameters that were passed into the constructor.
642 * This is supposed to happen at each level through the inheritance chain. So
643 * a DDProxy implentation will execute apply config on DDProxy, DD, and
644 * DragDrop in order to get all of the parameters that are available in
646 * @method applyConfig
648 applyConfig: function() {
650 // configurable properties:
651 // padding, isTarget, maintainOffset, primaryButtonOnly
652 this.padding = this.config.padding || [0, 0, 0, 0];
653 this.isTarget = (this.config.isTarget !== false);
654 this.maintainOffset = (this.config.maintainOffset);
655 this.primaryButtonOnly = (this.config.primaryButtonOnly !== false);
660 * Executed when the linked element is available
661 * @method handleOnAvailable
664 handleOnAvailable: function() {
665 this.available = true;
666 this.resetConstraints();
670 <div id="method-Ext.dd.DragDrop-setPadding"></div>/**
671 * Configures the padding for the target zone in px. Effectively expands
672 * (or reduces) the virtual object size for targeting calculations.
673 * Supports css-style shorthand; if only one parameter is passed, all sides
674 * will have that padding, and if only two are passed, the top and bottom
675 * will have the first param, the left and right the second.
677 * @param {int} iTop Top pad
678 * @param {int} iRight Right pad
679 * @param {int} iBot Bot pad
680 * @param {int} iLeft Left pad
682 setPadding: function(iTop, iRight, iBot, iLeft) {
683 // this.padding = [iLeft, iRight, iTop, iBot];
684 if (!iRight && 0 !== iRight) {
685 this.padding = [iTop, iTop, iTop, iTop];
686 } else if (!iBot && 0 !== iBot) {
687 this.padding = [iTop, iRight, iTop, iRight];
689 this.padding = [iTop, iRight, iBot, iLeft];
693 <div id="method-Ext.dd.DragDrop-setInitPosition"></div>/**
694 * Stores the initial placement of the linked element.
695 * @method setInitPosition
696 * @param {int} diffX the X offset, default 0
697 * @param {int} diffY the Y offset, default 0
699 setInitPosition: function(diffX, diffY) {
700 var el = this.getEl();
702 if (!this.DDM.verifyEl(el)) {
709 var p = Dom.getXY( el );
711 this.initPageX = p[0] - dx;
712 this.initPageY = p[1] - dy;
714 this.lastPageX = p[0];
715 this.lastPageY = p[1];
718 this.setStartPosition(p);
722 * Sets the start position of the element. This is set when the obj
723 * is initialized, the reset when a drag is started.
724 * @method setStartPosition
725 * @param pos current position (from previous lookup)
728 setStartPosition: function(pos) {
729 var p = pos || Dom.getXY( this.getEl() );
730 this.deltaSetXY = null;
732 this.startPageX = p[0];
733 this.startPageY = p[1];
736 <div id="method-Ext.dd.DragDrop-addToGroup"></div>/**
737 * Add this instance to a group of related drag/drop objects. All
738 * instances belong to at least one group, and can belong to as many
741 * @param sGroup {string} the name of the group
743 addToGroup: function(sGroup) {
744 this.groups[sGroup] = true;
745 this.DDM.regDragDrop(this, sGroup);
748 <div id="method-Ext.dd.DragDrop-removeFromGroup"></div>/**
749 * Remove's this instance from the supplied interaction group
750 * @method removeFromGroup
751 * @param {string} sGroup The group to drop
753 removeFromGroup: function(sGroup) {
754 if (this.groups[sGroup]) {
755 delete this.groups[sGroup];
758 this.DDM.removeDDFromGroup(this, sGroup);
761 <div id="method-Ext.dd.DragDrop-setDragElId"></div>/**
762 * Allows you to specify that an element other than the linked element
763 * will be moved with the cursor during a drag
764 * @method setDragElId
765 * @param id {string} the id of the element that will be used to initiate the drag
767 setDragElId: function(id) {
771 <div id="method-Ext.dd.DragDrop-setHandleElId"></div>/**
772 * Allows you to specify a child of the linked element that should be
773 * used to initiate the drag operation. An example of this would be if
774 * you have a content div with text and links. Clicking anywhere in the
775 * content area would normally start the drag operation. Use this method
776 * to specify that an element inside of the content div is the element
777 * that starts the drag operation.
778 * @method setHandleElId
779 * @param id {string} the id of the element that will be used to
782 setHandleElId: function(id) {
783 if (typeof id !== "string") {
786 this.handleElId = id;
787 this.DDM.regHandle(this.id, id);
790 <div id="method-Ext.dd.DragDrop-setOuterHandleElId"></div>/**
791 * Allows you to set an element outside of the linked element as a drag
793 * @method setOuterHandleElId
794 * @param id the id of the element that will be used to initiate the drag
796 setOuterHandleElId: function(id) {
797 if (typeof id !== "string") {
800 Event.on(id, "mousedown",
801 this.handleMouseDown, this);
802 this.setHandleElId(id);
804 this.hasOuterHandles = true;
807 <div id="method-Ext.dd.DragDrop-unreg"></div>/**
808 * Remove all drag and drop hooks for this element
812 Event.un(this.id, "mousedown",
813 this.handleMouseDown);
815 this.DDM._remove(this);
818 destroy : function(){
822 <div id="method-Ext.dd.DragDrop-isLocked"></div>/**
823 * Returns true if this instance is locked, or the drag drop mgr is locked
824 * (meaning that all drag/drop is disabled on the page.)
826 * @return {boolean} true if this obj or all drag/drop is locked, else
829 isLocked: function() {
830 return (this.DDM.isLocked() || this.locked);
834 * Fired when this object is clicked
835 * @method handleMouseDown
837 * @param {Ext.dd.DragDrop} oDD the clicked dd object (this dd obj)
840 handleMouseDown: function(e, oDD){
841 if (this.primaryButtonOnly && e.button != 0) {
845 if (this.isLocked()) {
849 this.DDM.refreshCache(this.groups);
851 var pt = new Ext.lib.Point(Ext.lib.Event.getPageX(e), Ext.lib.Event.getPageY(e));
852 if (!this.hasOuterHandles && !this.DDM.isOverTarget(pt, this) ) {
854 if (this.clickValidator(e)) {
856 // set the initial element position
857 this.setStartPosition();
863 this.DDM.handleMouseDown(e, this);
865 this.DDM.stopEvent(e);
873 clickValidator: function(e) {
874 var target = e.getTarget();
875 return ( this.isValidHandleChild(target) &&
876 (this.id == this.handleElId ||
877 this.DDM.handleWasClicked(target, this.id)) );
880 <div id="method-Ext.dd.DragDrop-addInvalidHandleType"></div>/**
881 * Allows you to specify a tag name that should not start a drag operation
882 * when clicked. This is designed to facilitate embedding links within a
883 * drag handle that do something other than start the drag.
884 * @method addInvalidHandleType
885 * @param {string} tagName the type of element to exclude
887 addInvalidHandleType: function(tagName) {
888 var type = tagName.toUpperCase();
889 this.invalidHandleTypes[type] = type;
892 <div id="method-Ext.dd.DragDrop-addInvalidHandleId"></div>/**
893 * Lets you to specify an element id for a child of a drag handle
894 * that should not initiate a drag
895 * @method addInvalidHandleId
896 * @param {string} id the element id of the element you wish to ignore
898 addInvalidHandleId: function(id) {
899 if (typeof id !== "string") {
902 this.invalidHandleIds[id] = id;
905 <div id="method-Ext.dd.DragDrop-addInvalidHandleClass"></div>/**
906 * Lets you specify a css class of elements that will not initiate a drag
907 * @method addInvalidHandleClass
908 * @param {string} cssClass the class of the elements you wish to ignore
910 addInvalidHandleClass: function(cssClass) {
911 this.invalidHandleClasses.push(cssClass);
914 <div id="method-Ext.dd.DragDrop-removeInvalidHandleType"></div>/**
915 * Unsets an excluded tag name set by addInvalidHandleType
916 * @method removeInvalidHandleType
917 * @param {string} tagName the type of element to unexclude
919 removeInvalidHandleType: function(tagName) {
920 var type = tagName.toUpperCase();
921 // this.invalidHandleTypes[type] = null;
922 delete this.invalidHandleTypes[type];
925 <div id="method-Ext.dd.DragDrop-removeInvalidHandleId"></div>/**
926 * Unsets an invalid handle id
927 * @method removeInvalidHandleId
928 * @param {string} id the id of the element to re-enable
930 removeInvalidHandleId: function(id) {
931 if (typeof id !== "string") {
934 delete this.invalidHandleIds[id];
937 <div id="method-Ext.dd.DragDrop-removeInvalidHandleClass"></div>/**
938 * Unsets an invalid css class
939 * @method removeInvalidHandleClass
940 * @param {string} cssClass the class of the element(s) you wish to
943 removeInvalidHandleClass: function(cssClass) {
944 for (var i=0, len=this.invalidHandleClasses.length; i<len; ++i) {
945 if (this.invalidHandleClasses[i] == cssClass) {
946 delete this.invalidHandleClasses[i];
951 <div id="method-Ext.dd.DragDrop-isValidHandleChild"></div>/**
952 * Checks the tag exclusion list to see if this click should be ignored
953 * @method isValidHandleChild
954 * @param {HTMLElement} node the HTMLElement to evaluate
955 * @return {boolean} true if this is a valid tag type, false if not
957 isValidHandleChild: function(node) {
960 // var n = (node.nodeName == "#text") ? node.parentNode : node;
963 nodeName = node.nodeName.toUpperCase();
965 nodeName = node.nodeName;
967 valid = valid && !this.invalidHandleTypes[nodeName];
968 valid = valid && !this.invalidHandleIds[node.id];
970 for (var i=0, len=this.invalidHandleClasses.length; valid && i<len; ++i) {
971 valid = !Ext.fly(node).hasClass(this.invalidHandleClasses[i]);
980 * Create the array of horizontal tick marks if an interval was specified
981 * in setXConstraint().
985 setXTicks: function(iStartX, iTickSize) {
987 this.xTickSize = iTickSize;
991 for (var i = this.initPageX; i >= this.minX; i = i - iTickSize) {
993 this.xTicks[this.xTicks.length] = i;
998 for (i = this.initPageX; i <= this.maxX; i = i + iTickSize) {
1000 this.xTicks[this.xTicks.length] = i;
1005 this.xTicks.sort(this.DDM.numericSort) ;
1009 * Create the array of vertical tick marks if an interval was specified in
1014 setYTicks: function(iStartY, iTickSize) {
1016 this.yTickSize = iTickSize;
1020 for (var i = this.initPageY; i >= this.minY; i = i - iTickSize) {
1022 this.yTicks[this.yTicks.length] = i;
1027 for (i = this.initPageY; i <= this.maxY; i = i + iTickSize) {
1029 this.yTicks[this.yTicks.length] = i;
1034 this.yTicks.sort(this.DDM.numericSort) ;
1037 <div id="method-Ext.dd.DragDrop-setXConstraint"></div>/**
1038 * By default, the element can be dragged any place on the screen. Use
1039 * this method to limit the horizontal travel of the element. Pass in
1040 * 0,0 for the parameters if you want to lock the drag to the y axis.
1041 * @method setXConstraint
1042 * @param {int} iLeft the number of pixels the element can move to the left
1043 * @param {int} iRight the number of pixels the element can move to the
1045 * @param {int} iTickSize optional parameter for specifying that the
1047 * should move iTickSize pixels at a time.
1049 setXConstraint: function(iLeft, iRight, iTickSize) {
1050 this.leftConstraint = iLeft;
1051 this.rightConstraint = iRight;
1053 this.minX = this.initPageX - iLeft;
1054 this.maxX = this.initPageX + iRight;
1055 if (iTickSize) { this.setXTicks(this.initPageX, iTickSize); }
1057 this.constrainX = true;
1060 <div id="method-Ext.dd.DragDrop-clearConstraints"></div>/**
1061 * Clears any constraints applied to this instance. Also clears ticks
1062 * since they can't exist independent of a constraint at this time.
1063 * @method clearConstraints
1065 clearConstraints: function() {
1066 this.constrainX = false;
1067 this.constrainY = false;
1071 <div id="method-Ext.dd.DragDrop-clearTicks"></div>/**
1072 * Clears any tick interval defined for this instance
1073 * @method clearTicks
1075 clearTicks: function() {
1082 <div id="method-Ext.dd.DragDrop-setYConstraint"></div>/**
1083 * By default, the element can be dragged any place on the screen. Set
1084 * this to limit the vertical travel of the element. Pass in 0,0 for the
1085 * parameters if you want to lock the drag to the x axis.
1086 * @method setYConstraint
1087 * @param {int} iUp the number of pixels the element can move up
1088 * @param {int} iDown the number of pixels the element can move down
1089 * @param {int} iTickSize optional parameter for specifying that the
1090 * element should move iTickSize pixels at a time.
1092 setYConstraint: function(iUp, iDown, iTickSize) {
1093 this.topConstraint = iUp;
1094 this.bottomConstraint = iDown;
1096 this.minY = this.initPageY - iUp;
1097 this.maxY = this.initPageY + iDown;
1098 if (iTickSize) { this.setYTicks(this.initPageY, iTickSize); }
1100 this.constrainY = true;
1104 <div id="method-Ext.dd.DragDrop-resetConstraints"></div>/**
1105 * resetConstraints must be called if you manually reposition a dd element.
1106 * @method resetConstraints
1107 * @param {boolean} maintainOffset
1109 resetConstraints: function() {
1112 // Maintain offsets if necessary
1113 if (this.initPageX || this.initPageX === 0) {
1114 // figure out how much this thing has moved
1115 var dx = (this.maintainOffset) ? this.lastPageX - this.initPageX : 0;
1116 var dy = (this.maintainOffset) ? this.lastPageY - this.initPageY : 0;
1118 this.setInitPosition(dx, dy);
1120 // This is the first time we have detected the element's position
1122 this.setInitPosition();
1125 if (this.constrainX) {
1126 this.setXConstraint( this.leftConstraint,
1127 this.rightConstraint,
1131 if (this.constrainY) {
1132 this.setYConstraint( this.topConstraint,
1133 this.bottomConstraint,
1139 * Normally the drag element is moved pixel by pixel, but we can specify
1140 * that it move a number of pixels at a time. This method resolves the
1141 * location when we have it set up like this.
1143 * @param {int} val where we want to place the object
1144 * @param {int[]} tickArray sorted array of valid points
1145 * @return {int} the closest tick
1148 getTick: function(val, tickArray) {
1151 // If tick interval is not defined, it is effectively 1 pixel,
1152 // so we return the value passed to us.
1154 } else if (tickArray[0] >= val) {
1155 // The value is lower than the first tick, so we return the first
1157 return tickArray[0];
1159 for (var i=0, len=tickArray.length; i<len; ++i) {
1161 if (tickArray[next] && tickArray[next] >= val) {
1162 var diff1 = val - tickArray[i];
1163 var diff2 = tickArray[next] - val;
1164 return (diff2 > diff1) ? tickArray[i] : tickArray[next];
1168 // The value is larger than the last tick, so we return the last
1170 return tickArray[tickArray.length - 1];
1174 <div id="method-Ext.dd.DragDrop-toString"></div>/**
1177 * @return {string} string representation of the dd obj
1179 toString: function() {
1180 return ("DragDrop " + this.id);
1186 <div id="prop-Ext.dd.DragDrop-Only"></div>/**
1187 * The drag and drop utility provides a framework for building drag and drop
1188 * applications. In addition to enabling drag and drop for specific elements,
1189 * the drag and drop elements are tracked by the manager class, and the
1190 * interactions between the various elements are tracked during the drag and
1191 * the implementing code is notified about these important moments.
1194 // Only load the library once. Rewriting the manager class would orphan
1195 // existing drag and drop instances.
1196 if (!Ext.dd.DragDropMgr) {
1198 <div id="cls-Ext.dd.DragDropMgr"></div>/**
1199 * @class Ext.dd.DragDropMgr
1200 * DragDropMgr is a singleton that tracks the element interaction for
1201 * all DragDrop items in the window. Generally, you will not call
1202 * this class directly, but it does have helper methods that could
1203 * be useful in your DragDrop implementations.
1206 Ext.dd.DragDropMgr = function() {
1208 var Event = Ext.EventManager;
1213 * Two dimensional Array of registered DragDrop objects. The first
1214 * dimension is the DragDrop item group, the second the DragDrop
1217 * @type {string: string}
1224 * Array of element ids defined as drag handles. Used to determine
1225 * if the element that generated the mousedown event is actually the
1226 * handle and not the html element itself.
1227 * @property handleIds
1228 * @type {string: string}
1235 * the DragDrop object that is currently being dragged
1236 * @property dragCurrent
1244 * the DragDrop object(s) that are being hovered over
1245 * @property dragOvers
1253 * the X distance between the cursor and the object being dragged
1262 * the Y distance between the cursor and the object being dragged
1270 <div id="prop-Ext.dd.DragDropMgr-preventDefault"></div>/**
1271 * Flag to determine if we should prevent the default behavior of the
1272 * events we define. By default this is true, but this can be set to
1273 * false if you need the default behavior (not recommended)
1274 * @property preventDefault
1278 preventDefault: true,
1280 <div id="prop-Ext.dd.DragDropMgr-stopPropagation"></div>/**
1281 * Flag to determine if we should stop the propagation of the events
1282 * we generate. This is true by default but you may want to set it to
1283 * false if the html element contains other features that require the
1285 * @property stopPropagation
1289 stopPropagation: true,
1292 * Internal flag that is set to true when drag and drop has been
1294 * @property initialized
1301 * All drag and drop can be disabled.
1309 * Called the first time an element is registered.
1315 this.initialized = true;
1318 <div id="prop-Ext.dd.DragDropMgr-POINT"></div>/**
1319 * In point mode, drag and drop interaction is defined by the
1320 * location of the cursor during the drag/drop
1327 <div id="prop-Ext.dd.DragDropMgr-INTERSECT"></div>/**
1328 * In intersect mode, drag and drop interaction is defined by the
1329 * overlap of two or more drag and drop objects.
1330 * @property INTERSECT
1336 <div id="prop-Ext.dd.DragDropMgr-mode"></div>/**
1337 * The current drag and drop mode. Default: POINT
1345 * Runs method on all drag and drop objects
1346 * @method _execOnAll
1350 _execOnAll: function(sMethod, args) {
1351 for (var i in this.ids) {
1352 for (var j in this.ids[i]) {
1353 var oDD = this.ids[i][j];
1354 if (! this.isTypeOfDD(oDD)) {
1357 oDD[sMethod].apply(oDD, args);
1363 * Drag and drop initialization. Sets up the global event handlers
1368 _onLoad: function() {
1373 Event.on(document, "mouseup", this.handleMouseUp, this, true);
1374 Event.on(document, "mousemove", this.handleMouseMove, this, true);
1375 Event.on(window, "unload", this._onUnload, this, true);
1376 Event.on(window, "resize", this._onResize, this, true);
1377 // Event.on(window, "mouseout", this._test);
1382 * Reset constraints on all drag and drop objs
1387 _onResize: function(e) {
1388 this._execOnAll("resetConstraints", []);
1391 <div id="method-Ext.dd.DragDropMgr-lock"></div>/**
1392 * Lock all drag and drop functionality
1396 lock: function() { this.locked = true; },
1398 <div id="method-Ext.dd.DragDropMgr-unlock"></div>/**
1399 * Unlock all drag and drop functionality
1403 unlock: function() { this.locked = false; },
1405 <div id="method-Ext.dd.DragDropMgr-isLocked"></div>/**
1406 * Is drag and drop locked?
1408 * @return {boolean} True if drag and drop is locked, false otherwise.
1411 isLocked: function() { return this.locked; },
1414 * Location cache that is set for all drag drop objects when a drag is
1415 * initiated, cleared when the drag is finished.
1416 * @property locationCache
1422 <div id="prop-Ext.dd.DragDropMgr-useCache"></div>/**
1423 * Set useCache to false if you want to force object the lookup of each
1424 * drag and drop linked element constantly during a drag.
1425 * @property useCache
1431 <div id="prop-Ext.dd.DragDropMgr-clickPixelThresh"></div>/**
1432 * The number of pixels that the mouse needs to move after the
1433 * mousedown before the drag is initiated. Default=3;
1434 * @property clickPixelThresh
1438 clickPixelThresh: 3,
1440 <div id="prop-Ext.dd.DragDropMgr-clickTimeThresh"></div>/**
1441 * The number of milliseconds after the mousedown event to initiate the
1442 * drag if we don't get a mouseup event. Default=350
1443 * @property clickTimeThresh
1447 clickTimeThresh: 350,
1450 * Flag that indicates that either the drag pixel threshold or the
1451 * mousdown time threshold has been met
1452 * @property dragThreshMet
1457 dragThreshMet: false,
1460 * Timeout used for the click time threshold
1461 * @property clickTimeout
1469 * The X position of the mousedown event stored for later use when a
1470 * drag threshold is met.
1479 * The Y position of the mousedown event stored for later use when a
1480 * drag threshold is met.
1488 <div id="method-Ext.dd.DragDropMgr-regDragDrop"></div>/**
1489 * Each DragDrop instance must be registered with the DragDropMgr.
1490 * This is executed in DragDrop.init()
1491 * @method regDragDrop
1492 * @param {DragDrop} oDD the DragDrop object to register
1493 * @param {String} sGroup the name of the group this element belongs to
1496 regDragDrop: function(oDD, sGroup) {
1497 if (!this.initialized) { this.init(); }
1499 if (!this.ids[sGroup]) {
1500 this.ids[sGroup] = {};
1502 this.ids[sGroup][oDD.id] = oDD;
1506 * Removes the supplied dd instance from the supplied group. Executed
1507 * by DragDrop.removeFromGroup, so don't call this function directly.
1508 * @method removeDDFromGroup
1512 removeDDFromGroup: function(oDD, sGroup) {
1513 if (!this.ids[sGroup]) {
1514 this.ids[sGroup] = {};
1517 var obj = this.ids[sGroup];
1518 if (obj && obj[oDD.id]) {
1524 * Unregisters a drag and drop item. This is executed in
1525 * DragDrop.unreg, use that method instead of calling this directly.
1530 _remove: function(oDD) {
1531 for (var g in oDD.groups) {
1532 if (g && this.ids[g] && this.ids[g][oDD.id]) {
1533 delete this.ids[g][oDD.id];
1536 delete this.handleIds[oDD.id];
1539 <div id="method-Ext.dd.DragDropMgr-regHandle"></div>/**
1540 * Each DragDrop handle element must be registered. This is done
1541 * automatically when executing DragDrop.setHandleElId()
1543 * @param {String} sDDId the DragDrop id this element is a handle for
1544 * @param {String} sHandleId the id of the element that is the drag
1548 regHandle: function(sDDId, sHandleId) {
1549 if (!this.handleIds[sDDId]) {
1550 this.handleIds[sDDId] = {};
1552 this.handleIds[sDDId][sHandleId] = sHandleId;
1555 <div id="method-Ext.dd.DragDropMgr-isDragDrop"></div>/**
1556 * Utility function to determine if a given element has been
1557 * registered as a drag drop item.
1558 * @method isDragDrop
1559 * @param {String} id the element id to check
1560 * @return {boolean} true if this element is a DragDrop item,
1564 isDragDrop: function(id) {
1565 return ( this.getDDById(id) ) ? true : false;
1568 <div id="method-Ext.dd.DragDropMgr-getRelated"></div>/**
1569 * Returns the drag and drop instances that are in all groups the
1570 * passed in instance belongs to.
1571 * @method getRelated
1572 * @param {DragDrop} p_oDD the obj to get related data for
1573 * @param {boolean} bTargetsOnly if true, only return targetable objs
1574 * @return {DragDrop[]} the related instances
1577 getRelated: function(p_oDD, bTargetsOnly) {
1579 for (var i in p_oDD.groups) {
1580 for (var j in this.ids[i]) {
1581 var dd = this.ids[i][j];
1582 if (! this.isTypeOfDD(dd)) {
1585 if (!bTargetsOnly || dd.isTarget) {
1586 oDDs[oDDs.length] = dd;
1594 <div id="method-Ext.dd.DragDropMgr-isLegalTarget"></div>/**
1595 * Returns true if the specified dd target is a legal target for
1596 * the specifice drag obj
1597 * @method isLegalTarget
1598 * @param {DragDrop} the drag obj
1599 * @param {DragDrop} the target
1600 * @return {boolean} true if the target is a legal target for the
1604 isLegalTarget: function (oDD, oTargetDD) {
1605 var targets = this.getRelated(oDD, true);
1606 for (var i=0, len=targets.length;i<len;++i) {
1607 if (targets[i].id == oTargetDD.id) {
1615 <div id="method-Ext.dd.DragDropMgr-isTypeOfDD"></div>/**
1616 * My goal is to be able to transparently determine if an object is
1617 * typeof DragDrop, and the exact subclass of DragDrop. typeof
1618 * returns "object", oDD.constructor.toString() always returns
1619 * "DragDrop" and not the name of the subclass. So for now it just
1620 * evaluates a well-known variable in DragDrop.
1621 * @method isTypeOfDD
1622 * @param {Object} the object to evaluate
1623 * @return {boolean} true if typeof oDD = DragDrop
1626 isTypeOfDD: function (oDD) {
1627 return (oDD && oDD.__ygDragDrop);
1630 <div id="method-Ext.dd.DragDropMgr-isHandle"></div>/**
1631 * Utility function to determine if a given element has been
1632 * registered as a drag drop handle for the given Drag Drop object.
1634 * @param {String} id the element id to check
1635 * @return {boolean} true if this element is a DragDrop handle, false
1639 isHandle: function(sDDId, sHandleId) {
1640 return ( this.handleIds[sDDId] &&
1641 this.handleIds[sDDId][sHandleId] );
1644 <div id="method-Ext.dd.DragDropMgr-getDDById"></div>/**
1645 * Returns the DragDrop instance for a given id
1647 * @param {String} id the id of the DragDrop object
1648 * @return {DragDrop} the drag drop object, null if it is not found
1651 getDDById: function(id) {
1652 for (var i in this.ids) {
1653 if (this.ids[i][id]) {
1654 return this.ids[i][id];
1661 * Fired after a registered DragDrop object gets the mousedown event.
1662 * Sets up the events required to track the object being dragged
1663 * @method handleMouseDown
1664 * @param {Event} e the event
1665 * @param oDD the DragDrop object being dragged
1669 handleMouseDown: function(e, oDD) {
1671 Ext.QuickTips.disable();
1673 if(this.dragCurrent){
1674 // the original browser mouseup wasn't handled (e.g. outside FF browser window)
1675 // so clean up first to avoid breaking the next drag
1676 this.handleMouseUp(e);
1679 this.currentTarget = e.getTarget();
1680 this.dragCurrent = oDD;
1682 var el = oDD.getEl();
1684 // track start position
1685 this.startX = e.getPageX();
1686 this.startY = e.getPageY();
1688 this.deltaX = this.startX - el.offsetLeft;
1689 this.deltaY = this.startY - el.offsetTop;
1691 this.dragThreshMet = false;
1693 this.clickTimeout = setTimeout(
1695 var DDM = Ext.dd.DDM;
1696 DDM.startDrag(DDM.startX, DDM.startY);
1698 this.clickTimeThresh );
1701 <div id="method-Ext.dd.DragDropMgr-startDrag"></div>/**
1702 * Fired when either the drag pixel threshol or the mousedown hold
1703 * time threshold has been met.
1705 * @param x {int} the X position of the original mousedown
1706 * @param y {int} the Y position of the original mousedown
1709 startDrag: function(x, y) {
1710 clearTimeout(this.clickTimeout);
1711 if (this.dragCurrent) {
1712 this.dragCurrent.b4StartDrag(x, y);
1713 this.dragCurrent.startDrag(x, y);
1715 this.dragThreshMet = true;
1719 * Internal function to handle the mouseup event. Will be invoked
1720 * from the context of the document.
1721 * @method handleMouseUp
1722 * @param {Event} e the event
1726 handleMouseUp: function(e) {
1729 Ext.QuickTips.enable();
1731 if (! this.dragCurrent) {
1735 clearTimeout(this.clickTimeout);
1737 if (this.dragThreshMet) {
1738 this.fireEvents(e, true);
1747 <div id="method-Ext.dd.DragDropMgr-stopEvent"></div>/**
1748 * Utility to stop event propagation and event default, if these
1749 * features are turned on.
1751 * @param {Event} e the event as returned by this.getEvent()
1754 stopEvent: function(e){
1755 if(this.stopPropagation) {
1756 e.stopPropagation();
1759 if (this.preventDefault) {
1765 * Internal function to clean up event handlers after the drag
1766 * operation is complete
1768 * @param {Event} e the event
1772 stopDrag: function(e) {
1773 // Fire the drag end event for the item that was dragged
1774 if (this.dragCurrent) {
1775 if (this.dragThreshMet) {
1776 this.dragCurrent.b4EndDrag(e);
1777 this.dragCurrent.endDrag(e);
1780 this.dragCurrent.onMouseUp(e);
1783 this.dragCurrent = null;
1784 this.dragOvers = {};
1788 * Internal function to handle the mousemove event. Will be invoked
1789 * from the context of the html element.
1791 * @TODO figure out what we can do about mouse events lost when the
1792 * user drags objects beyond the window boundary. Currently we can
1793 * detect this in internet explorer by verifying that the mouse is
1794 * down during the mousemove event. Firefox doesn't give us the
1795 * button state on the mousemove event.
1796 * @method handleMouseMove
1797 * @param {Event} e the event
1801 handleMouseMove: function(e) {
1802 if (! this.dragCurrent) {
1805 // var button = e.which || e.button;
1807 // check for IE mouseup outside of page boundary
1808 if (Ext.isIE && (e.button !== 0 && e.button !== 1 && e.button !== 2)) {
1810 return this.handleMouseUp(e);
1813 if (!this.dragThreshMet) {
1814 var diffX = Math.abs(this.startX - e.getPageX());
1815 var diffY = Math.abs(this.startY - e.getPageY());
1816 if (diffX > this.clickPixelThresh ||
1817 diffY > this.clickPixelThresh) {
1818 this.startDrag(this.startX, this.startY);
1822 if (this.dragThreshMet) {
1823 this.dragCurrent.b4Drag(e);
1824 this.dragCurrent.onDrag(e);
1825 if(!this.dragCurrent.moveOnly){
1826 this.fireEvents(e, false);
1836 * Iterates over all of the DragDrop elements to find ones we are
1837 * hovering over or dropping on
1838 * @method fireEvents
1839 * @param {Event} e the event
1840 * @param {boolean} isDrop is this a drop op or a mouseover op?
1844 fireEvents: function(e, isDrop) {
1845 var dc = this.dragCurrent;
1847 // If the user did the mouse up outside of the window, we could
1848 // get here even though we have ended the drag.
1849 if (!dc || dc.isLocked()) {
1853 var pt = e.getPoint();
1855 // cache the previous dragOver array
1863 // Check to see if the object(s) we were hovering over is no longer
1864 // being hovered over so we can fire the onDragOut event
1865 for (var i in this.dragOvers) {
1867 var ddo = this.dragOvers[i];
1869 if (! this.isTypeOfDD(ddo)) {
1873 if (! this.isOverTarget(pt, ddo, this.mode)) {
1874 outEvts.push( ddo );
1878 delete this.dragOvers[i];
1881 for (var sGroup in dc.groups) {
1883 if ("string" != typeof sGroup) {
1887 for (i in this.ids[sGroup]) {
1888 var oDD = this.ids[sGroup][i];
1889 if (! this.isTypeOfDD(oDD)) {
1893 if (oDD.isTarget && !oDD.isLocked() && ((oDD != dc) || (dc.ignoreSelf === false))) {
1894 if (this.isOverTarget(pt, oDD, this.mode)) {
1895 // look for drop interactions
1897 dropEvts.push( oDD );
1898 // look for drag enter and drag over interactions
1901 // initial drag over: dragEnter fires
1902 if (!oldOvers[oDD.id]) {
1903 enterEvts.push( oDD );
1904 // subsequent drag overs: dragOver fires
1906 overEvts.push( oDD );
1909 this.dragOvers[oDD.id] = oDD;
1917 if (outEvts.length) {
1918 dc.b4DragOut(e, outEvts);
1919 dc.onDragOut(e, outEvts);
1922 if (enterEvts.length) {
1923 dc.onDragEnter(e, enterEvts);
1926 if (overEvts.length) {
1927 dc.b4DragOver(e, overEvts);
1928 dc.onDragOver(e, overEvts);
1931 if (dropEvts.length) {
1932 dc.b4DragDrop(e, dropEvts);
1933 dc.onDragDrop(e, dropEvts);
1937 // fire dragout events
1939 for (i=0, len=outEvts.length; i<len; ++i) {
1940 dc.b4DragOut(e, outEvts[i].id);
1941 dc.onDragOut(e, outEvts[i].id);
1944 // fire enter events
1945 for (i=0,len=enterEvts.length; i<len; ++i) {
1946 // dc.b4DragEnter(e, oDD.id);
1947 dc.onDragEnter(e, enterEvts[i].id);
1951 for (i=0,len=overEvts.length; i<len; ++i) {
1952 dc.b4DragOver(e, overEvts[i].id);
1953 dc.onDragOver(e, overEvts[i].id);
1957 for (i=0, len=dropEvts.length; i<len; ++i) {
1958 dc.b4DragDrop(e, dropEvts[i].id);
1959 dc.onDragDrop(e, dropEvts[i].id);
1964 // notify about a drop that did not find a target
1965 if (isDrop && !dropEvts.length) {
1966 dc.onInvalidDrop(e);
1971 <div id="method-Ext.dd.DragDropMgr-getBestMatch"></div>/**
1972 * Helper function for getting the best match from the list of drag
1973 * and drop objects returned by the drag and drop events when we are
1974 * in INTERSECT mode. It returns either the first object that the
1975 * cursor is over, or the object that has the greatest overlap with
1976 * the dragged element.
1977 * @method getBestMatch
1978 * @param {DragDrop[]} dds The array of drag and drop objects
1980 * @return {DragDrop} The best single match
1983 getBestMatch: function(dds) {
1985 // Return null if the input is not what we expect
1986 //if (!dds || !dds.length || dds.length == 0) {
1988 // If there is only one item, it wins
1989 //} else if (dds.length == 1) {
1991 var len = dds.length;
1996 // Loop through the targeted items
1997 for (var i=0; i<len; ++i) {
1999 // If the cursor is over the object, it wins. If the
2000 // cursor is over multiple matches, the first one we come
2002 if (dd.cursorIsOver) {
2005 // Otherwise the object with the most overlap wins
2008 winner.overlap.getArea() < dd.overlap.getArea()) {
2018 <div id="method-Ext.dd.DragDropMgr-refreshCache"></div>/**
2019 * Refreshes the cache of the top-left and bottom-right points of the
2020 * drag and drop objects in the specified group(s). This is in the
2021 * format that is stored in the drag and drop instance, so typical
2024 * Ext.dd.DragDropMgr.refreshCache(ddinstance.groups);
2028 * Ext.dd.DragDropMgr.refreshCache({group1:true, group2:true});
2030 * @TODO this really should be an indexed array. Alternatively this
2031 * method could accept both.
2032 * @method refreshCache
2033 * @param {Object} groups an associative array of groups to refresh
2036 refreshCache: function(groups) {
2037 for (var sGroup in groups) {
2038 if ("string" != typeof sGroup) {
2041 for (var i in this.ids[sGroup]) {
2042 var oDD = this.ids[sGroup][i];
2044 if (this.isTypeOfDD(oDD)) {
2045 // if (this.isTypeOfDD(oDD) && oDD.isTarget) {
2046 var loc = this.getLocation(oDD);
2048 this.locationCache[oDD.id] = loc;
2050 delete this.locationCache[oDD.id];
2051 // this will unregister the drag and drop object if
2052 // the element is not in a usable state
2060 <div id="method-Ext.dd.DragDropMgr-verifyEl"></div>/**
2061 * This checks to make sure an element exists and is in the DOM. The
2062 * main purpose is to handle cases where innerHTML is used to remove
2063 * drag and drop objects from the DOM. IE provides an 'unspecified
2064 * error' when trying to access the offsetParent of such an element
2066 * @param {HTMLElement} el the element to check
2067 * @return {boolean} true if the element looks usable
2070 verifyEl: function(el) {
2075 parent = el.offsetParent;
2078 parent = el.offsetParent;
2088 <div id="method-Ext.dd.DragDropMgr-getLocation"></div>/**
2089 * Returns a Region object containing the drag and drop element's position
2090 * and size, including the padding configured for it
2091 * @method getLocation
2092 * @param {DragDrop} oDD the drag and drop object to get the
2094 * @return {Ext.lib.Region} a Region object representing the total area
2095 * the element occupies, including any padding
2096 * the instance is configured for.
2099 getLocation: function(oDD) {
2100 if (! this.isTypeOfDD(oDD)) {
2104 var el = oDD.getEl(), pos, x1, x2, y1, y2, t, r, b, l;
2107 pos= Ext.lib.Dom.getXY(el);
2115 x2 = x1 + el.offsetWidth;
2117 y2 = y1 + el.offsetHeight;
2119 t = y1 - oDD.padding[0];
2120 r = x2 + oDD.padding[1];
2121 b = y2 + oDD.padding[2];
2122 l = x1 - oDD.padding[3];
2124 return new Ext.lib.Region( t, r, b, l );
2128 * Checks the cursor location to see if it over the target
2129 * @method isOverTarget
2130 * @param {Ext.lib.Point} pt The point to evaluate
2131 * @param {DragDrop} oTarget the DragDrop object we are inspecting
2132 * @return {boolean} true if the mouse is over the target
2136 isOverTarget: function(pt, oTarget, intersect) {
2137 // use cache if available
2138 var loc = this.locationCache[oTarget.id];
2139 if (!loc || !this.useCache) {
2140 loc = this.getLocation(oTarget);
2141 this.locationCache[oTarget.id] = loc;
2149 oTarget.cursorIsOver = loc.contains( pt );
2151 // DragDrop is using this as a sanity check for the initial mousedown
2152 // in this case we are done. In POINT mode, if the drag obj has no
2153 // contraints, we are also done. Otherwise we need to evaluate the
2154 // location of the target as related to the actual location of the
2156 var dc = this.dragCurrent;
2157 if (!dc || !dc.getTargetCoord ||
2158 (!intersect && !dc.constrainX && !dc.constrainY)) {
2159 return oTarget.cursorIsOver;
2162 oTarget.overlap = null;
2164 // Get the current location of the drag element, this is the
2165 // location of the mouse event less the delta that represents
2166 // where the original mousedown happened on the element. We
2167 // need to consider constraints and ticks as well.
2168 var pos = dc.getTargetCoord(pt.x, pt.y);
2170 var el = dc.getDragEl();
2171 var curRegion = new Ext.lib.Region( pos.y,
2172 pos.x + el.offsetWidth,
2173 pos.y + el.offsetHeight,
2176 var overlap = curRegion.intersect(loc);
2179 oTarget.overlap = overlap;
2180 return (intersect) ? true : oTarget.cursorIsOver;
2187 * unload event handler
2192 _onUnload: function(e, me) {
2193 Ext.dd.DragDropMgr.unregAll();
2197 * Cleans up the drag and drop events and objects.
2202 unregAll: function() {
2204 if (this.dragCurrent) {
2206 this.dragCurrent = null;
2209 this._execOnAll("unreg", []);
2211 for (var i in this.elementCache) {
2212 delete this.elementCache[i];
2215 this.elementCache = {};
2220 * A cache of DOM elements
2221 * @property elementCache
2228 * Get the wrapper for the DOM element specified
2229 * @method getElWrapper
2230 * @param {String} id the id of the element to get
2231 * @return {Ext.dd.DDM.ElementWrapper} the wrapped element
2233 * @deprecated This wrapper isn't that useful
2236 getElWrapper: function(id) {
2237 var oWrapper = this.elementCache[id];
2238 if (!oWrapper || !oWrapper.el) {
2239 oWrapper = this.elementCache[id] =
2240 new this.ElementWrapper(Ext.getDom(id));
2245 <div id="method-Ext.dd.DragDropMgr-getElement"></div>/**
2246 * Returns the actual DOM element
2247 * @method getElement
2248 * @param {String} id the id of the elment to get
2249 * @return {Object} The element
2250 * @deprecated use Ext.lib.Ext.getDom instead
2253 getElement: function(id) {
2254 return Ext.getDom(id);
2257 <div id="method-Ext.dd.DragDropMgr-getCss"></div>/**
2258 * Returns the style property for the DOM element (i.e.,
2259 * document.getElById(id).style)
2261 * @param {String} id the id of the elment to get
2262 * @return {Object} The style property of the element
2263 * @deprecated use Ext.lib.Dom instead
2266 getCss: function(id) {
2267 var el = Ext.getDom(id);
2268 return (el) ? el.style : null;
2271 <div id="cls-DragDropMgr.ElementWrapper"></div>/**
2272 * Inner class for cached elements
2273 * @class DragDropMgr.ElementWrapper
2278 ElementWrapper: function(el) {
2279 <div id="prop-DragDropMgr.ElementWrapper-el"></div>/**
2283 this.el = el || null;
2284 <div id="prop-DragDropMgr.ElementWrapper-id"></div>/**
2288 this.id = this.el && el.id;
2289 <div id="prop-DragDropMgr.ElementWrapper-css"></div>/**
2290 * A reference to the style property
2293 this.css = this.el && el.style;
2296 <div id="method-DragDropMgr.ElementWrapper-getPosX"></div>/**
2297 * Returns the X position of an html element
2299 * @param el the element for which to get the position
2300 * @return {int} the X coordinate
2302 * @deprecated use Ext.lib.Dom.getX instead
2305 getPosX: function(el) {
2306 return Ext.lib.Dom.getX(el);
2309 <div id="method-DragDropMgr.ElementWrapper-getPosY"></div>/**
2310 * Returns the Y position of an html element
2312 * @param el the element for which to get the position
2313 * @return {int} the Y coordinate
2314 * @deprecated use Ext.lib.Dom.getY instead
2317 getPosY: function(el) {
2318 return Ext.lib.Dom.getY(el);
2321 <div id="method-DragDropMgr.ElementWrapper-swapNode"></div>/**
2322 * Swap two nodes. In IE, we use the native method, for others we
2323 * emulate the IE behavior
2325 * @param n1 the first node to swap
2326 * @param n2 the other node to swap
2329 swapNode: function(n1, n2) {
2333 var p = n2.parentNode;
2334 var s = n2.nextSibling;
2337 p.insertBefore(n1, n2);
2338 } else if (n2 == n1.nextSibling) {
2339 p.insertBefore(n2, n1);
2341 n1.parentNode.replaceChild(n2, n1);
2342 p.insertBefore(n1, s);
2348 * Returns the current scroll position
2353 getScroll: function () {
2354 var t, l, dde=document.documentElement, db=document.body;
2355 if (dde && (dde.scrollTop || dde.scrollLeft)) {
2364 return { top: t, left: l };
2367 <div id="method-DragDropMgr.ElementWrapper-getStyle"></div>/**
2368 * Returns the specified element style property
2370 * @param {HTMLElement} el the element
2371 * @param {string} styleProp the style property
2372 * @return {string} The value of the style property
2373 * @deprecated use Ext.lib.Dom.getStyle
2376 getStyle: function(el, styleProp) {
2377 return Ext.fly(el).getStyle(styleProp);
2380 <div id="method-DragDropMgr.ElementWrapper-getScrollTop"></div>/**
2381 * Gets the scrollTop
2382 * @method getScrollTop
2383 * @return {int} the document's scrollTop
2386 getScrollTop: function () { return this.getScroll().top; },
2388 <div id="method-DragDropMgr.ElementWrapper-getScrollLeft"></div>/**
2389 * Gets the scrollLeft
2390 * @method getScrollLeft
2391 * @return {int} the document's scrollTop
2394 getScrollLeft: function () { return this.getScroll().left; },
2396 <div id="method-DragDropMgr.ElementWrapper-moveToEl"></div>/**
2397 * Sets the x/y position of an element to the location of the
2400 * @param {HTMLElement} moveEl The element to move
2401 * @param {HTMLElement} targetEl The position reference element
2404 moveToEl: function (moveEl, targetEl) {
2405 var aCoord = Ext.lib.Dom.getXY(targetEl);
2406 Ext.lib.Dom.setXY(moveEl, aCoord);
2409 <div id="method-DragDropMgr.ElementWrapper-numericSort"></div>/**
2410 * Numeric array sort function
2411 * @method numericSort
2414 numericSort: function(a, b) { return (a - b); },
2418 * @property _timeoutCount
2425 * Trying to make the load order less important. Without this we get
2426 * an error if this file is loaded before the Event Utility.
2427 * @method _addListeners
2431 _addListeners: function() {
2432 var DDM = Ext.dd.DDM;
2433 if ( Ext.lib.Event && document ) {
2436 if (DDM._timeoutCount > 2000) {
2438 setTimeout(DDM._addListeners, 10);
2439 if (document && document.body) {
2440 DDM._timeoutCount += 1;
2446 <div id="method-DragDropMgr.ElementWrapper-handleWasClicked"></div>/**
2447 * Recursively searches the immediate parent and all child nodes for
2448 * the handle element in order to determine wheter or not it was
2450 * @method handleWasClicked
2451 * @param node the html element to inspect
2454 handleWasClicked: function(node, id) {
2455 if (this.isHandle(id, node.id)) {
2458 // check to see if this is a text node child of the one we want
2459 var p = node.parentNode;
2462 if (this.isHandle(id, p.id)) {
2477 // shorter alias, save a few bytes
2478 Ext.dd.DDM = Ext.dd.DragDropMgr;
2479 Ext.dd.DDM._addListeners();
2483 <div id="cls-Ext.dd.DD"></div>/**
2485 * A DragDrop implementation where the linked element follows the
2486 * mouse cursor during a drag.
2487 * @extends Ext.dd.DragDrop
2489 * @param {String} id the id of the linked element
2490 * @param {String} sGroup the group of related DragDrop items
2491 * @param {object} config an object containing configurable attributes
2492 * Valid properties for DD:
2495 Ext.dd.DD = function(id, sGroup, config) {
2497 this.init(id, sGroup, config);
2501 Ext.extend(Ext.dd.DD, Ext.dd.DragDrop, {
2503 <div id="prop-Ext.dd.DD-scroll"></div>/**
2504 * When set to true, the utility automatically tries to scroll the browser
2505 * window when a drag and drop element is dragged near the viewport boundary.
2512 <div id="method-Ext.dd.DD-autoOffset"></div>/**
2513 * Sets the pointer offset to the distance between the linked element's top
2514 * left corner and the location the element was clicked
2515 * @method autoOffset
2516 * @param {int} iPageX the X coordinate of the click
2517 * @param {int} iPageY the Y coordinate of the click
2519 autoOffset: function(iPageX, iPageY) {
2520 var x = iPageX - this.startPageX;
2521 var y = iPageY - this.startPageY;
2522 this.setDelta(x, y);
2525 <div id="method-Ext.dd.DD-setDelta"></div>/**
2526 * Sets the pointer offset. You can call this directly to force the
2527 * offset to be in a particular location (e.g., pass in 0,0 to set it
2528 * to the center of the object)
2530 * @param {int} iDeltaX the distance from the left
2531 * @param {int} iDeltaY the distance from the top
2533 setDelta: function(iDeltaX, iDeltaY) {
2534 this.deltaX = iDeltaX;
2535 this.deltaY = iDeltaY;
2538 <div id="method-Ext.dd.DD-setDragElPos"></div>/**
2539 * Sets the drag element to the location of the mousedown or click event,
2540 * maintaining the cursor location relative to the location on the element
2541 * that was clicked. Override this if you want to place the element in a
2542 * location other than where the cursor is.
2543 * @method setDragElPos
2544 * @param {int} iPageX the X coordinate of the mousedown or drag event
2545 * @param {int} iPageY the Y coordinate of the mousedown or drag event
2547 setDragElPos: function(iPageX, iPageY) {
2548 // the first time we do this, we are going to check to make sure
2549 // the element has css positioning
2551 var el = this.getDragEl();
2552 this.alignElWithMouse(el, iPageX, iPageY);
2555 <div id="method-Ext.dd.DD-alignElWithMouse"></div>/**
2556 * Sets the element to the location of the mousedown or click event,
2557 * maintaining the cursor location relative to the location on the element
2558 * that was clicked. Override this if you want to place the element in a
2559 * location other than where the cursor is.
2560 * @method alignElWithMouse
2561 * @param {HTMLElement} el the element to move
2562 * @param {int} iPageX the X coordinate of the mousedown or drag event
2563 * @param {int} iPageY the Y coordinate of the mousedown or drag event
2565 alignElWithMouse: function(el, iPageX, iPageY) {
2566 var oCoord = this.getTargetCoord(iPageX, iPageY);
2567 var fly = el.dom ? el : Ext.fly(el, '_dd');
2568 if (!this.deltaSetXY) {
2569 var aCoord = [oCoord.x, oCoord.y];
2571 var newLeft = fly.getLeft(true);
2572 var newTop = fly.getTop(true);
2573 this.deltaSetXY = [ newLeft - oCoord.x, newTop - oCoord.y ];
2575 fly.setLeftTop(oCoord.x + this.deltaSetXY[0], oCoord.y + this.deltaSetXY[1]);
2578 this.cachePosition(oCoord.x, oCoord.y);
2579 this.autoScroll(oCoord.x, oCoord.y, el.offsetHeight, el.offsetWidth);
2583 <div id="method-Ext.dd.DD-cachePosition"></div>/**
2584 * Saves the most recent position so that we can reset the constraints and
2585 * tick marks on-demand. We need to know this so that we can calculate the
2586 * number of pixels the element is offset from its original position.
2587 * @method cachePosition
2588 * @param iPageX the current x position (optional, this just makes it so we
2589 * don't have to look it up again)
2590 * @param iPageY the current y position (optional, this just makes it so we
2591 * don't have to look it up again)
2593 cachePosition: function(iPageX, iPageY) {
2595 this.lastPageX = iPageX;
2596 this.lastPageY = iPageY;
2598 var aCoord = Ext.lib.Dom.getXY(this.getEl());
2599 this.lastPageX = aCoord[0];
2600 this.lastPageY = aCoord[1];
2605 * Auto-scroll the window if the dragged object has been moved beyond the
2606 * visible window boundary.
2607 * @method autoScroll
2608 * @param {int} x the drag element's x position
2609 * @param {int} y the drag element's y position
2610 * @param {int} h the height of the drag element
2611 * @param {int} w the width of the drag element
2614 autoScroll: function(x, y, h, w) {
2617 // The client height
2618 var clientH = Ext.lib.Dom.getViewHeight();
2621 var clientW = Ext.lib.Dom.getViewWidth();
2623 // The amt scrolled down
2624 var st = this.DDM.getScrollTop();
2626 // The amt scrolled right
2627 var sl = this.DDM.getScrollLeft();
2629 // Location of the bottom of the element
2632 // Location of the right of the element
2635 // The distance from the cursor to the bottom of the visible area,
2636 // adjusted so that we don't scroll if the cursor is beyond the
2637 // element drag constraints
2638 var toBot = (clientH + st - y - this.deltaY);
2640 // The distance from the cursor to the right of the visible area
2641 var toRight = (clientW + sl - x - this.deltaX);
2644 // How close to the edge the cursor must be before we scroll
2645 // var thresh = (document.all) ? 100 : 40;
2648 // How many pixels to scroll per autoscroll op. This helps to reduce
2649 // clunky scrolling. IE is more sensitive about this ... it needs this
2650 // value to be higher.
2651 var scrAmt = (document.all) ? 80 : 30;
2653 // Scroll down if we are near the bottom of the visible page and the
2654 // obj extends below the crease
2655 if ( bot > clientH && toBot < thresh ) {
2656 window.scrollTo(sl, st + scrAmt);
2659 // Scroll up if the window is scrolled down and the top of the object
2660 // goes above the top border
2661 if ( y < st && st > 0 && y - st < thresh ) {
2662 window.scrollTo(sl, st - scrAmt);
2665 // Scroll right if the obj is beyond the right border and the cursor is
2667 if ( right > clientW && toRight < thresh ) {
2668 window.scrollTo(sl + scrAmt, st);
2671 // Scroll left if the window has been scrolled to the right and the obj
2672 // extends past the left border
2673 if ( x < sl && sl > 0 && x - sl < thresh ) {
2674 window.scrollTo(sl - scrAmt, st);
2680 * Finds the location the element should be placed if we want to move
2681 * it to where the mouse location less the click offset would place us.
2682 * @method getTargetCoord
2683 * @param {int} iPageX the X coordinate of the click
2684 * @param {int} iPageY the Y coordinate of the click
2685 * @return an object that contains the coordinates (Object.x and Object.y)
2688 getTargetCoord: function(iPageX, iPageY) {
2691 var x = iPageX - this.deltaX;
2692 var y = iPageY - this.deltaY;
2694 if (this.constrainX) {
2695 if (x < this.minX) { x = this.minX; }
2696 if (x > this.maxX) { x = this.maxX; }
2699 if (this.constrainY) {
2700 if (y < this.minY) { y = this.minY; }
2701 if (y > this.maxY) { y = this.maxY; }
2704 x = this.getTick(x, this.xTicks);
2705 y = this.getTick(y, this.yTicks);
2711 <div id="method-Ext.dd.DD-applyConfig"></div>/**
2712 * Sets up config options specific to this class. Overrides
2713 * Ext.dd.DragDrop, but all versions of this method through the
2714 * inheritance chain are called
2716 applyConfig: function() {
2717 Ext.dd.DD.superclass.applyConfig.call(this);
2718 this.scroll = (this.config.scroll !== false);
2721 <div id="method-Ext.dd.DD-b4MouseDown"></div>/**
2722 * Event that fires prior to the onMouseDown event. Overrides
2725 b4MouseDown: function(e) {
2726 // this.resetConstraints();
2727 this.autoOffset(e.getPageX(),
2731 <div id="method-Ext.dd.DD-b4Drag"></div>/**
2732 * Event that fires prior to the onDrag event. Overrides
2735 b4Drag: function(e) {
2736 this.setDragElPos(e.getPageX(),
2740 toString: function() {
2741 return ("DD " + this.id);
2744 //////////////////////////////////////////////////////////////////////////
2745 // Debugging ygDragDrop events that can be overridden
2746 //////////////////////////////////////////////////////////////////////////
2748 startDrag: function(x, y) {
2751 onDrag: function(e) {
2754 onDragEnter: function(e, id) {
2757 onDragOver: function(e, id) {
2760 onDragOut: function(e, id) {
2763 onDragDrop: function(e, id) {
2766 endDrag: function(e) {
2772 <div id="cls-Ext.dd.DDProxy"></div>/**
2773 * @class Ext.dd.DDProxy
2774 * A DragDrop implementation that inserts an empty, bordered div into
2775 * the document that follows the cursor during drag operations. At the time of
2776 * the click, the frame div is resized to the dimensions of the linked html
2777 * element, and moved to the exact location of the linked element.
2779 * References to the "frame" element refer to the single proxy element that
2780 * was created to be dragged in place of all DDProxy elements on the
2783 * @extends Ext.dd.DD
2785 * @param {String} id the id of the linked html element
2786 * @param {String} sGroup the group of related DragDrop objects
2787 * @param {object} config an object containing configurable attributes
2788 * Valid properties for DDProxy in addition to those in DragDrop:
2789 * resizeFrame, centerFrame, dragElId
2791 Ext.dd.DDProxy = function(id, sGroup, config) {
2793 this.init(id, sGroup, config);
2798 <div id="prop-Ext.dd.DDProxy-Ext.dd.DDProxy.dragElId"></div>/**
2799 * The default drag frame div id
2800 * @property Ext.dd.DDProxy.dragElId
2804 Ext.dd.DDProxy.dragElId = "ygddfdiv";
2806 Ext.extend(Ext.dd.DDProxy, Ext.dd.DD, {
2808 <div id="prop-Ext.dd.DDProxy-resizeFrame"></div>/**
2809 * By default we resize the drag frame to be the same size as the element
2810 * we want to drag (this is to get the frame effect). We can turn it off
2811 * if we want a different behavior.
2812 * @property resizeFrame
2817 <div id="prop-Ext.dd.DDProxy-centerFrame"></div>/**
2818 * By default the frame is positioned exactly where the drag element is, so
2819 * we use the cursor offset provided by Ext.dd.DD. Another option that works only if
2820 * you do not have constraints on the obj is to have the drag frame centered
2821 * around the cursor. Set centerFrame to true for this effect.
2822 * @property centerFrame
2827 <div id="method-Ext.dd.DDProxy-createFrame"></div>/**
2828 * Creates the proxy element if it does not yet exist
2829 * @method createFrame
2831 createFrame: function() {
2833 var body = document.body;
2835 if (!body || !body.firstChild) {
2836 setTimeout( function() { self.createFrame(); }, 50 );
2840 var div = this.getDragEl();
2843 div = document.createElement("div");
2844 div.id = this.dragElId;
2847 s.position = "absolute";
2848 s.visibility = "hidden";
2850 s.border = "2px solid #aaa";
2853 // appendChild can blow up IE if invoked prior to the window load event
2854 // while rendering a table. It is possible there are other scenarios
2855 // that would cause this to happen as well.
2856 body.insertBefore(div, body.firstChild);
2860 <div id="method-Ext.dd.DDProxy-initFrame"></div>/**
2861 * Initialization for the drag frame element. Must be called in the
2862 * constructor of all subclasses
2865 initFrame: function() {
2869 applyConfig: function() {
2870 Ext.dd.DDProxy.superclass.applyConfig.call(this);
2872 this.resizeFrame = (this.config.resizeFrame !== false);
2873 this.centerFrame = (this.config.centerFrame);
2874 this.setDragElId(this.config.dragElId || Ext.dd.DDProxy.dragElId);
2878 * Resizes the drag frame to the dimensions of the clicked object, positions
2879 * it over the object, and finally displays it
2881 * @param {int} iPageX X click position
2882 * @param {int} iPageY Y click position
2885 showFrame: function(iPageX, iPageY) {
2886 var el = this.getEl();
2887 var dragEl = this.getDragEl();
2888 var s = dragEl.style;
2890 this._resizeProxy();
2892 if (this.centerFrame) {
2893 this.setDelta( Math.round(parseInt(s.width, 10)/2),
2894 Math.round(parseInt(s.height, 10)/2) );
2897 this.setDragElPos(iPageX, iPageY);
2899 Ext.fly(dragEl).show();
2903 * The proxy is automatically resized to the dimensions of the linked
2904 * element when a drag is initiated, unless resizeFrame is set to false
2905 * @method _resizeProxy
2908 _resizeProxy: function() {
2909 if (this.resizeFrame) {
2910 var el = this.getEl();
2911 Ext.fly(this.getDragEl()).setSize(el.offsetWidth, el.offsetHeight);
2915 // overrides Ext.dd.DragDrop
2916 b4MouseDown: function(e) {
2917 var x = e.getPageX();
2918 var y = e.getPageY();
2919 this.autoOffset(x, y);
2920 this.setDragElPos(x, y);
2923 // overrides Ext.dd.DragDrop
2924 b4StartDrag: function(x, y) {
2925 // show the drag frame
2926 this.showFrame(x, y);
2929 // overrides Ext.dd.DragDrop
2930 b4EndDrag: function(e) {
2931 Ext.fly(this.getDragEl()).hide();
2934 // overrides Ext.dd.DragDrop
2935 // By default we try to move the element to the last location of the frame.
2936 // This is so that the default behavior mirrors that of Ext.dd.DD.
2937 endDrag: function(e) {
2939 var lel = this.getEl();
2940 var del = this.getDragEl();
2942 // Show the drag frame briefly so we can get its position
2943 del.style.visibility = "";
2946 // Hide the linked element before the move to get around a Safari
2948 lel.style.visibility = "hidden";
2949 Ext.dd.DDM.moveToEl(lel, del);
2950 del.style.visibility = "hidden";
2951 lel.style.visibility = "";
2956 beforeMove : function(){
2960 afterDrag : function(){
2964 toString: function() {
2965 return ("DDProxy " + this.id);
2969 <div id="cls-Ext.dd.DDTarget"></div>/**
2970 * @class Ext.dd.DDTarget
2971 * A DragDrop implementation that does not move, but can be a drop
2972 * target. You would get the same result by simply omitting implementation
2973 * for the event callbacks, but this way we reduce the processing cost of the
2974 * event listener and the callbacks.
2975 * @extends Ext.dd.DragDrop
2977 * @param {String} id the id of the element that is a drop target
2978 * @param {String} sGroup the group of related DragDrop objects
2979 * @param {object} config an object containing configurable attributes
2980 * Valid properties for DDTarget in addition to those in
2984 Ext.dd.DDTarget = function(id, sGroup, config) {
2986 this.initTarget(id, sGroup, config);
2990 // Ext.dd.DDTarget.prototype = new Ext.dd.DragDrop();
2991 Ext.extend(Ext.dd.DDTarget, Ext.dd.DragDrop, {
2992 <div id="method-Ext.dd.DDTarget-getDragEl"></div>/**
2994 * Overridden and disabled. A DDTarget does not support being dragged.
2997 getDragEl: Ext.emptyFn,
2998 <div id="method-Ext.dd.DDTarget-isValidHandleChild"></div>/**
3000 * Overridden and disabled. A DDTarget does not support being dragged.
3003 isValidHandleChild: Ext.emptyFn,
3004 <div id="method-Ext.dd.DDTarget-startDrag"></div>/**
3006 * Overridden and disabled. A DDTarget does not support being dragged.
3009 startDrag: Ext.emptyFn,
3010 <div id="method-Ext.dd.DDTarget-endDrag"></div>/**
3012 * Overridden and disabled. A DDTarget does not support being dragged.
3015 endDrag: Ext.emptyFn,
3016 <div id="method-Ext.dd.DDTarget-onDrag"></div>/**
3018 * Overridden and disabled. A DDTarget does not support being dragged.
3021 onDrag: Ext.emptyFn,
3022 <div id="method-Ext.dd.DDTarget-onDragDrop"></div>/**
3024 * Overridden and disabled. A DDTarget does not support being dragged.
3027 onDragDrop: Ext.emptyFn,
3028 <div id="method-Ext.dd.DDTarget-onDragEnter"></div>/**
3030 * Overridden and disabled. A DDTarget does not support being dragged.
3033 onDragEnter: Ext.emptyFn,
3034 <div id="method-Ext.dd.DDTarget-onDragOut"></div>/**
3036 * Overridden and disabled. A DDTarget does not support being dragged.
3039 onDragOut: Ext.emptyFn,
3040 <div id="method-Ext.dd.DDTarget-onDragOver"></div>/**
3042 * Overridden and disabled. A DDTarget does not support being dragged.
3045 onDragOver: Ext.emptyFn,
3046 <div id="method-Ext.dd.DDTarget-onInvalidDrop"></div>/**
3048 * Overridden and disabled. A DDTarget does not support being dragged.
3051 onInvalidDrop: Ext.emptyFn,
3052 <div id="method-Ext.dd.DDTarget-onMouseDown"></div>/**
3054 * Overridden and disabled. A DDTarget does not support being dragged.
3057 onMouseDown: Ext.emptyFn,
3058 <div id="method-Ext.dd.DDTarget-onMouseUp"></div>/**
3060 * Overridden and disabled. A DDTarget does not support being dragged.
3063 onMouseUp: Ext.emptyFn,
3064 <div id="method-Ext.dd.DDTarget-setXConstraint"></div>/**
3066 * Overridden and disabled. A DDTarget does not support being dragged.
3069 setXConstraint: Ext.emptyFn,
3070 <div id="method-Ext.dd.DDTarget-setYConstraint"></div>/**
3072 * Overridden and disabled. A DDTarget does not support being dragged.
3075 setYConstraint: Ext.emptyFn,
3076 <div id="method-Ext.dd.DDTarget-resetConstraints"></div>/**
3078 * Overridden and disabled. A DDTarget does not support being dragged.
3081 resetConstraints: Ext.emptyFn,
3082 <div id="method-Ext.dd.DDTarget-clearConstraints"></div>/**
3084 * Overridden and disabled. A DDTarget does not support being dragged.
3087 clearConstraints: Ext.emptyFn,
3088 <div id="method-Ext.dd.DDTarget-clearTicks"></div>/**
3090 * Overridden and disabled. A DDTarget does not support being dragged.
3093 clearTicks: Ext.emptyFn,
3094 <div id="method-Ext.dd.DDTarget-setInitPosition"></div>/**
3096 * Overridden and disabled. A DDTarget does not support being dragged.
3099 setInitPosition: Ext.emptyFn,
3100 <div id="method-Ext.dd.DDTarget-setDragElId"></div>/**
3102 * Overridden and disabled. A DDTarget does not support being dragged.
3105 setDragElId: Ext.emptyFn,
3106 <div id="method-Ext.dd.DDTarget-setHandleElId"></div>/**
3108 * Overridden and disabled. A DDTarget does not support being dragged.
3111 setHandleElId: Ext.emptyFn,
3112 <div id="method-Ext.dd.DDTarget-setOuterHandleElId"></div>/**
3114 * Overridden and disabled. A DDTarget does not support being dragged.
3117 setOuterHandleElId: Ext.emptyFn,
3118 <div id="method-Ext.dd.DDTarget-addInvalidHandleClass"></div>/**
3120 * Overridden and disabled. A DDTarget does not support being dragged.
3123 addInvalidHandleClass: Ext.emptyFn,
3124 <div id="method-Ext.dd.DDTarget-addInvalidHandleId"></div>/**
3126 * Overridden and disabled. A DDTarget does not support being dragged.
3129 addInvalidHandleId: Ext.emptyFn,
3130 <div id="method-Ext.dd.DDTarget-addInvalidHandleType"></div>/**
3132 * Overridden and disabled. A DDTarget does not support being dragged.
3135 addInvalidHandleType: Ext.emptyFn,
3136 <div id="method-Ext.dd.DDTarget-removeInvalidHandleClass"></div>/**
3138 * Overridden and disabled. A DDTarget does not support being dragged.
3141 removeInvalidHandleClass: Ext.emptyFn,
3142 <div id="method-Ext.dd.DDTarget-removeInvalidHandleId"></div>/**
3144 * Overridden and disabled. A DDTarget does not support being dragged.
3147 removeInvalidHandleId: Ext.emptyFn,
3148 <div id="method-Ext.dd.DDTarget-removeInvalidHandleType"></div>/**
3150 * Overridden and disabled. A DDTarget does not support being dragged.
3153 removeInvalidHandleType: Ext.emptyFn,
3155 toString: function() {
3156 return ("DDTarget " + this.id);