switch ($action) {
case 'ListEvents':
- $dates = Kronolith::listEvents(Util::getFormData('start'), Util::getFormData('end'));
+ $start = new Horde_Date(Util::getFormData('start'));
+ $end = new Horde_Date(Util::getFormData('end'));
+ $dates = Kronolith::listEvents($start, $end);
if (is_a($dates, 'PEAR_Error')) {
$notification->push($dates, 'horde.error');
$result = false;
} else {
$result = new stdClass;
- $result->events = array();
+ $result->sig = $start->dateString() . $end->dateString();
foreach ($dates as $date => $events) {
foreach ($events as $id => $event) {
$result->events[$date][$id] = $event->toJSON();
KronolithCore = {
// Vars used and defaulting to null/false:
// DMenu, alertrequest, inAjaxCallback, is_logout, onDoActionComplete,
- // eventForm
+ // eventForm, eventsLoading
view: '',
+ calendars: [],
+ ecache: {},
+ efifo: {},
date: new Date(),
doActionOpts: {
case 'year':
case 'agenda':
case 'tasks':
- if (this.view == loc) {
- break;
- }
-
var locCap = loc.capitalize();
[ 'Day', 'Week', 'Month', 'Year', 'Tasks', 'Agenda' ].each(function(a) {
$('kronolithNav' + a).removeClassName('on');
});
$('kronolithNav' + locCap).addClassName('on');
- if (this.view) {
+ if (this.view && this.view != loc) {
$('kronolithView' + this.view.capitalize()).fade();
}
date = this.date;
}
+ if (this.view == loc && date.getYear() == this.date.getYear() &&
+ ((loc == 'year') ||
+ (loc == 'month' && date.getMonth() == this.date.getMonth()) ||
+ (loc == 'day' && date.dateString() == this.date.dateString()))) {
+ return;
+ }
+
this.updateView(date, loc);
if ($('kronolithView' + locCap)) {
$('kronolithView' + locCap).appear();
case 'month':
var body = $('kronolithViewMonth').down('.kronolithViewBody'),
day = date.clone(), monthEnd = date.clone(),
- cell, monday, firstDay, lastDay;
+ cell, monday, firstDay;
// Calculate first and last days being displayed.
day.setDate(1);
- firstDay = day.clone()
day.moveToBeginOfWeek();
+ firstDay = day.clone()
monthEnd.moveToLastDayOfMonth();
- lastDay = monthEnd.clone();
monthEnd.moveToBeginOfWeek();
// Remove old rows. Maybe we should only rebuild the calendars if
}
// Load events.
- this.doAction('ListEvents', { start: firstDay.toJSON(), end: lastDay.toJSON() }, this._monthCallback.bind(this));
+ this._loadEvents(firstDay, monthEnd, this._monthCallback.bind(this));
break;
}
},
/**
+ */
+ _loadEvents: function(firstDay, lastDay, callback, calendar)
+ {
+ this.eventsLoading = firstDay.dateString() + lastDay.dateString();
+ this.doAction('ListEvents', { start: firstDay.toJSON(), end: lastDay.toJSON() }, callback);
+ },
+
+ /**
* Callback method for inserting events in the month view.
*
* @param object r The returned object.
{
var div;
- if (typeof r.response.events.length == 'undefined') {
+ // Check if this is the still the result of the most current request.
+ if (r.response.sig != this.eventsLoading) {
+ return;
+ }
+
+ if (r.response.events) {
$H(r.response.events).each(function(date) {
$H(date.value).each(function(event) {
- div = new Element('DIV', { 'class': 'kronolithEvent', 'style': 'background-color:' + event.value.bg + ';color:' + event.value.fg });
+ div = new Element('DIV', { 'class': 'kronolithEvent', 'style': 'background-color:' + event.value.bg + ';color:' + event.value.fg, 'calendar': event.value.c });
div.setText(event.value.t)
.observe('mouseover', div.addClassName.curry('kronolithSelected'))
.observe('mouseout', div.removeClassName.curry('kronolithSelected'));
elt = elt.up();
}
+ Prototype.emptyFunction();
},
mouseHandler: function(e, type)