Created
July 7, 2011 00:14
-
-
Save lu1s/1068647 to your computer and use it in GitHub Desktop.
jQuery Message Bar
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
/* | |
* jQuery Message Bar | |
* @author Luis Pulido <[email protected]> | |
* @params: | |
* what: String, the message to be displayed | |
* time (optional): Number, the time in milliseconds the bar will | |
* stay displaying. Default is 2000 ms | |
* opts (optional): Object, some optional values to customize the bar: | |
* - height: default 20px | |
* - fontSize: default 14px | |
* - background: default #2d2d2d | |
* - color: default #ff4a00 | |
* | |
* Required the jQuery Library (found at code.jquery.com) | |
* | |
* | |
*/ | |
var message = function(what,time,opts){ | |
if($("#message").length == 0){ | |
var w = $("<div/>").css({ | |
position: "fixed", | |
top: "0px", | |
left: "0px", | |
width: "100%", | |
height: (opts.height ? opts.height : "20px"), | |
fontSize: (opts.fontSize ? opts.fontSize : "14px"), | |
textAlign: "center", | |
background: (opts.background ? opts.background : "#2D2D2D"), | |
color: (opts.color ? opts.color : "#FF4A00"), | |
fontWeight: "800", | |
padding: "10px", | |
display: "none" | |
}).attr("id","message") | |
$("body").append(w); | |
} | |
else if(opts){ | |
opts.height ? $("#message").css({height:opts.height}) : null | |
opts.fontSize ? $("#message").css({fontSize:opts.fontSize}) : null | |
opts.background ? $("#message").css({background:opts.background}) : null | |
opts.color ? $("#message").css({color:opts.color}) : null | |
} | |
$("#message").html(what).slideDown() | |
window.setTimeout(function(){ | |
$("#message").slideUp() | |
},(time ? time : 2000)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment