* Mail: work around Firefox not offering an option to not ask again installing EGroupware as mail-handler

This commit is contained in:
ralf 2023-05-09 10:47:35 +02:00
parent 560ed79a5e
commit e2580aedea
3 changed files with 47 additions and 3 deletions

View File

@ -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
{
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();
}
}
}

View File

@ -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

View File

@ -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