Repository navigation
Expand file tree
/
Copy pathday.js
More file actions
109 lines (87 loc) · 2.53 KB
/
Copy pathday.js
File metadata and controls
109 lines (87 loc) · 2.53 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
Calendar.ns('Views').Day = (function() {
var Parent = Calendar.Views.TimeParent;
function Day() {
Parent.apply(this, arguments);
}
Day.prototype = {
__proto__: Parent.prototype,
panThreshold: 50,
childThreshold: 3,
scale: 'day',
childClass: Calendar.Views.DayChild,
selectors: {
element: '#day-view'
},
_initEvents: function() {
Parent.prototype._initEvents.call(this);
var delegateParent = this.delegateParent || this.frameContainer;
this.delegate(
delegateParent, 'click', '[data-id]', function(e, target) {
Calendar.App.router.show('/event/show/' + target.dataset.id + '/');
}
);
},
handleEvent: function(e) {
Parent.prototype.handleEvent.apply(
this, arguments
);
switch (e.type) {
case 'selectedDayChange':
case 'dayChange':
this.changeDate(e.data[0]);
break;
}
},
_nextTime: function(time) {
return new Date(
time.getFullYear(),
time.getMonth(),
time.getDate() + 1
);
},
_previousTime: function(time) {
return new Date(
time.getFullYear(),
time.getMonth(),
time.getDate() - 1
);
},
render: function() {
this.changeDate(
this.app.timeController.day
);
},
oninactive: function() {
Parent.prototype.oninactive.apply(this, arguments);
/**
* We disable events here because this view
* does not need to be updated while hidden
* notice this will not effect the day children
* at all...
*/
var controller = this.app.timeController;
controller.removeEventListener('dayChange', this);
controller.removeEventListener('selectedDayChange', this);
},
onactive: function() {
Parent.prototype.onactive.apply(this, arguments);
/**
* We only want to listen to views when
* this view is actually active...
*/
var controller = this.app.timeController;
controller.on('dayChange', this);
controller.on('selectedDayChange', this);
controller.moveToMostRecentDay();
// ensure we change the date, if this is already
// the selected date the cost here is very small.
this.changeDate(controller.position);
if (!this.frames || !this.frames.length) {
console.error('(Calendar: render error) no child frames');
console.trace();
}
}
};
Day.prototype.>
return Day;
}());