From 6cdea51c9e8cfc4638207477922b683927ec383c Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 6 Mar 2014 10:42:37 +0000 Subject: [PATCH] when activating mailto-links/email addresses use mail app unless (addressbook-)preference says otherwise --- etemplate/js/et2_core_common.js | 18 ++++++++++++++---- etemplate/js/et2_widget_url.js | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/etemplate/js/et2_core_common.js b/etemplate/js/et2_core_common.js index 346016272f..1bffe9b871 100644 --- a/etemplate/js/et2_core_common.js +++ b/etemplate/js/et2_core_common.js @@ -509,7 +509,7 @@ function et2_activateLinks(_content) } } - var mail_regExp = /mailto:([a-z0-9._-]+)@([a-z0-9_-]+)\.([a-z0-9._-]+)/i; + var mail_regExp = /(mailto:)?([a-z0-9._-]+)@([a-z0-9_-]+)\.([a-z0-9._-]+)/i; // First match things beginning with http:// (or other protocols) var protocol = '(http:\\/\\/|(ftp:\\/\\/|https:\\/\\/))'; // only http:// gets removed, other protocolls are shown @@ -535,8 +535,8 @@ function et2_activateLinks(_content) // No need make emailaddress spam-save, as it gets dynamically created _splitPush(_content.match(mail_regExp), function(_matches) { arr.push({ - "href": _matches[0], - "text": _matches[1] + "@" + _matches[2] + "." + _matches[3] + "href": (_matches[1]?'':'mailto:')+_matches[0], + "text": _matches[2] + "@" + _matches[3] + "." + _matches[4] }); }); @@ -610,10 +610,20 @@ function et2_insertLinkText(_text, _node, _target) .attr("href", s.href) .text(s.text); - if (typeof _target != "undefined" && _target && _target != "_self") + if (typeof _target != "undefined" && _target && _target != "_self" && s.href.substr(0, 7) != "mailto:") { a.attr("target", _target); } + // open mailto links depending on preferences in mail app + if (s.href.substr(0, 7) == "mailto:" && + (egw.user('apps').mail || egw.user('apps').felamimail) && + egw.preference('force_mailto','addressbook') != '1') + { + a.click(function(event){ + egw.open_link(this.href); + return false; + }); + } a.appendTo(_node); } diff --git a/etemplate/js/et2_widget_url.js b/etemplate/js/et2_widget_url.js index 485de65e89..ffcb657d13 100644 --- a/etemplate/js/et2_widget_url.js +++ b/etemplate/js/et2_widget_url.js @@ -182,7 +182,7 @@ var et2_url = et2_textbox.extend( value = "mailto:"+value; } if((this.egw().user('apps').mail || this.egw().user('apps').felamimail) && - this.egw().preference('force_mailto','addressbook') == '0' ) + this.egw().preference('force_mailto','addressbook') != '1' ) { return function() {egw.open_link(value);}; }