3 <title>The source code</title>
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 <body onload="prettyPrint();">
8 <pre class="prettyprint lang-js">/*!
10 * Copyright(c) 2006-2009 Ext JS, LLC
12 * http://www.extjs.com/license
15 * These classes are derivatives of the similarly named classes in the YUI Library.
16 * The original license:
17 * Copyright (c) 2006, Yahoo! Inc. All rights reserved.
18 * Code licensed under the BSD License:
19 * http://developer.yahoo.net/yui/license.txt
24 var Event=Ext.EventManager;
27 <div id="cls-Ext.dd.DragDrop"></div>/**
28 * @class Ext.dd.DragDrop
29 * Defines the interface and base operation of items that that can be
30 * dragged or can be drop targets. It was designed to be extended, overriding
31 * the event handlers for startDrag, onDrag, onDragOver and onDragOut.
32 * Up to three html elements can be associated with a DragDrop instance:
34 * <li>linked element: the element that is passed into the constructor.
35 * This is the element which defines the boundaries for interaction with
36 * other DragDrop objects.</li>
37 * <li>handle element(s): The drag operation only occurs if the element that
38 * was clicked matches a handle element. By default this is the linked
39 * element, but there are times that you will want only a portion of the
40 * linked element to initiate the drag operation, and the setHandleElId()
41 * method provides a way to define this.</li>
42 * <li>drag element: this represents the element that would be moved along
43 * with the cursor during a drag operation. By default, this is the linked
44 * element itself as in {@link Ext.dd.DD}. setDragElId() lets you define
45 * a separate element that would be moved, as in {@link Ext.dd.DDProxy}.
48 * This class should not be instantiated until the onload event to ensure that
49 * the associated elements are available.
50 * The following would define a DragDrop obj that would interact with any
51 * other DragDrop obj in the "group1" group:
53 * dd = new Ext.dd.DragDrop("div1", "group1");
55 * Since none of the event handlers have been implemented, nothing would
56 * actually happen if you were to run the code above. Normally you would
57 * override this class or one of the default implementations, but you can
58 * also override the methods you want on an instance of the class...
60 * dd.onDragDrop = function(e, id) {
61 * alert("dd was dropped on " + id);
65 * @param {String} id of the element that is linked to this instance
66 * @param {String} sGroup the group of related DragDrop objects
67 * @param {object} config an object containing configurable attributes
68 * Valid properties for DragDrop:
69 * padding, isTarget, maintainOffset, primaryButtonOnly
71 Ext.dd.DragDrop = function(id, sGroup, config) {
73 this.init(id, sGroup, config);
77 Ext.dd.DragDrop.prototype = {
79 <div id="prop-Ext.dd.DragDrop-ignoreSelf"></div>/**
80 * Set to false to enable a DragDrop object to fire drag events while dragging
81 * over its own Element. Defaults to true - DragDrop objects do not by default
82 * fire drag events to themselves.
83 * @property ignoreSelf
87 <div id="prop-Ext.dd.DragDrop-id"></div>/**
88 * The id of the element associated with this object. This is what we
89 * refer to as the "linked element" because the size and position of
90 * this element is used to determine when the drag and drop objects have
97 <div id="prop-Ext.dd.DragDrop-config"></div>/**
98 * Configuration attributes passed into the constructor
105 * The id of the element that will be dragged. By default this is same
106 * as the linked element , but could be changed to another element. Ex:
115 * The ID of the element that initiates the drag operation. By default
116 * this is the linked element, but could be changed to be a child of this
117 * element. This lets us do things like only starting the drag when the
118 * header element within the linked html element is clicked.
119 * @property handleElId
125 <div id="prop-Ext.dd.DragDrop-invalidHandleTypes"></div>/**
126 * An object who's property names identify HTML tags to be considered invalid as drag handles.
127 * A non-null property value identifies the tag as invalid. Defaults to the
128 * following value which prevents drag operations from being initiated by <a> elements:<pre><code>
132 * @property invalidHandleTypes
135 invalidHandleTypes: null,
137 <div id="prop-Ext.dd.DragDrop-invalidHandleIds"></div>/**
138 * An object who's property names identify the IDs of elements to be considered invalid as drag handles.
139 * A non-null property value identifies the ID as invalid. For example, to prevent
140 * dragging from being initiated on element ID "foo", use:<pre><code>
144 * @property invalidHandleIds
147 invalidHandleIds: null,
149 <div id="prop-Ext.dd.DragDrop-invalidHandleClasses"></div>/**
150 * An Array of CSS class names for elements to be considered in valid as drag handles.
151 * @property invalidHandleClasses
154 invalidHandleClasses: null,
157 * The linked element's absolute X position at the time the drag was
159 * @property startPageX
166 * The linked element's absolute X position at the time the drag was
168 * @property startPageY
174 <div id="prop-Ext.dd.DragDrop-groups"></div>/**
175 * The group defines a logical collection of DragDrop objects that are
176 * related. Instances only get events when interacting with other
177 * DragDrop object in the same group. This lets us define multiple
178 * groups using a single DragDrop subclass if we want.
180 * @type object An object in the format {'group1':true, 'group2':true}
185 * Individual drag/drop instances can be locked. This will prevent
186 * onmousedown start drag.
193 <div id="method-Ext.dd.DragDrop-lock"></div>/**
197 lock: function() { this.locked = true; },
199 <div id="prop-Ext.dd.DragDrop-moveOnly"></div>/**
200 * When set to true, other DD objects in cooperating DDGroups do not receive
201 * notification events when this DD object is dragged over them. Defaults to false.
207 <div id="method-Ext.dd.DragDrop-unlock"></div>/**
208 * Unlock this instace
211 unlock: function() { this.locked = false; },
213 <div id="prop-Ext.dd.DragDrop-isTarget"></div>/**
214 * By default, all instances can be a drop target. This can be disabled by
215 * setting isTarget to false.
221 <div id="prop-Ext.dd.DragDrop-padding"></div>/**
222 * The padding configured for this drag and drop object for calculating
223 * the drop zone intersection with this object.
225 * @type int[] An array containing the 4 padding values: [top, right, bottom, left]
230 * Cached reference to the linked element
237 * Internal typeof flag
238 * @property __ygDragDrop
244 * Set to true when horizontal contraints are applied
245 * @property constrainX
252 * Set to true when vertical contraints are applied
253 * @property constrainY
260 * The left constraint
268 * The right constraint
285 * The down constraint
292 <div id="prop-Ext.dd.DragDrop-maintainOffset"></div>/**
293 * Maintain offsets when we resetconstraints. Set to true when you want
294 * the position of the element relative to its parent to stay the same
295 * when the page changes
297 * @property maintainOffset
300 maintainOffset: false,
302 <div id="prop-Ext.dd.DragDrop-xTicks"></div>/**
303 * Array of pixel locations the element will snap to if we specified a
304 * horizontal graduation/interval. This array is generated automatically
305 * when you define a tick interval.
311 <div id="prop-Ext.dd.DragDrop-yTicks"></div>/**
312 * Array of pixel locations the element will snap to if we specified a
313 * vertical graduation/interval. This array is generated automatically
314 * when you define a tick interval.
320 <div id="prop-Ext.dd.DragDrop-primaryButtonOnly"></div>/**
321 * By default the drag and drop instance will only respond to the primary
322 * button click (left button for a right-handed mouse). Set to true to
323 * allow drag and drop to start with any mouse click that is propogated
325 * @property primaryButtonOnly
328 primaryButtonOnly: true,
330 <div id="prop-Ext.dd.DragDrop-available"></div>/**
331 * The availabe property is false until the linked dom element is accessible.
332 * @property available
337 <div id="prop-Ext.dd.DragDrop-hasOuterHandles"></div>/**
338 * By default, drags can only be initiated if the mousedown occurs in the
339 * region the linked element is. This is done in part to work around a
340 * bug in some browsers that mis-report the mousedown if the previous
341 * mouseup happened outside of the window. This property is set to true
342 * if outer handles are defined.
344 * @property hasOuterHandles
348 hasOuterHandles: false,
351 * Code that executes immediately before the startDrag event
352 * @method b4StartDrag
355 b4StartDrag: function(x, y) { },
357 <div id="method-Ext.dd.DragDrop-startDrag"></div>/**
358 * Abstract method called after a drag/drop object is clicked
359 * and the drag or mousedown time thresholds have beeen met.
361 * @param {int} X click location
362 * @param {int} Y click location
364 startDrag: function(x, y) { /* override this */ },
367 * Code that executes immediately before the onDrag event
371 b4Drag: function(e) { },
373 <div id="method-Ext.dd.DragDrop-onDrag"></div>/**
374 * Abstract method called during the onMouseMove event while dragging an
377 * @param {Event} e the mousemove event
379 onDrag: function(e) { /* override this */ },
381 <div id="method-Ext.dd.DragDrop-onDragEnter"></div>/**
382 * Abstract method called when this element fist begins hovering over
383 * another DragDrop obj
384 * @method onDragEnter
385 * @param {Event} e the mousemove event
386 * @param {String|DragDrop[]} id In POINT mode, the element
387 * id this is hovering over. In INTERSECT mode, an array of one or more
388 * dragdrop items being hovered over.
390 onDragEnter: function(e, id) { /* override this */ },
393 * Code that executes immediately before the onDragOver event
397 b4DragOver: function(e) { },
399 <div id="method-Ext.dd.DragDrop-onDragOver"></div>/**
400 * Abstract method called when this element is hovering over another
403 * @param {Event} e the mousemove event
404 * @param {String|DragDrop[]} id In POINT mode, the element
405 * id this is hovering over. In INTERSECT mode, an array of dd items
406 * being hovered over.
408 onDragOver: function(e, id) { /* override this */ },
411 * Code that executes immediately before the onDragOut event
415 b4DragOut: function(e) { },
417 <div id="method-Ext.dd.DragDrop-onDragOut"></div>/**
418 * Abstract method called when we are no longer hovering over an element
420 * @param {Event} e the mousemove event
421 * @param {String|DragDrop[]} id In POINT mode, the element
422 * id this was hovering over. In INTERSECT mode, an array of dd items
423 * that the mouse is no longer over.
425 onDragOut: function(e, id) { /* override this */ },
428 * Code that executes immediately before the onDragDrop event
432 b4DragDrop: function(e) { },
434 <div id="method-Ext.dd.DragDrop-onDragDrop"></div>/**
435 * Abstract method called when this item is dropped on another DragDrop
438 * @param {Event} e the mouseup event
439 * @param {String|DragDrop[]} id In POINT mode, the element
440 * id this was dropped on. In INTERSECT mode, an array of dd items this
443 onDragDrop: function(e, id) { /* override this */ },
445 <div id="method-Ext.dd.DragDrop-onInvalidDrop"></div>/**
446 * Abstract method called when this item is dropped on an area with no
448 * @method onInvalidDrop
449 * @param {Event} e the mouseup event
451 onInvalidDrop: function(e) { /* override this */ },
454 * Code that executes immediately before the endDrag event
458 b4EndDrag: function(e) { },
460 <div id="method-Ext.dd.DragDrop-endDrag"></div>/**
461 * Fired when we are done dragging the object
463 * @param {Event} e the mouseup event
465 endDrag: function(e) { /* override this */ },
468 * Code executed immediately before the onMouseDown event
469 * @method b4MouseDown
470 * @param {Event} e the mousedown event
473 b4MouseDown: function(e) { },
475 <div id="method-Ext.dd.DragDrop-onMouseDown"></div>/**
476 * Event handler that fires when a drag/drop obj gets a mousedown
477 * @method onMouseDown
478 * @param {Event} e the mousedown event
480 onMouseDown: function(e) { /* override this */ },
482 <div id="method-Ext.dd.DragDrop-onMouseUp"></div>/**
483 * Event handler that fires when a drag/drop obj gets a mouseup
485 * @param {Event} e the mouseup event
487 onMouseUp: function(e) { /* override this */ },
489 <div id="method-Ext.dd.DragDrop-onAvailable"></div>/**
490 * Override the onAvailable method to do what is needed after the initial
491 * position was determined.
492 * @method onAvailable
494 onAvailable: function () {
497 <div id="prop-Ext.dd.DragDrop-defaultPadding"></div>/**
498 * Provides default constraint padding to "constrainTo" elements (defaults to {left: 0, right:0, top:0, bottom:0}).
501 defaultPadding : {left:0, right:0, top:0, bottom:0},
503 <div id="method-Ext.dd.DragDrop-constrainTo"></div>/**
504 * Initializes the drag drop object's constraints to restrict movement to a certain element.
508 var dd = new Ext.dd.DDProxy("dragDiv1", "proxytest",
509 { dragElId: "existingProxyDiv" });
510 dd.startDrag = function(){
511 this.constrainTo("parent-id");
514 * Or you can initalize it using the {@link Ext.Element} object:
516 Ext.get("dragDiv1").initDDProxy("proxytest", {dragElId: "existingProxyDiv"}, {
517 startDrag : function(){
518 this.constrainTo("parent-id");
522 * @param {Mixed} constrainTo The element to constrain to.
523 * @param {Object/Number} pad (optional) Pad provides a way to specify "padding" of the constraints,
524 * and can be either a number for symmetrical padding (4 would be equal to {left:4, right:4, top:4, bottom:4}) or
525 * an object containing the sides to pad. For example: {right:10, bottom:10}
526 * @param {Boolean} inContent (optional) Constrain the draggable in the content box of the element (inside padding and borders)
528 constrainTo : function(constrainTo, pad, inContent){
529 if(typeof pad == "number"){
530 pad = {left: pad, right:pad, top:pad, bottom:pad};
532 pad = pad || this.defaultPadding;
533 var b = Ext.get(this.getEl()).getBox();
534 var ce = Ext.get(constrainTo);
535 var s = ce.getScroll();
537 if(cd == document.body){
538 c = { x: s.left, y: s.top, width: Ext.lib.Dom.getViewWidth(), height: Ext.lib.Dom.getViewHeight()};
541 c = {x : xy[0], y: xy[1], width: cd.clientWidth, height: cd.clientHeight};
545 var topSpace = b.y - c.y;
546 var leftSpace = b.x - c.x;
548 this.resetConstraints();
549 this.setXConstraint(leftSpace - (pad.left||0), // left
550 c.width - leftSpace - b.width - (pad.right||0), //right
553 this.setYConstraint(topSpace - (pad.top||0), //top
554 c.height - topSpace - b.height - (pad.bottom||0), //bottom
559 <div id="method-Ext.dd.DragDrop-getEl"></div>/**
560 * Returns a reference to the linked element
562 * @return {HTMLElement} the html element
566 this._domRef = Ext.getDom(this.id);
572 <div id="method-Ext.dd.DragDrop-getDragEl"></div>/**
573 * Returns a reference to the actual element to drag. By default this is
574 * the same as the html element, but it can be assigned to another
575 * element. An example of this can be found in Ext.dd.DDProxy
577 * @return {HTMLElement} the html element
579 getDragEl: function() {
580 return Ext.getDom(this.dragElId);
583 <div id="method-Ext.dd.DragDrop-init"></div>/**
584 * Sets up the DragDrop object. Must be called in the constructor of any
585 * Ext.dd.DragDrop subclass
587 * @param id the id of the linked element
588 * @param {String} sGroup the group of related items
589 * @param {object} config configuration attributes
591 init: function(id, sGroup, config) {
592 this.initTarget(id, sGroup, config);
593 Event.on(this.id, "mousedown", this.handleMouseDown, this);
594 // Event.on(this.id, "selectstart", Event.preventDefault);
597 <div id="method-Ext.dd.DragDrop-initTarget"></div>/**
598 * Initializes Targeting functionality only... the object does not
599 * get a mousedown handler.
601 * @param id the id of the linked element
602 * @param {String} sGroup the group of related items
603 * @param {object} config configuration attributes
605 initTarget: function(id, sGroup, config) {
607 // configuration attributes
608 this.config = config || {};
610 // create a local reference to the drag and drop manager
611 this.DDM = Ext.dd.DDM;
612 // initialize the groups array
615 // assume that we have an element reference instead of an id if the
616 // parameter is not a string
617 if (typeof id !== "string") {
624 // add to an interaction group
625 this.addToGroup((sGroup) ? sGroup : "default");
627 // We don't want to register this as the handle with the manager
628 // so we just set the id rather than calling the setter.
629 this.handleElId = id;
631 // the linked element is the element that gets dragged by default
632 this.setDragElId(id);
634 // by default, clicked anchors will not start drag operations.
635 this.invalidHandleTypes = { A: "A" };
636 this.invalidHandleIds = {};
637 this.invalidHandleClasses = [];
641 this.handleOnAvailable();
644 <div id="method-Ext.dd.DragDrop-applyConfig"></div>/**
645 * Applies the configuration parameters that were passed into the constructor.
646 * This is supposed to happen at each level through the inheritance chain. So
647 * a DDProxy implentation will execute apply config on DDProxy, DD, and
648 * DragDrop in order to get all of the parameters that are available in
650 * @method applyConfig
652 applyConfig: function() {
654 // configurable properties:
655 // padding, isTarget, maintainOffset, primaryButtonOnly
656 this.padding = this.config.padding || [0, 0, 0, 0];
657 this.isTarget = (this.config.isTarget !== false);
658 this.maintainOffset = (this.config.maintainOffset);
659 this.primaryButtonOnly = (this.config.primaryButtonOnly !== false);
664 * Executed when the linked element is available
665 * @method handleOnAvailable
668 handleOnAvailable: function() {
669 this.available = true;
670 this.resetConstraints();
674 <div id="method-Ext.dd.DragDrop-setPadding"></div>/**
675 * Configures the padding for the target zone in px. Effectively expands
676 * (or reduces) the virtual object size for targeting calculations.
677 * Supports css-style shorthand; if only one parameter is passed, all sides
678 * will have that padding, and if only two are passed, the top and bottom
679 * will have the first param, the left and right the second.
681 * @param {int} iTop Top pad
682 * @param {int} iRight Right pad
683 * @param {int} iBot Bot pad
684 * @param {int} iLeft Left pad
686 setPadding: function(iTop, iRight, iBot, iLeft) {
687 // this.padding = [iLeft, iRight, iTop, iBot];
688 if (!iRight && 0 !== iRight) {
689 this.padding = [iTop, iTop, iTop, iTop];
690 } else if (!iBot && 0 !== iBot) {
691 this.padding = [iTop, iRight, iTop, iRight];
693 this.padding = [iTop, iRight, iBot, iLeft];
697 <div id="method-Ext.dd.DragDrop-setInitPosition"></div>/**
698 * Stores the initial placement of the linked element.
699 * @method setInitPosition
700 * @param {int} diffX the X offset, default 0
701 * @param {int} diffY the Y offset, default 0
703 setInitPosition: function(diffX, diffY) {
704 var el = this.getEl();
706 if (!this.DDM.verifyEl(el)) {
713 var p = Dom.getXY( el );
715 this.initPageX = p[0] - dx;
716 this.initPageY = p[1] - dy;
718 this.lastPageX = p[0];
719 this.lastPageY = p[1];
722 this.setStartPosition(p);
726 * Sets the start position of the element. This is set when the obj
727 * is initialized, the reset when a drag is started.
728 * @method setStartPosition
729 * @param pos current position (from previous lookup)
732 setStartPosition: function(pos) {
733 var p = pos || Dom.getXY( this.getEl() );
734 this.deltaSetXY = null;
736 this.startPageX = p[0];
737 this.startPageY = p[1];
740 <div id="method-Ext.dd.DragDrop-addToGroup"></div>/**
741 * Add this instance to a group of related drag/drop objects. All
742 * instances belong to at least one group, and can belong to as many
745 * @param sGroup {string} the name of the group
747 addToGroup: function(sGroup) {
748 this.groups[sGroup] = true;
749 this.DDM.regDragDrop(this, sGroup);
752 <div id="method-Ext.dd.DragDrop-removeFromGroup"></div>/**
753 * Remove's this instance from the supplied interaction group
754 * @method removeFromGroup
755 * @param {string} sGroup The group to drop
757 removeFromGroup: function(sGroup) {
758 if (this.groups[sGroup]) {
759 delete this.groups[sGroup];
762 this.DDM.removeDDFromGroup(this, sGroup);
765 <div id="method-Ext.dd.DragDrop-setDragElId"></div>/**
766 * Allows you to specify that an element other than the linked element
767 * will be moved with the cursor during a drag
768 * @method setDragElId
769 * @param id {string} the id of the element that will be used to initiate the drag
771 setDragElId: function(id) {
775 <div id="method-Ext.dd.DragDrop-setHandleElId"></div>/**
776 * Allows you to specify a child of the linked element that should be
777 * used to initiate the drag operation. An example of this would be if
778 * you have a content div with text and links. Clicking anywhere in the
779 * content area would normally start the drag operation. Use this method
780 * to specify that an element inside of the content div is the element
781 * that starts the drag operation.
782 * @method setHandleElId
783 * @param id {string} the id of the element that will be used to
786 setHandleElId: function(id) {
787 if (typeof id !== "string") {
790 this.handleElId = id;
791 this.DDM.regHandle(this.id, id);
794 <div id="method-Ext.dd.DragDrop-setOuterHandleElId"></div>/**
795 * Allows you to set an element outside of the linked element as a drag
797 * @method setOuterHandleElId
798 * @param id the id of the element that will be used to initiate the drag
800 setOuterHandleElId: function(id) {
801 if (typeof id !== "string") {
804 Event.on(id, "mousedown",
805 this.handleMouseDown, this);
806 this.setHandleElId(id);
808 this.hasOuterHandles = true;
811 <div id="method-Ext.dd.DragDrop-unreg"></div>/**
812 * Remove all drag and drop hooks for this element
816 Event.un(this.id, "mousedown",
817 this.handleMouseDown);
819 this.DDM._remove(this);
822 destroy : function(){
826 <div id="method-Ext.dd.DragDrop-isLocked"></div>/**
827 * Returns true if this instance is locked, or the drag drop mgr is locked
828 * (meaning that all drag/drop is disabled on the page.)
830 * @return {boolean} true if this obj or all drag/drop is locked, else
833 isLocked: function() {
834 return (this.DDM.isLocked() || this.locked);
838 * Fired when this object is clicked
839 * @method handleMouseDown
841 * @param {Ext.dd.DragDrop} oDD the clicked dd object (this dd obj)
844 handleMouseDown: function(e, oDD){
845 if (this.primaryButtonOnly && e.button != 0) {
849 if (this.isLocked()) {
853 this.DDM.refreshCache(this.groups);
855 var pt = new Ext.lib.Point(Ext.lib.Event.getPageX(e), Ext.lib.Event.getPageY(e));
856 if (!this.hasOuterHandles && !this.DDM.isOverTarget(pt, this) ) {
858 if (this.clickValidator(e)) {
860 // set the initial element position
861 this.setStartPosition();
867 this.DDM.handleMouseDown(e, this);
869 this.DDM.stopEvent(e);
877 clickValidator: function(e) {
878 var target = e.getTarget();
879 return ( this.isValidHandleChild(target) &&
880 (this.id == this.handleElId ||
881 this.DDM.handleWasClicked(target, this.id)) );
884 <div id="method-Ext.dd.DragDrop-addInvalidHandleType"></div>/**
885 * Allows you to specify a tag name that should not start a drag operation
886 * when clicked. This is designed to facilitate embedding links within a
887 * drag handle that do something other than start the drag.
888 * @method addInvalidHandleType
889 * @param {string} tagName the type of element to exclude
891 addInvalidHandleType: function(tagName) {
892 var type = tagName.toUpperCase();
893 this.invalidHandleTypes[type] = type;
896 <div id="method-Ext.dd.DragDrop-addInvalidHandleId"></div>/**
897 * Lets you to specify an element id for a child of a drag handle
898 * that should not initiate a drag
899 * @method addInvalidHandleId
900 * @param {string} id the element id of the element you wish to ignore
902 addInvalidHandleId: function(id) {
903 if (typeof id !== "string") {
906 this.invalidHandleIds[id] = id;
909 <div id="method-Ext.dd.DragDrop-addInvalidHandleClass"></div>/**
910 * Lets you specify a css class of elements that will not initiate a drag
911 * @method addInvalidHandleClass
912 * @param {string} cssClass the class of the elements you wish to ignore
914 addInvalidHandleClass: function(cssClass) {
915 this.invalidHandleClasses.push(cssClass);
918 <div id="method-Ext.dd.DragDrop-removeInvalidHandleType"></div>/**
919 * Unsets an excluded tag name set by addInvalidHandleType
920 * @method removeInvalidHandleType
921 * @param {string} tagName the type of element to unexclude
923 removeInvalidHandleType: function(tagName) {
924 var type = tagName.toUpperCase();
925 // this.invalidHandleTypes[type] = null;
926 delete this.invalidHandleTypes[type];
929 <div id="method-Ext.dd.DragDrop-removeInvalidHandleId"></div>/**
930 * Unsets an invalid handle id
931 * @method removeInvalidHandleId
932 * @param {string} id the id of the element to re-enable
934 removeInvalidHandleId: function(id) {
935 if (typeof id !== "string") {
938 delete this.invalidHandleIds[id];
941 <div id="method-Ext.dd.DragDrop-removeInvalidHandleClass"></div>/**
942 * Unsets an invalid css class
943 * @method removeInvalidHandleClass
944 * @param {string} cssClass the class of the element(s) you wish to
947 removeInvalidHandleClass: function(cssClass) {
948 for (var i=0, len=this.invalidHandleClasses.length; i<len; ++i) {
949 if (this.invalidHandleClasses[i] == cssClass) {
950 delete this.invalidHandleClasses[i];
955 <div id="method-Ext.dd.DragDrop-isValidHandleChild"></div>/**
956 * Checks the tag exclusion list to see if this click should be ignored
957 * @method isValidHandleChild
958 * @param {HTMLElement} node the HTMLElement to evaluate
959 * @return {boolean} true if this is a valid tag type, false if not
961 isValidHandleChild: function(node) {
964 // var n = (node.nodeName == "#text") ? node.parentNode : node;
967 nodeName = node.nodeName.toUpperCase();
969 nodeName = node.nodeName;
971 valid = valid && !this.invalidHandleTypes[nodeName];
972 valid = valid && !this.invalidHandleIds[node.id];
974 for (var i=0, len=this.invalidHandleClasses.length; valid && i<len; ++i) {
975 valid = !Ext.fly(node).hasClass(this.invalidHandleClasses[i]);
984 * Create the array of horizontal tick marks if an interval was specified
985 * in setXConstraint().
989 setXTicks: function(iStartX, iTickSize) {
991 this.xTickSize = iTickSize;
995 for (var i = this.initPageX; i >= this.minX; i = i - iTickSize) {
997 this.xTicks[this.xTicks.length] = i;
1002 for (i = this.initPageX; i <= this.maxX; i = i + iTickSize) {
1004 this.xTicks[this.xTicks.length] = i;
1009 this.xTicks.sort(this.DDM.numericSort) ;
1013 * Create the array of vertical tick marks if an interval was specified in
1018 setYTicks: function(iStartY, iTickSize) {
1020 this.yTickSize = iTickSize;
1024 for (var i = this.initPageY; i >= this.minY; i = i - iTickSize) {
1026 this.yTicks[this.yTicks.length] = i;
1031 for (i = this.initPageY; i <= this.maxY; i = i + iTickSize) {
1033 this.yTicks[this.yTicks.length] = i;
1038 this.yTicks.sort(this.DDM.numericSort) ;
1041 <div id="method-Ext.dd.DragDrop-setXConstraint"></div>/**
1042 * By default, the element can be dragged any place on the screen. Use
1043 * this method to limit the horizontal travel of the element. Pass in
1044 * 0,0 for the parameters if you want to lock the drag to the y axis.
1045 * @method setXConstraint
1046 * @param {int} iLeft the number of pixels the element can move to the left
1047 * @param {int} iRight the number of pixels the element can move to the
1049 * @param {int} iTickSize optional parameter for specifying that the
1051 * should move iTickSize pixels at a time.
1053 setXConstraint: function(iLeft, iRight, iTickSize) {
1054 this.leftConstraint = iLeft;
1055 this.rightConstraint = iRight;
1057 this.minX = this.initPageX - iLeft;
1058 this.maxX = this.initPageX + iRight;
1059 if (iTickSize) { this.setXTicks(this.initPageX, iTickSize); }
1061 this.constrainX = true;
1064 <div id="method-Ext.dd.DragDrop-clearConstraints"></div>/**
1065 * Clears any constraints applied to this instance. Also clears ticks
1066 * since they can't exist independent of a constraint at this time.
1067 * @method clearConstraints
1069 clearConstraints: function() {
1070 this.constrainX = false;
1071 this.constrainY = false;
1075 <div id="method-Ext.dd.DragDrop-clearTicks"></div>/**
1076 * Clears any tick interval defined for this instance
1077 * @method clearTicks
1079 clearTicks: function() {
1086 <div id="method-Ext.dd.DragDrop-setYConstraint"></div>/**
1087 * By default, the element can be dragged any place on the screen. Set
1088 * this to limit the vertical travel of the element. Pass in 0,0 for the
1089 * parameters if you want to lock the drag to the x axis.
1090 * @method setYConstraint
1091 * @param {int} iUp the number of pixels the element can move up
1092 * @param {int} iDown the number of pixels the element can move down
1093 * @param {int} iTickSize optional parameter for specifying that the
1094 * element should move iTickSize pixels at a time.
1096 setYConstraint: function(iUp, iDown, iTickSize) {
1097 this.topConstraint = iUp;
1098 this.bottomConstraint = iDown;
1100 this.minY = this.initPageY - iUp;
1101 this.maxY = this.initPageY + iDown;
1102 if (iTickSize) { this.setYTicks(this.initPageY, iTickSize); }
1104 this.constrainY = true;
1108 <div id="method-Ext.dd.DragDrop-resetConstraints"></div>/**
1109 * resetConstraints must be called if you manually reposition a dd element.
1110 * @method resetConstraints
1111 * @param {boolean} maintainOffset
1113 resetConstraints: function() {
1116 // Maintain offsets if necessary
1117 if (this.initPageX || this.initPageX === 0) {
1118 // figure out how much this thing has moved
1119 var dx = (this.maintainOffset) ? this.lastPageX - this.initPageX : 0;
1120 var dy = (this.maintainOffset) ? this.lastPageY - this.initPageY : 0;
1122 this.setInitPosition(dx, dy);
1124 // This is the first time we have detected the element's position
1126 this.setInitPosition();
1129 if (this.constrainX) {
1130 this.setXConstraint( this.leftConstraint,
1131 this.rightConstraint,
1135 if (this.constrainY) {
1136 this.setYConstraint( this.topConstraint,
1137 this.bottomConstraint,
1143 * Normally the drag element is moved pixel by pixel, but we can specify
1144 * that it move a number of pixels at a time. This method resolves the
1145 * location when we have it set up like this.
1147 * @param {int} val where we want to place the object
1148 * @param {int[]} tickArray sorted array of valid points
1149 * @return {int} the closest tick
1152 getTick: function(val, tickArray) {
1155 // If tick interval is not defined, it is effectively 1 pixel,
1156 // so we return the value passed to us.
1158 } else if (tickArray[0] >= val) {
1159 // The value is lower than the first tick, so we return the first
1161 return tickArray[0];
1163 for (var i=0, len=tickArray.length; i<len; ++i) {
1165 if (tickArray[next] && tickArray[next] >= val) {
1166 var diff1 = val - tickArray[i];
1167 var diff2 = tickArray[next] - val;
1168 return (diff2 > diff1) ? tickArray[i] : tickArray[next];
1172 // The value is larger than the last tick, so we return the last
1174 return tickArray[tickArray.length - 1];
1178 <div id="method-Ext.dd.DragDrop-toString"></div>/**
1181 * @return {string} string representation of the dd obj
1183 toString: function() {
1184 return ("DragDrop " + this.id);
1190 <div id="prop-Ext.dd.DragDrop-Only"></div>/**
1191 * The drag and drop utility provides a framework for building drag and drop
1192 * applications. In addition to enabling drag and drop for specific elements,
1193 * the drag and drop elements are tracked by the manager class, and the
1194 * interactions between the various elements are tracked during the drag and
1195 * the implementing code is notified about these important moments.
1198 // Only load the library once. Rewriting the manager class would orphan
1199 // existing drag and drop instances.
1200 if (!Ext.dd.DragDropMgr) {
1202 <div id="cls-Ext.dd.DragDropMgr"></div>/**
1203 * @class Ext.dd.DragDropMgr
1204 * DragDropMgr is a singleton that tracks the element interaction for
1205 * all DragDrop items in the window. Generally, you will not call
1206 * this class directly, but it does have helper methods that could
1207 * be useful in your DragDrop implementations.
1210 Ext.dd.DragDropMgr = function() {
1212 var Event = Ext.EventManager;
1217 * Two dimensional Array of registered DragDrop objects. The first
1218 * dimension is the DragDrop item group, the second the DragDrop
1221 * @type {string: string}
1228 * Array of element ids defined as drag handles. Used to determine
1229 * if the element that generated the mousedown event is actually the
1230 * handle and not the html element itself.
1231 * @property handleIds
1232 * @type {string: string}
1239 * the DragDrop object that is currently being dragged
1240 * @property dragCurrent
1248 * the DragDrop object(s) that are being hovered over
1249 * @property dragOvers
1257 * the X distance between the cursor and the object being dragged
1266 * the Y distance between the cursor and the object being dragged
1274 <div id="prop-Ext.dd.DragDropMgr-preventDefault"></div>/**
1275 * Flag to determine if we should prevent the default behavior of the
1276 * events we define. By default this is true, but this can be set to
1277 * false if you need the default behavior (not recommended)
1278 * @property preventDefault
1282 preventDefault: true,
1284 <div id="prop-Ext.dd.DragDropMgr-stopPropagation"></div>/**
1285 * Flag to determine if we should stop the propagation of the events
1286 * we generate. This is true by default but you may want to set it to
1287 * false if the html element contains other features that require the
1289 * @property stopPropagation
1293 stopPropagation: true,
1296 * Internal flag that is set to true when drag and drop has been
1298 * @property initialized
1305 * All drag and drop can be disabled.
1313 * Called the first time an element is registered.
1319 this.initialized = true;
1322 <div id="prop-Ext.dd.DragDropMgr-POINT"></div>/**
1323 * In point mode, drag and drop interaction is defined by the
1324 * location of the cursor during the drag/drop
1331 <div id="prop-Ext.dd.DragDropMgr-INTERSECT"></div>/**
1332 * In intersect mode, drag and drop interaction is defined by the
1333 * overlap of two or more drag and drop objects.
1334 * @property INTERSECT
1340 <div id="prop-Ext.dd.DragDropMgr-mode"></div>/**
1341 * The current drag and drop mode. Default: POINT
1349 * Runs method on all drag and drop objects
1350 * @method _execOnAll
1354 _execOnAll: function(sMethod, args) {
1355 for (var i in this.ids) {
1356 for (var j in this.ids[i]) {
1357 var oDD = this.ids[i][j];
1358 if (! this.isTypeOfDD(oDD)) {
1361 oDD[sMethod].apply(oDD, args);
1367 * Drag and drop initialization. Sets up the global event handlers
1372 _onLoad: function() {
1377 Event.on(document, "mouseup", this.handleMouseUp, this, true);
1378 Event.on(document, "mousemove", this.handleMouseMove, this, true);
1379 Event.on(window, "unload", this._onUnload, this, true);
1380 Event.on(window, "resize", this._onResize, this, true);
1381 // Event.on(window, "mouseout", this._test);
1386 * Reset constraints on all drag and drop objs
1391 _onResize: function(e) {
1392 this._execOnAll("resetConstraints", []);
1395 <div id="method-Ext.dd.DragDropMgr-lock"></div>/**
1396 * Lock all drag and drop functionality
1400 lock: function() { this.locked = true; },
1402 <div id="method-Ext.dd.DragDropMgr-unlock"></div>/**
1403 * Unlock all drag and drop functionality
1407 unlock: function() { this.locked = false; },
1409 <div id="method-Ext.dd.DragDropMgr-isLocked"></div>/**
1410 * Is drag and drop locked?
1412 * @return {boolean} True if drag and drop is locked, false otherwise.
1415 isLocked: function() { return this.locked; },
1418 * Location cache that is set for all drag drop objects when a drag is
1419 * initiated, cleared when the drag is finished.
1420 * @property locationCache
1426 <div id="prop-Ext.dd.DragDropMgr-useCache"></div>/**
1427 * Set useCache to false if you want to force object the lookup of each
1428 * drag and drop linked element constantly during a drag.
1429 * @property useCache
1435 <div id="prop-Ext.dd.DragDropMgr-clickPixelThresh"></div>/**
1436 * The number of pixels that the mouse needs to move after the
1437 * mousedown before the drag is initiated. Default=3;
1438 * @property clickPixelThresh
1442 clickPixelThresh: 3,
1444 <div id="prop-Ext.dd.DragDropMgr-clickTimeThresh"></div>/**
1445 * The number of milliseconds after the mousedown event to initiate the
1446 * drag if we don't get a mouseup event. Default=1000
1447 * @property clickTimeThresh
1451 clickTimeThresh: 350,
1454 * Flag that indicates that either the drag pixel threshold or the
1455 * mousdown time threshold has been met
1456 * @property dragThreshMet
1461 dragThreshMet: false,
1464 * Timeout used for the click time threshold
1465 * @property clickTimeout
1473 * The X position of the mousedown event stored for later use when a
1474 * drag threshold is met.
1483 * The Y position of the mousedown event stored for later use when a
1484 * drag threshold is met.
1492 <div id="method-Ext.dd.DragDropMgr-regDragDrop"></div>/**
1493 * Each DragDrop instance must be registered with the DragDropMgr.
1494 * This is executed in DragDrop.init()
1495 * @method regDragDrop
1496 * @param {DragDrop} oDD the DragDrop object to register
1497 * @param {String} sGroup the name of the group this element belongs to
1500 regDragDrop: function(oDD, sGroup) {
1501 if (!this.initialized) { this.init(); }
1503 if (!this.ids[sGroup]) {
1504 this.ids[sGroup] = {};
1506 this.ids[sGroup][oDD.id] = oDD;
1510 * Removes the supplied dd instance from the supplied group. Executed
1511 * by DragDrop.removeFromGroup, so don't call this function directly.
1512 * @method removeDDFromGroup
1516 removeDDFromGroup: function(oDD, sGroup) {
1517 if (!this.ids[sGroup]) {
1518 this.ids[sGroup] = {};
1521 var obj = this.ids[sGroup];
1522 if (obj && obj[oDD.id]) {
1528 * Unregisters a drag and drop item. This is executed in
1529 * DragDrop.unreg, use that method instead of calling this directly.
1534 _remove: function(oDD) {
1535 for (var g in oDD.groups) {
1536 if (g && this.ids[g] && this.ids[g][oDD.id]) {
1537 delete this.ids[g][oDD.id];
1540 delete this.handleIds[oDD.id];
1543 <div id="method-Ext.dd.DragDropMgr-regHandle"></div>/**
1544 * Each DragDrop handle element must be registered. This is done
1545 * automatically when executing DragDrop.setHandleElId()
1547 * @param {String} sDDId the DragDrop id this element is a handle for
1548 * @param {String} sHandleId the id of the element that is the drag
1552 regHandle: function(sDDId, sHandleId) {
1553 if (!this.handleIds[sDDId]) {
1554 this.handleIds[sDDId] = {};
1556 this.handleIds[sDDId][sHandleId] = sHandleId;
1559 <div id="method-Ext.dd.DragDropMgr-isDragDrop"></div>/**
1560 * Utility function to determine if a given element has been
1561 * registered as a drag drop item.
1562 * @method isDragDrop
1563 * @param {String} id the element id to check
1564 * @return {boolean} true if this element is a DragDrop item,
1568 isDragDrop: function(id) {
1569 return ( this.getDDById(id) ) ? true : false;
1572 <div id="method-Ext.dd.DragDropMgr-getRelated"></div>/**
1573 * Returns the drag and drop instances that are in all groups the
1574 * passed in instance belongs to.
1575 * @method getRelated
1576 * @param {DragDrop} p_oDD the obj to get related data for
1577 * @param {boolean} bTargetsOnly if true, only return targetable objs
1578 * @return {DragDrop[]} the related instances
1581 getRelated: function(p_oDD, bTargetsOnly) {
1583 for (var i in p_oDD.groups) {
1584 for (var j in this.ids[i]) {
1585 var dd = this.ids[i][j];
1586 if (! this.isTypeOfDD(dd)) {
1589 if (!bTargetsOnly || dd.isTarget) {
1590 oDDs[oDDs.length] = dd;
1598 <div id="method-Ext.dd.DragDropMgr-isLegalTarget"></div>/**
1599 * Returns true if the specified dd target is a legal target for
1600 * the specifice drag obj
1601 * @method isLegalTarget
1602 * @param {DragDrop} the drag obj
1603 * @param {DragDrop} the target
1604 * @return {boolean} true if the target is a legal target for the
1608 isLegalTarget: function (oDD, oTargetDD) {
1609 var targets = this.getRelated(oDD, true);
1610 for (var i=0, len=targets.length;i<len;++i) {
1611 if (targets[i].id == oTargetDD.id) {
1619 <div id="method-Ext.dd.DragDropMgr-isTypeOfDD"></div>/**
1620 * My goal is to be able to transparently determine if an object is
1621 * typeof DragDrop, and the exact subclass of DragDrop. typeof
1622 * returns "object", oDD.constructor.toString() always returns
1623 * "DragDrop" and not the name of the subclass. So for now it just
1624 * evaluates a well-known variable in DragDrop.
1625 * @method isTypeOfDD
1626 * @param {Object} the object to evaluate
1627 * @return {boolean} true if typeof oDD = DragDrop
1630 isTypeOfDD: function (oDD) {
1631 return (oDD && oDD.__ygDragDrop);
1634 <div id="method-Ext.dd.DragDropMgr-isHandle"></div>/**
1635 * Utility function to determine if a given element has been
1636 * registered as a drag drop handle for the given Drag Drop object.
1638 * @param {String} id the element id to check
1639 * @return {boolean} true if this element is a DragDrop handle, false
1643 isHandle: function(sDDId, sHandleId) {
1644 return ( this.handleIds[sDDId] &&
1645 this.handleIds[sDDId][sHandleId] );
1648 <div id="method-Ext.dd.DragDropMgr-getDDById"></div>/**
1649 * Returns the DragDrop instance for a given id
1651 * @param {String} id the id of the DragDrop object
1652 * @return {DragDrop} the drag drop object, null if it is not found
1655 getDDById: function(id) {
1656 for (var i in this.ids) {
1657 if (this.ids[i][id]) {
1658 return this.ids[i][id];
1665 * Fired after a registered DragDrop object gets the mousedown event.
1666 * Sets up the events required to track the object being dragged
1667 * @method handleMouseDown
1668 * @param {Event} e the event
1669 * @param oDD the DragDrop object being dragged
1673 handleMouseDown: function(e, oDD) {
1675 Ext.QuickTips.disable();
1677 if(this.dragCurrent){
1678 // the original browser mouseup wasn't handled (e.g. outside FF browser window)
1679 // so clean up first to avoid breaking the next drag
1680 this.handleMouseUp(e);
1683 this.currentTarget = e.getTarget();
1684 this.dragCurrent = oDD;
1686 var el = oDD.getEl();
1688 // track start position
1689 this.startX = e.getPageX();
1690 this.startY = e.getPageY();
1692 this.deltaX = this.startX - el.offsetLeft;
1693 this.deltaY = this.startY - el.offsetTop;
1695 this.dragThreshMet = false;
1697 this.clickTimeout = setTimeout(
1699 var DDM = Ext.dd.DDM;
1700 DDM.startDrag(DDM.startX, DDM.startY);
1702 this.clickTimeThresh );
1705 <div id="method-Ext.dd.DragDropMgr-startDrag"></div>/**
1706 * Fired when either the drag pixel threshol or the mousedown hold
1707 * time threshold has been met.
1709 * @param x {int} the X position of the original mousedown
1710 * @param y {int} the Y position of the original mousedown
1713 startDrag: function(x, y) {
1714 clearTimeout(this.clickTimeout);
1715 if (this.dragCurrent) {
1716 this.dragCurrent.b4StartDrag(x, y);
1717 this.dragCurrent.startDrag(x, y);
1719 this.dragThreshMet = true;
1723 * Internal function to handle the mouseup event. Will be invoked
1724 * from the context of the document.
1725 * @method handleMouseUp
1726 * @param {Event} e the event
1730 handleMouseUp: function(e) {
1733 Ext.QuickTips.enable();
1735 if (! this.dragCurrent) {
1739 clearTimeout(this.clickTimeout);
1741 if (this.dragThreshMet) {
1742 this.fireEvents(e, true);
1751 <div id="method-Ext.dd.DragDropMgr-stopEvent"></div>/**
1752 * Utility to stop event propagation and event default, if these
1753 * features are turned on.
1755 * @param {Event} e the event as returned by this.getEvent()
1758 stopEvent: function(e){
1759 if(this.stopPropagation) {
1760 e.stopPropagation();
1763 if (this.preventDefault) {
1769 * Internal function to clean up event handlers after the drag
1770 * operation is complete
1772 * @param {Event} e the event
1776 stopDrag: function(e) {
1777 // Fire the drag end event for the item that was dragged
1778 if (this.dragCurrent) {
1779 if (this.dragThreshMet) {
1780 this.dragCurrent.b4EndDrag(e);
1781 this.dragCurrent.endDrag(e);
1784 this.dragCurrent.onMouseUp(e);
1787 this.dragCurrent = null;
1788 this.dragOvers = {};
1792 * Internal function to handle the mousemove event. Will be invoked
1793 * from the context of the html element.
1795 * @TODO figure out what we can do about mouse events lost when the
1796 * user drags objects beyond the window boundary. Currently we can
1797 * detect this in internet explorer by verifying that the mouse is
1798 * down during the mousemove event. Firefox doesn't give us the
1799 * button state on the mousemove event.
1800 * @method handleMouseMove
1801 * @param {Event} e the event
1805 handleMouseMove: function(e) {
1806 if (! this.dragCurrent) {
1809 // var button = e.which || e.button;
1811 // check for IE mouseup outside of page boundary
1812 if (Ext.isIE && (e.button !== 0 && e.button !== 1 && e.button !== 2)) {
1814 return this.handleMouseUp(e);
1817 if (!this.dragThreshMet) {
1818 var diffX = Math.abs(this.startX - e.getPageX());
1819 var diffY = Math.abs(this.startY - e.getPageY());
1820 if (diffX > this.clickPixelThresh ||
1821 diffY > this.clickPixelThresh) {
1822 this.startDrag(this.startX, this.startY);
1826 if (this.dragThreshMet) {
1827 this.dragCurrent.b4Drag(e);
1828 this.dragCurrent.onDrag(e);
1829 if(!this.dragCurrent.moveOnly){
1830 this.fireEvents(e, false);
1840 * Iterates over all of the DragDrop elements to find ones we are
1841 * hovering over or dropping on
1842 * @method fireEvents
1843 * @param {Event} e the event
1844 * @param {boolean} isDrop is this a drop op or a mouseover op?
1848 fireEvents: function(e, isDrop) {
1849 var dc = this.dragCurrent;
1851 // If the user did the mouse up outside of the window, we could
1852 // get here even though we have ended the drag.
1853 if (!dc || dc.isLocked()) {
1857 var pt = e.getPoint();
1859 // cache the previous dragOver array
1867 // Check to see if the object(s) we were hovering over is no longer
1868 // being hovered over so we can fire the onDragOut event
1869 for (var i in this.dragOvers) {
1871 var ddo = this.dragOvers[i];
1873 if (! this.isTypeOfDD(ddo)) {
1877 if (! this.isOverTarget(pt, ddo, this.mode)) {
1878 outEvts.push( ddo );
1882 delete this.dragOvers[i];
1885 for (var sGroup in dc.groups) {
1887 if ("string" != typeof sGroup) {
1891 for (i in this.ids[sGroup]) {
1892 var oDD = this.ids[sGroup][i];
1893 if (! this.isTypeOfDD(oDD)) {
1897 if (oDD.isTarget && !oDD.isLocked() && ((oDD != dc) || (dc.ignoreSelf === false))) {
1898 if (this.isOverTarget(pt, oDD, this.mode)) {
1899 // look for drop interactions
1901 dropEvts.push( oDD );
1902 // look for drag enter and drag over interactions
1905 // initial drag over: dragEnter fires
1906 if (!oldOvers[oDD.id]) {
1907 enterEvts.push( oDD );
1908 // subsequent drag overs: dragOver fires
1910 overEvts.push( oDD );
1913 this.dragOvers[oDD.id] = oDD;
1921 if (outEvts.length) {
1922 dc.b4DragOut(e, outEvts);
1923 dc.onDragOut(e, outEvts);
1926 if (enterEvts.length) {
1927 dc.onDragEnter(e, enterEvts);
1930 if (overEvts.length) {
1931 dc.b4DragOver(e, overEvts);
1932 dc.onDragOver(e, overEvts);
1935 if (dropEvts.length) {
1936 dc.b4DragDrop(e, dropEvts);
1937 dc.onDragDrop(e, dropEvts);
1941 // fire dragout events
1943 for (i=0, len=outEvts.length; i<len; ++i) {
1944 dc.b4DragOut(e, outEvts[i].id);
1945 dc.onDragOut(e, outEvts[i].id);
1948 // fire enter events
1949 for (i=0,len=enterEvts.length; i<len; ++i) {
1950 // dc.b4DragEnter(e, oDD.id);
1951 dc.onDragEnter(e, enterEvts[i].id);
1955 for (i=0,len=overEvts.length; i<len; ++i) {
1956 dc.b4DragOver(e, overEvts[i].id);
1957 dc.onDragOver(e, overEvts[i].id);
1961 for (i=0, len=dropEvts.length; i<len; ++i) {
1962 dc.b4DragDrop(e, dropEvts[i].id);
1963 dc.onDragDrop(e, dropEvts[i].id);
1968 // notify about a drop that did not find a target
1969 if (isDrop && !dropEvts.length) {
1970 dc.onInvalidDrop(e);
1975 <div id="method-Ext.dd.DragDropMgr-getBestMatch"></div>/**
1976 * Helper function for getting the best match from the list of drag
1977 * and drop objects returned by the drag and drop events when we are
1978 * in INTERSECT mode. It returns either the first object that the
1979 * cursor is over, or the object that has the greatest overlap with
1980 * the dragged element.
1981 * @method getBestMatch
1982 * @param {DragDrop[]} dds The array of drag and drop objects
1984 * @return {DragDrop} The best single match
1987 getBestMatch: function(dds) {
1989 // Return null if the input is not what we expect
1990 //if (!dds || !dds.length || dds.length == 0) {
1992 // If there is only one item, it wins
1993 //} else if (dds.length == 1) {
1995 var len = dds.length;
2000 // Loop through the targeted items
2001 for (var i=0; i<len; ++i) {
2003 // If the cursor is over the object, it wins. If the
2004 // cursor is over multiple matches, the first one we come
2006 if (dd.cursorIsOver) {
2009 // Otherwise the object with the most overlap wins
2012 winner.overlap.getArea() < dd.overlap.getArea()) {
2022 <div id="method-Ext.dd.DragDropMgr-refreshCache"></div>/**
2023 * Refreshes the cache of the top-left and bottom-right points of the
2024 * drag and drop objects in the specified group(s). This is in the
2025 * format that is stored in the drag and drop instance, so typical
2028 * Ext.dd.DragDropMgr.refreshCache(ddinstance.groups);
2032 * Ext.dd.DragDropMgr.refreshCache({group1:true, group2:true});
2034 * @TODO this really should be an indexed array. Alternatively this
2035 * method could accept both.
2036 * @method refreshCache
2037 * @param {Object} groups an associative array of groups to refresh
2040 refreshCache: function(groups) {
2041 for (var sGroup in groups) {
2042 if ("string" != typeof sGroup) {
2045 for (var i in this.ids[sGroup]) {
2046 var oDD = this.ids[sGroup][i];
2048 if (this.isTypeOfDD(oDD)) {
2049 // if (this.isTypeOfDD(oDD) && oDD.isTarget) {
2050 var loc = this.getLocation(oDD);
2052 this.locationCache[oDD.id] = loc;
2054 delete this.locationCache[oDD.id];
2055 // this will unregister the drag and drop object if
2056 // the element is not in a usable state
2064 <div id="method-Ext.dd.DragDropMgr-verifyEl"></div>/**
2065 * This checks to make sure an element exists and is in the DOM. The
2066 * main purpose is to handle cases where innerHTML is used to remove
2067 * drag and drop objects from the DOM. IE provides an 'unspecified
2068 * error' when trying to access the offsetParent of such an element
2070 * @param {HTMLElement} el the element to check
2071 * @return {boolean} true if the element looks usable
2074 verifyEl: function(el) {
2079 parent = el.offsetParent;
2082 parent = el.offsetParent;
2092 <div id="method-Ext.dd.DragDropMgr-getLocation"></div>/**
2093 * Returns a Region object containing the drag and drop element's position
2094 * and size, including the padding configured for it
2095 * @method getLocation
2096 * @param {DragDrop} oDD the drag and drop object to get the
2098 * @return {Ext.lib.Region} a Region object representing the total area
2099 * the element occupies, including any padding
2100 * the instance is configured for.
2103 getLocation: function(oDD) {
2104 if (! this.isTypeOfDD(oDD)) {
2108 var el = oDD.getEl(), pos, x1, x2, y1, y2, t, r, b, l;
2111 pos= Ext.lib.Dom.getXY(el);
2119 x2 = x1 + el.offsetWidth;
2121 y2 = y1 + el.offsetHeight;
2123 t = y1 - oDD.padding[0];
2124 r = x2 + oDD.padding[1];
2125 b = y2 + oDD.padding[2];
2126 l = x1 - oDD.padding[3];
2128 return new Ext.lib.Region( t, r, b, l );
2132 * Checks the cursor location to see if it over the target
2133 * @method isOverTarget
2134 * @param {Ext.lib.Point} pt The point to evaluate
2135 * @param {DragDrop} oTarget the DragDrop object we are inspecting
2136 * @return {boolean} true if the mouse is over the target
2140 isOverTarget: function(pt, oTarget, intersect) {
2141 // use cache if available
2142 var loc = this.locationCache[oTarget.id];
2143 if (!loc || !this.useCache) {
2144 loc = this.getLocation(oTarget);
2145 this.locationCache[oTarget.id] = loc;
2153 oTarget.cursorIsOver = loc.contains( pt );
2155 // DragDrop is using this as a sanity check for the initial mousedown
2156 // in this case we are done. In POINT mode, if the drag obj has no
2157 // contraints, we are also done. Otherwise we need to evaluate the
2158 // location of the target as related to the actual location of the
2160 var dc = this.dragCurrent;
2161 if (!dc || !dc.getTargetCoord ||
2162 (!intersect && !dc.constrainX && !dc.constrainY)) {
2163 return oTarget.cursorIsOver;
2166 oTarget.overlap = null;
2168 // Get the current location of the drag element, this is the
2169 // location of the mouse event less the delta that represents
2170 // where the original mousedown happened on the element. We
2171 // need to consider constraints and ticks as well.
2172 var pos = dc.getTargetCoord(pt.x, pt.y);
2174 var el = dc.getDragEl();
2175 var curRegion = new Ext.lib.Region( pos.y,
2176 pos.x + el.offsetWidth,
2177 pos.y + el.offsetHeight,
2180 var overlap = curRegion.intersect(loc);
2183 oTarget.overlap = overlap;
2184 return (intersect) ? true : oTarget.cursorIsOver;
2191 * unload event handler
2196 _onUnload: function(e, me) {
2197 Ext.dd.DragDropMgr.unregAll();
2201 * Cleans up the drag and drop events and objects.
2206 unregAll: function() {
2208 if (this.dragCurrent) {
2210 this.dragCurrent = null;
2213 this._execOnAll("unreg", []);
2215 for (var i in this.elementCache) {
2216 delete this.elementCache[i];
2219 this.elementCache = {};
2224 * A cache of DOM elements
2225 * @property elementCache
2232 * Get the wrapper for the DOM element specified
2233 * @method getElWrapper
2234 * @param {String} id the id of the element to get
2235 * @return {Ext.dd.DDM.ElementWrapper} the wrapped element
2237 * @deprecated This wrapper isn't that useful
2240 getElWrapper: function(id) {
2241 var oWrapper = this.elementCache[id];
2242 if (!oWrapper || !oWrapper.el) {
2243 oWrapper = this.elementCache[id] =
2244 new this.ElementWrapper(Ext.getDom(id));
2249 <div id="method-Ext.dd.DragDropMgr-getElement"></div>/**
2250 * Returns the actual DOM element
2251 * @method getElement
2252 * @param {String} id the id of the elment to get
2253 * @return {Object} The element
2254 * @deprecated use Ext.lib.Ext.getDom instead
2257 getElement: function(id) {
2258 return Ext.getDom(id);
2261 <div id="method-Ext.dd.DragDropMgr-getCss"></div>/**
2262 * Returns the style property for the DOM element (i.e.,
2263 * document.getElById(id).style)
2265 * @param {String} id the id of the elment to get
2266 * @return {Object} The style property of the element
2267 * @deprecated use Ext.lib.Dom instead
2270 getCss: function(id) {
2271 var el = Ext.getDom(id);
2272 return (el) ? el.style : null;
2275 <div id="cls-DragDropMgr.ElementWrapper"></div>/**
2276 * Inner class for cached elements
2277 * @class DragDropMgr.ElementWrapper
2282 ElementWrapper: function(el) {
2283 <div id="prop-DragDropMgr.ElementWrapper-el"></div>/**
2287 this.el = el || null;
2288 <div id="prop-DragDropMgr.ElementWrapper-id"></div>/**
2292 this.id = this.el && el.id;
2293 <div id="prop-DragDropMgr.ElementWrapper-css"></div>/**
2294 * A reference to the style property
2297 this.css = this.el && el.style;
2300 <div id="method-DragDropMgr.ElementWrapper-getPosX"></div>/**
2301 * Returns the X position of an html element
2303 * @param el the element for which to get the position
2304 * @return {int} the X coordinate
2306 * @deprecated use Ext.lib.Dom.getX instead
2309 getPosX: function(el) {
2310 return Ext.lib.Dom.getX(el);
2313 <div id="method-DragDropMgr.ElementWrapper-getPosY"></div>/**
2314 * Returns the Y position of an html element
2316 * @param el the element for which to get the position
2317 * @return {int} the Y coordinate
2318 * @deprecated use Ext.lib.Dom.getY instead
2321 getPosY: function(el) {
2322 return Ext.lib.Dom.getY(el);
2325 <div id="method-DragDropMgr.ElementWrapper-swapNode"></div>/**
2326 * Swap two nodes. In IE, we use the native method, for others we
2327 * emulate the IE behavior
2329 * @param n1 the first node to swap
2330 * @param n2 the other node to swap
2333 swapNode: function(n1, n2) {
2337 var p = n2.parentNode;
2338 var s = n2.nextSibling;
2341 p.insertBefore(n1, n2);
2342 } else if (n2 == n1.nextSibling) {
2343 p.insertBefore(n2, n1);
2345 n1.parentNode.replaceChild(n2, n1);
2346 p.insertBefore(n1, s);
2352 * Returns the current scroll position
2357 getScroll: function () {
2358 var t, l, dde=document.documentElement, db=document.body;
2359 if (dde && (dde.scrollTop || dde.scrollLeft)) {
2368 return { top: t, left: l };
2371 <div id="method-DragDropMgr.ElementWrapper-getStyle"></div>/**
2372 * Returns the specified element style property
2374 * @param {HTMLElement} el the element
2375 * @param {string} styleProp the style property
2376 * @return {string} The value of the style property
2377 * @deprecated use Ext.lib.Dom.getStyle
2380 getStyle: function(el, styleProp) {
2381 return Ext.fly(el).getStyle(styleProp);
2384 <div id="method-DragDropMgr.ElementWrapper-getScrollTop"></div>/**
2385 * Gets the scrollTop
2386 * @method getScrollTop
2387 * @return {int} the document's scrollTop
2390 getScrollTop: function () { return this.getScroll().top; },
2392 <div id="method-DragDropMgr.ElementWrapper-getScrollLeft"></div>/**
2393 * Gets the scrollLeft
2394 * @method getScrollLeft
2395 * @return {int} the document's scrollTop
2398 getScrollLeft: function () { return this.getScroll().left; },
2400 <div id="method-DragDropMgr.ElementWrapper-moveToEl"></div>/**
2401 * Sets the x/y position of an element to the location of the
2404 * @param {HTMLElement} moveEl The element to move
2405 * @param {HTMLElement} targetEl The position reference element
2408 moveToEl: function (moveEl, targetEl) {
2409 var aCoord = Ext.lib.Dom.getXY(targetEl);
2410 Ext.lib.Dom.setXY(moveEl, aCoord);
2413 <div id="method-DragDropMgr.ElementWrapper-numericSort"></div>/**
2414 * Numeric array sort function
2415 * @method numericSort
2418 numericSort: function(a, b) { return (a - b); },
2422 * @property _timeoutCount
2429 * Trying to make the load order less important. Without this we get
2430 * an error if this file is loaded before the Event Utility.
2431 * @method _addListeners
2435 _addListeners: function() {
2436 var DDM = Ext.dd.DDM;
2437 if ( Ext.lib.Event && document ) {
2440 if (DDM._timeoutCount > 2000) {
2442 setTimeout(DDM._addListeners, 10);
2443 if (document && document.body) {
2444 DDM._timeoutCount += 1;
2450 <div id="method-DragDropMgr.ElementWrapper-handleWasClicked"></div>/**
2451 * Recursively searches the immediate parent and all child nodes for
2452 * the handle element in order to determine wheter or not it was
2454 * @method handleWasClicked
2455 * @param node the html element to inspect
2458 handleWasClicked: function(node, id) {
2459 if (this.isHandle(id, node.id)) {
2462 // check to see if this is a text node child of the one we want
2463 var p = node.parentNode;
2466 if (this.isHandle(id, p.id)) {
2481 // shorter alias, save a few bytes
2482 Ext.dd.DDM = Ext.dd.DragDropMgr;
2483 Ext.dd.DDM._addListeners();
2487 <div id="cls-Ext.dd.DD"></div>/**
2489 * A DragDrop implementation where the linked element follows the
2490 * mouse cursor during a drag.
2491 * @extends Ext.dd.DragDrop
2493 * @param {String} id the id of the linked element
2494 * @param {String} sGroup the group of related DragDrop items
2495 * @param {object} config an object containing configurable attributes
2496 * Valid properties for DD:
2499 Ext.dd.DD = function(id, sGroup, config) {
2501 this.init(id, sGroup, config);
2505 Ext.extend(Ext.dd.DD, Ext.dd.DragDrop, {
2507 <div id="prop-Ext.dd.DD-scroll"></div>/**
2508 * When set to true, the utility automatically tries to scroll the browser
2509 * window when a drag and drop element is dragged near the viewport boundary.
2516 <div id="method-Ext.dd.DD-autoOffset"></div>/**
2517 * Sets the pointer offset to the distance between the linked element's top
2518 * left corner and the location the element was clicked
2519 * @method autoOffset
2520 * @param {int} iPageX the X coordinate of the click
2521 * @param {int} iPageY the Y coordinate of the click
2523 autoOffset: function(iPageX, iPageY) {
2524 var x = iPageX - this.startPageX;
2525 var y = iPageY - this.startPageY;
2526 this.setDelta(x, y);
2529 <div id="method-Ext.dd.DD-setDelta"></div>/**
2530 * Sets the pointer offset. You can call this directly to force the
2531 * offset to be in a particular location (e.g., pass in 0,0 to set it
2532 * to the center of the object)
2534 * @param {int} iDeltaX the distance from the left
2535 * @param {int} iDeltaY the distance from the top
2537 setDelta: function(iDeltaX, iDeltaY) {
2538 this.deltaX = iDeltaX;
2539 this.deltaY = iDeltaY;
2542 <div id="method-Ext.dd.DD-setDragElPos"></div>/**
2543 * Sets the drag element to the location of the mousedown or click event,
2544 * maintaining the cursor location relative to the location on the element
2545 * that was clicked. Override this if you want to place the element in a
2546 * location other than where the cursor is.
2547 * @method setDragElPos
2548 * @param {int} iPageX the X coordinate of the mousedown or drag event
2549 * @param {int} iPageY the Y coordinate of the mousedown or drag event
2551 setDragElPos: function(iPageX, iPageY) {
2552 // the first time we do this, we are going to check to make sure
2553 // the element has css positioning
2555 var el = this.getDragEl();
2556 this.alignElWithMouse(el, iPageX, iPageY);
2559 <div id="method-Ext.dd.DD-alignElWithMouse"></div>/**
2560 * Sets the element to the location of the mousedown or click event,
2561 * maintaining the cursor location relative to the location on the element
2562 * that was clicked. Override this if you want to place the element in a
2563 * location other than where the cursor is.
2564 * @method alignElWithMouse
2565 * @param {HTMLElement} el the element to move
2566 * @param {int} iPageX the X coordinate of the mousedown or drag event
2567 * @param {int} iPageY the Y coordinate of the mousedown or drag event
2569 alignElWithMouse: function(el, iPageX, iPageY) {
2570 var oCoord = this.getTargetCoord(iPageX, iPageY);
2571 var fly = el.dom ? el : Ext.fly(el, '_dd');
2572 if (!this.deltaSetXY) {
2573 var aCoord = [oCoord.x, oCoord.y];
2575 var newLeft = fly.getLeft(true);
2576 var newTop = fly.getTop(true);
2577 this.deltaSetXY = [ newLeft - oCoord.x, newTop - oCoord.y ];
2579 fly.setLeftTop(oCoord.x + this.deltaSetXY[0], oCoord.y + this.deltaSetXY[1]);
2582 this.cachePosition(oCoord.x, oCoord.y);
2583 this.autoScroll(oCoord.x, oCoord.y, el.offsetHeight, el.offsetWidth);
2587 <div id="method-Ext.dd.DD-cachePosition"></div>/**
2588 * Saves the most recent position so that we can reset the constraints and
2589 * tick marks on-demand. We need to know this so that we can calculate the
2590 * number of pixels the element is offset from its original position.
2591 * @method cachePosition
2592 * @param iPageX the current x position (optional, this just makes it so we
2593 * don't have to look it up again)
2594 * @param iPageY the current y position (optional, this just makes it so we
2595 * don't have to look it up again)
2597 cachePosition: function(iPageX, iPageY) {
2599 this.lastPageX = iPageX;
2600 this.lastPageY = iPageY;
2602 var aCoord = Ext.lib.Dom.getXY(this.getEl());
2603 this.lastPageX = aCoord[0];
2604 this.lastPageY = aCoord[1];
2609 * Auto-scroll the window if the dragged object has been moved beyond the
2610 * visible window boundary.
2611 * @method autoScroll
2612 * @param {int} x the drag element's x position
2613 * @param {int} y the drag element's y position
2614 * @param {int} h the height of the drag element
2615 * @param {int} w the width of the drag element
2618 autoScroll: function(x, y, h, w) {
2621 // The client height
2622 var clientH = Ext.lib.Dom.getViewHeight();
2625 var clientW = Ext.lib.Dom.getViewWidth();
2627 // The amt scrolled down
2628 var st = this.DDM.getScrollTop();
2630 // The amt scrolled right
2631 var sl = this.DDM.getScrollLeft();
2633 // Location of the bottom of the element
2636 // Location of the right of the element
2639 // The distance from the cursor to the bottom of the visible area,
2640 // adjusted so that we don't scroll if the cursor is beyond the
2641 // element drag constraints
2642 var toBot = (clientH + st - y - this.deltaY);
2644 // The distance from the cursor to the right of the visible area
2645 var toRight = (clientW + sl - x - this.deltaX);
2648 // How close to the edge the cursor must be before we scroll
2649 // var thresh = (document.all) ? 100 : 40;
2652 // How many pixels to scroll per autoscroll op. This helps to reduce
2653 // clunky scrolling. IE is more sensitive about this ... it needs this
2654 // value to be higher.
2655 var scrAmt = (document.all) ? 80 : 30;
2657 // Scroll down if we are near the bottom of the visible page and the
2658 // obj extends below the crease
2659 if ( bot > clientH && toBot < thresh ) {
2660 window.scrollTo(sl, st + scrAmt);
2663 // Scroll up if the window is scrolled down and the top of the object
2664 // goes above the top border
2665 if ( y < st && st > 0 && y - st < thresh ) {
2666 window.scrollTo(sl, st - scrAmt);
2669 // Scroll right if the obj is beyond the right border and the cursor is
2671 if ( right > clientW && toRight < thresh ) {
2672 window.scrollTo(sl + scrAmt, st);
2675 // Scroll left if the window has been scrolled to the right and the obj
2676 // extends past the left border
2677 if ( x < sl && sl > 0 && x - sl < thresh ) {
2678 window.scrollTo(sl - scrAmt, st);
2684 * Finds the location the element should be placed if we want to move
2685 * it to where the mouse location less the click offset would place us.
2686 * @method getTargetCoord
2687 * @param {int} iPageX the X coordinate of the click
2688 * @param {int} iPageY the Y coordinate of the click
2689 * @return an object that contains the coordinates (Object.x and Object.y)
2692 getTargetCoord: function(iPageX, iPageY) {
2695 var x = iPageX - this.deltaX;
2696 var y = iPageY - this.deltaY;
2698 if (this.constrainX) {
2699 if (x < this.minX) { x = this.minX; }
2700 if (x > this.maxX) { x = this.maxX; }
2703 if (this.constrainY) {
2704 if (y < this.minY) { y = this.minY; }
2705 if (y > this.maxY) { y = this.maxY; }
2708 x = this.getTick(x, this.xTicks);
2709 y = this.getTick(y, this.yTicks);
2715 <div id="method-Ext.dd.DD-applyConfig"></div>/**
2716 * Sets up config options specific to this class. Overrides
2717 * Ext.dd.DragDrop, but all versions of this method through the
2718 * inheritance chain are called
2720 applyConfig: function() {
2721 Ext.dd.DD.superclass.applyConfig.call(this);
2722 this.scroll = (this.config.scroll !== false);
2725 <div id="method-Ext.dd.DD-b4MouseDown"></div>/**
2726 * Event that fires prior to the onMouseDown event. Overrides
2729 b4MouseDown: function(e) {
2730 // this.resetConstraints();
2731 this.autoOffset(e.getPageX(),
2735 <div id="method-Ext.dd.DD-b4Drag"></div>/**
2736 * Event that fires prior to the onDrag event. Overrides
2739 b4Drag: function(e) {
2740 this.setDragElPos(e.getPageX(),
2744 toString: function() {
2745 return ("DD " + this.id);
2748 //////////////////////////////////////////////////////////////////////////
2749 // Debugging ygDragDrop events that can be overridden
2750 //////////////////////////////////////////////////////////////////////////
2752 startDrag: function(x, y) {
2755 onDrag: function(e) {
2758 onDragEnter: function(e, id) {
2761 onDragOver: function(e, id) {
2764 onDragOut: function(e, id) {
2767 onDragDrop: function(e, id) {
2770 endDrag: function(e) {
2776 <div id="cls-Ext.dd.DDProxy"></div>/**
2777 * @class Ext.dd.DDProxy
2778 * A DragDrop implementation that inserts an empty, bordered div into
2779 * the document that follows the cursor during drag operations. At the time of
2780 * the click, the frame div is resized to the dimensions of the linked html
2781 * element, and moved to the exact location of the linked element.
2783 * References to the "frame" element refer to the single proxy element that
2784 * was created to be dragged in place of all DDProxy elements on the
2787 * @extends Ext.dd.DD
2789 * @param {String} id the id of the linked html element
2790 * @param {String} sGroup the group of related DragDrop objects
2791 * @param {object} config an object containing configurable attributes
2792 * Valid properties for DDProxy in addition to those in DragDrop:
2793 * resizeFrame, centerFrame, dragElId
2795 Ext.dd.DDProxy = function(id, sGroup, config) {
2797 this.init(id, sGroup, config);
2802 <div id="prop-Ext.dd.DDProxy-Ext.dd.DDProxy.dragElId"></div>/**
2803 * The default drag frame div id
2804 * @property Ext.dd.DDProxy.dragElId
2808 Ext.dd.DDProxy.dragElId = "ygddfdiv";
2810 Ext.extend(Ext.dd.DDProxy, Ext.dd.DD, {
2812 <div id="prop-Ext.dd.DDProxy-resizeFrame"></div>/**
2813 * By default we resize the drag frame to be the same size as the element
2814 * we want to drag (this is to get the frame effect). We can turn it off
2815 * if we want a different behavior.
2816 * @property resizeFrame
2821 <div id="prop-Ext.dd.DDProxy-centerFrame"></div>/**
2822 * By default the frame is positioned exactly where the drag element is, so
2823 * we use the cursor offset provided by Ext.dd.DD. Another option that works only if
2824 * you do not have constraints on the obj is to have the drag frame centered
2825 * around the cursor. Set centerFrame to true for this effect.
2826 * @property centerFrame
2831 <div id="method-Ext.dd.DDProxy-createFrame"></div>/**
2832 * Creates the proxy element if it does not yet exist
2833 * @method createFrame
2835 createFrame: function() {
2837 var body = document.body;
2839 if (!body || !body.firstChild) {
2840 setTimeout( function() { self.createFrame(); }, 50 );
2844 var div = this.getDragEl();
2847 div = document.createElement("div");
2848 div.id = this.dragElId;
2851 s.position = "absolute";
2852 s.visibility = "hidden";
2854 s.border = "2px solid #aaa";
2857 // appendChild can blow up IE if invoked prior to the window load event
2858 // while rendering a table. It is possible there are other scenarios
2859 // that would cause this to happen as well.
2860 body.insertBefore(div, body.firstChild);
2864 <div id="method-Ext.dd.DDProxy-initFrame"></div>/**
2865 * Initialization for the drag frame element. Must be called in the
2866 * constructor of all subclasses
2869 initFrame: function() {
2873 applyConfig: function() {
2874 Ext.dd.DDProxy.superclass.applyConfig.call(this);
2876 this.resizeFrame = (this.config.resizeFrame !== false);
2877 this.centerFrame = (this.config.centerFrame);
2878 this.setDragElId(this.config.dragElId || Ext.dd.DDProxy.dragElId);
2882 * Resizes the drag frame to the dimensions of the clicked object, positions
2883 * it over the object, and finally displays it
2885 * @param {int} iPageX X click position
2886 * @param {int} iPageY Y click position
2889 showFrame: function(iPageX, iPageY) {
2890 var el = this.getEl();
2891 var dragEl = this.getDragEl();
2892 var s = dragEl.style;
2894 this._resizeProxy();
2896 if (this.centerFrame) {
2897 this.setDelta( Math.round(parseInt(s.width, 10)/2),
2898 Math.round(parseInt(s.height, 10)/2) );
2901 this.setDragElPos(iPageX, iPageY);
2903 Ext.fly(dragEl).show();
2907 * The proxy is automatically resized to the dimensions of the linked
2908 * element when a drag is initiated, unless resizeFrame is set to false
2909 * @method _resizeProxy
2912 _resizeProxy: function() {
2913 if (this.resizeFrame) {
2914 var el = this.getEl();
2915 Ext.fly(this.getDragEl()).setSize(el.offsetWidth, el.offsetHeight);
2919 // overrides Ext.dd.DragDrop
2920 b4MouseDown: function(e) {
2921 var x = e.getPageX();
2922 var y = e.getPageY();
2923 this.autoOffset(x, y);
2924 this.setDragElPos(x, y);
2927 // overrides Ext.dd.DragDrop
2928 b4StartDrag: function(x, y) {
2929 // show the drag frame
2930 this.showFrame(x, y);
2933 // overrides Ext.dd.DragDrop
2934 b4EndDrag: function(e) {
2935 Ext.fly(this.getDragEl()).hide();
2938 // overrides Ext.dd.DragDrop
2939 // By default we try to move the element to the last location of the frame.
2940 // This is so that the default behavior mirrors that of Ext.dd.DD.
2941 endDrag: function(e) {
2943 var lel = this.getEl();
2944 var del = this.getDragEl();
2946 // Show the drag frame briefly so we can get its position
2947 del.style.visibility = "";
2950 // Hide the linked element before the move to get around a Safari
2952 lel.style.visibility = "hidden";
2953 Ext.dd.DDM.moveToEl(lel, del);
2954 del.style.visibility = "hidden";
2955 lel.style.visibility = "";
2960 beforeMove : function(){
2964 afterDrag : function(){
2968 toString: function() {
2969 return ("DDProxy " + this.id);
2973 <div id="cls-Ext.dd.DDTarget"></div>/**
2974 * @class Ext.dd.DDTarget
2975 * A DragDrop implementation that does not move, but can be a drop
2976 * target. You would get the same result by simply omitting implementation
2977 * for the event callbacks, but this way we reduce the processing cost of the
2978 * event listener and the callbacks.
2979 * @extends Ext.dd.DragDrop
2981 * @param {String} id the id of the element that is a drop target
2982 * @param {String} sGroup the group of related DragDrop objects
2983 * @param {object} config an object containing configurable attributes
2984 * Valid properties for DDTarget in addition to those in
2988 Ext.dd.DDTarget = function(id, sGroup, config) {
2990 this.initTarget(id, sGroup, config);
2994 // Ext.dd.DDTarget.prototype = new Ext.dd.DragDrop();
2995 Ext.extend(Ext.dd.DDTarget, Ext.dd.DragDrop, {
2996 toString: function() {
2997 return ("DDTarget " + this.id);