1 | /* |
---|
2 | * Ext JS Library 2.2.1 |
---|
3 | * Copyright(c) 2006-2009, Ext JS, LLC. |
---|
4 | * licensing@extjs.com |
---|
5 | * |
---|
6 | * http://extjs.com/license |
---|
7 | */ |
---|
8 | |
---|
9 | /** |
---|
10 | * @class Ext.dd.DragZone |
---|
11 | * @extends Ext.dd.DragSource |
---|
12 | * This class provides a container DD instance that proxies for multiple child node sources.<br /> |
---|
13 | * By default, this class requires that draggable child nodes are registered with {@link Ext.dd.Registry}. |
---|
14 | * @constructor |
---|
15 | * @param {Mixed} el The container element |
---|
16 | * @param {Object} config |
---|
17 | */ |
---|
18 | Ext.dd.DragZone = function(el, config){ |
---|
19 | Ext.dd.DragZone.superclass.constructor.call(this, el, config); |
---|
20 | if(this.containerScroll){ |
---|
21 | Ext.dd.ScrollManager.register(this.el); |
---|
22 | } |
---|
23 | }; |
---|
24 | |
---|
25 | Ext.extend(Ext.dd.DragZone, Ext.dd.DragSource, { |
---|
26 | /** |
---|
27 | * @cfg {Boolean} containerScroll True to register this container with the Scrollmanager |
---|
28 | * for auto scrolling during drag operations. |
---|
29 | */ |
---|
30 | /** |
---|
31 | * @cfg {String} hlColor The color to use when visually highlighting the drag source in the afterRepair |
---|
32 | * method after a failed drop (defaults to "c3daf9" - light blue) |
---|
33 | */ |
---|
34 | |
---|
35 | /** |
---|
36 | * Called when a mousedown occurs in this container. Looks in {@link Ext.dd.Registry} |
---|
37 | * for a valid target to drag based on the mouse down. Override this method |
---|
38 | * to provide your own lookup logic (e.g. finding a child by class name). Make sure your returned |
---|
39 | * object has a "ddel" attribute (with an HTML Element) for other functions to work. |
---|
40 | * @param {EventObject} e The mouse down event |
---|
41 | * @return {Object} The dragData |
---|
42 | */ |
---|
43 | getDragData : function(e){ |
---|
44 | return Ext.dd.Registry.getHandleFromEvent(e); |
---|
45 | }, |
---|
46 | |
---|
47 | /** |
---|
48 | * Called once drag threshold has been reached to initialize the proxy element. By default, it clones the |
---|
49 | * this.dragData.ddel |
---|
50 | * @param {Number} x The x position of the click on the dragged object |
---|
51 | * @param {Number} y The y position of the click on the dragged object |
---|
52 | * @return {Boolean} true to continue the drag, false to cancel |
---|
53 | */ |
---|
54 | onInitDrag : function(x, y){ |
---|
55 | this.proxy.update(this.dragData.ddel.cloneNode(true)); |
---|
56 | this.onStartDrag(x, y); |
---|
57 | return true; |
---|
58 | }, |
---|
59 | |
---|
60 | /** |
---|
61 | * Called after a repair of an invalid drop. By default, highlights this.dragData.ddel |
---|
62 | */ |
---|
63 | afterRepair : function(){ |
---|
64 | if(Ext.enableFx){ |
---|
65 | Ext.Element.fly(this.dragData.ddel).highlight(this.hlColor || "c3daf9"); |
---|
66 | } |
---|
67 | this.dragging = false; |
---|
68 | }, |
---|
69 | |
---|
70 | /** |
---|
71 | * Called before a repair of an invalid drop to get the XY to animate to. By default returns |
---|
72 | * the XY of this.dragData.ddel |
---|
73 | * @param {EventObject} e The mouse up event |
---|
74 | * @return {Array} The xy location (e.g. [100, 200]) |
---|
75 | */ |
---|
76 | getRepairXY : function(e){ |
---|
77 | return Ext.Element.fly(this.dragData.ddel).getXY(); |
---|
78 | } |
---|
79 | }); |
---|