Skip to content

Commit

Permalink
fix nextFreebusy/prevFreebusy
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Schneider <jan@horde.org>
Bug: 13757
  • Loading branch information
Pascal Rigaux authored and yunosh committed Dec 19, 2014
1 parent dc9eed5 commit bd8ef95
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions kronolith/js/kronolith.js
Expand Up @@ -1295,10 +1295,10 @@ KronolithCore = {
}
switch (tab.identify()) {
case 'kronolithEventTabAttendees':
this.attendeeStartDateHandler($('kronolithFBDate').innerHTML);
this.attendeeStartDateHandler(this.getFBDate());
break;
case 'kronolithEventTabResources':
this.resourceStartDateHandler($('kronolithFBDate').innerHTML);
this.resourceStartDateHandler(this.getFBDate());
break;
}
},
Expand Down Expand Up @@ -6144,7 +6144,7 @@ KronolithCore = {
}
if (!Object.isUndefined(r.fb)) {
this.freeBusy.get(attendee.l)[1] = r.fb;
this.insertFreeBusy(attendee.l, $('kronolithFBDate').innerHTML);
this.insertFreeBusy(attendee.l, this.getFBDate());
}
}.bind(this)
});
Expand Down Expand Up @@ -6298,6 +6298,17 @@ KronolithCore = {
}
},

getFBDate: function () {
var startDate = $('kronolithFBDate').innerHTML;
startDate = startDate.split(' ');
if (startDate.length > 1) {
startDate = startDate[1];
} else {
startDate = startDate[0];
}
return Date.parseExact(startDate, Kronolith.conf.date_format);
},

/**
* Updates rows with free/busy information in the attendees table.
*
Expand All @@ -6306,7 +6317,7 @@ KronolithCore = {
* @param date start An optinal start date for f/b info. If omitted,
* $('kronolithEventStartDate') is used.
*/
insertFreeBusy: function(attendee, startDate)
insertFreeBusy: function(attendee, start)
{
if (!$('kronolithEventDialog').visible() ||
!this.freeBusy.get(attendee)) {
Expand All @@ -6321,23 +6332,15 @@ KronolithCore = {
}

if (!td.getWidth()) {
this.insertFreeBusy.bind(this, attendee, startDate).defer();
this.insertFreeBusy.bind(this, attendee, start).defer();
return;
}

if (div) {
div.purge();
div.remove();
}
if (startDate) {
startDate = startDate.split(' ');
if (startDate.length > 1) {
startDate = startDate[1];
} else {
startDate = startDate[0];
}
start = Date.parseExact(startDate, Kronolith.conf.date_format);
} else {
if (!start) {
start = Date.parseExact($F('kronolithEventStartDate'), Kronolith.conf.date_format);
}
var end = start.clone().add(1).days(),
Expand Down Expand Up @@ -6387,7 +6390,7 @@ KronolithCore = {

fbStartDateHandler: function(start)
{
this.updateFBDate(Date.parseExact(start, Kronolith.conf.date_format));
this.updateFBDate(start);
this.resetFBRows();
// Need to check visisbility - multiple changes will break the display
// due to the use of .defer() in insertFreeBusy().
Expand Down Expand Up @@ -6415,14 +6418,14 @@ KronolithCore = {

nextFreebusy: function()
{
var fbdate = Date.parse($('kronolithFBDate').innerHTML);
this.fbStartDateHandler(fbdate.addDays(1).toString(Kronolith.conf.date_format));
var fbdate = this.getFBDate();
this.fbStartDateHandler(fbdate.addDays(1));
},

prevFreebusy: function()
{
var fbdate = Date.parse($('kronolithFBDate').innerHTML);
this.fbStartDateHandler(fbdate.addDays(-1).toString(Kronolith.conf.date_format));
var fbdate = this.getFBDate();
this.fbStartDateHandler(fbdate.addDays(-1));
},

/**
Expand Down

0 comments on commit bd8ef95

Please sign in to comment.