My First JQuery Plugin

/*
* jQuery SDE Page Actions plugin
*
*
* 
*/
(function($) {
 
    var pageStack = new Array();
 
    $.fn.sdePageActions = function(cmd) {
        if (cmd == undefined) { cmd = ""; }
        
        var containers = $(".PageActionContainer");
 
        switch (cmd.toLowerCase()) {
 
            case "pop":
                //remove the current links
                var items = pageStack.pop();
                if (items != undefined) {
                    $(items).remove();
                }
 
                //display the previous link set
                if (pageStack.length > 0) {
                    $(pageStack[pageStack.length - 1]).show();
                }
                break;
 
            case "push":
            default:
                //Hide the display of the existing links
                var children = $(containers).children();
                $(children).hide();
 
                //If stack is empty add any children to the stack
                if (pageStack.length == 0) {
                    pageStack.push(children);
                }
 
                //Add new link items to the stack and display them
                pageStack.push(this);
                this.appendTo($(containers));
 
                break;
        }
        return this;
    };
 
})(jQuery);

We haven’t completed tested it yet but it’s a lot less code than I though I was going to be when I started on it this morning.

Tuesday, October 06, 2009 5:12 PM

Comments have been closed on this topic.