Commit a1a27014 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Update unread message count in header when reading messages


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent ac9c08a0
......@@ -133,14 +133,15 @@ function markread(form, action) {
}
function updateUnreadCount(n, decrement) {
var newcount = -1;
forEach(getElementsByTagAndClassName('span', 'unreadmessagescontainer'), function(message) {
var countnode = message.firstChild;
if (decrement == 'decrement') {
var oldcount = parseInt(countnode.innerHTML);
var newcount = (oldcount - n);
newcount = (oldcount - n);
}
else {
var newcount = n;
newcount = n;
}
var messagenode = message.lastChild;
if (newcount == 1) { // jump through hoops to change between plural and singular
......@@ -151,6 +152,11 @@ function updateUnreadCount(n, decrement) {
}
countnode.innerHTML = newcount;
});
if (newcount > -1) {
forEach(getElementsByTagAndClassName('span', 'unreadmessagecount', 'right-nav'), function(element) {
element.innerHTML = newcount;
});
}
}
function showHideMessage(id) {
......
......@@ -1971,6 +1971,7 @@ function right_nav() {
'icon' => $THEME->get_url('images/email.gif'),
'alt' => get_string('inbox'),
'count' => $unread,
'countclass' => 'unreadmessagecount',
'weight' => 20,
),
array(
......
......@@ -2,7 +2,7 @@
<div id="right-nav">
<ul>{strip}
{foreach from=$RIGHTNAV item=item}
<li{if $item.selected}{assign var=MAINNAVSELECTED value=$item} class="selected"{/if}><a href="{if $item.wwwroot}{$item.wwwroot}{else}{$WWWROOT}{/if}{$item.url|escape}">{if $item.title}{$item.title|escape}{/if}{if $item.icon}<img src="{$item.icon}" alt="{$item.alt|escape}">{if isset($item.count) && !$item.selected}<span class="navcount">{$item.count|escape}</span>{/if}</a></li>
<li{if $item.selected}{assign var=MAINNAVSELECTED value=$item} class="selected"{/if}><a href="{if $item.wwwroot}{$item.wwwroot}{else}{$WWWROOT}{/if}{$item.url|escape}">{if $item.title}{$item.title|escape}{/if}{if $item.icon}<img src="{$item.icon}" alt="{$item.alt|escape}">{if isset($item.count)}<span class="navcount{if $item.countclass} {$item.countclass}{/if}">{$item.count|escape}</span>{/if}</a></li>
{/foreach}
<li><a href="{$WWWROOT}?logout" accesskey="l">{str tag="logout"}</a></li>
{/strip}</ul>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment