diff --git a/lib/persona.js b/lib/persona.js index 76b862f..78599cc 100644 --- a/lib/persona.js +++ b/lib/persona.js @@ -49,16 +49,33 @@ $(document).ready(function() { if (data.module === 'composer') { data.options.icon = 'fa-plus'; } else if (data.module === 'chat') { - data.options.icon = 'fa-spinner fa-spin'; - - $.getJSON(config.relative_path + '/api/user/' + utils.slugify(data.options.title), function(user) { - var el = $('#taskbar [data-uuid="' + data.uuid + '"] a'); - el.find('i').remove(); - el.css('background-image', 'url(' + user.picture + ')'); - }); + if (!data.element.length) { + createChatIcon(data); + $(window).one('action:taskbar.pushed', function(ev, data) { + updateChatCount(data.element); + }); + + } else if (!data.element.hasClass('active')) { + updateChatCount(data.element); + } } - }); + + + function createChatIcon(data) { + data.options.icon = 'fa-spinner fa-spin'; + + $.getJSON(config.relative_path + '/api/user/' + utils.slugify(data.options.title), function(user) { + var el = $('#taskbar [data-uuid="' + data.uuid + '"] a'); + el.find('i').remove(); + el.css('background-image', 'url(' + user.picture + ')'); + }); + } + + function updateChatCount(el) { + var count = (parseInt($(el).attr('data-content'), 10) || 0) + 1; + $(el).attr('data-content', count); + } } diff --git a/modules/taskbar.less b/modules/taskbar.less index 5799cc8..bebaa4e 100644 --- a/modules/taskbar.less +++ b/modules/taskbar.less @@ -89,6 +89,23 @@ color: @gray; } } + + &.new:after { + content: attr(data-content); + position: absolute; + left: 52px; + top: 0px; + font-size: 10px; + text-align: center; + border: 1px solid #890405; + color: #fff; + font-weight: bold; + min-width: 20px; + .border-radius(4px); + background: #c91106; + padding: 1px 2px; + font-family: @font-family-sans-serif; + } } &.taskbar-composer, &.taskbar-chat {