]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | /*\r |
2 | * Internal drag zone implementation for the calendar components. This provides base functionality\r | |
3 | * and is primarily for the month view -- DayViewDD adds day/week view-specific functionality.\r | |
4 | */\r | |
5 | Ext.define('Ext.calendar.dd.DragZone', {\r | |
6 | extend: 'Ext.dd.DragZone',\r | |
7 | \r | |
8 | requires: [\r | |
9 | 'Ext.calendar.dd.StatusProxy',\r | |
10 | 'Ext.calendar.data.EventMappings'\r | |
11 | ],\r | |
12 | \r | |
13 | ddGroup: 'CalendarDD',\r | |
14 | eventSelector: '.ext-cal-evt',\r | |
15 | \r | |
16 | constructor: function(el, config) {\r | |
17 | if (!Ext.calendar._statusProxyInstance) {\r | |
18 | Ext.calendar._statusProxyInstance = new Ext.calendar.dd.StatusProxy();\r | |
19 | }\r | |
20 | this.proxy = Ext.calendar._statusProxyInstance;\r | |
21 | this.callParent(arguments);\r | |
22 | },\r | |
23 | \r | |
24 | getDragData: function(e) {\r | |
25 | // Check whether we are dragging on an event first\r | |
26 | var t = e.getTarget(this.eventSelector, 3);\r | |
27 | if (t) {\r | |
28 | var rec = this.view.getEventRecordFromEl(t);\r | |
29 | return {\r | |
30 | type: 'eventdrag',\r | |
31 | ddel: t,\r | |
32 | eventStart: rec.data[Ext.calendar.data.EventMappings.StartDate.name],\r | |
33 | eventEnd: rec.data[Ext.calendar.data.EventMappings.EndDate.name],\r | |
34 | proxy: this.proxy\r | |
35 | };\r | |
36 | }\r | |
37 | \r | |
38 | // If not dragging an event then we are dragging on\r | |
39 | // the calendar to add a new event\r | |
40 | t = this.view.getDayAt(e.getX(), e.getY());\r | |
41 | if (t.el) {\r | |
42 | return {\r | |
43 | type: 'caldrag',\r | |
44 | start: t.date,\r | |
45 | proxy: this.proxy\r | |
46 | };\r | |
47 | }\r | |
48 | return null;\r | |
49 | },\r | |
50 | \r | |
51 | onInitDrag: function(x, y) {\r | |
52 | if (this.dragData.ddel) {\r | |
53 | var ghost = this.dragData.ddel.cloneNode(true),\r | |
54 | child = Ext.fly(ghost).down('dl');\r | |
55 | \r | |
56 | Ext.fly(ghost).setWidth('auto');\r | |
57 | \r | |
58 | if (child) {\r | |
59 | // for IE/Opera\r | |
60 | child.setHeight('auto');\r | |
61 | }\r | |
62 | this.proxy.update(ghost);\r | |
63 | this.onStartDrag(x, y);\r | |
64 | }\r | |
65 | else if (this.dragData.start) {\r | |
66 | this.onStartDrag(x, y);\r | |
67 | }\r | |
68 | this.view.onInitDrag();\r | |
69 | return true;\r | |
70 | },\r | |
71 | \r | |
72 | afterRepair: function() {\r | |
73 | if (Ext.enableFx && this.dragData.ddel) {\r | |
74 | Ext.fly(this.dragData.ddel).highlight(this.hlColor || 'c3daf9');\r | |
75 | }\r | |
76 | this.dragging = false;\r | |
77 | },\r | |
78 | \r | |
79 | getRepairXY: function(e) {\r | |
80 | if (this.dragData.ddel) {\r | |
81 | return Ext.fly(this.dragData.ddel).getXY();\r | |
82 | }\r | |
83 | },\r | |
84 | \r | |
85 | afterInvalidDrop: function(e, id) {\r | |
86 | Ext.select('.ext-dd-shim').hide();\r | |
87 | }\r | |
88 | }); |