3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.3.1
11 * Copyright(c) 2006-2010 Sencha Inc.
12 * licensing@sencha.com
13 * http://www.sencha.com/license
16 * These classes are derivatives of the similarly named classes in the YUI Library.
17 * The original license:
18 * Copyright (c) 2006, Yahoo! Inc. All rights reserved.
19 * Code licensed under the BSD License:
20 * http://developer.yahoo.net/yui/license.txt
25 var Event=Ext.EventManager;
28 <div id="cls-Ext.dd.DragDrop"></div>/**
29 * @class Ext.dd.DragDrop
30 * Defines the interface and base operation of items that that can be
31 * dragged or can be drop targets. It was designed to be extended, overriding
32 * the event handlers for startDrag, onDrag, onDragOver and onDragOut.
33 * Up to three html elements can be associated with a DragDrop instance:
35 * <li>linked element: the element that is passed into the constructor.
36 * This is the element which defines the boundaries for interaction with
37 * other DragDrop objects.</li>
38 * <li>handle element(s): The drag operation only occurs if the element that
39 * was clicked matches a handle element. By default this is the linked
40 * element, but there are times that you will want only a portion of the
41 * linked element to initiate the drag operation, and the setHandleElId()
42 * method provides a way to define this.</li>
43 * <li>drag element: this represents the element that would be moved along
44 * with the cursor during a drag operation. By default, this is the linked
45 * element itself as in {@link Ext.dd.DD}. setDragElId() lets you define
46 * a separate element that would be moved, as in {@link Ext.dd.DDProxy}.
49 * This class should not be instantiated until the onload event to ensure that
50 * the associated elements are available.
51 * The following would define a DragDrop obj that would interact with any
52 * other DragDrop obj in the "group1" group:
54 * dd = new Ext.dd.DragDrop("div1", "group1");
56 * Since none of the event handlers have been implemented, nothing would
57 * actually happen if you were to run the code above. Normally you would
58 * override this class or one of the default implementations, but you can
59 * also override the methods you want on an instance of the class...
61 * dd.onDragDrop = function(e, id) {
62 * alert("dd was dropped on " + id);
66 * @param {String} id of the element that is linked to this instance
67 * @param {String} sGroup the group of related DragDrop objects
68 * @param {object} config an object containing configurable attributes
69 * Valid properties for DragDrop:
70 * padding, isTarget, maintainOffset, primaryButtonOnly
72 Ext.dd.DragDrop = function(id, sGroup, config) {
74 this.init(id, sGroup, config);
78 Ext.dd.DragDrop.prototype = {
80 <div id="prop-Ext.dd.DragDrop-ignoreSelf"></div>/**
81 * Set to false to enable a DragDrop object to fire drag events while dragging
82 * over its own Element. Defaults to true - DragDrop objects do not by default
83 * fire drag events to themselves.
84 * @property ignoreSelf
88 <div id="prop-Ext.dd.DragDrop-id"></div>/**
89 * The id of the element associated with this object. This is what we
90 * refer to as the "linked element" because the size and position of
91 * this element is used to determine when the drag and drop objects have
98 <div id="prop-Ext.dd.DragDrop-config"></div>/**
99 * Configuration attributes passed into the constructor
106 * The id of the element that will be dragged. By default this is same
107 * as the linked element, but could be changed to another element. Ex:
116 * The ID of the element that initiates the drag operation. By default
117 * this is the linked element, but could be changed to be a child of this
118 * element. This lets us do things like only starting the drag when the
119 * header element within the linked html element is clicked.
120 * @property handleElId
126 <div id="prop-Ext.dd.DragDrop-invalidHandleTypes"></div>/**
127 * An object who's property names identify HTML tags to be considered invalid as drag handles.
128 * A non-null property value identifies the tag as invalid. Defaults to the
129 * following value which prevents drag operations from being initiated by <a> elements:<pre><code>
133 * @property invalidHandleTypes
136 invalidHandleTypes: null,
138 <div id="prop-Ext.dd.DragDrop-invalidHandleIds"></div>/**
139 * An object who's property names identify the IDs of elements to be considered invalid as drag handles.
140 * A non-null property value identifies the ID as invalid. For example, to prevent
141 * dragging from being initiated on element ID "foo", use:<pre><code>
145 * @property invalidHandleIds
148 invalidHandleIds: null,
150 <div id="prop-Ext.dd.DragDrop-invalidHandleClasses"></div>/**
151 * An Array of CSS class names for elements to be considered in valid as drag handles.
152 * @property invalidHandleClasses
155 invalidHandleClasses: null,
158 * The linked element's absolute X position at the time the drag was
160 * @property startPageX
167 * The linked element's absolute X position at the time the drag was
169 * @property startPageY
175 <div id="prop-Ext.dd.DragDrop-groups"></div>/**
176 * The group defines a logical collection of DragDrop objects that are
177 * related. Instances only get events when interacting with other
178 * DragDrop object in the same group. This lets us define multiple
179 * groups using a single DragDrop subclass if we want.
181 * @type object An object in the format {'group1':true, 'group2':true}
186 * Individual drag/drop instances can be locked. This will prevent
187 * onmousedown start drag.
194 <div id="method-Ext.dd.DragDrop-lock"></div>/**
202 <div id="prop-Ext.dd.DragDrop-moveOnly"></div>/**
203 * When set to true, other DD objects in cooperating DDGroups do not receive
204 * notification events when this DD object is dragged over them. Defaults to false.
210 <div id="method-Ext.dd.DragDrop-unlock"></div>/**
211 * Unlock this instace
218 <div id="prop-Ext.dd.DragDrop-isTarget"></div>/**
219 * By default, all instances can be a drop target. This can be disabled by
220 * setting isTarget to false.
226 <div id="prop-Ext.dd.DragDrop-padding"></div>/**
227 * The padding configured for this drag and drop object for calculating
228 * the drop zone intersection with this object.
230 * @type int[] An array containing the 4 padding values: [top, right, bottom, left]
235 * Cached reference to the linked element
242 * Internal typeof flag
243 * @property __ygDragDrop
249 * Set to true when horizontal contraints are applied
250 * @property constrainX
257 * Set to true when vertical contraints are applied
258 * @property constrainY
265 * The left constraint
273 * The right constraint
289 * The down constraint
296 <div id="prop-Ext.dd.DragDrop-maintainOffset"></div>/**
297 * Maintain offsets when we resetconstraints. Set to true when you want
298 * the position of the element relative to its parent to stay the same
299 * when the page changes
301 * @property maintainOffset
304 maintainOffset: false,
306 <div id="prop-Ext.dd.DragDrop-xTicks"></div>/**
307 * Array of pixel locations the element will snap to if we specified a
308 * horizontal graduation/interval. This array is generated automatically
309 * when you define a tick interval.
315 <div id="prop-Ext.dd.DragDrop-yTicks"></div>/**
316 * Array of pixel locations the element will snap to if we specified a
317 * vertical graduation/interval. This array is generated automatically
318 * when you define a tick interval.
324 <div id="prop-Ext.dd.DragDrop-primaryButtonOnly"></div>/**
325 * By default the drag and drop instance will only respond to the primary
326 * button click (left button for a right-handed mouse). Set to true to
327 * allow drag and drop to start with any mouse click that is propogated
329 * @property primaryButtonOnly
332 primaryButtonOnly: true,
334 <div id="prop-Ext.dd.DragDrop-available"></div>/**
335 * The available property is false until the linked dom element is accessible.
336 * @property available
341 <div id="prop-Ext.dd.DragDrop-hasOuterHandles"></div>/**
342 * By default, drags can only be initiated if the mousedown occurs in the
343 * region the linked element is. This is done in part to work around a
344 * bug in some browsers that mis-report the mousedown if the previous
345 * mouseup happened outside of the window. This property is set to true
346 * if outer handles are defined.
348 * @property hasOuterHandles
352 hasOuterHandles: false,
355 * Code that executes immediately before the startDrag event
356 * @method b4StartDrag
359 b4StartDrag: function(x, y) { },
361 <div id="method-Ext.dd.DragDrop-startDrag"></div>/**
362 * Abstract method called after a drag/drop object is clicked
363 * and the drag or mousedown time thresholds have beeen met.
365 * @param {int} X click location
366 * @param {int} Y click location
368 startDrag: function(x, y) { /* override this */ },
371 * Code that executes immediately before the onDrag event
375 b4Drag: function(e) { },
377 <div id="method-Ext.dd.DragDrop-onDrag"></div>/**
378 * Abstract method called during the onMouseMove event while dragging an
381 * @param {Event} e the mousemove event
383 onDrag: function(e) { /* override this */ },
385 <div id="method-Ext.dd.DragDrop-onDragEnter"></div>/**
386 * Abstract method called when this element fist begins hovering over
387 * another DragDrop obj
388 * @method onDragEnter
389 * @param {Event} e the mousemove event
390 * @param {String|DragDrop[]} id In POINT mode, the element
391 * id this is hovering over. In INTERSECT mode, an array of one or more
392 * dragdrop items being hovered over.
394 onDragEnter: function(e, id) { /* override this */ },
397 * Code that executes immediately before the onDragOver event
401 b4DragOver: function(e) { },
403 <div id="method-Ext.dd.DragDrop-onDragOver"></div>/**
404 * Abstract method called when this element is hovering over another
407 * @param {Event} e the mousemove event
408 * @param {String|DragDrop[]} id In POINT mode, the element
409 * id this is hovering over. In INTERSECT mode, an array of dd items
410 * being hovered over.
412 onDragOver: function(e, id) { /* override this */ },
415 * Code that executes immediately before the onDragOut event
419 b4DragOut: function(e) { },
421 <div id="method-Ext.dd.DragDrop-onDragOut"></div>/**
422 * Abstract method called when we are no longer hovering over an element
424 * @param {Event} e the mousemove event
425 * @param {String|DragDrop[]} id In POINT mode, the element
426 * id this was hovering over. In INTERSECT mode, an array of dd items
427 * that the mouse is no longer over.
429 onDragOut: function(e, id) { /* override this */ },
432 * Code that executes immediately before the onDragDrop event
436 b4DragDrop: function(e) { },
438 <div id="method-Ext.dd.DragDrop-onDragDrop"></div>/**
439 * Abstract method called when this item is dropped on another DragDrop
442 * @param {Event} e the mouseup event
443 * @param {String|DragDrop[]} id In POINT mode, the element
444 * id this was dropped on. In INTERSECT mode, an array of dd items this
447 onDragDrop: function(e, id) { /* override this */ },
449 <div id="method-Ext.dd.DragDrop-onInvalidDrop"></div>/**
450 * Abstract method called when this item is dropped on an area with no
452 * @method onInvalidDrop
453 * @param {Event} e the mouseup event
455 onInvalidDrop: function(e) { /* override this */ },
458 * Code that executes immediately before the endDrag event
462 b4EndDrag: function(e) { },
464 <div id="method-Ext.dd.DragDrop-endDrag"></div>/**
465 * Fired when we are done dragging the object
467 * @param {Event} e the mouseup event
469 endDrag: function(e) { /* override this */ },
472 * Code executed immediately before the onMouseDown event
473 * @method b4MouseDown
474 * @param {Event} e the mousedown event
477 b4MouseDown: function(e) { },
479 <div id="method-Ext.dd.DragDrop-onMouseDown"></div>/**
480 * Event handler that fires when a drag/drop obj gets a mousedown
481 * @method onMouseDown
482 * @param {Event} e the mousedown event
484 onMouseDown: function(e) { /* override this */ },
486 <div id="method-Ext.dd.DragDrop-onMouseUp"></div>/**
487 * Event handler that fires when a drag/drop obj gets a mouseup
489 * @param {Event} e the mouseup event
491 onMouseUp: function(e) { /* override this */ },
493 <div id="method-Ext.dd.DragDrop-onAvailable"></div>/**
494 * Override the onAvailable method to do what is needed after the initial
495 * position was determined.
496 * @method onAvailable
498 onAvailable: function () {
501 <div id="prop-Ext.dd.DragDrop-defaultPadding"></div>/**
502 * Provides default constraint padding to "constrainTo" elements (defaults to {left: 0, right:0, top:0, bottom:0}).
505 defaultPadding : {left:0, right:0, top:0, bottom:0},
507 <div id="method-Ext.dd.DragDrop-constrainTo"></div>/**
508 * Initializes the drag drop object's constraints to restrict movement to a certain element.
512 var dd = new Ext.dd.DDProxy("dragDiv1", "proxytest",
513 { dragElId: "existingProxyDiv" });
514 dd.startDrag = function(){
515 this.constrainTo("parent-id");
518 * Or you can initalize it using the {@link Ext.Element} object:
520 Ext.get("dragDiv1").initDDProxy("proxytest", {dragElId: "existingProxyDiv"}, {
521 startDrag : function(){
522 this.constrainTo("parent-id");
526 * @param {Mixed} constrainTo The element to constrain to.
527 * @param {Object/Number} pad (optional) Pad provides a way to specify "padding" of the constraints,
528 * and can be either a number for symmetrical padding (4 would be equal to {left:4, right:4, top:4, bottom:4}) or
529 * an object containing the sides to pad. For example: {right:10, bottom:10}
530 * @param {Boolean} inContent (optional) Constrain the draggable in the content box of the element (inside padding and borders)
532 constrainTo : function(constrainTo, pad, inContent){
533 if(Ext.isNumber(pad)){
534 pad = {left: pad, right:pad, top:pad, bottom:pad};
536 pad = pad || this.defaultPadding;
537 var b = Ext.get(this.getEl()).getBox(),
538 ce = Ext.get(constrainTo),
542 if(cd == document.body){
543 c = { x: s.left, y: s.top, width: Ext.lib.Dom.getViewWidth(), height: Ext.lib.Dom.getViewHeight()};
546 c = {x : xy[0], y: xy[1], width: cd.clientWidth, height: cd.clientHeight};
550 var topSpace = b.y - c.y,
551 leftSpace = b.x - c.x;
553 this.resetConstraints();
554 this.setXConstraint(leftSpace - (pad.left||0), // left
555 c.width - leftSpace - b.width - (pad.right||0), //right
558 this.setYConstraint(topSpace - (pad.top||0), //top
559 c.height - topSpace - b.height - (pad.bottom||0), //bottom
564 <div id="method-Ext.dd.DragDrop-getEl"></div>/**
565 * Returns a reference to the linked element
567 * @return {HTMLElement} the html element
571 this._domRef = Ext.getDom(this.id);
577 <div id="method-Ext.dd.DragDrop-getDragEl"></div>/**
578 * Returns a reference to the actual element to drag. By default this is
579 * the same as the html element, but it can be assigned to another
580 * element. An example of this can be found in Ext.dd.DDProxy
582 * @return {HTMLElement} the html element
584 getDragEl: function() {
585 return Ext.getDom(this.dragElId);
588 <div id="method-Ext.dd.DragDrop-init"></div>/**
589 * Sets up the DragDrop object. Must be called in the constructor of any
590 * Ext.dd.DragDrop subclass
592 * @param id the id of the linked element
593 * @param {String} sGroup the group of related items
594 * @param {object} config configuration attributes
596 init: function(id, sGroup, config) {
597 this.initTarget(id, sGroup, config);
598 Event.on(this.id, "mousedown", this.handleMouseDown, this);
599 // Event.on(this.id, "selectstart", Event.preventDefault);
602 <div id="method-Ext.dd.DragDrop-initTarget"></div>/**
603 * Initializes Targeting functionality only... the object does not
604 * get a mousedown handler.
606 * @param id the id of the linked element
607 * @param {String} sGroup the group of related items
608 * @param {object} config configuration attributes
610 initTarget: function(id, sGroup, config) {
612 // configuration attributes
613 this.config = config || {};
615 // create a local reference to the drag and drop manager
616 this.DDM = Ext.dd.DDM;
617 // initialize the groups array
620 // assume that we have an element reference instead of an id if the
621 // parameter is not a string
622 if (typeof id !== "string") {
629 // add to an interaction group
630 this.addToGroup((sGroup) ? sGroup : "default");
632 // We don't want to register this as the handle with the manager
633 // so we just set the id rather than calling the setter.
634 this.handleElId = id;
636 // the linked element is the element that gets dragged by default
637 this.setDragElId(id);
639 // by default, clicked anchors will not start drag operations.
640 this.invalidHandleTypes = { A: "A" };
641 this.invalidHandleIds = {};
642 this.invalidHandleClasses = [];
646 this.handleOnAvailable();
649 <div id="method-Ext.dd.DragDrop-applyConfig"></div>/**
650 * Applies the configuration parameters that were passed into the constructor.
651 * This is supposed to happen at each level through the inheritance chain. So
652 * a DDProxy implentation will execute apply config on DDProxy, DD, and
653 * DragDrop in order to get all of the parameters that are available in
655 * @method applyConfig
657 applyConfig: function() {
659 // configurable properties:
660 // padding, isTarget, maintainOffset, primaryButtonOnly
661 this.padding = this.config.padding || [0, 0, 0, 0];
662 this.isTarget = (this.config.isTarget !== false);
663 this.maintainOffset = (this.config.maintainOffset);
664 this.primaryButtonOnly = (this.config.primaryButtonOnly !== false);
669 * Executed when the linked element is available
670 * @method handleOnAvailable
673 handleOnAvailable: function() {
674 this.available = true;
675 this.resetConstraints();
679 <div id="method-Ext.dd.DragDrop-setPadding"></div>/**
680 * Configures the padding for the target zone in px. Effectively expands
681 * (or reduces) the virtual object size for targeting calculations.
682 * Supports css-style shorthand; if only one parameter is passed, all sides
683 * will have that padding, and if only two are passed, the top and bottom
684 * will have the first param, the left and right the second.
686 * @param {int} iTop Top pad
687 * @param {int} iRight Right pad
688 * @param {int} iBot Bot pad
689 * @param {int} iLeft Left pad
691 setPadding: function(iTop, iRight, iBot, iLeft) {
692 // this.padding = [iLeft, iRight, iTop, iBot];
693 if (!iRight && 0 !== iRight) {
694 this.padding = [iTop, iTop, iTop, iTop];
695 } else if (!iBot && 0 !== iBot) {
696 this.padding = [iTop, iRight, iTop, iRight];
698 this.padding = [iTop, iRight, iBot, iLeft];
702 <div id="method-Ext.dd.DragDrop-setInitPosition"></div>/**
703 * Stores the initial placement of the linked element.
704 * @method setInitPosition
705 * @param {int} diffX the X offset, default 0
706 * @param {int} diffY the Y offset, default 0
708 setInitPosition: function(diffX, diffY) {
709 var el = this.getEl();
711 if (!this.DDM.verifyEl(el)) {
718 var p = Dom.getXY( el );
720 this.initPageX = p[0] - dx;
721 this.initPageY = p[1] - dy;
723 this.lastPageX = p[0];
724 this.lastPageY = p[1];
726 this.setStartPosition(p);
730 * Sets the start position of the element. This is set when the obj
731 * is initialized, the reset when a drag is started.
732 * @method setStartPosition
733 * @param pos current position (from previous lookup)
736 setStartPosition: function(pos) {
737 var p = pos || Dom.getXY( this.getEl() );
738 this.deltaSetXY = null;
740 this.startPageX = p[0];
741 this.startPageY = p[1];
744 <div id="method-Ext.dd.DragDrop-addToGroup"></div>/**
745 * Add this instance to a group of related drag/drop objects. All
746 * instances belong to at least one group, and can belong to as many
749 * @param sGroup {string} the name of the group
751 addToGroup: function(sGroup) {
752 this.groups[sGroup] = true;
753 this.DDM.regDragDrop(this, sGroup);
756 <div id="method-Ext.dd.DragDrop-removeFromGroup"></div>/**
757 * Remove's this instance from the supplied interaction group
758 * @method removeFromGroup
759 * @param {string} sGroup The group to drop
761 removeFromGroup: function(sGroup) {
762 if (this.groups[sGroup]) {
763 delete this.groups[sGroup];
766 this.DDM.removeDDFromGroup(this, sGroup);
769 <div id="method-Ext.dd.DragDrop-setDragElId"></div>/**
770 * Allows you to specify that an element other than the linked element
771 * will be moved with the cursor during a drag
772 * @method setDragElId
773 * @param id {string} the id of the element that will be used to initiate the drag
775 setDragElId: function(id) {
779 <div id="method-Ext.dd.DragDrop-setHandleElId"></div>/**
780 * Allows you to specify a child of the linked element that should be
781 * used to initiate the drag operation. An example of this would be if
782 * you have a content div with text and links. Clicking anywhere in the
783 * content area would normally start the drag operation. Use this method
784 * to specify that an element inside of the content div is the element
785 * that starts the drag operation.
786 * @method setHandleElId
787 * @param id {string} the id of the element that will be used to
790 setHandleElId: function(id) {
791 if (typeof id !== "string") {
794 this.handleElId = id;
795 this.DDM.regHandle(this.id, id);
798 <div id="method-Ext.dd.DragDrop-setOuterHandleElId"></div>/**
799 * Allows you to set an element outside of the linked element as a drag
801 * @method setOuterHandleElId
802 * @param id the id of the element that will be used to initiate the drag
804 setOuterHandleElId: function(id) {
805 if (typeof id !== "string") {
808 Event.on(id, "mousedown",
809 this.handleMouseDown, this);
810 this.setHandleElId(id);
812 this.hasOuterHandles = true;
815 <div id="method-Ext.dd.DragDrop-unreg"></div>/**
816 * Remove all drag and drop hooks for this element
820 Event.un(this.id, "mousedown",
821 this.handleMouseDown);
823 this.DDM._remove(this);
826 destroy : function(){
830 <div id="method-Ext.dd.DragDrop-isLocked"></div>/**
831 * Returns true if this instance is locked, or the drag drop mgr is locked
832 * (meaning that all drag/drop is disabled on the page.)
834 * @return {boolean} true if this obj or all drag/drop is locked, else
837 isLocked: function() {
838 return (this.DDM.isLocked() || this.locked);
842 * Fired when this object is clicked
843 * @method handleMouseDown
845 * @param {Ext.dd.DragDrop} oDD the clicked dd object (this dd obj)
848 handleMouseDown: function(e, oDD){
849 if (this.primaryButtonOnly && e.button != 0) {
853 if (this.isLocked()) {
857 this.DDM.refreshCache(this.groups);
859 var pt = new Ext.lib.Point(Ext.lib.Event.getPageX(e), Ext.lib.Event.getPageY(e));
860 if (!this.hasOuterHandles && !this.DDM.isOverTarget(pt, this) ) {
862 if (this.clickValidator(e)) {
864 // set the initial element position
865 this.setStartPosition();
870 this.DDM.handleMouseDown(e, this);
872 this.DDM.stopEvent(e);
880 clickValidator: function(e) {
881 var target = e.getTarget();
882 return ( this.isValidHandleChild(target) &&
883 (this.id == this.handleElId ||
884 this.DDM.handleWasClicked(target, this.id)) );
887 <div id="method-Ext.dd.DragDrop-addInvalidHandleType"></div>/**
888 * Allows you to specify a tag name that should not start a drag operation
889 * when clicked. This is designed to facilitate embedding links within a
890 * drag handle that do something other than start the drag.
891 * @method addInvalidHandleType
892 * @param {string} tagName the type of element to exclude
894 addInvalidHandleType: function(tagName) {
895 var type = tagName.toUpperCase();
896 this.invalidHandleTypes[type] = type;
899 <div id="method-Ext.dd.DragDrop-addInvalidHandleId"></div>/**
900 * Lets you to specify an element id for a child of a drag handle
901 * that should not initiate a drag
902 * @method addInvalidHandleId
903 * @param {string} id the element id of the element you wish to ignore
905 addInvalidHandleId: function(id) {
906 if (typeof id !== "string") {
909 this.invalidHandleIds[id] = id;
912 <div id="method-Ext.dd.DragDrop-addInvalidHandleClass"></div>/**
913 * Lets you specify a css class of elements that will not initiate a drag
914 * @method addInvalidHandleClass
915 * @param {string} cssClass the class of the elements you wish to ignore
917 addInvalidHandleClass: function(cssClass) {
918 this.invalidHandleClasses.push(cssClass);
921 <div id="method-Ext.dd.DragDrop-removeInvalidHandleType"></div>/**
922 * Unsets an excluded tag name set by addInvalidHandleType
923 * @method removeInvalidHandleType
924 * @param {string} tagName the type of element to unexclude
926 removeInvalidHandleType: function(tagName) {
927 var type = tagName.toUpperCase();
928 // this.invalidHandleTypes[type] = null;
929 delete this.invalidHandleTypes[type];
932 <div id="method-Ext.dd.DragDrop-removeInvalidHandleId"></div>/**
933 * Unsets an invalid handle id
934 * @method removeInvalidHandleId
935 * @param {string} id the id of the element to re-enable
937 removeInvalidHandleId: function(id) {
938 if (typeof id !== "string") {
941 delete this.invalidHandleIds[id];
944 <div id="method-Ext.dd.DragDrop-removeInvalidHandleClass"></div>/**
945 * Unsets an invalid css class
946 * @method removeInvalidHandleClass
947 * @param {string} cssClass the class of the element(s) you wish to
950 removeInvalidHandleClass: function(cssClass) {
951 for (var i=0, len=this.invalidHandleClasses.length; i<len; ++i) {
952 if (this.invalidHandleClasses[i] == cssClass) {
953 delete this.invalidHandleClasses[i];
958 <div id="method-Ext.dd.DragDrop-isValidHandleChild"></div>/**
959 * Checks the tag exclusion list to see if this click should be ignored
960 * @method isValidHandleChild
961 * @param {HTMLElement} node the HTMLElement to evaluate
962 * @return {boolean} true if this is a valid tag type, false if not
964 isValidHandleChild: function(node) {
967 // var n = (node.nodeName == "#text") ? node.parentNode : node;
970 nodeName = node.nodeName.toUpperCase();
972 nodeName = node.nodeName;
974 valid = valid && !this.invalidHandleTypes[nodeName];
975 valid = valid && !this.invalidHandleIds[node.id];
977 for (var i=0, len=this.invalidHandleClasses.length; valid && i<len; ++i) {
978 valid = !Ext.fly(node).hasClass(this.invalidHandleClasses[i]);
987 * Create the array of horizontal tick marks if an interval was specified
988 * in setXConstraint().
992 setXTicks: function(iStartX, iTickSize) {
994 this.xTickSize = iTickSize;
998 for (var i = this.initPageX; i >= this.minX; i = i - iTickSize) {
1000 this.xTicks[this.xTicks.length] = i;
1005 for (i = this.initPageX; i <= this.maxX; i = i + iTickSize) {
1007 this.xTicks[this.xTicks.length] = i;
1012 this.xTicks.sort(this.DDM.numericSort) ;
1016 * Create the array of vertical tick marks if an interval was specified in
1021 setYTicks: function(iStartY, iTickSize) {
1023 this.yTickSize = iTickSize;
1027 for (var i = this.initPageY; i >= this.minY; i = i - iTickSize) {
1029 this.yTicks[this.yTicks.length] = i;
1034 for (i = this.initPageY; i <= this.maxY; i = i + iTickSize) {
1036 this.yTicks[this.yTicks.length] = i;
1041 this.yTicks.sort(this.DDM.numericSort) ;
1044 <div id="method-Ext.dd.DragDrop-setXConstraint"></div>/**
1045 * By default, the element can be dragged any place on the screen. Use
1046 * this method to limit the horizontal travel of the element. Pass in
1047 * 0,0 for the parameters if you want to lock the drag to the y axis.
1048 * @method setXConstraint
1049 * @param {int} iLeft the number of pixels the element can move to the left
1050 * @param {int} iRight the number of pixels the element can move to the
1052 * @param {int} iTickSize optional parameter for specifying that the
1054 * should move iTickSize pixels at a time.
1056 setXConstraint: function(iLeft, iRight, iTickSize) {
1057 this.leftConstraint = iLeft;
1058 this.rightConstraint = iRight;
1060 this.minX = this.initPageX - iLeft;
1061 this.maxX = this.initPageX + iRight;
1062 if (iTickSize) { this.setXTicks(this.initPageX, iTickSize); }
1064 this.constrainX = true;
1067 <div id="method-Ext.dd.DragDrop-clearConstraints"></div>/**
1068 * Clears any constraints applied to this instance. Also clears ticks
1069 * since they can't exist independent of a constraint at this time.
1070 * @method clearConstraints
1072 clearConstraints: function() {
1073 this.constrainX = false;
1074 this.constrainY = false;
1078 <div id="method-Ext.dd.DragDrop-clearTicks"></div>/**
1079 * Clears any tick interval defined for this instance
1080 * @method clearTicks
1082 clearTicks: function() {
1089 <div id="method-Ext.dd.DragDrop-setYConstraint"></div>/**
1090 * By default, the element can be dragged any place on the screen. Set
1091 * this to limit the vertical travel of the element. Pass in 0,0 for the
1092 * parameters if you want to lock the drag to the x axis.
1093 * @method setYConstraint
1094 * @param {int} iUp the number of pixels the element can move up
1095 * @param {int} iDown the number of pixels the element can move down
1096 * @param {int} iTickSize optional parameter for specifying that the
1097 * element should move iTickSize pixels at a time.
1099 setYConstraint: function(iUp, iDown, iTickSize) {
1100 this.topConstraint = iUp;
1101 this.bottomConstraint = iDown;
1103 this.minY = this.initPageY - iUp;
1104 this.maxY = this.initPageY + iDown;
1105 if (iTickSize) { this.setYTicks(this.initPageY, iTickSize); }
1107 this.constrainY = true;
1111 <div id="method-Ext.dd.DragDrop-resetConstraints"></div>/**
1112 * resetConstraints must be called if you manually reposition a dd element.
1113 * @method resetConstraints
1114 * @param {boolean} maintainOffset
1116 resetConstraints: function() {
1117 // Maintain offsets if necessary
1118 if (this.initPageX || this.initPageX === 0) {
1119 // figure out how much this thing has moved
1120 var dx = (this.maintainOffset) ? this.lastPageX - this.initPageX : 0;
1121 var dy = (this.maintainOffset) ? this.lastPageY - this.initPageY : 0;
1123 this.setInitPosition(dx, dy);
1125 // This is the first time we have detected the element's position
1127 this.setInitPosition();
1130 if (this.constrainX) {
1131 this.setXConstraint( this.leftConstraint,
1132 this.rightConstraint,
1136 if (this.constrainY) {
1137 this.setYConstraint( this.topConstraint,
1138 this.bottomConstraint,
1144 * Normally the drag element is moved pixel by pixel, but we can specify
1145 * that it move a number of pixels at a time. This method resolves the
1146 * location when we have it set up like this.
1148 * @param {int} val where we want to place the object
1149 * @param {int[]} tickArray sorted array of valid points
1150 * @return {int} the closest tick
1153 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);
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
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
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=350
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} oDD the drag obj
1603 * @param {DragDrop} oTargetDD 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.ddDisable();
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.ddEnable();
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-Ext.dd.DragDropMgr.ElementWrapper"></div>/**
2276 * Inner class for cached elements
2277 * @class Ext.dd.DragDropMgr.ElementWrapper
2282 ElementWrapper: function(el) {
2283 <div id="prop-Ext.dd.DragDropMgr.ElementWrapper-el"></div>/**
2287 this.el = el || null;
2288 <div id="prop-Ext.dd.DragDropMgr.ElementWrapper-id"></div>/**
2292 this.id = this.el && el.id;
2293 <div id="prop-Ext.dd.DragDropMgr.ElementWrapper-css"></div>/**
2294 * A reference to the style property
2297 this.css = this.el && el.style;
2300 <div id="method-Ext.dd.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-Ext.dd.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-Ext.dd.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-Ext.dd.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-Ext.dd.DragDropMgr.ElementWrapper-getScrollTop"></div>/**
2385 * Gets the scrollTop
2386 * @method getScrollTop
2387 * @return {int} the document's scrollTop
2390 getScrollTop: function () {
2391 return this.getScroll().top;
2394 <div id="method-Ext.dd.DragDropMgr.ElementWrapper-getScrollLeft"></div>/**
2395 * Gets the scrollLeft
2396 * @method getScrollLeft
2397 * @return {int} the document's scrollTop
2400 getScrollLeft: function () {
2401 return this.getScroll().left;
2404 <div id="method-Ext.dd.DragDropMgr.ElementWrapper-moveToEl"></div>/**
2405 * Sets the x/y position of an element to the location of the
2408 * @param {HTMLElement} moveEl The element to move
2409 * @param {HTMLElement} targetEl The position reference element
2412 moveToEl: function (moveEl, targetEl) {
2413 var aCoord = Ext.lib.Dom.getXY(targetEl);
2414 Ext.lib.Dom.setXY(moveEl, aCoord);
2417 <div id="method-Ext.dd.DragDropMgr.ElementWrapper-numericSort"></div>/**
2418 * Numeric array sort function
2419 * @method numericSort
2422 numericSort: function(a, b) {
2428 * @property _timeoutCount
2435 * Trying to make the load order less important. Without this we get
2436 * an error if this file is loaded before the Event Utility.
2437 * @method _addListeners
2441 _addListeners: function() {
2442 var DDM = Ext.dd.DDM;
2443 if ( Ext.lib.Event && document ) {
2446 if (DDM._timeoutCount > 2000) {
2448 setTimeout(DDM._addListeners, 10);
2449 if (document && document.body) {
2450 DDM._timeoutCount += 1;
2456 <div id="method-Ext.dd.DragDropMgr.ElementWrapper-handleWasClicked"></div>/**
2457 * Recursively searches the immediate parent and all child nodes for
2458 * the handle element in order to determine wheter or not it was
2460 * @method handleWasClicked
2461 * @param node the html element to inspect
2464 handleWasClicked: function(node, id) {
2465 if (this.isHandle(id, node.id)) {
2468 // check to see if this is a text node child of the one we want
2469 var p = node.parentNode;
2472 if (this.isHandle(id, p.id)) {
2487 // shorter alias, save a few bytes
2488 Ext.dd.DDM = Ext.dd.DragDropMgr;
2489 Ext.dd.DDM._addListeners();
2493 <div id="cls-Ext.dd.DD"></div>/**
2495 * A DragDrop implementation where the linked element follows the
2496 * mouse cursor during a drag.
2497 * @extends Ext.dd.DragDrop
2499 * @param {String} id the id of the linked element
2500 * @param {String} sGroup the group of related DragDrop items
2501 * @param {object} config an object containing configurable attributes
2502 * Valid properties for DD:
2505 Ext.dd.DD = function(id, sGroup, config) {
2507 this.init(id, sGroup, config);
2511 Ext.extend(Ext.dd.DD, Ext.dd.DragDrop, {
2513 <div id="prop-Ext.dd.DD-scroll"></div>/**
2514 * When set to true, the utility automatically tries to scroll the browser
2515 * window when a drag and drop element is dragged near the viewport boundary.
2522 <div id="method-Ext.dd.DD-autoOffset"></div>/**
2523 * Sets the pointer offset to the distance between the linked element's top
2524 * left corner and the location the element was clicked
2525 * @method autoOffset
2526 * @param {int} iPageX the X coordinate of the click
2527 * @param {int} iPageY the Y coordinate of the click
2529 autoOffset: function(iPageX, iPageY) {
2530 var x = iPageX - this.startPageX;
2531 var y = iPageY - this.startPageY;
2532 this.setDelta(x, y);
2535 <div id="method-Ext.dd.DD-setDelta"></div>/**
2536 * Sets the pointer offset. You can call this directly to force the
2537 * offset to be in a particular location (e.g., pass in 0,0 to set it
2538 * to the center of the object)
2540 * @param {int} iDeltaX the distance from the left
2541 * @param {int} iDeltaY the distance from the top
2543 setDelta: function(iDeltaX, iDeltaY) {
2544 this.deltaX = iDeltaX;
2545 this.deltaY = iDeltaY;
2548 <div id="method-Ext.dd.DD-setDragElPos"></div>/**
2549 * Sets the drag element to the location of the mousedown or click event,
2550 * maintaining the cursor location relative to the location on the element
2551 * that was clicked. Override this if you want to place the element in a
2552 * location other than where the cursor is.
2553 * @method setDragElPos
2554 * @param {int} iPageX the X coordinate of the mousedown or drag event
2555 * @param {int} iPageY the Y coordinate of the mousedown or drag event
2557 setDragElPos: function(iPageX, iPageY) {
2558 // the first time we do this, we are going to check to make sure
2559 // the element has css positioning
2561 var el = this.getDragEl();
2562 this.alignElWithMouse(el, iPageX, iPageY);
2565 <div id="method-Ext.dd.DD-alignElWithMouse"></div>/**
2566 * Sets the element to the location of the mousedown or click event,
2567 * maintaining the cursor location relative to the location on the element
2568 * that was clicked. Override this if you want to place the element in a
2569 * location other than where the cursor is.
2570 * @method alignElWithMouse
2571 * @param {HTMLElement} el the element to move
2572 * @param {int} iPageX the X coordinate of the mousedown or drag event
2573 * @param {int} iPageY the Y coordinate of the mousedown or drag event
2575 alignElWithMouse: function(el, iPageX, iPageY) {
2576 var oCoord = this.getTargetCoord(iPageX, iPageY);
2577 var fly = el.dom ? el : Ext.fly(el, '_dd');
2578 if (!this.deltaSetXY) {
2579 var aCoord = [oCoord.x, oCoord.y];
2581 var newLeft = fly.getLeft(true);
2582 var newTop = fly.getTop(true);
2583 this.deltaSetXY = [ newLeft - oCoord.x, newTop - oCoord.y ];
2585 fly.setLeftTop(oCoord.x + this.deltaSetXY[0], oCoord.y + this.deltaSetXY[1]);
2588 this.cachePosition(oCoord.x, oCoord.y);
2589 this.autoScroll(oCoord.x, oCoord.y, el.offsetHeight, el.offsetWidth);
2593 <div id="method-Ext.dd.DD-cachePosition"></div>/**
2594 * Saves the most recent position so that we can reset the constraints and
2595 * tick marks on-demand. We need to know this so that we can calculate the
2596 * number of pixels the element is offset from its original position.
2597 * @method cachePosition
2598 * @param iPageX the current x position (optional, this just makes it so we
2599 * don't have to look it up again)
2600 * @param iPageY the current y position (optional, this just makes it so we
2601 * don't have to look it up again)
2603 cachePosition: function(iPageX, iPageY) {
2605 this.lastPageX = iPageX;
2606 this.lastPageY = iPageY;
2608 var aCoord = Ext.lib.Dom.getXY(this.getEl());
2609 this.lastPageX = aCoord[0];
2610 this.lastPageY = aCoord[1];
2615 * Auto-scroll the window if the dragged object has been moved beyond the
2616 * visible window boundary.
2617 * @method autoScroll
2618 * @param {int} x the drag element's x position
2619 * @param {int} y the drag element's y position
2620 * @param {int} h the height of the drag element
2621 * @param {int} w the width of the drag element
2624 autoScroll: function(x, y, h, w) {
2627 // The client height
2628 var clientH = Ext.lib.Dom.getViewHeight();
2631 var clientW = Ext.lib.Dom.getViewWidth();
2633 // The amt scrolled down
2634 var st = this.DDM.getScrollTop();
2636 // The amt scrolled right
2637 var sl = this.DDM.getScrollLeft();
2639 // Location of the bottom of the element
2642 // Location of the right of the element
2645 // The distance from the cursor to the bottom of the visible area,
2646 // adjusted so that we don't scroll if the cursor is beyond the
2647 // element drag constraints
2648 var toBot = (clientH + st - y - this.deltaY);
2650 // The distance from the cursor to the right of the visible area
2651 var toRight = (clientW + sl - x - this.deltaX);
2654 // How close to the edge the cursor must be before we scroll
2655 // var thresh = (document.all) ? 100 : 40;
2658 // How many pixels to scroll per autoscroll op. This helps to reduce
2659 // clunky scrolling. IE is more sensitive about this ... it needs this
2660 // value to be higher.
2661 var scrAmt = (document.all) ? 80 : 30;
2663 // Scroll down if we are near the bottom of the visible page and the
2664 // obj extends below the crease
2665 if ( bot > clientH && toBot < thresh ) {
2666 window.scrollTo(sl, st + scrAmt);
2669 // Scroll up if the window is scrolled down and the top of the object
2670 // goes above the top border
2671 if ( y < st && st > 0 && y - st < thresh ) {
2672 window.scrollTo(sl, st - scrAmt);
2675 // Scroll right if the obj is beyond the right border and the cursor is
2677 if ( right > clientW && toRight < thresh ) {
2678 window.scrollTo(sl + scrAmt, st);
2681 // Scroll left if the window has been scrolled to the right and the obj
2682 // extends past the left border
2683 if ( x < sl && sl > 0 && x - sl < thresh ) {
2684 window.scrollTo(sl - scrAmt, st);
2690 * Finds the location the element should be placed if we want to move
2691 * it to where the mouse location less the click offset would place us.
2692 * @method getTargetCoord
2693 * @param {int} iPageX the X coordinate of the click
2694 * @param {int} iPageY the Y coordinate of the click
2695 * @return an object that contains the coordinates (Object.x and Object.y)
2698 getTargetCoord: function(iPageX, iPageY) {
2699 var x = iPageX - this.deltaX;
2700 var y = iPageY - this.deltaY;
2702 if (this.constrainX) {
2703 if (x < this.minX) { x = this.minX; }
2704 if (x > this.maxX) { x = this.maxX; }
2707 if (this.constrainY) {
2708 if (y < this.minY) { y = this.minY; }
2709 if (y > this.maxY) { y = this.maxY; }
2712 x = this.getTick(x, this.xTicks);
2713 y = this.getTick(y, this.yTicks);
2719 <div id="method-Ext.dd.DD-applyConfig"></div>/**
2720 * Sets up config options specific to this class. Overrides
2721 * Ext.dd.DragDrop, but all versions of this method through the
2722 * inheritance chain are called
2724 applyConfig: function() {
2725 Ext.dd.DD.superclass.applyConfig.call(this);
2726 this.scroll = (this.config.scroll !== false);
2729 <div id="method-Ext.dd.DD-b4MouseDown"></div>/**
2730 * Event that fires prior to the onMouseDown event. Overrides
2733 b4MouseDown: function(e) {
2734 // this.resetConstraints();
2735 this.autoOffset(e.getPageX(),
2739 <div id="method-Ext.dd.DD-b4Drag"></div>/**
2740 * Event that fires prior to the onDrag event. Overrides
2743 b4Drag: function(e) {
2744 this.setDragElPos(e.getPageX(),
2748 toString: function() {
2749 return ("DD " + this.id);
2752 //////////////////////////////////////////////////////////////////////////
2753 // Debugging ygDragDrop events that can be overridden
2754 //////////////////////////////////////////////////////////////////////////
2756 startDrag: function(x, y) {
2759 onDrag: function(e) {
2762 onDragEnter: function(e, id) {
2765 onDragOver: function(e, id) {
2768 onDragOut: function(e, id) {
2771 onDragDrop: function(e, id) {
2774 endDrag: function(e) {
2780 <div id="cls-Ext.dd.DDProxy"></div>/**
2781 * @class Ext.dd.DDProxy
2782 * A DragDrop implementation that inserts an empty, bordered div into
2783 * the document that follows the cursor during drag operations. At the time of
2784 * the click, the frame div is resized to the dimensions of the linked html
2785 * element, and moved to the exact location of the linked element.
2787 * References to the "frame" element refer to the single proxy element that
2788 * was created to be dragged in place of all DDProxy elements on the
2791 * @extends Ext.dd.DD
2793 * @param {String} id the id of the linked html element
2794 * @param {String} sGroup the group of related DragDrop objects
2795 * @param {object} config an object containing configurable attributes
2796 * Valid properties for DDProxy in addition to those in DragDrop:
2797 * resizeFrame, centerFrame, dragElId
2799 Ext.dd.DDProxy = function(id, sGroup, config) {
2801 this.init(id, sGroup, config);
2806 <div id="prop-Ext.dd.DDProxy-Ext.dd.DDProxy.dragElId"></div>/**
2807 * The default drag frame div id
2808 * @property Ext.dd.DDProxy.dragElId
2812 Ext.dd.DDProxy.dragElId = "ygddfdiv";
2814 Ext.extend(Ext.dd.DDProxy, Ext.dd.DD, {
2816 <div id="prop-Ext.dd.DDProxy-resizeFrame"></div>/**
2817 * By default we resize the drag frame to be the same size as the element
2818 * we want to drag (this is to get the frame effect). We can turn it off
2819 * if we want a different behavior.
2820 * @property resizeFrame
2825 <div id="prop-Ext.dd.DDProxy-centerFrame"></div>/**
2826 * By default the frame is positioned exactly where the drag element is, so
2827 * we use the cursor offset provided by Ext.dd.DD. Another option that works only if
2828 * you do not have constraints on the obj is to have the drag frame centered
2829 * around the cursor. Set centerFrame to true for this effect.
2830 * @property centerFrame
2835 <div id="method-Ext.dd.DDProxy-createFrame"></div>/**
2836 * Creates the proxy element if it does not yet exist
2837 * @method createFrame
2839 createFrame: function() {
2841 var body = document.body;
2843 if (!body || !body.firstChild) {
2844 setTimeout( function() { self.createFrame(); }, 50 );
2848 var div = this.getDragEl();
2851 div = document.createElement("div");
2852 div.id = this.dragElId;
2855 s.position = "absolute";
2856 s.visibility = "hidden";
2858 s.border = "2px solid #aaa";
2861 // appendChild can blow up IE if invoked prior to the window load event
2862 // while rendering a table. It is possible there are other scenarios
2863 // that would cause this to happen as well.
2864 body.insertBefore(div, body.firstChild);
2868 <div id="method-Ext.dd.DDProxy-initFrame"></div>/**
2869 * Initialization for the drag frame element. Must be called in the
2870 * constructor of all subclasses
2873 initFrame: function() {
2877 applyConfig: function() {
2878 Ext.dd.DDProxy.superclass.applyConfig.call(this);
2880 this.resizeFrame = (this.config.resizeFrame !== false);
2881 this.centerFrame = (this.config.centerFrame);
2882 this.setDragElId(this.config.dragElId || Ext.dd.DDProxy.dragElId);
2886 * Resizes the drag frame to the dimensions of the clicked object, positions
2887 * it over the object, and finally displays it
2889 * @param {int} iPageX X click position
2890 * @param {int} iPageY Y click position
2893 showFrame: function(iPageX, iPageY) {
2894 var el = this.getEl();
2895 var dragEl = this.getDragEl();
2896 var s = dragEl.style;
2898 this._resizeProxy();
2900 if (this.centerFrame) {
2901 this.setDelta( Math.round(parseInt(s.width, 10)/2),
2902 Math.round(parseInt(s.height, 10)/2) );
2905 this.setDragElPos(iPageX, iPageY);
2907 Ext.fly(dragEl).show();
2911 * The proxy is automatically resized to the dimensions of the linked
2912 * element when a drag is initiated, unless resizeFrame is set to false
2913 * @method _resizeProxy
2916 _resizeProxy: function() {
2917 if (this.resizeFrame) {
2918 var el = this.getEl();
2919 Ext.fly(this.getDragEl()).setSize(el.offsetWidth, el.offsetHeight);
2923 // overrides Ext.dd.DragDrop
2924 b4MouseDown: function(e) {
2925 var x = e.getPageX();
2926 var y = e.getPageY();
2927 this.autoOffset(x, y);
2928 this.setDragElPos(x, y);
2931 // overrides Ext.dd.DragDrop
2932 b4StartDrag: function(x, y) {
2933 // show the drag frame
2934 this.showFrame(x, y);
2937 // overrides Ext.dd.DragDrop
2938 b4EndDrag: function(e) {
2939 Ext.fly(this.getDragEl()).hide();
2942 // overrides Ext.dd.DragDrop
2943 // By default we try to move the element to the last location of the frame.
2944 // This is so that the default behavior mirrors that of Ext.dd.DD.
2945 endDrag: function(e) {
2947 var lel = this.getEl();
2948 var del = this.getDragEl();
2950 // Show the drag frame briefly so we can get its position
2951 del.style.visibility = "";
2954 // Hide the linked element before the move to get around a Safari
2956 lel.style.visibility = "hidden";
2957 Ext.dd.DDM.moveToEl(lel, del);
2958 del.style.visibility = "hidden";
2959 lel.style.visibility = "";
2964 beforeMove : function(){
2968 afterDrag : function(){
2972 toString: function() {
2973 return ("DDProxy " + this.id);
2977 <div id="cls-Ext.dd.DDTarget"></div>/**
2978 * @class Ext.dd.DDTarget
2979 * A DragDrop implementation that does not move, but can be a drop
2980 * target. You would get the same result by simply omitting implementation
2981 * for the event callbacks, but this way we reduce the processing cost of the
2982 * event listener and the callbacks.
2983 * @extends Ext.dd.DragDrop
2985 * @param {String} id the id of the element that is a drop target
2986 * @param {String} sGroup the group of related DragDrop objects
2987 * @param {object} config an object containing configurable attributes
2988 * Valid properties for DDTarget in addition to those in
2992 Ext.dd.DDTarget = function(id, sGroup, config) {
2994 this.initTarget(id, sGroup, config);
2998 // Ext.dd.DDTarget.prototype = new Ext.dd.DragDrop();
2999 Ext.extend(Ext.dd.DDTarget, Ext.dd.DragDrop, {
3000 <div id="method-Ext.dd.DDTarget-getDragEl"></div>/**
3002 * Overridden and disabled. A DDTarget does not support being dragged.
3005 getDragEl: Ext.emptyFn,
3006 <div id="method-Ext.dd.DDTarget-isValidHandleChild"></div>/**
3008 * Overridden and disabled. A DDTarget does not support being dragged.
3011 isValidHandleChild: Ext.emptyFn,
3012 <div id="method-Ext.dd.DDTarget-startDrag"></div>/**
3014 * Overridden and disabled. A DDTarget does not support being dragged.
3017 startDrag: Ext.emptyFn,
3018 <div id="method-Ext.dd.DDTarget-endDrag"></div>/**
3020 * Overridden and disabled. A DDTarget does not support being dragged.
3023 endDrag: Ext.emptyFn,
3024 <div id="method-Ext.dd.DDTarget-onDrag"></div>/**
3026 * Overridden and disabled. A DDTarget does not support being dragged.
3029 onDrag: Ext.emptyFn,
3030 <div id="method-Ext.dd.DDTarget-onDragDrop"></div>/**
3032 * Overridden and disabled. A DDTarget does not support being dragged.
3035 onDragDrop: Ext.emptyFn,
3036 <div id="method-Ext.dd.DDTarget-onDragEnter"></div>/**
3038 * Overridden and disabled. A DDTarget does not support being dragged.
3041 onDragEnter: Ext.emptyFn,
3042 <div id="method-Ext.dd.DDTarget-onDragOut"></div>/**
3044 * Overridden and disabled. A DDTarget does not support being dragged.
3047 onDragOut: Ext.emptyFn,
3048 <div id="method-Ext.dd.DDTarget-onDragOver"></div>/**
3050 * Overridden and disabled. A DDTarget does not support being dragged.
3053 onDragOver: Ext.emptyFn,
3054 <div id="method-Ext.dd.DDTarget-onInvalidDrop"></div>/**
3056 * Overridden and disabled. A DDTarget does not support being dragged.
3059 onInvalidDrop: Ext.emptyFn,
3060 <div id="method-Ext.dd.DDTarget-onMouseDown"></div>/**
3062 * Overridden and disabled. A DDTarget does not support being dragged.
3065 onMouseDown: Ext.emptyFn,
3066 <div id="method-Ext.dd.DDTarget-onMouseUp"></div>/**
3068 * Overridden and disabled. A DDTarget does not support being dragged.
3071 onMouseUp: Ext.emptyFn,
3072 <div id="method-Ext.dd.DDTarget-setXConstraint"></div>/**
3074 * Overridden and disabled. A DDTarget does not support being dragged.
3077 setXConstraint: Ext.emptyFn,
3078 <div id="method-Ext.dd.DDTarget-setYConstraint"></div>/**
3080 * Overridden and disabled. A DDTarget does not support being dragged.
3083 setYConstraint: Ext.emptyFn,
3084 <div id="method-Ext.dd.DDTarget-resetConstraints"></div>/**
3086 * Overridden and disabled. A DDTarget does not support being dragged.
3089 resetConstraints: Ext.emptyFn,
3090 <div id="method-Ext.dd.DDTarget-clearConstraints"></div>/**
3092 * Overridden and disabled. A DDTarget does not support being dragged.
3095 clearConstraints: Ext.emptyFn,
3096 <div id="method-Ext.dd.DDTarget-clearTicks"></div>/**
3098 * Overridden and disabled. A DDTarget does not support being dragged.
3101 clearTicks: Ext.emptyFn,
3102 <div id="method-Ext.dd.DDTarget-setInitPosition"></div>/**
3104 * Overridden and disabled. A DDTarget does not support being dragged.
3107 setInitPosition: Ext.emptyFn,
3108 <div id="method-Ext.dd.DDTarget-setDragElId"></div>/**
3110 * Overridden and disabled. A DDTarget does not support being dragged.
3113 setDragElId: Ext.emptyFn,
3114 <div id="method-Ext.dd.DDTarget-setHandleElId"></div>/**
3116 * Overridden and disabled. A DDTarget does not support being dragged.
3119 setHandleElId: Ext.emptyFn,
3120 <div id="method-Ext.dd.DDTarget-setOuterHandleElId"></div>/**
3122 * Overridden and disabled. A DDTarget does not support being dragged.
3125 setOuterHandleElId: Ext.emptyFn,
3126 <div id="method-Ext.dd.DDTarget-addInvalidHandleClass"></div>/**
3128 * Overridden and disabled. A DDTarget does not support being dragged.
3131 addInvalidHandleClass: Ext.emptyFn,
3132 <div id="method-Ext.dd.DDTarget-addInvalidHandleId"></div>/**
3134 * Overridden and disabled. A DDTarget does not support being dragged.
3137 addInvalidHandleId: Ext.emptyFn,
3138 <div id="method-Ext.dd.DDTarget-addInvalidHandleType"></div>/**
3140 * Overridden and disabled. A DDTarget does not support being dragged.
3143 addInvalidHandleType: Ext.emptyFn,
3144 <div id="method-Ext.dd.DDTarget-removeInvalidHandleClass"></div>/**
3146 * Overridden and disabled. A DDTarget does not support being dragged.
3149 removeInvalidHandleClass: Ext.emptyFn,
3150 <div id="method-Ext.dd.DDTarget-removeInvalidHandleId"></div>/**
3152 * Overridden and disabled. A DDTarget does not support being dragged.
3155 removeInvalidHandleId: Ext.emptyFn,
3156 <div id="method-Ext.dd.DDTarget-removeInvalidHandleType"></div>/**
3158 * Overridden and disabled. A DDTarget does not support being dragged.
3161 removeInvalidHandleType: Ext.emptyFn,
3163 toString: function() {
3164 return ("DDTarget " + this.id);