From: Michael M Slusarz Date: Sat, 2 Oct 2010 08:34:02 +0000 (-0600) Subject: Auto hide mailto_handler link if browser does not support it X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=49ef50b6620b1878b9add981d07172d1e34675d0;p=horde.git Auto hide mailto_handler link if browser does not support it --- diff --git a/imp/config/prefs.php.dist b/imp/config/prefs.php.dist index 1c5df8f64..38522d1bd 100644 --- a/imp/config/prefs.php.dist +++ b/imp/config/prefs.php.dist @@ -430,14 +430,7 @@ $prefGroups['compose'] = array( // Link to add a Firefox 3 mailto: handler $_prefs['mailto_handler'] = array( - 'type' => 'link', - 'img' => 'compose.png', - 'xurl' => 'javascript:if(typeof navigator.registerProtocolHandler==\'undefined\')alert(\'' - . addslashes(_("Your browser does not support this feature.")) - . '\');else navigator.registerProtocolHandler(\'mailto\',\'' - . Horde::url('compose.php', true)->setRaw(true)->add(array('actionID' => 'mailto_link', 'to' => '')) - . '%s\',\'' . $GLOBALS['registry']->get('name') . '\');', - 'desc' => sprintf(_("Click here to open all mailto: links in %s."), $GLOBALS['registry']->get('name')) + 'type' => 'special' ); // Show Cc: field? diff --git a/imp/lib/Prefs/Ui.php b/imp/lib/Prefs/Ui.php index 38fd297d2..f86c855ee 100644 --- a/imp/lib/Prefs/Ui.php +++ b/imp/lib/Prefs/Ui.php @@ -394,6 +394,9 @@ class IMP_Prefs_Ui case 'initialpageselect': return $this->_initialPage(); + case 'mailto_handler': + return $this->_mailtoHandler(); + case 'pgpprivatekey': return $this->_pgpPrivateKey($ui); @@ -1053,6 +1056,36 @@ class IMP_Prefs_Ui return $t->fetch(IMP_TEMPLATES . '/prefs/initialpage.html'); } + /* Mailto: handler. */ + + /** + * Create code for the mailto handler link. + * + * @return string HTML UI code. + */ + protected function _mailtoHandler() + { + Horde::addInlineScript(array( + 'if (!Object.isUndefined(navigator.registerProtocolHandler))' . + '$("mailto_handler").show().down("A").observe("click", function() {' . + 'navigator.registerProtocolHandler("mailto","' . + Horde::url('compose.php', true)->setRaw(true)->add(array( + 'actionID' => 'mailto_link', + 'to' => '' + )) . + '%s","' . $GLOBALS['registry']->get('name') . '");' . + '})' + ), 'dom'); + + $t = $GLOBALS['injector']->createInstance('Horde_Template'); + $t->setOption('gettext', true); + + $t->set('desc', sprintf(_("Click here to open all mailto: links using %s."), $GLOBALS['registry']->get('name'))); + $t->set('img', Horde::img('compose.png')); + + return $t->fetch(IMP_TEMPLATES . '/prefs/mailto.html'); + } + /* PGP Private Key management. */ /** diff --git a/imp/templates/prefs/mailto.html b/imp/templates/prefs/mailto.html new file mode 100644 index 000000000..d9be1a261 --- /dev/null +++ b/imp/templates/prefs/mailto.html @@ -0,0 +1,4 @@ +