tags:

views:

247

answers:

2

Hi everybody,

I just have a short question about switching the color of sifr objects on the fly with changeCSS:

The point is, that I'd like to change the color of the two headers whenever the user clicks on the "Switch style to..." on the upper right corner. Check the example page: www.capsule.hu/index2.html - and after clicking on the link nothing happens with sifr objects. Version is: sIFR, version 3, revision 436.

I'm using Kelvin Lucks styleswitcher script with some modifications (the script is hardly the same as here: http://www.digital-campaign.com/dc-example/) - on my current page I'm calling the sIFR.replace method whenever user changes the style (www.capsule.hu), but it seems a little bit slow for me, that's why I'd like to change.

Thanks for every help in forth, Csongor

A: 

You can place the following in the body of the switchSifrColor function on your site:

$('h2').removeClass("sIFR-replaced"); 

sIFR.replace(helvetica, {
    selector: 'h2',
    wmode: 'transparent',
    css: [ '.sIFR-root { color: #' + color + '; }' ]
});

The main change is that the css property is an array of strings, unlike the object that you were passing.

And a side-note: great work! The site looks very nice.

[Edit]

I guess this will prove more useful than calling replace again.

var css = '.sIFR-root {color:#ff1ff1;}';

$.each(sIFR.replacements['h2'], function() {
    this.changeCSS(css);
});

I just tried it through Firebug and it looks great :)

[/Edit]

Alexander Gyoshev
Yepp, the problem is not with the current version (www.capsule.hu) but with this one: http://www.capsule.hu/index2.html - I'd like to avoid to recall sIFR.replace, like on the above mentioned example, but it doesn't works somehow (it's realy almost the same as in the example).Side-note: Thank you :]
How about the edited solution? :)
Alexander Gyoshev
Still it doesn't works for me :[ jquery throws 'object is undefined' error for sIFR.replacements['h2'] - if I use normal js 'for', the result is still the same... Now I've replaced the main script capsule.hu to the switchstyle-sifr.js because it's much more easier to handle, but I can't get it work without redrawing the flash :[ Anyway it's not a big problem, if cache is enabled it doesn't takes too much time to redraw, but I simply can't understand why it doesn't work. But thank you for the help Alexander :]
`sIFR.replacements[]` contains all replaced elements as array indices. It also has the replaced elements per selector used, so that'd be `sIFR.replacements['h2']` for replaced `h2` elements. Could it be that you're using a different selector than `h2`?
Mark Wubben
It's applied to h2, that's sure :)
A: 

It's the same for me.

I'm unable to use sIFR.replacements[].

It returns a JS error : "sIFR.replacements['h5#pullquote']" is undefined". Even, "sIFR.replacements" is undefined.

I'm using sIFR 3 revison 436.

Franck