From 090693c1225678d1a998d6dd4603eb3c8afaa811 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 3 Mar 2014 14:57:17 +0000 Subject: [PATCH] fixed mail preview was not sending CSP headers and clicking on mailto-urls redirected to home --- mail/js/preview.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 mail/js/preview.js diff --git a/mail/js/preview.js b/mail/js/preview.js new file mode 100644 index 0000000000..060fdd01f7 --- /dev/null +++ b/mail/js/preview.js @@ -0,0 +1,32 @@ +/** + * mail - handle mailto and other links in preview + * + * @link http://www.egroupware.org + * @author Stylite AG [info@stylite.de] + * @copyright (c) 2014 by Stylite AG + * @package mail + * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License + * @version $Id$ + */ + +/*egw:uses + phpgwapi.jquery.jquery.base64; +*/ + +jQuery(function() +{ + jQuery('body').on('click', 'a[href]', function() + { + // active mailto: links with mail compose + if (this.href.substr(0, 7) == 'mailto:') + { + egw(window).open(null, 'mail', 'add', {send_to: jQuery.base64Encode(this.href.substr(7).replace('%40', '@'))}); + + return false; // cant do event.stopImediatePropagation() in on! + } + else // add target=_blank to all other links, gives CSP error and would open in preview + { + this.target = '_blank'; + } + }); +}); \ No newline at end of file