From c945b55cced7acac9442a22fe863a430e3ebcc67 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Mon, 22 May 2017 12:18:53 +0200 Subject: [PATCH] WIP of Notifications system: - Add click handler on message box - Do not send update status request if the message is already seen --- notifications/js/notificationajaxpopup.js | 30 ++++++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/notifications/js/notificationajaxpopup.js b/notifications/js/notificationajaxpopup.js index 26abdecb5f..1c09c2f0d2 100644 --- a/notifications/js/notificationajaxpopup.js +++ b/notifications/js/notificationajaxpopup.js @@ -108,7 +108,7 @@ ).addClass('et2_link'); $egwpopup_list.append($message); // bind click handler after the message container is attached - $message.click(jQuery.proxy(this.message_seen, this,[$message])); + $message.click(jQuery.proxy(this.clickOnMessage, this,[$message])); this.update_message_status(show, notifymessages[show]['status']); } this.counterUpdate(); @@ -128,6 +128,25 @@ } }; + notifications.prototype.clickOnMessage = function (_node, _event){ + _event.stopPropagation(); + this.message_seen(_node, _event); + if (_event.target.classList.contains('link')) return; + var egwpopup_message = _node[0]; + var id = egwpopup_message[0].id.replace(/egwpopup_message_/ig,''); + if (notifymessages[id]['data']) + { + if (notifymessages[id]['data']['id']) + { + egw.open(notifymessages[id]['data']['id'], notifymessages[id]['data']['app']); + } + else + { + egw.open_link(notifymessages[id]['data']['url'],'_blank',notifymessages[id]['data']['popup']); + } + } + }; + /** * Display or hide notifcation-bell * @@ -150,9 +169,12 @@ _event.stopPropagation(); var egwpopup_message = _node[0]; var id = egwpopup_message[0].id.replace(/egwpopup_message_/ig,''); - var request = egw.json("notifications.notifications_ajax.update_status", [id, "SEEN"]); - request.sendRequest(true); - this.update_message_status(id, "SEEN"); + if (notifymessages[id]['status'] !='SEEN') + { + var request = egw.json("notifications.notifications_ajax.update_status", [id, "SEEN"]); + request.sendRequest(true); + this.update_message_status(id, "SEEN"); + } }; notifications.prototype.mark_all_seen = function()