Wiki.Novemberborn, sIFR 3 Documentation & FAQ

Add-ons

Official Add-ons

None have been added yet.

Unofficial Add-ons

Rollback

Rollback is an unsupported and unofficial add-on derived from the previous rollback function in sIFR 2 official add-ons 1.2. This version is designed to work with sIFR 3.

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().

You can optionally use selectors when rolling back: sIFR.rollback("h1")

/*  sIFR Unofficial Rollback addon for sIFR 3
    Modified by Paul Hassinger - hassinger.paul@ipaul.com - http://www.ipaul.com
    (modified from sIFR 2.0.1 Official Add-ons 1.2)

    Copyright 2005 Mark Wubben

    This software is licensed under the CC-GNU LGPL <http://creativecommons.org/licenses/LGPL/2.1/>
*/

if(typeof sIFR == "object"){
    sIFR.rollback = function(){
        function rollback(sSelector){
            if(sSelector == null){
                sSelector = "";
            } else {
                sSelector += ">";
            };

            sIFR.removeFlashClass();

            if(doRollback(sSelector+"embed") == false){
                doRollback(sSelector+"object");
            };
        };

        function doRollback(sSelector){
            var node, nodeParent, nodeAlternate, nodeAlternateChild, nodeAlternateNextChild, indexNodeToRemove;
            var listNodes = parseSelector(sSelector);
            var i = listNodes.length - 1;
            var bHasRun = false;

            while(i >= 0){
                node = listNodes[i];
                listNodes.length--;
                nodeParent = node.parentNode;

                if(node.className == 'sIFR-flash'){
                    /*  Flash blockers may add other nodes as siblings to the Flash element. 
                        Thus, we remove all children of nodeParent, and look for nodeAlternate at the same time */
                    indexNodeToRemove = 0;

                    while(indexNodeToRemove < nodeParent.childNodes.length){
                        node = nodeParent.childNodes[indexNodeToRemove];
                        if(node.className == "sIFR-alternate"){
                            nodeAlternate = node;
                            indexNodeToRemove++;
                            continue;
                        };
                        nodeParent.removeChild(node);
                    };

                    if(nodeAlternate != null){
                        nodeAlternateChild = nodeAlternate.firstChild;
                        while(nodeAlternateChild != null){
                            nodeAlternateNextChild = nodeAlternateChild.nextSibling;
                            nodeParent.appendChild(nodeAlternate.removeChild(nodeAlternateChild));
                            nodeAlternateChild = nodeAlternateNextChild;
                        };
                        nodeParent.removeChild(nodeAlternate);
                    };

                    nodeParent.className = nodeParent.className.replace(/\bsIFR\-replaced\b/, "");
                    bHasRun = true;
                };

                i--;
            };

            return bHasRun;
        };

        return rollback;
    }();
};

"Rollforward"

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>

Remove Flash Class

You can use this method to remove the sIFR-hasFlash class from the html and body element. Invoke it using sIFR.removeFlashClass(). Yeah


Updated on September 20, 2008 10:20 by Anonymous Coward (80.220.27.187)

| See revision | Back in time (5 older revisions)


Navigation

sIFR 3 Documentation & FAQ

sIFR lets you use your favorite font on your websites by cleverly working with Flash, JavaScript and CSS. Here you'll find it's documentation and the FAQ. Leave a link to your implementation in the Examples!

Please donate

If you like sIFR, please consider making a donation so Mark can spend more time on it. Thank you.

Inside this wiki

Other destinations

Licensing

This wiki is licensed under the GNU Free Documentation License.

Miscellaneous

TextDrive

RubyOnRails