From 7f135e53235c1b0ef1fc634919be72f812045a7c Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Tue, 31 Jul 2018 09:11:45 -0400 Subject: [PATCH] (js) Improve popup window detection in mailer Fixes #4518 --- NEWS | 1 + UI/WebServerResources/js/Mailer/MessageController.js | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 2de73d359..c734e3bd9 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,7 @@ Enhancements Bug fixes - [core] handle multi-valued mozillasecondemail attribute mapping + - [web] improve popup window detection in message viewer (#4518) 4.0.1 (2018-07-10) ------------------ diff --git a/UI/WebServerResources/js/Mailer/MessageController.js b/UI/WebServerResources/js/Mailer/MessageController.js index be59ff3dc..1a5320cc1 100644 --- a/UI/WebServerResources/js/Mailer/MessageController.js +++ b/UI/WebServerResources/js/Mailer/MessageController.js @@ -11,6 +11,8 @@ var vm = this, popupWindow = null, hotkeys = []; this.$onInit = function() { + var isPopupWindow = false; + // Expose controller $window.$messageController = vm; @@ -30,9 +32,14 @@ _registerHotkeys(hotkeys); + // Detect if this is message appears in a separate window + try { + isPopupWindow = $window.opener && '$mailboxController' in $window.opener; + } + catch (e) {} + // One-way refresh of the parent window when modifying the message from a popup window. - if ($window.opener && - '$mailboxController' in $window.opener) { + if (isPopupWindow) { // Update the message flags. The message must be displayed in the parent window. $scope.$watchCollection(function() { return vm.message.flags; }, function(newTags, oldTags) { var ctrls;