Bundled with sIFR are three add-ons. You can find more information about them here under "Official Add-ons". Additionaly, if you have written an add-on yourself, please post it here under "Unofficial Add-ons". The reason for this is that official add-ons will be bundled with the releases and are verified to work with these releases. These guarantees cannot be given for unofficial add-ons.
Anyway, let's get down to business.
These are the add-ons which are officially supported by the sIFR team. The latest version of these add-ons is 1.1. You can find them under sifr-addons.js
in the download. Using them is simple: just load this file after you load the main sIFR code:
<script src="sifr.js" type="text/javascript"></script>
<script src="sifr-addons.js" type="text/javascript"></script>
The preference manager allows you to give your visitors the option of enabling or disabling sIFR. It's accessible via sIFR.preferenceManager
(as always make sure that sIFR is in fact a function!). It has the following self-explanatory methods: enable
, disable
and test
. It's important to note that test
returns a boolean value, so you can use it in an if
statement:
if(sIFR.preferenceManager.test() == false){
// do stuff
}
This is in fact what is done in the add-on: if the visitor has set it's preference not to use sIFR the script takes care of adhering to this decision.
If you want to reset the preference, you can use sIFR.preferenceManager.storage.reset()
. Note that depending on the browser this may not take place immediately.
Disabling sIFR will not remove the headlines. To do so, you'll have to use the rollback add-on (see below).
By default the preferences are stored in a cookie. If, instead, you want to use your own storage system, you can replace the default method by your own.
The storage methods are accessible through sIFR.preferenceManager.storage
. The default system has the following methods: set
, get
and reset
. set
takes a boolean as it's only argument, the other two methods take no arguments. As long as your own system uses these three methods it will intergrate with the Preference Manager perfectly.
Aside from these three methods the default storage system also has a property named sCookieId
. This is the ID of the cookie in which the preference is stored.
Rollback removes the sIFR elements from the page. This can be useful if you want to provide a styleswitcher: first rollback the sIFR elements, and then replace them again based on the preference of the visitor. You can invoke Rollback via sIFR.rollback()
.
sIFR.rollback("h1")
And:
sIFR.rollback(named({sSelector:"h1"}))
To implement a rollforward option you have to wrap the replacement statements in a function. To do the replacement you call this function, this means you have to call it once, right after you have created it, and when you want to roll forward.
For example:
function do_sIFR(){
// replacement statements go here
};
do_sIFR(); // execute immediately, so the headlines will get replaced
And a link to the rollforward option:
<a href="javascript:do_sIFR();">Show sIFR headlines</a>
sIFR-hasFlash
class from the html
and body
element. Invoke it using sIFR.removeDecoyClasses()
.
None have been added yet.