From e2580aedeabb37ed4fe1f64ce10215387887fa35 Mon Sep 17 00:00:00 2001 From: ralf Date: Tue, 9 May 2023 10:47:35 +0200 Subject: [PATCH] * Mail: work around Firefox not offering an option to not ask again installing EGroupware as mail-handler --- api/js/jsapi/egw_config.js | 46 +++++++++++++++++++++++++++++++++++--- api/lang/egw_de.lang | 2 ++ api/lang/egw_en.lang | 2 ++ 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/api/js/jsapi/egw_config.js b/api/js/jsapi/egw_config.js index 5a63afa5f3..c602964273 100644 --- a/api/js/jsapi/egw_config.js +++ b/api/js/jsapi/egw_config.js @@ -33,11 +33,51 @@ egw.extend('config', egw.MODULE_GLOBAL, function() function install_mailto_handler() { if (document.location.href.match(/(\?|&)cd=yes(&|$)/) && + !window.sessionStorage.getItem('asked-mailto-handler') && typeof navigator.registerProtocolHandler === 'function') // eg. Safari 15.5 does NOT implement it { - let url = egw_webserverUrl; - if (url[0] === '/') url = document.location.protocol+'://'+document.location.hostname+(url !== '/' ? url : ''); - navigator.registerProtocolHandler('mailto', url+'/index.php?menuaction=mail.mail_compose.compose&preset[mailto]=%s', 'Mail'); + const _ask_mailto_handler = () => { + let url = egw_webserverUrl; + if (url[0] === '/') url = document.location.protocol+'://'+document.location.hostname+(url !== '/' ? url : ''); + navigator.registerProtocolHandler('mailto', url+'/index.php?menuaction=mail.mail_compose.compose&preset[mailto]=%s', 'Mail'); + // remember not to ask again for this "session" + window.sessionStorage.setItem('asked-mailto-handler', 'yes'); + }; + // FF does not support user to opt out of the mailto-handler / have a "Don't ask me again" option, + // so we add that ourselves here for Firefox only: + if (navigator.userAgent.match(/firefox/i) && !navigator.userAgent.match(/chrome/i)) + { + if (window.localStorage.getItem('asked-mailto-handler')) + { + return; + } + const dialog = window.Et2Dialog; + if (typeof dialog === 'undefined') + { + window.setTimeout(install_mailto_handler.bind(this), 1000); + return; + } + dialog.show_dialog((_button) => + { + switch(_button) + { + case dialog.YES_BUTTON: + _ask_mailto_handler(); + // fall through + case dialog.NO_BUTTON: + window.localStorage.setItem('asked-mailto-handler', _button == dialog.YES_BUTTON ? 'answer-was-yes' : 'answer-was-no'); + break; + case dialog.CANCEL_BUTTON: + // ask again next session ... + window.sessionStorage.setItem('asked-mailto-handler', 'yes'); + } + }, egw.lang('Answering no will not ask you again for this browser.'), egw.lang('Install EGroupware as mail-handler?'), + undefined, dialog.BUTTONS_YES_NO_CANCEL); + } + else + { + _ask_mailto_handler(); + } } } diff --git a/api/lang/egw_de.lang b/api/lang/egw_de.lang index c560ae843f..fe94df1c1b 100644 --- a/api/lang/egw_de.lang +++ b/api/lang/egw_de.lang @@ -137,6 +137,7 @@ and common de UND andorra common de ANDORRA angola common de ANGOLA anguilla common de ANGUILLA +answering no will not ask you again for this browser. common de Wenn Sie mit Nein antworten, werden Sie für diesen Browser nicht mehr gefragt. antarctica common de ANTARKTIS antigua and barbuda common de ANTIGUA UND BARBUDA api common de EGroupware API @@ -738,6 +739,7 @@ insert row after common de Zeile danach einfügen insert row before common de Zeile davor einfügen insert timestamp into description field common de Zeitstempel in das Beschreibungs-Feld einfügen install common de Installieren +install egroupware as mail-handler? common de EGroupware als Mail-Handler installieren? integer common de Ganzzahl international common de International introduction common de Einführung diff --git a/api/lang/egw_en.lang b/api/lang/egw_en.lang index 88f91b825b..a838b69110 100644 --- a/api/lang/egw_en.lang +++ b/api/lang/egw_en.lang @@ -137,6 +137,7 @@ and common en AND andorra common en ANDORRA angola common en ANGOLA anguilla common en ANGUILLA +answering no will not ask you again for this browser. common en Answering no will not ask you again for this browser. antarctica common en ANTARCTICA antigua and barbuda common en ANTIGUA AND BARBUDA api common en EGroupware API @@ -738,6 +739,7 @@ insert row after common en Insert row after insert row before common en Insert row before insert timestamp into description field common en Insert timestamp into description field install common en Install +install egroupware as mail-handler? common en Install EGroupware as mail-handler? integer common en Integer international common en International introduction common en Introduction