Skip to content

Instantly share code, notes, and snippets.

@awesomephant
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awesomephant/dc0c87ca4cb175ce09af to your computer and use it in GitHub Desktop.
Save awesomephant/dc0c87ca4cb175ce09af to your computer and use it in GitHub Desktop.
Codecanyon Simple Notifications
$(document).ready(function(){
$('.close').click(function(){
var box = $(this).parent();
box.addClass('inactive');
window.setTimeout(function(){
box.remove()
}, 700)
})
});
var fireNotification = function(config){
if($('.n-container.' + config.position).length === 0){
$('body').append('<div class="n-container ' + config.position + '"></div>');
}
var id = 'id-' + Math.floor(Math.random() * 100);
$('.n-container.' + config.position).prepend('<aside class="notification-' + config.type + ' ' + config.position + ' animation-' + config.animation + ' ' + id + '"><img alt="" src="' + config.img + '"/><h1>' + config.heading + '</h1><p>' + config.text + '</p><button class="close">Close</button></aside>');
if(config.duration > 0){
window.setTimeout(function(){
$('.' + id).addClass('inactive');
}, config.duration);
var t = config.duration * 1 + 1000;
window.setTimeout(function(){
$('.' + id).remove();
}, t )
console.log(id)
}
$('.close').click(function(){
var box = $(this).parent();
window.setTimeout(function(){
box.remove()
}, 700)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment