Created
March 16, 2011 22:20
-
-
Save rmax/873447 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
window.FlashMessages = { | |
init: function() { | |
this.container = $("#flash-messages") | |
.find("a.message-close") | |
.fadeIn("slow") | |
.live("click", function() { | |
$(this).parent() | |
.fadeOut("slow", function() { | |
$(this).remove(); | |
}); | |
return false; | |
}) | |
.end() | |
; | |
}, | |
success: f("success"), | |
info: f("info"), | |
warning: f("warning"), | |
error: f("error") | |
}; | |
function f(tag) { | |
return function(message) { | |
return li(tag, message).hide() | |
.prependTo(this.container).end() | |
.fadeIn("slow", function() { | |
$(this).children("a.message-close").fadeIn("slow"); | |
}) | |
; | |
}; | |
} | |
function li(tag, message) { | |
return $("<li/>") | |
.addClass(tag) | |
.html(message) | |
.prepend(close()) | |
; | |
} | |
function close() { | |
return $("<a/>") | |
.attr("href", "#") | |
.attr("title", "Dismiss this message") | |
.addClass("message-close") | |
.text("X") | |
; | |
} | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment