Commit bc3db3ed authored by Robert Lyon's avatar Robert Lyon
Browse files

Fixing the inbox block opening the message (Bug #1465485)



Got it to use jquery instead of mochikit

Change-Id: Ia2204de5ada9d6c1f21e6a0879c6c864f6ac1d8c
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent bfb2f83f
......@@ -965,6 +965,20 @@ function quotaUpdate(quotaused, quota) {
}
}
function updateUnreadCount(data) {
var inboxmenu = jQuery(".navbar-right .inbox");
if (!inboxmenu.length) {
return;
}
if (typeof(data.data.newunreadcount) != 'undefined') {
var countnode = inboxmenu.find('span.unreadmessagecount');
if (countnode.length) {
countnode.text(data.data.newunreadcount);
}
}
}
// Work around hack for Mochikit Event key function
// (returns 0 for ff and onkeypress)
function keypressKeyCode(e) {
......
......@@ -32,31 +32,30 @@
<div class="morelinkwrap"><a class="morelink" href="{$WWWROOT}account/activity/index.php?type={$desiredtypes}">{str tag=More section=blocktype.inbox} &raquo;</a></div>
<div class="cb"></div>
{/if}
<script>
{literal}
addLoadEvent(function() {
forEach(
{/literal}
getElementsByTagAndClassName('a', 'inbox-showmessage', '{$blockid}'),
{literal}
function(element) {
connect(element, 'onclick', function(e) {
e.stop();
var message = getFirstElementByTagAndClassName('div', 'inbox-message', element.parentNode);
var unreadText = getFirstElementByTagAndClassName(null, 'accessible-hidden', element);
toggleElementClass('hidden', message);
if (hasElementClass(element, 'unread')) {
var id = getNodeAttribute(message, 'id').replace(/inbox-message-(\d+)$/, '$1');
var pd = {'readone':id};
sendjsonrequest(config.wwwroot + 'account/activity/index.json.php', pd, 'GET', function(data) {
removeElementClass(element, 'unread');
removeElement(unreadText);
updateUnreadCount(data);
<script type="application/javascript">
var blockid = '{$blockid}';
{literal}
jQuery(window).ready(function() {
jQuery("#" + blockid + " a.inbox-showmessage").each(function() {
var el = jQuery(this);
el.click(function(e) {
e.preventDefault();
var message = jQuery(e.target).parent().find(".inbox-message");
message.toggleClass('hidden');
var unreadText = jQuery(e.target).find(".accessible-hidden");
if (unreadText.length) {
var tableinfo = message.attr('id').split('-');
var id = tableinfo.pop();
var table = tableinfo.pop();
var pd = {'readone':id, 'table':table};
sendjsonrequest(config.wwwroot + 'account/activity/index.json.php', pd, 'GET', function(data) {
unreadText.remove();
updateUnreadCount(data);
});
}
});
}
});
});
});
});
{/literal}
</script>
{/literal}
</script>
{/if}
......@@ -38,34 +38,29 @@
{/if}
</div>
{/foreach}
<script>
<script type="application/javascript">
var blockid = '{$blockid}';
{literal}
addLoadEvent(function() {
forEach(
{/literal}
getElementsByTagAndClassName('a', 'inbox-showmessage', '{$blockid}'),
{literal}
function(element) {
connect(element, 'onclick', function(e) {
e.stop();
var message = getFirstElementByTagAndClassName('div', 'inbox-message', element.parentNode);
var unreadText = getFirstElementByTagAndClassName(null, 'accessible-hidden', element);
toggleElementClass('hidden', message);
if (hasElementClass(element, 'unread')) {
var tableid = getNodeAttribute(message, 'id').replace(/inbox-message-(.+)$/, '$1');
var delimiterposition = tableid.indexOf("-");
var table = tableid.substr(0, delimiterposition);
var id = tableid.substr(delimiterposition + 1);
var pd = {'readone':id, 'table':table};
sendjsonrequest(config.wwwroot + 'artefact/multirecipientnotification/indexin.json.php', pd, 'GET', function(data) {
removeElementClass(element, 'unread');
removeElement(unreadText);
updateUnreadCount(data);
});
}
});
jQuery(window).ready(function() {
jQuery("#" + blockid + " a.inbox-showmessage").each(function() {
var el = jQuery(this);
el.click(function(e) {
e.preventDefault();
var message = jQuery(e.target).parent().find(".inbox-message");
message.toggleClass('hidden');
var unreadText = jQuery(e.target).find(".accessible-hidden");
if (unreadText.length) {
var tableinfo = message.attr('id').split('-');
var id = tableinfo.pop();
var table = tableinfo.pop();
var pd = {'readone':id, 'table':table};
sendjsonrequest(config.wwwroot + 'artefact/multirecipientnotification/indexin.json.php', pd, 'GET', function(data) {
unreadText.remove();
updateUnreadCount(data);
});
}
});
});
});
{/literal}
</script>
......
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