]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | /**\r |
2 | * DD implementation for Panels.\r | |
3 | * @private\r | |
4 | */\r | |
5 | Ext.define('Ext.panel.DD', {\r | |
6 | extend: 'Ext.dd.DragSource',\r | |
7 | requires: ['Ext.panel.Proxy'],\r | |
8 | \r | |
9 | constructor : function(panel, cfg){\r | |
10 | var me = this;\r | |
11 | \r | |
12 | me.panel = panel;\r | |
13 | me.dragData = {panel: panel};\r | |
14 | me.panelProxy = new Ext.panel.Proxy(panel, cfg);\r | |
15 | me.proxy = me.panelProxy.proxy;\r | |
16 | \r | |
17 | me.callParent([panel.el, cfg]);\r | |
18 | me.setupEl(panel);\r | |
19 | },\r | |
20 | \r | |
21 | setupEl: function(panel){\r | |
22 | var me = this,\r | |
23 | header = panel.header,\r | |
24 | el = panel.body;\r | |
25 | \r | |
26 | if (header) {\r | |
27 | me.setHandleElId(header.id);\r | |
28 | el = header.el;\r | |
29 | }\r | |
30 | if (el) {\r | |
31 | el.setStyle('cursor', 'move');\r | |
32 | me.scroll = false;\r | |
33 | } else {\r | |
34 | // boxready fires after first layout, so we'll definitely be rendered\r | |
35 | panel.on('boxready', me.setupEl, me, {single: true});\r | |
36 | }\r | |
37 | },\r | |
38 | \r | |
39 | showFrame: Ext.emptyFn,\r | |
40 | startDrag: Ext.emptyFn,\r | |
41 | \r | |
42 | b4StartDrag: function(x, y) {\r | |
43 | this.panelProxy.show();\r | |
44 | },\r | |
45 | \r | |
46 | b4MouseDown: function(e) {\r | |
47 | var xy = e.getXY(),\r | |
48 | x = xy[0],\r | |
49 | y = xy[1];\r | |
50 | \r | |
51 | this.autoOffset(x, y);\r | |
52 | },\r | |
53 | \r | |
54 | onInitDrag : function(x, y){\r | |
55 | this.onStartDrag(x, y);\r | |
56 | return true;\r | |
57 | },\r | |
58 | \r | |
59 | createFrame : Ext.emptyFn,\r | |
60 | \r | |
61 | getDragEl : function(e){\r | |
62 | var ghost = this.panelProxy.ghost;\r | |
63 | if (ghost) {\r | |
64 | return ghost.el.dom;\r | |
65 | }\r | |
66 | },\r | |
67 | \r | |
68 | endDrag : function(e){\r | |
69 | this.panelProxy.hide();\r | |
70 | this.panel.saveState();\r | |
71 | },\r | |
72 | \r | |
73 | autoOffset : function(x, y) {\r | |
74 | x -= this.startPageX;\r | |
75 | y -= this.startPageY;\r | |
76 | this.setDelta(x, y);\r | |
77 | },\r | |
78 | \r | |
79 | // Override this, we don't want to repair on an "invalid" drop, the panel\r | |
80 | // should main it's position\r | |
81 | onInvalidDrop: function(target, e, id) {\r | |
82 | var me = this;\r | |
83 | \r | |
84 | if (me.beforeInvalidDrop(target, e, id) !== false) {\r | |
85 | if (me.cachedTarget) {\r | |
86 | if(me.cachedTarget.isNotifyTarget){\r | |
87 | me.cachedTarget.notifyOut(me, e, me.dragData);\r | |
88 | }\r | |
89 | me.cacheTarget = null;\r | |
90 | }\r | |
91 | \r | |
92 | if (me.afterInvalidDrop) {\r | |
93 | /**\r | |
94 | * An empty function by default, but provided so that you can perform a custom action\r | |
95 | * after an invalid drop has occurred by providing an implementation.\r | |
96 | * @param {Event} e The event object\r | |
97 | * @param {String} id The id of the dropped element\r | |
98 | * @method afterInvalidDrop\r | |
99 | */\r | |
100 | me.afterInvalidDrop(e, id);\r | |
101 | }\r | |
102 | }\r | |
103 | }\r | |
104 | }); |