Closed
Bug 360674
Opened 19 years ago
Closed 19 years ago
prototype event dialog : implement zoom-feature for free/busy grid
Categories
(Calendar :: General, enhancement)
Calendar
General
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: michael.buettner, Assigned: michael.buettner)
Details
Attachments
(1 file)
|
28.04 KB,
patch
|
thomas.benisch
:
first-review+
|
Details | Diff | Splinter Review |
according to the specification the free/busy grid should have the possibility to modify the granularity of the displayed time-grid. please see http://wiki.mozilla.org/Calendar:SMB_Event_Dialog_-_Invite_Attendee for further information on this topic.
| Assignee | ||
Comment 1•19 years ago
|
||
This patch implements the zoom-feature. It adds a menulist to the lower left of the free/busy dialog which offers the zoom-factor (ranging from 400% to 25%). This factor affects the scale of the timebar instead of changing the size of the grid-boxes.
Attachment #245828 -
Flags: first-review?(thomas.benisch)
Comment 2•19 years ago
|
||
mozilla/calendar/prototypes/wcap/sun-calendar-event-dialog-attendees.xml
========================================================================
+ <xul:menulist anonid="zoom-menulist" oncommand="onZoomFactor(this.value);">
+ <xul:menupopup>
+ <xul:menuitem label="400%" value="25"/>
+ <xul:menuitem label="200%" value="50"/>
+ <xul:menuitem label="100%" value="100"/>
+ <xul:menuitem label="50%" value="200"/>
+ <xul:menuitem label="25%" value="400"/>
+ </xul:menupopup>
+ </xul:menulist>
The labels should be moved into a dtd.
+ <method name="onZoomFactor">
+ <parameter name="aValue"/>
+ <body>
+ <![CDATA[
+ this.zoomFactor = parseInt(aValue);
+ ]]>
+ </body>
+ </method>
Why do you need parseInt() here? I think the values you pass are well defined
in your menuitems. This might be different if you have to parse some user input.
In addition, I prefer to have the start and end of the CDATA sequence in the
same line as the body tags.
mozilla/calendar/prototypes/wcap/sun-calendar-event-dialog-freebusy.xml
=======================================================================
// last but not least set the 'scheduled' attribute according
// to the specified start- and enddate.
- var numChilds = hours.childNodes.length;
+ /*var numChilds = hours.childNodes.length;
for(var i=0; i<numChilds; i++) {
var hour = hours.childNodes[i];
date.hour = i + this.mStartHour;
if (date.compare(this.mStartDate) >= 0 && date.compare(this.mEndDate) < 0) {
hour.setAttribute("scheduled","true");
} else {
hour.removeAttribute("scheduled");
}
- }
+ }*/
If this code is not needed, remove it.
<property name="dayOffset">
<setter>
<![CDATA[
- var numHours = this.mEndHour - this.mStartHour;
+ var numHours = this.numHours;
this.mOffset = val*numHours;
this.showState();
return val;
]]>
</setter>
</property>
You don't need an extra variable numHours, use this.mOffset = val*this.numHours
instead.
var duration = rangeEnd.subtractDate(rangeStart);
- var startHours = Math.floor(offset.inSeconds / 3600);
- var endHours = startHours +
- Math.ceil((duration.inSeconds / 3600) +
- (offset.inSeconds / 3600 % startHours));
+ var start_in_minutes = Math.floor(offset.inSeconds / 60);
+ var end_in_minutes = start_in_minutes +
+ Math.ceil((duration.inSeconds / 60) +
+ (offset.inSeconds / 60 % start_in_minutes));
- // set all affected state slots to 'busy'
- for(var i=startHours; i<endHours; i++) {
-
- // 'i' is some integer in the interval [0,range*24].
+ var minute2offset = function(value,fNumHours,numHours,start_hour,zoomfactor) {
+
+ // 'value' is some integer in the interval [0,range*24*60].
// we need to map this offset into our array which
// holds elements for 'range' days with [start,end] hours each.
- var day = (i-(i%24))/24;
- var hour = Math.floor(i%24) - this.mStartHour;
- if(hour >= 0 && hour < numHours) {
- this.mState[numHours*day+hour] = 2;
- }
+ var minutes_per_day = 24*60;
+ var day = (value-(value%minutes_per_day))/minutes_per_day;
+ var minute = Math.floor(value%minutes_per_day) - (start_hour*60);
+
+ if(minute < 0)
+ minute = 0;
+ if(minute >= (numHours*60))
+ minute = (numHours*60)-1;
+
+ // how to get from minutes to offset?
+ // 60 = 100%, 30 = 50%, 15 = 25%, etc.
+ var minutes_per_block = 60 * zoomfactor / 100;
+
+ var block = Math.floor(minute / minutes_per_block);
+
+ return Math.ceil(fNumHours)*day+block;
+ }
Can you elaborate your usage of Math.floor() and Math.ceil() in more detail,
that means why rounding up in some cases and rounding down in other cases
leads to a valid result.
Comment 3•19 years ago
|
||
Comment on attachment 245828 [details] [diff] [review]
patch v1
r1=tbe with the questions in comment #2 answered.
Attachment #245828 -
Flags: first-review?(thomas.benisch) → first-review+
| Assignee | ||
Comment 4•19 years ago
|
||
all nits have been addressed. I also added several comments to the source code in order to explain the calculations in more detail.
Checked in on trunk and MOZILLA_1_8_BRANCH
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•