﻿// Author: David Wainwright

// Depends on jquery.timers.js and logger.js

(function($) {
    jQuery.fn.notification = function(options) {

        var settings = jQuery.extend({
            delayInterval: 500,
            effectSpeed: '50',
            autoHideAfter: 5000,
            autoHide: false,
            text: null
        }, options);

        jQuery(this).each(function() {
            jQuery(this).hide();

            if (options.text != null)
                jQuery(this).append(options.text);

            if (!$.string($(this).text()).blank()) {
                jQuery(this).slideDown(settings.effectSpeed);

                if (settings.autoHide == true) {
                    jQuery(this).stopTime("autohide").oneTime(settings.autoHideAfter, "autohide", function() {
                        jQuery(this).slideUp(settings.effectSpeed)
                    });
                }

                if (jQuery(this).children().size() > 0)
                    jQuery(this).oneTime(settings.delayInterval, "show", function() { jQuery(this).slideDown(settings.effectSpeed); });
            }
        });
    };
})(jQuery);
