Last active
August 29, 2015 14:06
-
-
Save awesomephant/dc0c87ca4cb175ce09af to your computer and use it in GitHub Desktop.
Codecanyon Simple Notifications
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
$(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