jQueryUI Tooltip Growl
Simple and nice sticky growl built on top of jQueryUI Tooltip.
by yarshevich
HTML
<link href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-1.8.3.js" type="text/javascript"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js" type="text/javascript"></script>
<div id="root" style="width: 100%; height: 100%">
</div>
CSS
.growl.ui-tooltip {
margin: 0;
padding: 10px 10px;
border-radius: 10px;
background: rgb(48,48,48);
background: rgba(16,16,16, 0.75);
background: transparent\9; /* For IE 7 - 8 */
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#4b101010, endColorstr=#4b101010); /* For IE 7 */
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#4b101010, endColorstr=#4b101010)"; /* For IE 8 */
box-shadow: 0 0 7px Black;
}
.growl.ui-tooltip .ui-tooltip-content {
color: white;
}
.growl.ui-tooltip.success .ui-tooltip-content {
padding-left: 55px;
background: url("http://www.iconfinder.com/ajax/download/png/?id=10249&s=48") no-repeat 0px 0px;
}
.growl.ui-tooltip.error .ui-tooltip-content {
padding-left: 55px;
background: url("http://www.iconfinder.com/ajax/download/png/?id=2686&s=48") no-repeat 0px 0px;
}
.growl.ui-tooltip .ui-tooltip-close {
display: inline-block;
position: relative;
float: right;
}
JavaScript
$.fn.growl = function(params) {
var $root = this;
// tooltip content and styling
var $content = $(
'<a class="ui-tooltip-close ui-icon ui-icon-close" href="#"></a>'+
'<h1 style="color: white; font-size: 12pt; font-weight: bold; padding-bottom: 5px;">' + params.title + '</h1>' +
'<p style="margin: 0; padding: 5px 0 5px 0; font-size: 10pt;">' + params.text + '</p>');
// add 'Close' button functionality
var $close = $($content[0]);
$close.click(function(e) {
$root.tooltip('close').tooltip('destroy');
});
// prevent standard tooltip from closing
$root.bind('focusout mouseleave', function(e) { e.preventDefault(); e.stopImmediatePropagation(); return false; });
// build tooltip
$root.tooltip({
content: function() { return $content; },
items: $root.selector,
tooltipClass: 'growl ' + params.growlClass,
position: {
my: 'right top',
at: 'right top+10'
}
}).tooltip('open');
};
$('#root').growl({ title: 'Simple growl', text: 'Simple and nice sticky growl built on top of jQueryUI Tooltip.', growlClass: 'success' });