2 * Notify Bar - jQuery plugin
4 * Copyright (c) 2009-2010 Dmitri Smirnov
6 * Licensed under the MIT license:
7 * http://www.opensource.org/licenses/mit-license.php
12 * http://www.dmitri.me/blog/notify-bar
18 jQuery.notifyBar = function(settings) {
22 var bar = notifyBarNS = {};
23 notifyBarNS.shown = false;
29 notifyBarNS.html = settings.html || "Your message here";
31 //How long bar will be delayed, doesn't count animation time.
32 notifyBarNS.delay = settings.delay || 2000;
34 //How long notifyBarNS bar will be slided up and down
35 notifyBarNS.animationSpeed = settings.animationSpeed || 200;
37 //Use own jquery object usually DIV, or use default
38 notifyBarNS.jqObject = settings.jqObject;
41 notifyBarNS.cls = settings.cls || "";
44 notifyBarNS.close = settings.close || false;
46 if( notifyBarNS.jqObject) {
47 bar = notifyBarNS.jqObject;
48 notifyBarNS.html = bar.html();
50 bar = jQuery("<div></div>")
51 .addClass("jquery-notify-bar")
52 .addClass(notifyBarNS.cls)
53 .attr("id", "__notifyBar");
56 bar.html(notifyBarNS.html).hide();
57 var id = bar.attr("id");
58 switch (notifyBarNS.animationSpeed) {
69 asTime = notifyBarNS.animationSpeed;
71 if( bar != 'object'); {
72 jQuery("body").prepend(bar);
75 // Style close button in CSS file
76 if( notifyBarNS.close) {
77 bar.append(jQuery("<a href='#' class='notify-bar-close'>Close [X]</a>"));
78 jQuery(".notify-bar-close").click(function() {
79 if( bar.attr("id") == "__notifyBar") {
80 jQuery("#" + id).slideUp(asTime, function() { jQuery("#" + id).remove() });
82 jQuery("#" + id).slideUp(asTime);
88 bar.slideDown(asTime);
90 // If taken from DOM dot not remove just hide
91 if( bar.attr("id") == "__notifyBar") {
92 setTimeout("jQuery('#" + id + "').slideUp(" + asTime +", function() {jQuery('#" + id + "').remove()});", notifyBarNS.delay + asTime);
94 setTimeout("jQuery('#" + id + "').slideUp(" + asTime +", function() {jQuery('#" + id + "')});", notifyBarNS.delay + asTime);