jQuery plugin stub

by mmarcon

JavaScript

(function($) {
    /*** PRIVATE ***/
    /*
    var privateFunction = function() {}
    */
    var defaults = {
        
    }

    // Create an object literal for our methods
    var methods = {
        // Define individual methods within the literal
        init: function() {
            var $this = $(this);

            // Use extend to create settings from passed options and the defaults
            var settings = $.extend({}, defaults, options);
        },
        destroy: function() {
            // run code here
        }
    };

    $.fn.jOVI = function(method) {
        if (methods[method]) {
            method = methods[method];
            // Our method was sent as an argument, remove it using slice because it's not an argument for our method
            arguments = Array.prototype.slice.call(arguments, 1);
        } else if (typeof(method) == 'object' || !method) {
            method = methods.init;
        } else {
            $.error('Method ' + method + ' does not exist on jOVI');
            return this;
        }
        return this.each(function() {
            // Use apply to sent arguments when calling our selected method
            method.apply(this, arguments);
        });
    }

})(jQuery);