From 8eae975fce29f0be4ea674f538509cdfa5310890 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Wed, 10 Jan 2018 12:42:42 +0100 Subject: [PATCH] Make notification sidebar disappear when click away --- notifications/js/notificationajaxpopup.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/notifications/js/notificationajaxpopup.js b/notifications/js/notificationajaxpopup.js index 22d392a0dd..26c08e5b94 100644 --- a/notifications/js/notificationajaxpopup.js +++ b/notifications/js/notificationajaxpopup.js @@ -504,10 +504,28 @@ */ notifications.prototype.toggle = function () { + var $egwpopup = jQuery('#egwpopup'); + var $body = jQuery('body'); + var $counter = jQuery('#egwpopup_fw_notifications'); + + if (!$egwpopup.is(":visible")) + { + $body.on('click', function(e){ + if (!$counter.is(e.target) && e.originalEvent.target.className !== 'popup_note' && + !$egwpopup.is(e.target) && $egwpopup.has(e.target).length == 0) + { + jQuery(this).off(e); + $egwpopup.slideToggle('fast'); + } + }); + } + else + { + $body.off('click'); + } // Remove popup_note as soon as message list is toggled jQuery('.popup_note', '#egwpopup_fw_notifications').remove(); - var $egwpopup = jQuery('#egwpopup'); if ($egwpopup.length>0) $egwpopup.slideToggle('fast'); };