Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
176 lines (148 sloc) 6.88 KB
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery UI Notification Widget by Eric Hynds</title>
<link type="text/css" rel="stylesheet" href="http://www.erichynds.com/examples/style.css" />
<link type="text/css" rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/redmond/jquery-ui.css" />
<link type="text/css" rel="stylesheet" href="ui.notify.css" />
<style type="text/css">form input { display:block; width:250px; margin-bottom:5px }</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.js" type="text/javascript"></script>
<script src="src/jquery.notify.js" type="text/javascript"></script>
<script type="text/javascript">
function create( template, vars, opts ){
return $container.notify("create", template, vars, opts);
}
$(function(){
// initialize widget on a container, passing in all the defaults.
// the defaults will apply to any notification created within this
// container, but can be overwritten on notification-by-notification
// basis.
$container = $("#container").notify();
// create two when the pg loads
create("default", { title:'Default Notification', text:'Example of a default notification. I will fade out after 5 seconds'});
create("sticky", { title:'Sticky Notification', text:'Example of a "sticky" notification. Click on the X above to close me.'},{ expires:false });
// bindings for the examples
$("#default").click(function(){
create("default", { title:'Default Notification', text:'Example of a default notification. I will fade out after 5 seconds'});
});
$("#sticky").click(function(){
create("sticky", { title:'Sticky Notification', text:'Example of a "sticky" notification. Click on the X above to close me.'},{ expires:false });
});
$("#warning").click(function(){
create("withIcon", { title:'Warning!', text:'OMG the quick brown fox jumped over the lazy dog. You\'ve been warned. <a href="#" class="ui-notify-close">Close me.</a>', icon:'alert.png' },{
expires:false
});
});
$("#themeroller").click(function(){
create("themeroller", { title:'Warning!', text:'The <code>custom</code> option is set to false for this notification, which prevents the widget from imposing it\'s own coloring. With this option off, you\'re free to style however you want without changing the original widget\'s CSS.' },{
custom: true,
expires: false
});
});
$("#clickable").click(function(){
create("default", { title:'Clickable Notification', text:'Click on me to fire a callback. Do it quick though because I will fade out after 5 seconds.'}, {
click: function(e,instance){
alert("Click triggered!\n\nTwo options are passed into the click callback: the original event obj and the instance object.");
}
});
});
$("#buttons").click(function(){
var n = create("buttons", { title:'Confirm some action', text:'This template has a button.' },{
expires:false
});
n.widget().delegate("input","click", function(){
n.close();
});
});
// second
var container = $("#container-bottom").notify({ stack:'above' });
container.notify("create", {
title:'Look ma, two containers!',
text:'This container is positioned on the bottom of the screen. Notifications will stack on top of each other with the <code>position</code> attribute set to <code>above</code>.'
},{ expires:false });
container.notify("widget").find("input").bind("click", function(){
container.notify("create", 1, { title:'Another Notification!', text:'The quick brown fox jumped over the lazy dog.' });
});
// third
var container = $("#container-bottom-right").notify();
$("#queue").click(function(){
container.notify("create", "queueing", {
title:'Queueing', text:'Example of a notification with queuing. For this container, no more than three notifications of this type will be visible at one time.'
}, { queue: 3 });
});
});
</script>
</head>
<body>
<div id="content">
<h1>jQuery UI Notify Widget</h1>
<p>This is a growl/ubuntu-like notification system built on top of jQuery UI.</p>
<p>Download &amp; follow @ <a href="http://github.com/ehynds/jquery-notify">http://github.com/ehynds/jquery-notify</a>.</p>
<p>Documentation @ <a href="http://www.erichynds.com/jquery/a-jquery-ui-growl-ubuntu-notification-widget/">http://www.erichynds.com/jquery/a-jquery-ui-growl-ubuntu-notification-widget/</a></p>
<form style="margin:20px 0">
<input type="button" id="default" value="Open with default configuration" />
<input type="button" id="queue" value="Or with Queueing" />
<input type="button" id="sticky" value="Create a &quot;sticky&quot; notification" />
<input type="button" id="warning" value="Use icons in your templates" />
<input type="button" id="buttons" value="Or buttons even" />
<input type="button" id="clickable" value="The entire notification can be clicked on" />
<input type="button" id="themeroller" value="ThemeRoller Support" />
</form>
<!--- container to hold notifications, and default templates --->
<div id="container" style="display:none">
<div id="default">
<h1>#{title}</h1>
<p>#{text}</p>
</div>
<div id="sticky">
<a class="ui-notify-close ui-notify-cross" href="#">x</a>
<h1>#{title}</h1>
<p>#{text}</p>
</div>
<div id="themeroller" class="ui-state-error" style="padding:10px; -moz-box-shadow:0 0 6px #980000; -webkit-box-shadow:0 0 6px #980000; box-shadow:0 0 6px #980000;">
<a class="ui-notify-close" href="#"><span class="ui-icon ui-icon-close" style="float:right"></span></a>
<span style="float:left; margin:0 5px 0 0;" class="ui-icon ui-icon-alert"></span>
<h1>#{title}</h1>
<p>#{text}</p>
<p style="text-align:center"><a class="ui-notify-close" href="#">Close Me</a></p>
</div>
<div id="withIcon">
<a class="ui-notify-close ui-notify-cross" href="#">x</a>
<div style="float:left;margin:0 10px 0 0"><img src="#{icon}" alt="warning" /></div>
<h1>#{title}</h1>
<p>#{text}</p>
</div>
<div id="buttons">
<h1>#{title}</h1>
<p>#{text}</p>
<p style="margin-top:10px;text-align:center">
<input type="button" class="confirm" value="Close Dialog" />
</p>
</div>
</div>
<!--- second container - bottom notifications --->
<div id="container-bottom" style="display:none; top:auto; left:0; bottom:0; margin:0 0 10px 10px">
<div>
<h1>#{title}</h1>
<p>#{text}</p>
<p style="margin-top:10px;text-align:center">
<input type="button" class="confirm" value="Create Another Notification!" />
</p>
</div>
<div>
<h1>#{title}</h1>
<p>#{text}</p>
</div>
</div>
<!--- third container - bottom-right notifications --->
<div id="container-bottom-right" style="display:none; top:0; right:360px; margin:10px 10px 0 0">
<div id="queueing">
<h1>#{title}</h1>
<p>#{text}</p>
</div>
</div>
</div>
</body>
</html>