Refactor notifications.

This commit is contained in:
Lars Jung 2015-04-29 01:13:30 +02:00
parent 73496c6b7c
commit 2365c23af7
2 changed files with 26 additions and 10 deletions

View file

@ -1,19 +1,21 @@
modulejs.define('view/notification', ['$'], function ($) {
modulejs.define('view/notification', ['$', 'view/root'], function ($, root) {
var template = '<div id="notification"/>';
var $el = $(template);
function set(content) {
if (content) {
$('#notification').stop(true, true).html(content).fadeIn(400);
$el.stop(true, true).html(content).fadeIn(400);
} else {
$('#notification').stop(true, true).fadeOut(400);
$el.stop(true, true).fadeOut(400);
}
}
$(template).hide().appendTo('body');
$el.hide().appendTo(root.$el);
return {
$el: $el,
set: set
};
});