Hi Adrien,
I just ran the first parts of your patch against the timeline.js file
on my sandbox.
You replace:
var ether = new Timeline.LinearEther({
centersOn: ("date" in params) ? params.date : new Date(),
interval:
SimileAjax.DateTime.gregorianUnitLengths[params.intervalUnit],
pixelsPerInterval: params.intervalPixels,
theme: theme
});
with
var etherParams = {
interval:
SimileAjax.DateTime.gregorianUnitLengths[params.intervalUnit],
pixelsPerInterval: params.intervalPixels
};
if ('startsOn' in params || 'endsOn' in params) {
if ('startsOn' in params) {
etherParams.startsOn = params.startsOn;
}
if ('endsOn' in params) {
etherParams.endsOn = params.endsOn;
}
} else {
if ('date' in params) {
etherParams.centersOn = params.date;
} else {
etherParams.centersOn = new Date();
}
}
var ether = new Timeline.LinearEther(etherParams);
Several issues:
1) You're not sending the theme to LinearEther
2) You shouldn't use startsOn and endsOn to control "beginningOfTime"
and "endOfTime." The reason is that startsOn and endsOn variables are
already in use (as you note), but for something completely different:
they are used to move the left side or right side of an ether to a
specific date. So to avoid confusion, use different variable names, eg
"beginningOfTime" and "endOfTime."
2) You haven't defined startsOn or endsOn if they're missing from the
incoming params. Perhaps this was intentional, but if so, it usually
isn't a good idea to have to deal with missing keys unless really
necessary. Why not define them with value null to indicate that they
haven't been set? It also enables the code to be shorter.
3) Too many nested if statements. Since LinearEther is already taking
an object, not positional args, it is clear to define a static object
rather than creating a new variable (etherParams) and a bunch of if
statements.
4) The Javascript conditional operator is cleaner than ifs, see below.
5) Regarding key centersOn: Your logic does not include the key if
startsOn or endsOn is defined. Same issues of missing keys as above, I
suggest that you always include the key. Your logic in the Ether code
will ignore centersOn if startsOn or endsOn is defined. (Be sure to
document the usage of the keys as appropriate.)
My reworked version:
var ether = new Timeline.LinearEther({
centersOn: ("date" in params) ? params.date : new Date(),
interval:
SimileAjax.DateTime.gregorianUnitLengths[params.intervalUnit],
pixelsPerInterval: params.intervalPixels,
theme: theme,
beginningOfTime: ('beginningOfTime' in params) ?
params.beginningOfTime : null,
endOfTime: ('endOfTime' in params) ?
params.endOfTime : null
});
As mentioned above, since you are adding more keys to LinearEther, you
should take this opportunity to document ALL of them. The
documentation should be added to the definition of LinearEther, not to
where it is called.
Another issue is that I suggest that rather than subclassing the _band
object, you may just want to add more logic to its methods that need
to be changed.
Or, for bands that have beginningOfTime/endOfTime dates: after the
band object has been instantiated, just replace the couple of methods
that are different. Eg I presume the _moveEther would change.
My thought on adding beginningOfTime/endOfTime dates is that the
Ether would simply ignore _moveEther requests that would result in
showing dates earlier that beginningOfTime (when moving back in time)
or later than endOfTime when moving forward in time. Note that you
should allow for the corner case of a *wide* monitor that would have
the beginningOfTime on the left side of the screen and a date AFTER
the endOfTime on the right side. You could also solve by having the
etherPainter show a neutral gray before the beginningOfTime and after
the endOfTime.
My suggestion for the next step is that you prepare all of your
changes as one checkin so they can be evaluated as a whole. And please
also create a demonstration / test file.
Thanks again for your time with the project.
Comments and feedback on this email are appreciated.
Regards,
Larry
>
> On Oct 23, 5:24 am, "Adrien Di Mascio" <[EMAIL PROTECTED]> wrote:
>
> > Hi there,
>
> > I'm currently implementing a basic version of a "FixedBand" in the timeline,
> > that is a band for which you specify a "start date", a "stop date". Once
> > displayed, this band cannot itself be scrolled but you can double click
> > somewhere in it and the synchronized bands get centered on this date.
> > I also implemented the classic "scroll" mechansim on this fixed band
> > but then only the "highlight" div moves (and other bands are synchronized).
>
> > That said, it's not yet ready for a patch because it relies on a few
> > hardcoded
> > informations for now and I will tackle this as soon as I can.
>
> > Nervertheless, I've changed a bit scripts/timeline.js (patch attached, based
> > on rev. 1623). The patch consists in 2 parts :
>
> > 1. I noticed that LinearEther is able to use a "startsOn" and a "endsOn"
> > parameters but Timeline.createBandInfo() doesn't try to use them. The
> > patch looks for a "startsOn" and a "endsOn" parameter in the bandInfo
> > and pass them to LinearEther.
>
> > 2. I create a "FixedBand" subclass of "Timeline._Band". In order to use
> > it easily, I changed the way Bands were instanciated.
>
> > Please let me know if I overlooked the problem or if something is wrong
> > with my patch. I will provide my FixedBand code as soon as it gets
> > tidied.
>
> > Cheers,
> > Adrien.
>
> > timeline.js.patch
> > 2KViewDownload
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"SIMILE Widgets" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/simile-widgets?hl=en
-~----------~----~----~----~------~----~------~--~---