3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">/*
9 * These classes are derivatives of the similarly named classes in the YUI Library.
10 * The original license:
11 * Copyright (c) 2006, Yahoo! Inc. All rights reserved.
12 * Code licensed under the BSD License:
13 * http://developer.yahoo.net/yui/license.txt
18 var Event=Ext.EventManager;
21 <div id="cls-Ext.dd.DragDrop"></div>/**
22 * @class Ext.dd.DragDrop
23 * Defines the interface and base operation of items that that can be
24 * dragged or can be drop targets. It was designed to be extended, overriding
25 * the event handlers for startDrag, onDrag, onDragOver and onDragOut.
26 * Up to three html elements can be associated with a DragDrop instance:
28 * <li>linked element: the element that is passed into the constructor.
29 * This is the element which defines the boundaries for interaction with
30 * other DragDrop objects.</li>
31 * <li>handle element(s): The drag operation only occurs if the element that
32 * was clicked matches a handle element. By default this is the linked
33 * element, but there are times that you will want only a portion of the
34 * linked element to initiate the drag operation, and the setHandleElId()
35 * method provides a way to define this.</li>
36 * <li>drag element: this represents the element that would be moved along
37 * with the cursor during a drag operation. By default, this is the linked
38 * element itself as in {@link Ext.dd.DD}. setDragElId() lets you define
39 * a separate element that would be moved, as in {@link Ext.dd.DDProxy}.
42 * This class should not be instantiated until the onload event to ensure that
43 * the associated elements are available.
44 * The following would define a DragDrop obj that would interact with any
45 * other DragDrop obj in the "group1" group:
47 * dd = new Ext.dd.DragDrop("div1", "group1");
49 * Since none of the event handlers have been implemented, nothing would
50 * actually happen if you were to run the code above. Normally you would
51 * override this class or one of the default implementations, but you can
52 * also override the methods you want on an instance of the class...
54 * dd.onDragDrop = function(e, id) {
55 * alert("dd was dropped on " + id);
59 * @param {String} id of the element that is linked to this instance
60 * @param {String} sGroup the group of related DragDrop objects
61 * @param {object} config an object containing configurable attributes
62 * Valid properties for DragDrop:
63 * padding, isTarget, maintainOffset, primaryButtonOnly
65 Ext.dd.DragDrop = function(id, sGroup, config) {
67 this.init(id, sGroup, config);
71 Ext.dd.DragDrop.prototype = {
73 <div id="prop-Ext.dd.DragDrop-ignoreSelf"></div>/**
74 * Set to false to enable a DragDrop object to fire drag events while dragging
75 * over its own Element. Defaults to true - DragDrop objects do not by default
76 * fire drag events to themselves.
77 * @property ignoreSelf
81 <div id="prop-Ext.dd.DragDrop-id"></div>/**
82 * The id of the element associated with this object. This is what we
83 * refer to as the "linked element" because the size and position of
84 * this element is used to determine when the drag and drop objects have
91 <div id="prop-Ext.dd.DragDrop-config"></div>/**
92 * Configuration attributes passed into the constructor
99 * The id of the element that will be dragged. By default this is same
100 * as the linked element , but could be changed to another element. Ex:
109 * The ID of the element that initiates the drag operation. By default
110 * this is the linked element, but could be changed to be a child of this
111 * element. This lets us do things like only starting the drag when the
112 * header element within the linked html element is clicked.
113 * @property handleElId
119 <div id="prop-Ext.dd.DragDrop-invalidHandleTypes"></div>/**
120 * An object who's property names identify HTML tags to be considered invalid as drag handles.
121 * A non-null property value identifies the tag as invalid. Defaults to the
122 * following value which prevents drag operations from being initiated by <a> elements:<pre><code>
126 * @property invalidHandleTypes
129 invalidHandleTypes: null,
131 <div id="prop-Ext.dd.DragDrop-invalidHandleIds"></div>/**
132 * An object who's property names identify the IDs of elements to be considered invalid as drag handles.
133 * A non-null property value identifies the ID as invalid. For example, to prevent
134 * dragging from being initiated on element ID "foo", use:<pre><code>
138 * @property invalidHandleIds
141 invalidHandleIds: null,
143 <div id="prop-Ext.dd.DragDrop-invalidHandleClasses"></div>/**
144 * An Array of CSS class names for elements to be considered in valid as drag handles.
145 * @property invalidHandleClasses
148 invalidHandleClasses: null,
151 * The linked element's absolute X position at the time the drag was
153 * @property startPageX
160 * The linked element's absolute X position at the time the drag was
162 * @property startPageY
168 <div id="prop-Ext.dd.DragDrop-groups"></div>/**
169 * The group defines a logical collection of DragDrop objects that are
170 * related. Instances only get events when interacting with other
171 * DragDrop object in the same group. This lets us define multiple
172 * groups using a single DragDrop subclass if we want.
174 * @type object An object in the format {'group1':true, 'group2':true}
179 * Individual drag/drop instances can be locked. This will prevent
180 * onmousedown start drag.
187 <div id="method-Ext.dd.DragDrop-lock"></div>/**
191 lock: function() { this.locked = true; },
193 <div id="prop-Ext.dd.DragDrop-moveOnly"></div>/**
194 * When set to true, other DD objects in cooperating DDGroups do not receive
195 * notification events when this DD object is dragged over them. Defaults to false.
201 <div id="method-Ext.dd.DragDrop-unlock"></div>/**
202 * Unlock this instace
205 unlock: function() { this.locked = false; },
207 <div id="prop-Ext.dd.DragDrop-isTarget"></div>/**
208 * By default, all instances can be a drop target. This can be disabled by
209 * setting isTarget to false.
215 <div id="prop-Ext.dd.DragDrop-padding"></div>/**
216 * The padding configured for this drag and drop object for calculating
217 * the drop zone intersection with this object.
219 * @type int[] An array containing the 4 padding values: [top, right, bottom, left]
224 * Cached reference to the linked element
231 * Internal typeof flag
232 * @property __ygDragDrop
238 * Set to true when horizontal contraints are applied
239 * @property constrainX
246 * Set to true when vertical contraints are applied
247 * @property constrainY
254 * The left constraint
262 * The right constraint
279 * The down constraint
286 <div id="prop-Ext.dd.DragDrop-maintainOffset"></div>/**
287 * Maintain offsets when we resetconstraints. Set to true when you want
288 * the position of the element relative to its parent to stay the same
289 * when the page changes
291 * @property maintainOffset
294 maintainOffset: false,
296 <div id="prop-Ext.dd.DragDrop-xTicks"></div>/**
297 * Array of pixel locations the element will snap to if we specified a
298 * horizontal graduation/interval. This array is generated automatically
299 * when you define a tick interval.
305 <div id="prop-Ext.dd.DragDrop-yTicks"></div>/**
306 * Array of pixel locations the element will snap to if we specified a
307 * vertical graduation/interval. This array is generated automatically
308 * when you define a tick interval.
314 <div id="prop-Ext.dd.DragDrop-primaryButtonOnly"></div>/**
315 * By default the drag and drop instance will only respond to the primary
316 * button click (left button for a right-handed mouse). Set to true to
317 * allow drag and drop to start with any mouse click that is propogated
319 * @property primaryButtonOnly
322 primaryButtonOnly: true,
324 <div id="prop-Ext.dd.DragDrop-available"></div>/**
325 * The availabe property is false until the linked dom element is accessible.
326 * @property available
331 <div id="prop-Ext.dd.DragDrop-hasOuterHandles"></div>/**
332 * By default, drags can only be initiated if the mousedown occurs in the
333 * region the linked element is. This is done in part to work around a
334 * bug in some browsers that mis-report the mousedown if the previous
335 * mouseup happened outside of the window. This property is set to true
336 * if outer handles are defined.
338 * @property hasOuterHandles
342 hasOuterHandles: false,
345 * Code that executes immediately before the startDrag event
346 * @method b4StartDrag
349 b4StartDrag: function(x, y) { },
351 <div id="method-Ext.dd.DragDrop-startDrag"></div>/**
352 * Abstract method called after a drag/drop object is clicked
353 * and the drag or mousedown time thresholds have beeen met.
355 * @param {int} X click location
356 * @param {int} Y click location
358 startDrag: function(x, y) { /* override this */ },
361 * Code that executes immediately before the onDrag event
365 b4Drag: function(e) { },
367 <div id="method-Ext.dd.DragDrop-onDrag"></div>/**
368 * Abstract method called during the onMouseMove event while dragging an
371 * @param {Event} e the mousemove event
373 onDrag: function(e) { /* override this */ },
375 <div id="method-Ext.dd.DragDrop-onDragEnter"></div>/**
376 * Abstract method called when this element fist begins hovering over
377 * another DragDrop obj
378 * @method onDragEnter
379 * @param {Event} e the mousemove event
380 * @param {String|DragDrop[]} id In POINT mode, the element
381 * id this is hovering over. In INTERSECT mode, an array of one or more
382 * dragdrop items being hovered over.
384 onDragEnter: function(e, id) { /* override this */ },
387 * Code that executes immediately before the onDragOver event
391 b4DragOver: function(e) { },
393 <div id="method-Ext.dd.DragDrop-onDragOver"></div>/**
394 * Abstract method called when this element is hovering over another
397 * @param {Event} e the mousemove event
398 * @param {String|DragDrop[]} id In POINT mode, the element
399 * id this is hovering over. In INTERSECT mode, an array of dd items
400 * being hovered over.
402 onDragOver: function(e, id) { /* override this */ },
405 * Code that executes immediately before the onDragOut event
409 b4DragOut: function(e) { },
411 <div id="method-Ext.dd.DragDrop-onDragOut"></div>/**
412 * Abstract method called when we are no longer hovering over an element
414 * @param {Event} e the mousemove event
415 * @param {String|DragDrop[]} id In POINT mode, the element
416 * id this was hovering over. In INTERSECT mode, an array of dd items
417 * that the mouse is no longer over.
419 onDragOut: function(e, id) { /* override this */ },
422 * Code that executes immediately before the onDragDrop event
426 b4DragDrop: function(e) { },
428 <div id="method-Ext.dd.DragDrop-onDragDrop"></div>/**
429 * Abstract method called when this item is dropped on another DragDrop
432 * @param {Event} e the mouseup event
433 * @param {String|DragDrop[]} id In POINT mode, the element
434 * id this was dropped on. In INTERSECT mode, an array of dd items this
437 onDragDrop: function(e, id) { /* override this */ },
439 <div id="method-Ext.dd.DragDrop-onInvalidDrop"></div>/**
440 * Abstract method called when this item is dropped on an area with no
442 * @method onInvalidDrop
443 * @param {Event} e the mouseup event
445 onInvalidDrop: function(e) { /* override this */ },
448 * Code that executes immediately before the endDrag event
452 b4EndDrag: function(e) { },
454 <div id="method-Ext.dd.DragDrop-endDrag"></div>/**
455 * Fired when we are done dragging the object
457 * @param {Event} e the mouseup event
459 endDrag: function(e) { /* override this */ },
462 * Code executed immediately before the onMouseDown event
463 * @method b4MouseDown
464 * @param {Event} e the mousedown event
467 b4MouseDown: function(e) { },
469 <div id="method-Ext.dd.DragDrop-onMouseDown"></div>/**
470 * Event handler that fires when a drag/drop obj gets a mousedown
471 * @method onMouseDown
472 * @param {Event} e the mousedown event
474 onMouseDown: function(e) { /* override this */ },
476 <div id="method-Ext.dd.DragDrop-onMouseUp"></div>/**
477 * Event handler that fires when a drag/drop obj gets a mouseup
479 * @param {Event} e the mouseup event
481 onMouseUp: function(e) { /* override this */ },
483 <div id="method-Ext.dd.DragDrop-onAvailable"></div>/**
484 * Override the onAvailable method to do what is needed after the initial
485 * position was determined.
486 * @method onAvailable
488 onAvailable: function () {
491 <div id="prop-Ext.dd.DragDrop-defaultPadding"></div>/**
492 * Provides default constraint padding to "constrainTo" elements (defaults to {left: 0, right:0, top:0, bottom:0}).
495 defaultPadding : {left:0, right:0, top:0, bottom:0},
497 <div id="method-Ext.dd.DragDrop-constrainTo"></div>/**
498 * Initializes the drag drop object's constraints to restrict movement to a certain element.
502 var dd = new Ext.dd.DDProxy("dragDiv1", "proxytest",
503 { dragElId: "existingProxyDiv" });
504 dd.startDrag = function(){
505 this.constrainTo("parent-id");
508 * Or you can initalize it using the {@link Ext.Element} object:
510 Ext.get("dragDiv1").initDDProxy("proxytest", {dragElId: "existingProxyDiv"}, {
511 startDrag : function(){
512 this.constrainTo("parent-id");
516 * @param {Mixed} constrainTo The element to constrain to.
517 * @param {Object/Number} pad (optional) Pad provides a way to specify "padding" of the constraints,
518 * and can be either a number for symmetrical padding (4 would be equal to {left:4, right:4, top:4, bottom:4}) or
519 * an object containing the sides to pad. For example: {right:10, bottom:10}
520 * @param {Boolean} inContent (optional) Constrain the draggable in the content box of the element (inside padding and borders)
522 constrainTo : function(constrainTo, pad, inContent){
523 if(typeof pad == "number"){
524 pad = {left: pad, right:pad, top:pad, bottom:pad};
526 pad = pad || this.defaultPadding;
527 var b = Ext.get(this.getEl()).getBox();
528 var ce = Ext.get(constrainTo);
529 var s = ce.getScroll();
531 if(cd == document.body){
532 c = { x: s.left, y: s.top, width: Ext.lib.Dom.getViewWidth(), height: Ext.lib.Dom.getViewHeight()};
535 c = {x : xy[0]+s.left, y: xy[1]+s.top, width: cd.clientWidth, height: cd.clientHeight};
539 var topSpace = b.y - c.y;
540 var leftSpace = b.x - c.x;
542 this.resetConstraints();
543 this.setXConstraint(leftSpace - (pad.left||0), // left
544 c.width - leftSpace - b.width - (pad.right||0), //right
547 this.setYConstraint(topSpace - (pad.top||0), //top
548 c.height - topSpace - b.height - (pad.bottom||0), //bottom
553 <div id="method-Ext.dd.DragDrop-getEl"></div>/**
554 * Returns a reference to the linked element
556 * @return {HTMLElement} the html element
560 this._domRef = Ext.getDom(this.id);
566 <div id="method-Ext.dd.DragDrop-getDragEl"></div>/**
567 * Returns a reference to the actual element to drag. By default this is
568 * the same as the html element, but it can be assigned to another
569 * element. An example of this can be found in Ext.dd.DDProxy
571 * @return {HTMLElement} the html element
573 getDragEl: function() {
574 return Ext.getDom(this.dragElId);
577 <div id="method-Ext.dd.DragDrop-init"></div>/**
578 * Sets up the DragDrop object. Must be called in the constructor of any
579 * Ext.dd.DragDrop subclass
581 * @param id the id of the linked element
582 * @param {String} sGroup the group of related items
583 * @param {object} config configuration attributes
585 init: function(id, sGroup, config) {
586 this.initTarget(id, sGroup, config);
587 Event.on(this.id, "mousedown", this.handleMouseDown, this);
588 // Event.on(this.id, "selectstart", Event.preventDefault);
591 <div id="method-Ext.dd.DragDrop-initTarget"></div>/**
592 * Initializes Targeting functionality only... the object does not
593 * get a mousedown handler.
595 * @param id the id of the linked element
596 * @param {String} sGroup the group of related items
597 * @param {object} config configuration attributes
599 initTarget: function(id, sGroup, config) {
601 // configuration attributes
602 this.config = config || {};
604 // create a local reference to the drag and drop manager
605 this.DDM = Ext.dd.DDM;
606 // initialize the groups array
609 // assume that we have an element reference instead of an id if the
610 // parameter is not a string
611 if (typeof id !== "string") {
618 // add to an interaction group
619 this.addToGroup((sGroup) ? sGroup : "default");
621 // We don't want to register this as the handle with the manager
622 // so we just set the id rather than calling the setter.
623 this.handleElId = id;
625 // the linked element is the element that gets dragged by default
626 this.setDragElId(id);
628 // by default, clicked anchors will not start drag operations.
629 this.invalidHandleTypes = { A: "A" };
630 this.invalidHandleIds = {};
631 this.invalidHandleClasses = [];
635 this.handleOnAvailable();
638 <div id="method-Ext.dd.DragDrop-applyConfig"></div>/**
639 * Applies the configuration parameters that were passed into the constructor.
640 * This is supposed to happen at each level through the inheritance chain. So
641 * a DDProxy implentation will execute apply config on DDProxy, DD, and
642 * DragDrop in order to get all of the parameters that are available in
644 * @method applyConfig
646 applyConfig: function() {
648 // configurable properties:
649 // padding, isTarget, maintainOffset, primaryButtonOnly
650 this.padding = this.config.padding || [0, 0, 0, 0];
651 this.isTarget = (this.config.isTarget !== false);
652 this.maintainOffset = (this.config.maintainOffset);
653 this.primaryButtonOnly = (this.config.primaryButtonOnly !== false);
658 * Executed when the linked element is available
659 * @method handleOnAvailable
662 handleOnAvailable: function() {
663 this.available = true;
664 this.resetConstraints();
668 <div id="method-Ext.dd.DragDrop-setPadding"></div>/**
669 * Configures the padding for the target zone in px. Effectively expands
670 * (or reduces) the virtual object size for targeting calculations.
671 * Supports css-style shorthand; if only one parameter is passed, all sides
672 * will have that padding, and if only two are passed, the top and bottom
673 * will have the first param, the left and right the second.
675 * @param {int} iTop Top pad
676 * @param {int} iRight Right pad
677 * @param {int} iBot Bot pad
678 * @param {int} iLeft Left pad
680 setPadding: function(iTop, iRight, iBot, iLeft) {
681 // this.padding = [iLeft, iRight, iTop, iBot];
682 if (!iRight && 0 !== iRight) {
683 this.padding = [iTop, iTop, iTop, iTop];
684 } else if (!iBot && 0 !== iBot) {
685 this.padding = [iTop, iRight, iTop, iRight];
687 this.padding = [iTop, iRight, iBot, iLeft];
691 <div id="method-Ext.dd.DragDrop-setInitPosition"></div>/**
692 * Stores the initial placement of the linked element.
693 * @method setInitPosition
694 * @param {int} diffX the X offset, default 0
695 * @param {int} diffY the Y offset, default 0
697 setInitPosition: function(diffX, diffY) {
698 var el = this.getEl();
700 if (!this.DDM.verifyEl(el)) {
707 var p = Dom.getXY( el );
709 this.initPageX = p[0] - dx;
710 this.initPageY = p[1] - dy;
712 this.lastPageX = p[0];
713 this.lastPageY = p[1];
716 this.setStartPosition(p);
720 * Sets the start position of the element. This is set when the obj
721 * is initialized, the reset when a drag is started.
722 * @method setStartPosition
723 * @param pos current position (from previous lookup)
726 setStartPosition: function(pos) {
727 var p = pos || Dom.getXY( this.getEl() );
728 this.deltaSetXY = null;
730 this.startPageX = p[0];
731 this.startPageY = p[1];
734 <div id="method-Ext.dd.DragDrop-addToGroup"></div>/**
735 * Add this instance to a group of related drag/drop objects. All
736 * instances belong to at least one group, and can belong to as many
739 * @param sGroup {string} the name of the group
741 addToGroup: function(sGroup) {
742 this.groups[sGroup] = true;
743 this.DDM.regDragDrop(this, sGroup);
746 <div id="method-Ext.dd.DragDrop-removeFromGroup"></div>/**
747 * Remove's this instance from the supplied interaction group
748 * @method removeFromGroup
749 * @param {string} sGroup The group to drop
751 removeFromGroup: function(sGroup) {
752 if (this.groups[sGroup]) {
753 delete this.groups[sGroup];
756 this.DDM.removeDDFromGroup(this, sGroup);
759 <div id="method-Ext.dd.DragDrop-setDragElId"></div>/**
760 * Allows you to specify that an element other than the linked element
761 * will be moved with the cursor during a drag
762 * @method setDragElId
763 * @param id {string} the id of the element that will be used to initiate the drag
765 setDragElId: function(id) {
769 <div id="method-Ext.dd.DragDrop-setHandleElId"></div>/**
770 * Allows you to specify a child of the linked element that should be
771 * used to initiate the drag operation. An example of this would be if
772 * you have a content div with text and links. Clicking anywhere in the
773 * content area would normally start the drag operation. Use this method
774 * to specify that an element inside of the content div is the element
775 * that starts the drag operation.
776 * @method setHandleElId
777 * @param id {string} the id of the element that will be used to
780 setHandleElId: function(id) {
781 if (typeof id !== "string") {
784 this.handleElId = id;
785 this.DDM.regHandle(this.id, id);
788 <div id="method-Ext.dd.DragDrop-setOuterHandleElId"></div>/**
789 * Allows you to set an element outside of the linked element as a drag
791 * @method setOuterHandleElId
792 * @param id the id of the element that will be used to initiate the drag
794 setOuterHandleElId: function(id) {
795 if (typeof id !== "string") {
798 Event.on(id, "mousedown",
799 this.handleMouseDown, this);
800 this.setHandleElId(id);
802 this.hasOuterHandles = true;
805 <div id="method-Ext.dd.DragDrop-unreg"></div>/**
806 * Remove all drag and drop hooks for this element
810 Event.un(this.id, "mousedown",
811 this.handleMouseDown);
813 this.DDM._remove(this);
816 destroy : function(){
820 <div id="method-Ext.dd.DragDrop-isLocked"></div>/**
821 * Returns true if this instance is locked, or the drag drop mgr is locked
822 * (meaning that all drag/drop is disabled on the page.)
824 * @return {boolean} true if this obj or all drag/drop is locked, else
827 isLocked: function() {
828 return (this.DDM.isLocked() || this.locked);
832 * Fired when this object is clicked
833 * @method handleMouseDown
835 * @param {Ext.dd.DragDrop} oDD the clicked dd object (this dd obj)
838 handleMouseDown: function(e, oDD){
839 if (this.primaryButtonOnly && e.button != 0) {
843 if (this.isLocked()) {
847 this.DDM.refreshCache(this.groups);
849 var pt = new Ext.lib.Point(Ext.lib.Event.getPageX(e), Ext.lib.Event.getPageY(e));
850 if (!this.hasOuterHandles && !this.DDM.isOverTarget(pt, this) ) {
852 if (this.clickValidator(e)) {
854 // set the initial element position
855 this.setStartPosition();
861 this.DDM.handleMouseDown(e, this);
863 this.DDM.stopEvent(e);
871 clickValidator: function(e) {
872 var target = e.getTarget();
873 return ( this.isValidHandleChild(target) &&
874 (this.id == this.handleElId ||
875 this.DDM.handleWasClicked(target, this.id)) );
878 <div id="method-Ext.dd.DragDrop-addInvalidHandleType"></div>/**
879 * Allows you to specify a tag name that should not start a drag operation
880 * when clicked. This is designed to facilitate embedding links within a
881 * drag handle that do something other than start the drag.
882 * @method addInvalidHandleType
883 * @param {string} tagName the type of element to exclude
885 addInvalidHandleType: function(tagName) {
886 var type = tagName.toUpperCase();
887 this.invalidHandleTypes[type] = type;
890 <div id="method-Ext.dd.DragDrop-addInvalidHandleId"></div>/**
891 * Lets you to specify an element id for a child of a drag handle
892 * that should not initiate a drag
893 * @method addInvalidHandleId
894 * @param {string} id the element id of the element you wish to ignore
896 addInvalidHandleId: function(id) {
897 if (typeof id !== "string") {
900 this.invalidHandleIds[id] = id;
903 <div id="method-Ext.dd.DragDrop-addInvalidHandleClass"></div>/**
904 * Lets you specify a css class of elements that will not initiate a drag
905 * @method addInvalidHandleClass
906 * @param {string} cssClass the class of the elements you wish to ignore
908 addInvalidHandleClass: function(cssClass) {
909 this.invalidHandleClasses.push(cssClass);
912 <div id="method-Ext.dd.DragDrop-removeInvalidHandleType"></div>/**
913 * Unsets an excluded tag name set by addInvalidHandleType
914 * @method removeInvalidHandleType
915 * @param {string} tagName the type of element to unexclude
917 removeInvalidHandleType: function(tagName) {
918 var type = tagName.toUpperCase();
919 // this.invalidHandleTypes[type] = null;
920 delete this.invalidHandleTypes[type];
923 <div id="method-Ext.dd.DragDrop-removeInvalidHandleId"></div>/**
924 * Unsets an invalid handle id
925 * @method removeInvalidHandleId
926 * @param {string} id the id of the element to re-enable
928 removeInvalidHandleId: function(id) {
929 if (typeof id !== "string") {
932 delete this.invalidHandleIds[id];
935 <div id="method-Ext.dd.DragDrop-removeInvalidHandleClass"></div>/**
936 * Unsets an invalid css class
937 * @method removeInvalidHandleClass
938 * @param {string} cssClass the class of the element(s) you wish to
941 removeInvalidHandleClass: function(cssClass) {
942 for (var i=0, len=this.invalidHandleClasses.length; i<len; ++i) {
943 if (this.invalidHandleClasses[i] == cssClass) {
944 delete this.invalidHandleClasses[i];
949 <div id="method-Ext.dd.DragDrop-isValidHandleChild"></div>/**
950 * Checks the tag exclusion list to see if this click should be ignored
951 * @method isValidHandleChild
952 * @param {HTMLElement} node the HTMLElement to evaluate
953 * @return {boolean} true if this is a valid tag type, false if not
955 isValidHandleChild: function(node) {
958 // var n = (node.nodeName == "#text") ? node.parentNode : node;
961 nodeName = node.nodeName.toUpperCase();
963 nodeName = node.nodeName;
965 valid = valid && !this.invalidHandleTypes[nodeName];
966 valid = valid && !this.invalidHandleIds[node.id];
968 for (var i=0, len=this.invalidHandleClasses.length; valid && i<len; ++i) {
969 valid = !Ext.fly(node).hasClass(this.invalidHandleClasses[i]);
978 * Create the array of horizontal tick marks if an interval was specified
979 * in setXConstraint().
983 setXTicks: function(iStartX, iTickSize) {
985 this.xTickSize = iTickSize;
989 for (var i = this.initPageX; i >= this.minX; i = i - iTickSize) {
991 this.xTicks[this.xTicks.length] = i;
996 for (i = this.initPageX; i <= this.maxX; i = i + iTickSize) {
998 this.xTicks[this.xTicks.length] = i;
1003 this.xTicks.sort(this.DDM.numericSort) ;
1007 * Create the array of vertical tick marks if an interval was specified in
1012 setYTicks: function(iStartY, iTickSize) {
1014 this.yTickSize = iTickSize;
1018 for (var i = this.initPageY; i >= this.minY; i = i - iTickSize) {
1020 this.yTicks[this.yTicks.length] = i;
1025 for (i = this.initPageY; i <= this.maxY; i = i + iTickSize) {
1027 this.yTicks[this.yTicks.length] = i;
1032 this.yTicks.sort(this.DDM.numericSort) ;
1035 <div id="method-Ext.dd.DragDrop-setXConstraint"></div>/**
1036 * By default, the element can be dragged any place on the screen. Use
1037 * this method to limit the horizontal travel of the element. Pass in
1038 * 0,0 for the parameters if you want to lock the drag to the y axis.
1039 * @method setXConstraint
1040 * @param {int} iLeft the number of pixels the element can move to the left
1041 * @param {int} iRight the number of pixels the element can move to the
1043 * @param {int} iTickSize optional parameter for specifying that the
1045 * should move iTickSize pixels at a time.
1047 setXConstraint: function(iLeft, iRight, iTickSize) {
1048 this.leftConstraint = iLeft;
1049 this.rightConstraint = iRight;
1051 this.minX = this.initPageX - iLeft;
1052 this.maxX = this.initPageX + iRight;
1053 if (iTickSize) { this.setXTicks(this.initPageX, iTickSize); }
1055 this.constrainX = true;
1058 <div id="method-Ext.dd.DragDrop-clearConstraints"></div>/**
1059 * Clears any constraints applied to this instance. Also clears ticks
1060 * since they can't exist independent of a constraint at this time.
1061 * @method clearConstraints
1063 clearConstraints: function() {
1064 this.constrainX = false;
1065 this.constrainY = false;
1069 <div id="method-Ext.dd.DragDrop-clearTicks"></div>/**
1070 * Clears any tick interval defined for this instance
1071 * @method clearTicks
1073 clearTicks: function() {
1080 <div id="method-Ext.dd.DragDrop-setYConstraint"></div>/**
1081 * By default, the element can be dragged any place on the screen. Set
1082 * this to limit the vertical travel of the element. Pass in 0,0 for the
1083 * parameters if you want to lock the drag to the x axis.
1084 * @method setYConstraint
1085 * @param {int} iUp the number of pixels the element can move up
1086 * @param {int} iDown the number of pixels the element can move down
1087 * @param {int} iTickSize optional parameter for specifying that the
1088 * element should move iTickSize pixels at a time.
1090 setYConstraint: function(iUp, iDown, iTickSize) {
1091 this.topConstraint = iUp;
1092 this.bottomConstraint = iDown;
1094 this.minY = this.initPageY - iUp;
1095 this.maxY = this.initPageY + iDown;
1096 if (iTickSize) { this.setYTicks(this.initPageY, iTickSize); }
1098 this.constrainY = true;
1102 <div id="method-Ext.dd.DragDrop-resetConstraints"></div>/**
1103 * resetConstraints must be called if you manually reposition a dd element.
1104 * @method resetConstraints
1105 * @param {boolean} maintainOffset
1107 resetConstraints: function() {
1110 // Maintain offsets if necessary
1111 if (this.initPageX || this.initPageX === 0) {
1112 // figure out how much this thing has moved
1113 var dx = (this.maintainOffset) ? this.lastPageX - this.initPageX : 0;
1114 var dy = (this.maintainOffset) ? this.lastPageY - this.initPageY : 0;
1116 this.setInitPosition(dx, dy);
1118 // This is the first time we have detected the element's position
1120 this.setInitPosition();
1123 if (this.constrainX) {
1124 this.setXConstraint( this.leftConstraint,
1125 this.rightConstraint,
1129 if (this.constrainY) {
1130 this.setYConstraint( this.topConstraint,
1131 this.bottomConstraint,
1137 * Normally the drag element is moved pixel by pixel, but we can specify
1138 * that it move a number of pixels at a time. This method resolves the
1139 * location when we have it set up like this.
1141 * @param {int} val where we want to place the object
1142 * @param {int[]} tickArray sorted array of valid points
1143 * @return {int} the closest tick
1146 getTick: function(val, tickArray) {
1149 // If tick interval is not defined, it is effectively 1 pixel,
1150 // so we return the value passed to us.
1152 } else if (tickArray[0] >= val) {
1153 // The value is lower than the first tick, so we return the first
1155 return tickArray[0];
1157 for (var i=0, len=tickArray.length; i<len; ++i) {
1159 if (tickArray[next] && tickArray[next] >= val) {
1160 var diff1 = val - tickArray[i];
1161 var diff2 = tickArray[next] - val;
1162 return (diff2 > diff1) ? tickArray[i] : tickArray[next];
1166 // The value is larger than the last tick, so we return the last
1168 return tickArray[tickArray.length - 1];
1172 <div id="method-Ext.dd.DragDrop-toString"></div>/**
1175 * @return {string} string representation of the dd obj
1177 toString: function() {
1178 return ("DragDrop " + this.id);
1184 <div id="prop-Ext.dd.DragDrop-Only"></div>/**
1185 * The drag and drop utility provides a framework for building drag and drop
1186 * applications. In addition to enabling drag and drop for specific elements,
1187 * the drag and drop elements are tracked by the manager class, and the
1188 * interactions between the various elements are tracked during the drag and
1189 * the implementing code is notified about these important moments.
1192 // Only load the library once. Rewriting the manager class would orphan
1193 // existing drag and drop instances.
1194 if (!Ext.dd.DragDropMgr) {
1196 <div id="cls-Ext.dd.DragDropMgr"></div>/**
1197 * @class Ext.dd.DragDropMgr
1198 * DragDropMgr is a singleton that tracks the element interaction for
1199 * all DragDrop items in the window. Generally, you will not call
1200 * this class directly, but it does have helper methods that could
1201 * be useful in your DragDrop implementations.
1204 Ext.dd.DragDropMgr = function() {
1206 var Event = Ext.EventManager;
1211 * Two dimensional Array of registered DragDrop objects. The first
1212 * dimension is the DragDrop item group, the second the DragDrop
1215 * @type {string: string}
1222 * Array of element ids defined as drag handles. Used to determine
1223 * if the element that generated the mousedown event is actually the
1224 * handle and not the html element itself.
1225 * @property handleIds
1226 * @type {string: string}
1233 * the DragDrop object that is currently being dragged
1234 * @property dragCurrent
1242 * the DragDrop object(s) that are being hovered over
1243 * @property dragOvers
1251 * the X distance between the cursor and the object being dragged
1260 * the Y distance between the cursor and the object being dragged
1268 <div id="prop-Ext.dd.DragDropMgr-preventDefault"></div>/**
1269 * Flag to determine if we should prevent the default behavior of the
1270 * events we define. By default this is true, but this can be set to
1271 * false if you need the default behavior (not recommended)
1272 * @property preventDefault
1276 preventDefault: true,
1278 <div id="prop-Ext.dd.DragDropMgr-stopPropagation"></div>/**
1279 * Flag to determine if we should stop the propagation of the events
1280 * we generate. This is true by default but you may want to set it to
1281 * false if the html element contains other features that require the
1283 * @property stopPropagation
1287 stopPropagation: true,
1290 * Internal flag that is set to true when drag and drop has been
1292 * @property initialized
1299 * All drag and drop can be disabled.
1307 * Called the first time an element is registered.
1313 this.initialized = true;
1316 <div id="prop-Ext.dd.DragDropMgr-POINT"></div>/**
1317 * In point mode, drag and drop interaction is defined by the
1318 * location of the cursor during the drag/drop
1325 <div id="prop-Ext.dd.DragDropMgr-INTERSECT"></div>/**
1326 * In intersect mode, drag and drop interaction is defined by the
1327 * overlap of two or more drag and drop objects.
1328 * @property INTERSECT
1334 <div id="prop-Ext.dd.DragDropMgr-mode"></div>/**
1335 * The current drag and drop mode. Default: POINT
1343 * Runs method on all drag and drop objects
1344 * @method _execOnAll
1348 _execOnAll: function(sMethod, args) {
1349 for (var i in this.ids) {
1350 for (var j in this.ids[i]) {
1351 var oDD = this.ids[i][j];
1352 if (! this.isTypeOfDD(oDD)) {
1355 oDD[sMethod].apply(oDD, args);
1361 * Drag and drop initialization. Sets up the global event handlers
1366 _onLoad: function() {
1371 Event.on(document, "mouseup", this.handleMouseUp, this, true);
1372 Event.on(document, "mousemove", this.handleMouseMove, this, true);
1373 Event.on(window, "unload", this._onUnload, this, true);
1374 Event.on(window, "resize", this._onResize, this, true);
1375 // Event.on(window, "mouseout", this._test);
1380 * Reset constraints on all drag and drop objs
1385 _onResize: function(e) {
1386 this._execOnAll("resetConstraints", []);
1389 <div id="method-Ext.dd.DragDropMgr-lock"></div>/**
1390 * Lock all drag and drop functionality
1394 lock: function() { this.locked = true; },
1396 <div id="method-Ext.dd.DragDropMgr-unlock"></div>/**
1397 * Unlock all drag and drop functionality
1401 unlock: function() { this.locked = false; },
1403 <div id="method-Ext.dd.DragDropMgr-isLocked"></div>/**
1404 * Is drag and drop locked?
1406 * @return {boolean} True if drag and drop is locked, false otherwise.
1409 isLocked: function() { return this.locked; },
1412 * Location cache that is set for all drag drop objects when a drag is
1413 * initiated, cleared when the drag is finished.
1414 * @property locationCache
1420 <div id="prop-Ext.dd.DragDropMgr-useCache"></div>/**
1421 * Set useCache to false if you want to force object the lookup of each
1422 * drag and drop linked element constantly during a drag.
1423 * @property useCache
1429 <div id="prop-Ext.dd.DragDropMgr-clickPixelThresh"></div>/**
1430 * The number of pixels that the mouse needs to move after the
1431 * mousedown before the drag is initiated. Default=3;
1432 * @property clickPixelThresh
1436 clickPixelThresh: 3,
1438 <div id="prop-Ext.dd.DragDropMgr-clickTimeThresh"></div>/**
1439 * The number of milliseconds after the mousedown event to initiate the
1440 * drag if we don't get a mouseup event. Default=1000
1441 * @property clickTimeThresh
1445 clickTimeThresh: 350,
1448 * Flag that indicates that either the drag pixel threshold or the
1449 * mousdown time threshold has been met
1450 * @property dragThreshMet
1455 dragThreshMet: false,
1458 * Timeout used for the click time threshold
1459 * @property clickTimeout
1467 * The X position of the mousedown event stored for later use when a
1468 * drag threshold is met.
1477 * The Y position of the mousedown event stored for later use when a
1478 * drag threshold is met.
1486 <div id="method-Ext.dd.DragDropMgr-regDragDrop"></div>/**
1487 * Each DragDrop instance must be registered with the DragDropMgr.
1488 * This is executed in DragDrop.init()
1489 * @method regDragDrop
1490 * @param {DragDrop} oDD the DragDrop object to register
1491 * @param {String} sGroup the name of the group this element belongs to
1494 regDragDrop: function(oDD, sGroup) {
1495 if (!this.initialized) { this.init(); }
1497 if (!this.ids[sGroup]) {
1498 this.ids[sGroup] = {};
1500 this.ids[sGroup][oDD.id] = oDD;
1504 * Removes the supplied dd instance from the supplied group. Executed
1505 * by DragDrop.removeFromGroup, so don't call this function directly.
1506 * @method removeDDFromGroup
1510 removeDDFromGroup: function(oDD, sGroup) {
1511 if (!this.ids[sGroup]) {
1512 this.ids[sGroup] = {};
1515 var obj = this.ids[sGroup];
1516 if (obj && obj[oDD.id]) {
1522 * Unregisters a drag and drop item. This is executed in
1523 * DragDrop.unreg, use that method instead of calling this directly.
1528 _remove: function(oDD) {
1529 for (var g in oDD.groups) {
1530 if (g && this.ids[g] && this.ids[g][oDD.id]) {
1531 delete this.ids[g][oDD.id];
1534 delete this.handleIds[oDD.id];
1537 <div id="method-Ext.dd.DragDropMgr-regHandle"></div>/**
1538 * Each DragDrop handle element must be registered. This is done
1539 * automatically when executing DragDrop.setHandleElId()
1541 * @param {String} sDDId the DragDrop id this element is a handle for
1542 * @param {String} sHandleId the id of the element that is the drag
1546 regHandle: function(sDDId, sHandleId) {
1547 if (!this.handleIds[sDDId]) {
1548 this.handleIds[sDDId] = {};
1550 this.handleIds[sDDId][sHandleId] = sHandleId;
1553 <div id="method-Ext.dd.DragDropMgr-isDragDrop"></div>/**
1554 * Utility function to determine if a given element has been
1555 * registered as a drag drop item.
1556 * @method isDragDrop
1557 * @param {String} id the element id to check
1558 * @return {boolean} true if this element is a DragDrop item,
1562 isDragDrop: function(id) {
1563 return ( this.getDDById(id) ) ? true : false;
1566 <div id="method-Ext.dd.DragDropMgr-getRelated"></div>/**
1567 * Returns the drag and drop instances that are in all groups the
1568 * passed in instance belongs to.
1569 * @method getRelated
1570 * @param {DragDrop} p_oDD the obj to get related data for
1571 * @param {boolean} bTargetsOnly if true, only return targetable objs
1572 * @return {DragDrop[]} the related instances
1575 getRelated: function(p_oDD, bTargetsOnly) {
1577 for (var i in p_oDD.groups) {
1578 for (var j in this.ids[i]) {
1579 var dd = this.ids[i][j];
1580 if (! this.isTypeOfDD(dd)) {
1583 if (!bTargetsOnly || dd.isTarget) {
1584 oDDs[oDDs.length] = dd;
1592 <div id="method-Ext.dd.DragDropMgr-isLegalTarget"></div>/**
1593 * Returns true if the specified dd target is a legal target for
1594 * the specifice drag obj
1595 * @method isLegalTarget
1596 * @param {DragDrop} the drag obj
1597 * @param {DragDrop} the target
1598 * @return {boolean} true if the target is a legal target for the
1602 isLegalTarget: function (oDD, oTargetDD) {
1603 var targets = this.getRelated(oDD, true);
1604 for (var i=0, len=targets.length;i<len;++i) {
1605 if (targets[i].id == oTargetDD.id) {
1613 <div id="method-Ext.dd.DragDropMgr-isTypeOfDD"></div>/**
1614 * My goal is to be able to transparently determine if an object is
1615 * typeof DragDrop, and the exact subclass of DragDrop. typeof
1616 * returns "object", oDD.constructor.toString() always returns
1617 * "DragDrop" and not the name of the subclass. So for now it just
1618 * evaluates a well-known variable in DragDrop.
1619 * @method isTypeOfDD
1620 * @param {Object} the object to evaluate
1621 * @return {boolean} true if typeof oDD = DragDrop
1624 isTypeOfDD: function (oDD) {
1625 return (oDD && oDD.__ygDragDrop);
1628 <div id="method-Ext.dd.DragDropMgr-isHandle"></div>/**
1629 * Utility function to determine if a given element has been
1630 * registered as a drag drop handle for the given Drag Drop object.
1632 * @param {String} id the element id to check
1633 * @return {boolean} true if this element is a DragDrop handle, false
1637 isHandle: function(sDDId, sHandleId) {
1638 return ( this.handleIds[sDDId] &&
1639 this.handleIds[sDDId][sHandleId] );
1642 <div id="method-Ext.dd.DragDropMgr-getDDById"></div>/**
1643 * Returns the DragDrop instance for a given id
1645 * @param {String} id the id of the DragDrop object
1646 * @return {DragDrop} the drag drop object, null if it is not found
1649 getDDById: function(id) {
1650 for (var i in this.ids) {
1651 if (this.ids[i][id]) {
1652 return this.ids[i][id];
1659 * Fired after a registered DragDrop object gets the mousedown event.
1660 * Sets up the events required to track the object being dragged
1661 * @method handleMouseDown
1662 * @param {Event} e the event
1663 * @param oDD the DragDrop object being dragged
1667 handleMouseDown: function(e, oDD) {
1669 Ext.QuickTips.disable();
1671 if(this.dragCurrent){
1672 // the original browser mouseup wasn't handled (e.g. outside FF browser window)
1673 // so clean up first to avoid breaking the next drag
1674 this.handleMouseUp(e);
1677 this.currentTarget = e.getTarget();
1678 this.dragCurrent = oDD;
1680 var el = oDD.getEl();
1682 // track start position
1683 this.startX = e.getPageX();
1684 this.startY = e.getPageY();
1686 this.deltaX = this.startX - el.offsetLeft;
1687 this.deltaY = this.startY - el.offsetTop;
1689 this.dragThreshMet = false;
1691 this.clickTimeout = setTimeout(
1693 var DDM = Ext.dd.DDM;
1694 DDM.startDrag(DDM.startX, DDM.startY);
1696 this.clickTimeThresh );
1699 <div id="method-Ext.dd.DragDropMgr-startDrag"></div>/**
1700 * Fired when either the drag pixel threshol or the mousedown hold
1701 * time threshold has been met.
1703 * @param x {int} the X position of the original mousedown
1704 * @param y {int} the Y position of the original mousedown
1707 startDrag: function(x, y) {
1708 clearTimeout(this.clickTimeout);
1709 if (this.dragCurrent) {
1710 this.dragCurrent.b4StartDrag(x, y);
1711 this.dragCurrent.startDrag(x, y);
1713 this.dragThreshMet = true;
1717 * Internal function to handle the mouseup event. Will be invoked
1718 * from the context of the document.
1719 * @method handleMouseUp
1720 * @param {Event} e the event
1724 handleMouseUp: function(e) {
1727 Ext.QuickTips.enable();
1729 if (! this.dragCurrent) {
1733 clearTimeout(this.clickTimeout);
1735 if (this.dragThreshMet) {
1736 this.fireEvents(e, true);
1745 <div id="method-Ext.dd.DragDropMgr-stopEvent"></div>/**
1746 * Utility to stop event propagation and event default, if these
1747 * features are turned on.
1749 * @param {Event} e the event as returned by this.getEvent()
1752 stopEvent: function(e){
1753 if(this.stopPropagation) {
1754 e.stopPropagation();
1757 if (this.preventDefault) {
1763 * Internal function to clean up event handlers after the drag
1764 * operation is complete
1766 * @param {Event} e the event
1770 stopDrag: function(e) {
1771 // Fire the drag end event for the item that was dragged
1772 if (this.dragCurrent) {
1773 if (this.dragThreshMet) {
1774 this.dragCurrent.b4EndDrag(e);
1775 this.dragCurrent.endDrag(e);
1778 this.dragCurrent.onMouseUp(e);
1781 this.dragCurrent = null;
1782 this.dragOvers = {};
1786 * Internal function to handle the mousemove event. Will be invoked
1787 * from the context of the html element.
1789 * @TODO figure out what we can do about mouse events lost when the
1790 * user drags objects beyond the window boundary. Currently we can
1791 * detect this in internet explorer by verifying that the mouse is
1792 * down during the mousemove event. Firefox doesn't give us the
1793 * button state on the mousemove event.
1794 * @method handleMouseMove
1795 * @param {Event} e the event
1799 handleMouseMove: function(e) {
1800 if (! this.dragCurrent) {
1803 // var button = e.which || e.button;
1805 // check for IE mouseup outside of page boundary
1806 if (Ext.isIE && (e.button !== 0 && e.button !== 1 && e.button !== 2)) {
1808 return this.handleMouseUp(e);
1811 if (!this.dragThreshMet) {
1812 var diffX = Math.abs(this.startX - e.getPageX());
1813 var diffY = Math.abs(this.startY - e.getPageY());
1814 if (diffX > this.clickPixelThresh ||
1815 diffY > this.clickPixelThresh) {
1816 this.startDrag(this.startX, this.startY);
1820 if (this.dragThreshMet) {
1821 this.dragCurrent.b4Drag(e);
1822 this.dragCurrent.onDrag(e);
1823 if(!this.dragCurrent.moveOnly){
1824 this.fireEvents(e, false);
1834 * Iterates over all of the DragDrop elements to find ones we are
1835 * hovering over or dropping on
1836 * @method fireEvents
1837 * @param {Event} e the event
1838 * @param {boolean} isDrop is this a drop op or a mouseover op?
1842 fireEvents: function(e, isDrop) {
1843 var dc = this.dragCurrent;
1845 // If the user did the mouse up outside of the window, we could
1846 // get here even though we have ended the drag.
1847 if (!dc || dc.isLocked()) {
1851 var pt = e.getPoint();
1853 // cache the previous dragOver array
1861 // Check to see if the object(s) we were hovering over is no longer
1862 // being hovered over so we can fire the onDragOut event
1863 for (var i in this.dragOvers) {
1865 var ddo = this.dragOvers[i];
1867 if (! this.isTypeOfDD(ddo)) {
1871 if (! this.isOverTarget(pt, ddo, this.mode)) {
1872 outEvts.push( ddo );
1876 delete this.dragOvers[i];
1879 for (var sGroup in dc.groups) {
1881 if ("string" != typeof sGroup) {
1885 for (i in this.ids[sGroup]) {
1886 var oDD = this.ids[sGroup][i];
1887 if (! this.isTypeOfDD(oDD)) {
1891 if (oDD.isTarget && !oDD.isLocked() && ((oDD != dc) || (dc.ignoreSelf === false))) {
1892 if (this.isOverTarget(pt, oDD, this.mode)) {
1893 // look for drop interactions
1895 dropEvts.push( oDD );
1896 // look for drag enter and drag over interactions
1899 // initial drag over: dragEnter fires
1900 if (!oldOvers[oDD.id]) {
1901 enterEvts.push( oDD );
1902 // subsequent drag overs: dragOver fires
1904 overEvts.push( oDD );
1907 this.dragOvers[oDD.id] = oDD;
1915 if (outEvts.length) {
1916 dc.b4DragOut(e, outEvts);
1917 dc.onDragOut(e, outEvts);
1920 if (enterEvts.length) {
1921 dc.onDragEnter(e, enterEvts);
1924 if (overEvts.length) {
1925 dc.b4DragOver(e, overEvts);
1926 dc.onDragOver(e, overEvts);
1929 if (dropEvts.length) {
1930 dc.b4DragDrop(e, dropEvts);
1931 dc.onDragDrop(e, dropEvts);
1935 // fire dragout events
1937 for (i=0, len=outEvts.length; i<len; ++i) {
1938 dc.b4DragOut(e, outEvts[i].id);
1939 dc.onDragOut(e, outEvts[i].id);
1942 // fire enter events
1943 for (i=0,len=enterEvts.length; i<len; ++i) {
1944 // dc.b4DragEnter(e, oDD.id);
1945 dc.onDragEnter(e, enterEvts[i].id);
1949 for (i=0,len=overEvts.length; i<len; ++i) {
1950 dc.b4DragOver(e, overEvts[i].id);
1951 dc.onDragOver(e, overEvts[i].id);
1955 for (i=0, len=dropEvts.length; i<len; ++i) {
1956 dc.b4DragDrop(e, dropEvts[i].id);
1957 dc.onDragDrop(e, dropEvts[i].id);
1962 // notify about a drop that did not find a target
1963 if (isDrop && !dropEvts.length) {
1964 dc.onInvalidDrop(e);
1969 <div id="method-Ext.dd.DragDropMgr-getBestMatch"></div>/**
1970 * Helper function for getting the best match from the list of drag
1971 * and drop objects returned by the drag and drop events when we are
1972 * in INTERSECT mode. It returns either the first object that the
1973 * cursor is over, or the object that has the greatest overlap with
1974 * the dragged element.
1975 * @method getBestMatch
1976 * @param {DragDrop[]} dds The array of drag and drop objects
1978 * @return {DragDrop} The best single match
1981 getBestMatch: function(dds) {
1983 // Return null if the input is not what we expect
1984 //if (!dds || !dds.length || dds.length == 0) {
1986 // If there is only one item, it wins
1987 //} else if (dds.length == 1) {
1989 var len = dds.length;
1994 // Loop through the targeted items
1995 for (var i=0; i<len; ++i) {
1997 // If the cursor is over the object, it wins. If the
1998 // cursor is over multiple matches, the first one we come
2000 if (dd.cursorIsOver) {
2003 // Otherwise the object with the most overlap wins
2006 winner.overlap.getArea() < dd.overlap.getArea()) {
2016 <div id="method-Ext.dd.DragDropMgr-refreshCache"></div>/**
2017 * Refreshes the cache of the top-left and bottom-right points of the
2018 * drag and drop objects in the specified group(s). This is in the
2019 * format that is stored in the drag and drop instance, so typical
2022 * Ext.dd.DragDropMgr.refreshCache(ddinstance.groups);
2026 * Ext.dd.DragDropMgr.refreshCache({group1:true, group2:true});
2028 * @TODO this really should be an indexed array. Alternatively this
2029 * method could accept both.
2030 * @method refreshCache
2031 * @param {Object} groups an associative array of groups to refresh
2034 refreshCache: function(groups) {
2035 for (var sGroup in groups) {
2036 if ("string" != typeof sGroup) {
2039 for (var i in this.ids[sGroup]) {
2040 var oDD = this.ids[sGroup][i];
2042 if (this.isTypeOfDD(oDD)) {
2043 // if (this.isTypeOfDD(oDD) && oDD.isTarget) {
2044 var loc = this.getLocation(oDD);
2046 this.locationCache[oDD.id] = loc;
2048 delete this.locationCache[oDD.id];
2049 // this will unregister the drag and drop object if
2050 // the element is not in a usable state
2058 <div id="method-Ext.dd.DragDropMgr-verifyEl"></div>/**
2059 * This checks to make sure an element exists and is in the DOM. The
2060 * main purpose is to handle cases where innerHTML is used to remove
2061 * drag and drop objects from the DOM. IE provides an 'unspecified
2062 * error' when trying to access the offsetParent of such an element
2064 * @param {HTMLElement} el the element to check
2065 * @return {boolean} true if the element looks usable
2068 verifyEl: function(el) {
2073 parent = el.offsetParent;
2076 parent = el.offsetParent;
2086 <div id="method-Ext.dd.DragDropMgr-getLocation"></div>/**
2087 * Returns a Region object containing the drag and drop element's position
2088 * and size, including the padding configured for it
2089 * @method getLocation
2090 * @param {DragDrop} oDD the drag and drop object to get the
2092 * @return {Ext.lib.Region} a Region object representing the total area
2093 * the element occupies, including any padding
2094 * the instance is configured for.
2097 getLocation: function(oDD) {
2098 if (! this.isTypeOfDD(oDD)) {
2102 var el = oDD.getEl(), pos, x1, x2, y1, y2, t, r, b, l;
2105 pos= Ext.lib.Dom.getXY(el);
2113 x2 = x1 + el.offsetWidth;
2115 y2 = y1 + el.offsetHeight;
2117 t = y1 - oDD.padding[0];
2118 r = x2 + oDD.padding[1];
2119 b = y2 + oDD.padding[2];
2120 l = x1 - oDD.padding[3];
2122 return new Ext.lib.Region( t, r, b, l );
2126 * Checks the cursor location to see if it over the target
2127 * @method isOverTarget
2128 * @param {Ext.lib.Point} pt The point to evaluate
2129 * @param {DragDrop} oTarget the DragDrop object we are inspecting
2130 * @return {boolean} true if the mouse is over the target
2134 isOverTarget: function(pt, oTarget, intersect) {
2135 // use cache if available
2136 var loc = this.locationCache[oTarget.id];
2137 if (!loc || !this.useCache) {
2138 loc = this.getLocation(oTarget);
2139 this.locationCache[oTarget.id] = loc;
2147 oTarget.cursorIsOver = loc.contains( pt );
2149 // DragDrop is using this as a sanity check for the initial mousedown
2150 // in this case we are done. In POINT mode, if the drag obj has no
2151 // contraints, we are also done. Otherwise we need to evaluate the
2152 // location of the target as related to the actual location of the
2154 var dc = this.dragCurrent;
2155 if (!dc || !dc.getTargetCoord ||
2156 (!intersect && !dc.constrainX && !dc.constrainY)) {
2157 return oTarget.cursorIsOver;
2160 oTarget.overlap = null;
2162 // Get the current location of the drag element, this is the
2163 // location of the mouse event less the delta that represents
2164 // where the original mousedown happened on the element. We
2165 // need to consider constraints and ticks as well.
2166 var pos = dc.getTargetCoord(pt.x, pt.y);
2168 var el = dc.getDragEl();
2169 var curRegion = new Ext.lib.Region( pos.y,
2170 pos.x + el.offsetWidth,
2171 pos.y + el.offsetHeight,
2174 var overlap = curRegion.intersect(loc);
2177 oTarget.overlap = overlap;
2178 return (intersect) ? true : oTarget.cursorIsOver;
2185 * unload event handler
2190 _onUnload: function(e, me) {
2191 Ext.dd.DragDropMgr.unregAll();
2195 * Cleans up the drag and drop events and objects.
2200 unregAll: function() {
2202 if (this.dragCurrent) {
2204 this.dragCurrent = null;
2207 this._execOnAll("unreg", []);
2209 for (var i in this.elementCache) {
2210 delete this.elementCache[i];
2213 this.elementCache = {};
2218 * A cache of DOM elements
2219 * @property elementCache
2226 * Get the wrapper for the DOM element specified
2227 * @method getElWrapper
2228 * @param {String} id the id of the element to get
2229 * @return {Ext.dd.DDM.ElementWrapper} the wrapped element
2231 * @deprecated This wrapper isn't that useful
2234 getElWrapper: function(id) {
2235 var oWrapper = this.elementCache[id];
2236 if (!oWrapper || !oWrapper.el) {
2237 oWrapper = this.elementCache[id] =
2238 new this.ElementWrapper(Ext.getDom(id));
2243 <div id="method-Ext.dd.DragDropMgr-getElement"></div>/**
2244 * Returns the actual DOM element
2245 * @method getElement
2246 * @param {String} id the id of the elment to get
2247 * @return {Object} The element
2248 * @deprecated use Ext.lib.Ext.getDom instead
2251 getElement: function(id) {
2252 return Ext.getDom(id);
2255 <div id="method-Ext.dd.DragDropMgr-getCss"></div>/**
2256 * Returns the style property for the DOM element (i.e.,
2257 * document.getElById(id).style)
2259 * @param {String} id the id of the elment to get
2260 * @return {Object} The style property of the element
2261 * @deprecated use Ext.lib.Dom instead
2264 getCss: function(id) {
2265 var el = Ext.getDom(id);
2266 return (el) ? el.style : null;
2269 <div id="cls-DragDropMgr.ElementWrapper"></div>/**
2270 * Inner class for cached elements
2271 * @class DragDropMgr.ElementWrapper
2276 ElementWrapper: function(el) {
2277 <div id="prop-DragDropMgr.ElementWrapper-el"></div>/**
2281 this.el = el || null;
2282 <div id="prop-DragDropMgr.ElementWrapper-id"></div>/**
2286 this.id = this.el && el.id;
2287 <div id="prop-DragDropMgr.ElementWrapper-css"></div>/**
2288 * A reference to the style property
2291 this.css = this.el && el.style;
2294 <div id="method-DragDropMgr.ElementWrapper-getPosX"></div>/**
2295 * Returns the X position of an html element
2297 * @param el the element for which to get the position
2298 * @return {int} the X coordinate
2300 * @deprecated use Ext.lib.Dom.getX instead
2303 getPosX: function(el) {
2304 return Ext.lib.Dom.getX(el);
2307 <div id="method-DragDropMgr.ElementWrapper-getPosY"></div>/**
2308 * Returns the Y position of an html element
2310 * @param el the element for which to get the position
2311 * @return {int} the Y coordinate
2312 * @deprecated use Ext.lib.Dom.getY instead
2315 getPosY: function(el) {
2316 return Ext.lib.Dom.getY(el);
2319 <div id="method-DragDropMgr.ElementWrapper-swapNode"></div>/**
2320 * Swap two nodes. In IE, we use the native method, for others we
2321 * emulate the IE behavior
2323 * @param n1 the first node to swap
2324 * @param n2 the other node to swap
2327 swapNode: function(n1, n2) {
2331 var p = n2.parentNode;
2332 var s = n2.nextSibling;
2335 p.insertBefore(n1, n2);
2336 } else if (n2 == n1.nextSibling) {
2337 p.insertBefore(n2, n1);
2339 n1.parentNode.replaceChild(n2, n1);
2340 p.insertBefore(n1, s);
2346 * Returns the current scroll position
2351 getScroll: function () {
2352 var t, l, dde=document.documentElement, db=document.body;
2353 if (dde && (dde.scrollTop || dde.scrollLeft)) {
2362 return { top: t, left: l };
2365 <div id="method-DragDropMgr.ElementWrapper-getStyle"></div>/**
2366 * Returns the specified element style property
2368 * @param {HTMLElement} el the element
2369 * @param {string} styleProp the style property
2370 * @return {string} The value of the style property
2371 * @deprecated use Ext.lib.Dom.getStyle
2374 getStyle: function(el, styleProp) {
2375 return Ext.fly(el).getStyle(styleProp);
2378 <div id="method-DragDropMgr.ElementWrapper-getScrollTop"></div>/**
2379 * Gets the scrollTop
2380 * @method getScrollTop
2381 * @return {int} the document's scrollTop
2384 getScrollTop: function () { return this.getScroll().top; },
2386 <div id="method-DragDropMgr.ElementWrapper-getScrollLeft"></div>/**
2387 * Gets the scrollLeft
2388 * @method getScrollLeft
2389 * @return {int} the document's scrollTop
2392 getScrollLeft: function () { return this.getScroll().left; },
2394 <div id="method-DragDropMgr.ElementWrapper-moveToEl"></div>/**
2395 * Sets the x/y position of an element to the location of the
2398 * @param {HTMLElement} moveEl The element to move
2399 * @param {HTMLElement} targetEl The position reference element
2402 moveToEl: function (moveEl, targetEl) {
2403 var aCoord = Ext.lib.Dom.getXY(targetEl);
2404 Ext.lib.Dom.setXY(moveEl, aCoord);
2407 <div id="method-DragDropMgr.ElementWrapper-numericSort"></div>/**
2408 * Numeric array sort function
2409 * @method numericSort
2412 numericSort: function(a, b) { return (a - b); },
2416 * @property _timeoutCount
2423 * Trying to make the load order less important. Without this we get
2424 * an error if this file is loaded before the Event Utility.
2425 * @method _addListeners
2429 _addListeners: function() {
2430 var DDM = Ext.dd.DDM;
2431 if ( Ext.lib.Event && document ) {
2434 if (DDM._timeoutCount > 2000) {
2436 setTimeout(DDM._addListeners, 10);
2437 if (document && document.body) {
2438 DDM._timeoutCount += 1;
2444 <div id="method-DragDropMgr.ElementWrapper-handleWasClicked"></div>/**
2445 * Recursively searches the immediate parent and all child nodes for
2446 * the handle element in order to determine wheter or not it was
2448 * @method handleWasClicked
2449 * @param node the html element to inspect
2452 handleWasClicked: function(node, id) {
2453 if (this.isHandle(id, node.id)) {
2456 // check to see if this is a text node child of the one we want
2457 var p = node.parentNode;
2460 if (this.isHandle(id, p.id)) {
2475 // shorter alias, save a few bytes
2476 Ext.dd.DDM = Ext.dd.DragDropMgr;
2477 Ext.dd.DDM._addListeners();
2481 <div id="cls-Ext.dd.DD"></div>/**
2483 * A DragDrop implementation where the linked element follows the
2484 * mouse cursor during a drag.
2485 * @extends Ext.dd.DragDrop
2487 * @param {String} id the id of the linked element
2488 * @param {String} sGroup the group of related DragDrop items
2489 * @param {object} config an object containing configurable attributes
2490 * Valid properties for DD:
2493 Ext.dd.DD = function(id, sGroup, config) {
2495 this.init(id, sGroup, config);
2499 Ext.extend(Ext.dd.DD, Ext.dd.DragDrop, {
2501 <div id="prop-Ext.dd.DD-scroll"></div>/**
2502 * When set to true, the utility automatically tries to scroll the browser
2503 * window when a drag and drop element is dragged near the viewport boundary.
2510 <div id="method-Ext.dd.DD-autoOffset"></div>/**
2511 * Sets the pointer offset to the distance between the linked element's top
2512 * left corner and the location the element was clicked
2513 * @method autoOffset
2514 * @param {int} iPageX the X coordinate of the click
2515 * @param {int} iPageY the Y coordinate of the click
2517 autoOffset: function(iPageX, iPageY) {
2518 var x = iPageX - this.startPageX;
2519 var y = iPageY - this.startPageY;
2520 this.setDelta(x, y);
2523 <div id="method-Ext.dd.DD-setDelta"></div>/**
2524 * Sets the pointer offset. You can call this directly to force the
2525 * offset to be in a particular location (e.g., pass in 0,0 to set it
2526 * to the center of the object)
2528 * @param {int} iDeltaX the distance from the left
2529 * @param {int} iDeltaY the distance from the top
2531 setDelta: function(iDeltaX, iDeltaY) {
2532 this.deltaX = iDeltaX;
2533 this.deltaY = iDeltaY;
2536 <div id="method-Ext.dd.DD-setDragElPos"></div>/**
2537 * Sets the drag element to the location of the mousedown or click event,
2538 * maintaining the cursor location relative to the location on the element
2539 * that was clicked. Override this if you want to place the element in a
2540 * location other than where the cursor is.
2541 * @method setDragElPos
2542 * @param {int} iPageX the X coordinate of the mousedown or drag event
2543 * @param {int} iPageY the Y coordinate of the mousedown or drag event
2545 setDragElPos: function(iPageX, iPageY) {
2546 // the first time we do this, we are going to check to make sure
2547 // the element has css positioning
2549 var el = this.getDragEl();
2550 this.alignElWithMouse(el, iPageX, iPageY);
2553 <div id="method-Ext.dd.DD-alignElWithMouse"></div>/**
2554 * Sets the element to the location of the mousedown or click event,
2555 * maintaining the cursor location relative to the location on the element
2556 * that was clicked. Override this if you want to place the element in a
2557 * location other than where the cursor is.
2558 * @method alignElWithMouse
2559 * @param {HTMLElement} el the element to move
2560 * @param {int} iPageX the X coordinate of the mousedown or drag event
2561 * @param {int} iPageY the Y coordinate of the mousedown or drag event
2563 alignElWithMouse: function(el, iPageX, iPageY) {
2564 var oCoord = this.getTargetCoord(iPageX, iPageY);
2565 var fly = el.dom ? el : Ext.fly(el, '_dd');
2566 if (!this.deltaSetXY) {
2567 var aCoord = [oCoord.x, oCoord.y];
2569 var newLeft = fly.getLeft(true);
2570 var newTop = fly.getTop(true);
2571 this.deltaSetXY = [ newLeft - oCoord.x, newTop - oCoord.y ];
2573 fly.setLeftTop(oCoord.x + this.deltaSetXY[0], oCoord.y + this.deltaSetXY[1]);
2576 this.cachePosition(oCoord.x, oCoord.y);
2577 this.autoScroll(oCoord.x, oCoord.y, el.offsetHeight, el.offsetWidth);
2581 <div id="method-Ext.dd.DD-cachePosition"></div>/**
2582 * Saves the most recent position so that we can reset the constraints and
2583 * tick marks on-demand. We need to know this so that we can calculate the
2584 * number of pixels the element is offset from its original position.
2585 * @method cachePosition
2586 * @param iPageX the current x position (optional, this just makes it so we
2587 * don't have to look it up again)
2588 * @param iPageY the current y position (optional, this just makes it so we
2589 * don't have to look it up again)
2591 cachePosition: function(iPageX, iPageY) {
2593 this.lastPageX = iPageX;
2594 this.lastPageY = iPageY;
2596 var aCoord = Ext.lib.Dom.getXY(this.getEl());
2597 this.lastPageX = aCoord[0];
2598 this.lastPageY = aCoord[1];
2603 * Auto-scroll the window if the dragged object has been moved beyond the
2604 * visible window boundary.
2605 * @method autoScroll
2606 * @param {int} x the drag element's x position
2607 * @param {int} y the drag element's y position
2608 * @param {int} h the height of the drag element
2609 * @param {int} w the width of the drag element
2612 autoScroll: function(x, y, h, w) {
2615 // The client height
2616 var clientH = Ext.lib.Dom.getViewHeight();
2619 var clientW = Ext.lib.Dom.getViewWidth();
2621 // The amt scrolled down
2622 var st = this.DDM.getScrollTop();
2624 // The amt scrolled right
2625 var sl = this.DDM.getScrollLeft();
2627 // Location of the bottom of the element
2630 // Location of the right of the element
2633 // The distance from the cursor to the bottom of the visible area,
2634 // adjusted so that we don't scroll if the cursor is beyond the
2635 // element drag constraints
2636 var toBot = (clientH + st - y - this.deltaY);
2638 // The distance from the cursor to the right of the visible area
2639 var toRight = (clientW + sl - x - this.deltaX);
2642 // How close to the edge the cursor must be before we scroll
2643 // var thresh = (document.all) ? 100 : 40;
2646 // How many pixels to scroll per autoscroll op. This helps to reduce
2647 // clunky scrolling. IE is more sensitive about this ... it needs this
2648 // value to be higher.
2649 var scrAmt = (document.all) ? 80 : 30;
2651 // Scroll down if we are near the bottom of the visible page and the
2652 // obj extends below the crease
2653 if ( bot > clientH && toBot < thresh ) {
2654 window.scrollTo(sl, st + scrAmt);
2657 // Scroll up if the window is scrolled down and the top of the object
2658 // goes above the top border
2659 if ( y < st && st > 0 && y - st < thresh ) {
2660 window.scrollTo(sl, st - scrAmt);
2663 // Scroll right if the obj is beyond the right border and the cursor is
2665 if ( right > clientW && toRight < thresh ) {
2666 window.scrollTo(sl + scrAmt, st);
2669 // Scroll left if the window has been scrolled to the right and the obj
2670 // extends past the left border
2671 if ( x < sl && sl > 0 && x - sl < thresh ) {
2672 window.scrollTo(sl - scrAmt, st);
2678 * Finds the location the element should be placed if we want to move
2679 * it to where the mouse location less the click offset would place us.
2680 * @method getTargetCoord
2681 * @param {int} iPageX the X coordinate of the click
2682 * @param {int} iPageY the Y coordinate of the click
2683 * @return an object that contains the coordinates (Object.x and Object.y)
2686 getTargetCoord: function(iPageX, iPageY) {
2689 var x = iPageX - this.deltaX;
2690 var y = iPageY - this.deltaY;
2692 if (this.constrainX) {
2693 if (x < this.minX) { x = this.minX; }
2694 if (x > this.maxX) { x = this.maxX; }
2697 if (this.constrainY) {
2698 if (y < this.minY) { y = this.minY; }
2699 if (y > this.maxY) { y = this.maxY; }
2702 x = this.getTick(x, this.xTicks);
2703 y = this.getTick(y, this.yTicks);
2709 <div id="method-Ext.dd.DD-applyConfig"></div>/**
2710 * Sets up config options specific to this class. Overrides
2711 * Ext.dd.DragDrop, but all versions of this method through the
2712 * inheritance chain are called
2714 applyConfig: function() {
2715 Ext.dd.DD.superclass.applyConfig.call(this);
2716 this.scroll = (this.config.scroll !== false);
2719 <div id="method-Ext.dd.DD-b4MouseDown"></div>/**
2720 * Event that fires prior to the onMouseDown event. Overrides
2723 b4MouseDown: function(e) {
2724 // this.resetConstraints();
2725 this.autoOffset(e.getPageX(),
2729 <div id="method-Ext.dd.DD-b4Drag"></div>/**
2730 * Event that fires prior to the onDrag event. Overrides
2733 b4Drag: function(e) {
2734 this.setDragElPos(e.getPageX(),
2738 toString: function() {
2739 return ("DD " + this.id);
2742 //////////////////////////////////////////////////////////////////////////
2743 // Debugging ygDragDrop events that can be overridden
2744 //////////////////////////////////////////////////////////////////////////
2746 startDrag: function(x, y) {
2749 onDrag: function(e) {
2752 onDragEnter: function(e, id) {
2755 onDragOver: function(e, id) {
2758 onDragOut: function(e, id) {
2761 onDragDrop: function(e, id) {
2764 endDrag: function(e) {
2770 <div id="cls-Ext.dd.DDProxy"></div>/**
2771 * @class Ext.dd.DDProxy
2772 * A DragDrop implementation that inserts an empty, bordered div into
2773 * the document that follows the cursor during drag operations. At the time of
2774 * the click, the frame div is resized to the dimensions of the linked html
2775 * element, and moved to the exact location of the linked element.
2777 * References to the "frame" element refer to the single proxy element that
2778 * was created to be dragged in place of all DDProxy elements on the
2781 * @extends Ext.dd.DD
2783 * @param {String} id the id of the linked html element
2784 * @param {String} sGroup the group of related DragDrop objects
2785 * @param {object} config an object containing configurable attributes
2786 * Valid properties for DDProxy in addition to those in DragDrop:
2787 * resizeFrame, centerFrame, dragElId
2789 Ext.dd.DDProxy = function(id, sGroup, config) {
2791 this.init(id, sGroup, config);
2796 <div id="prop-Ext.dd.DDProxy-Ext.dd.DDProxy.dragElId"></div>/**
2797 * The default drag frame div id
2798 * @property Ext.dd.DDProxy.dragElId
2802 Ext.dd.DDProxy.dragElId = "ygddfdiv";
2804 Ext.extend(Ext.dd.DDProxy, Ext.dd.DD, {
2806 <div id="prop-Ext.dd.DDProxy-resizeFrame"></div>/**
2807 * By default we resize the drag frame to be the same size as the element
2808 * we want to drag (this is to get the frame effect). We can turn it off
2809 * if we want a different behavior.
2810 * @property resizeFrame
2815 <div id="prop-Ext.dd.DDProxy-centerFrame"></div>/**
2816 * By default the frame is positioned exactly where the drag element is, so
2817 * we use the cursor offset provided by Ext.dd.DD. Another option that works only if
2818 * you do not have constraints on the obj is to have the drag frame centered
2819 * around the cursor. Set centerFrame to true for this effect.
2820 * @property centerFrame
2825 <div id="method-Ext.dd.DDProxy-createFrame"></div>/**
2826 * Creates the proxy element if it does not yet exist
2827 * @method createFrame
2829 createFrame: function() {
2831 var body = document.body;
2833 if (!body || !body.firstChild) {
2834 setTimeout( function() { self.createFrame(); }, 50 );
2838 var div = this.getDragEl();
2841 div = document.createElement("div");
2842 div.id = this.dragElId;
2845 s.position = "absolute";
2846 s.visibility = "hidden";
2848 s.border = "2px solid #aaa";
2851 // appendChild can blow up IE if invoked prior to the window load event
2852 // while rendering a table. It is possible there are other scenarios
2853 // that would cause this to happen as well.
2854 body.insertBefore(div, body.firstChild);
2858 <div id="method-Ext.dd.DDProxy-initFrame"></div>/**
2859 * Initialization for the drag frame element. Must be called in the
2860 * constructor of all subclasses
2863 initFrame: function() {
2867 applyConfig: function() {
2868 Ext.dd.DDProxy.superclass.applyConfig.call(this);
2870 this.resizeFrame = (this.config.resizeFrame !== false);
2871 this.centerFrame = (this.config.centerFrame);
2872 this.setDragElId(this.config.dragElId || Ext.dd.DDProxy.dragElId);
2876 * Resizes the drag frame to the dimensions of the clicked object, positions
2877 * it over the object, and finally displays it
2879 * @param {int} iPageX X click position
2880 * @param {int} iPageY Y click position
2883 showFrame: function(iPageX, iPageY) {
2884 var el = this.getEl();
2885 var dragEl = this.getDragEl();
2886 var s = dragEl.style;
2888 this._resizeProxy();
2890 if (this.centerFrame) {
2891 this.setDelta( Math.round(parseInt(s.width, 10)/2),
2892 Math.round(parseInt(s.height, 10)/2) );
2895 this.setDragElPos(iPageX, iPageY);
2897 Ext.fly(dragEl).show();
2901 * The proxy is automatically resized to the dimensions of the linked
2902 * element when a drag is initiated, unless resizeFrame is set to false
2903 * @method _resizeProxy
2906 _resizeProxy: function() {
2907 if (this.resizeFrame) {
2908 var el = this.getEl();
2909 Ext.fly(this.getDragEl()).setSize(el.offsetWidth, el.offsetHeight);
2913 // overrides Ext.dd.DragDrop
2914 b4MouseDown: function(e) {
2915 var x = e.getPageX();
2916 var y = e.getPageY();
2917 this.autoOffset(x, y);
2918 this.setDragElPos(x, y);
2921 // overrides Ext.dd.DragDrop
2922 b4StartDrag: function(x, y) {
2923 // show the drag frame
2924 this.showFrame(x, y);
2927 // overrides Ext.dd.DragDrop
2928 b4EndDrag: function(e) {
2929 Ext.fly(this.getDragEl()).hide();
2932 // overrides Ext.dd.DragDrop
2933 // By default we try to move the element to the last location of the frame.
2934 // This is so that the default behavior mirrors that of Ext.dd.DD.
2935 endDrag: function(e) {
2937 var lel = this.getEl();
2938 var del = this.getDragEl();
2940 // Show the drag frame briefly so we can get its position
2941 del.style.visibility = "";
2944 // Hide the linked element before the move to get around a Safari
2946 lel.style.visibility = "hidden";
2947 Ext.dd.DDM.moveToEl(lel, del);
2948 del.style.visibility = "hidden";
2949 lel.style.visibility = "";
2954 beforeMove : function(){
2958 afterDrag : function(){
2962 toString: function() {
2963 return ("DDProxy " + this.id);
2967 <div id="cls-Ext.dd.DDTarget"></div>/**
2968 * @class Ext.dd.DDTarget
2969 * A DragDrop implementation that does not move, but can be a drop
2970 * target. You would get the same result by simply omitting implementation
2971 * for the event callbacks, but this way we reduce the processing cost of the
2972 * event listener and the callbacks.
2973 * @extends Ext.dd.DragDrop
2975 * @param {String} id the id of the element that is a drop target
2976 * @param {String} sGroup the group of related DragDrop objects
2977 * @param {object} config an object containing configurable attributes
2978 * Valid properties for DDTarget in addition to those in
2982 Ext.dd.DDTarget = function(id, sGroup, config) {
2984 this.initTarget(id, sGroup, config);
2988 // Ext.dd.DDTarget.prototype = new Ext.dd.DragDrop();
2989 Ext.extend(Ext.dd.DDTarget, Ext.dd.DragDrop, {
2990 toString: function() {
2991 return ("DDTarget " + this.id);