jquery.litelay.js 1.14 KB
// LiteLay v0.2 - jQuery content loading overlay plugin
(function ($) {
    $.fn.litelay = function (options) {
        options = options || {};

        this.each(function () {
            var
                $this	= $(this),
                data	= $this.data('litelay'),
                litelay	= $('<div/>').addClass('litelay'),
            content = $('<div/>').addClass('content').appendTo(litelay);

            if (options.off === true && !data) {
                return;
            }

            // Check if litelay has already been initialized on this element. If so, remove it.
            if (data) {
                $this.find('> .litelay').remove();
                $this.removeData('litelay');
                return;
            }

            if (options.message) {
                content.append('<div class="message">' + options.message + '<div/>');
            }

            if (options.spinner) {
                content.append('<div class="spinner"><div/>');
            }

            $this.append(litelay);
            $this.data('litelay', {
                init: true,
            });
        });

        return this;
    };
}(jQuery));