PonteIneptique / simile-widgets

Automatically exported from code.google.com/p/simile-widgets
0 stars 0 forks source link

TIMELINE. Error in IE when the number of bands is greater than the number of background colors in the theme. #175

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
If you have more bands in your timeline than the number of background
colors in the theme, for instance five bands while using the ClassicTheme,
which has four colors, you get an error. This error occurs in the
EtherPainter's initialize function, when it tries to set the background
color using the following line:

this._backgroundLayer.style.background =
this._theme.ether.backgroundColors[band.getIndex()];

The band.getIndex() eventually returns a number greater than the length of
the array of backgroundColors and throws an exception - at least in IE.
Firefox seems to treat the out-of-bounds as a zero index and give you the
first background color.

I've fixed this adding a backgroundColor method to the theme. In theme.js,
I modified the ether definition of the ClassicTheme implementation to be:

this.ether = {
        backgroundColors: [
            "#EEE",
            "#DDD",
            "#CCC",
            "#AAA"
        ],
        backgroundColor: function(index) {
            return this.backgroundColors[index % this.backgroundColors.length];
        },
        highlightColor: "white",
        ....

Then in ether-painters.js, in each EtherPainter initialize method, I
changed the line:

this._backgroundLayer.style.background =
this._theme.ether.backgroundColors[band.getIndex()];

to read:

this._backgroundLayer.style.background =
this._theme.ether.backgroundColor(band.getIndex());

Now the bands will cycle through the background colors instead of running
over the index bounds.

IE 6

[Submitted by Robert Thew on simile.mit.edu]

Original issue reported on code.google.com by GabrielR...@googlemail.com on 7 Apr 2009 at 7:27