From ec409c06f50db5301467f323a29d206228c4d40a Mon Sep 17 00:00:00 2001 From: "michael.buettner%sun.com" Date: Tue, 1 Aug 2006 11:23:00 +0000 Subject: [PATCH] 'previous/next timeslot' now respects working hours --- .../sun-calendar-event-dialog-attendees.xml | 15 +- .../sun-calendar-event-dialog-freebusy.xml | 149 ++++++++++++------ 2 files changed, 118 insertions(+), 46 deletions(-) diff --git a/calendar/prototypes/wcap/sun-calendar-event-dialog-attendees.xml b/calendar/prototypes/wcap/sun-calendar-event-dialog-attendees.xml index 2dc8fac7d6d..8f02131785d 100644 --- a/calendar/prototypes/wcap/sun-calendar-event-dialog-attendees.xml +++ b/calendar/prototypes/wcap/sun-calendar-event-dialog-attendees.xml @@ -1291,6 +1291,8 @@ null null + 0 + 24 null null @@ -1306,6 +1308,17 @@ if (isToDo(item)) return; + var pb2 = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch2); + + // get default start/end times from prefs and set on the + // view. if we hit an error (eg because sunbird's pref + // infrastructure hasn't created the pref yet), the + // defaults will do + try { + this.mStartHour = pb2.getIntPref("calendar.view.defaultstarthour"); + this.mEndHour = pb2.getIntPref("calendar.view.defaultendhour"); + } catch (ex) {} + var self = this; var load = function loadHandler() { self.onLoad(); }; window.addEventListener("load", load, true); @@ -1602,7 +1615,7 @@ = 1.0) diff --git a/calendar/prototypes/wcap/sun-calendar-event-dialog-freebusy.xml b/calendar/prototypes/wcap/sun-calendar-event-dialog-freebusy.xml index 9e26539531a..47f639df5d7 100644 --- a/calendar/prototypes/wcap/sun-calendar-event-dialog-freebusy.xml +++ b/calendar/prototypes/wcap/sun-calendar-event-dialog-freebusy.xml @@ -661,7 +661,9 @@ var offset = entry.dtRangeStart.subtractDate(start); var duration = entry.dtRangeEnd.subtractDate(entry.dtRangeStart); var startHours = Math.floor(offset.inSeconds / 3600); - var endHours = startHours + Math.ceil(duration.inSeconds / 3600); + var endHours = startHours + + Math.ceil((duration.inSeconds / 3600) + + (offset.inSeconds / 3600 % startHours)); // set all affected state slots to 'busy' for(var i=startHours; i= 0) { - - // time could be considered as a possible candidate, - // we need to check if 'numHours' are free from here on. - var startCheck = offset; - var endCheck = offset+numHours; - while(startCheck < endCheck) { - if(startCheck >= maxOffset) - break; - if(this.mState[startCheck] == 2) - break; - startCheck++; - } - // return if a new free slot has been found. - if(startCheck == endCheck) - return start; + if(start.hour >= this.mStartHour) { + if((start.hour+numHours) <= this.mEndHour) { + + // time could be considered as a possible candidate, + // we need to check if 'numHours' are free from here on. + var numHoursPerDay = this.mEndHour - this.mStartHour; + var startCheck = (start.day-base.day)*numHoursPerDay+(start.hour-this.mStartHour); + var endCheck = startCheck+numHours; + while(startCheck < endCheck) { + if(this.mState[startCheck] == 2) + break; + startCheck++; + } + + // return if a new free slot has been found. + if(startCheck == endCheck) + return start; + } + } } start.hour++; start.normalize(); - offset++; } return aTime; @@ -767,50 +771,49 @@ = maxOffset) - break; - if(this.mState[startCheck] == 2) - break; - startCheck++; - } + if(start.hour >= this.mStartHour) { + if((start.hour+numHours) <= this.mEndHour) { + + // time could be considered as a possible candidate, + // we need to check if 'numHours' are free from here on. + var numHoursPerDay = this.mEndHour - this.mStartHour; + var startCheck = (start.day-base.day)*numHoursPerDay+(start.hour-this.mStartHour); + var endCheck = startCheck+numHours; + while(startCheck < endCheck) { + if(this.mState[startCheck] == 2) + break; + startCheck++; + } - // return if a new free slot has been found. - if(startCheck == endCheck) - return start; + // return if a new free slot has been found. + if(startCheck == endCheck) + return start; + } + } } start.hour--; start.normalize(); - offset--; } return aTime; @@ -1106,7 +1109,7 @@ this.mFreeBusy.push(i); this.mFreeBusySequence = this.mFreeBusy.length-1; - this.mCalendar.getFreeBusyTimes(calid,start,end,true,this.mFreeBusyListener,true,this.mFreeBusySequence); + this.mCalendar.session.getFreeBusyTimes(calid,start,end,true,this.mFreeBusyListener,true,this.mFreeBusySequence); } } catch (ex) {} @@ -1147,12 +1150,21 @@ @@ -1169,12 +1200,21 @@