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