2011-08-26 00:42:07 +02:00
|
|
|
/**
|
2013-04-13 21:00:13 +02:00
|
|
|
* EGroupware eTemplate2 - JS URL object
|
2011-08-26 00:42:07 +02:00
|
|
|
*
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package etemplate
|
|
|
|
* @subpackage api
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Nathan Gray
|
|
|
|
* @copyright Nathan Gray 2011
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*egw:uses
|
|
|
|
et2_textbox;
|
|
|
|
et2_valueWidget;
|
2016-06-07 09:38:11 +02:00
|
|
|
/api/js/jquery/jquery.base64.js;
|
2011-08-26 00:42:07 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class which implements the "url" XET-Tag, which covers URLs, email & phone
|
2014-01-10 17:19:05 +01:00
|
|
|
*
|
2013-04-13 21:00:13 +02:00
|
|
|
* @augments et2_textbox
|
2014-01-10 17:19:05 +01:00
|
|
|
*/
|
2016-02-29 21:40:43 +01:00
|
|
|
var et2_url = (function(){ "use strict"; return et2_textbox.extend(
|
2013-04-13 21:00:13 +02:00
|
|
|
{
|
2011-08-26 00:42:07 +02:00
|
|
|
attributes: {
|
|
|
|
"multiline": {
|
|
|
|
"ignore": true
|
|
|
|
}
|
|
|
|
},
|
2014-01-10 17:19:05 +01:00
|
|
|
|
2014-01-16 19:10:06 +01:00
|
|
|
/**
|
|
|
|
* Regexes for validating email addresses incl. email in angle-brackets eg.
|
|
|
|
* + "Ralf Becker <rb@stylite.de>"
|
|
|
|
* + "Ralf Becker (Stylite AG) <rb@stylite.de>"
|
|
|
|
* + "<rb@stylite.de>" or "rb@stylite.de"
|
|
|
|
* + '"Becker, Ralf" <rb@stylite.de>'
|
|
|
|
* + "'Becker, Ralf' <rb@stylite.de>"
|
|
|
|
* but NOT:
|
|
|
|
* - "Becker, Ralf <rb@stylite.de>" (contains comma outside " or ' enclosed block)
|
|
|
|
* - "Becker < Ralf <rb@stylite.de>" (contains < ----------- " ---------------)
|
|
|
|
*
|
|
|
|
* About umlaut or IDN domains: we currently only allow German umlauts in domain part!
|
2016-10-20 12:29:56 +02:00
|
|
|
* We forbid all non-ascii chars in local part, as Horde does not yet support SMTPUTF8 extension (rfc6531)
|
|
|
|
* and we get a "SMTP server does not support internationalized header data" error otherwise.
|
2014-01-16 19:10:06 +01:00
|
|
|
*
|
|
|
|
* Using \042 instead of " to NOT stall minifyer!
|
|
|
|
*
|
2018-02-05 17:01:15 +01:00
|
|
|
* Similar, but not identical, preg is in Etemplate\Widget\Url PHP class!
|
|
|
|
* We can not use "(?<![.\s])", used to check that name-part does not end in
|
|
|
|
* a dot or white-space. The expression is valid in recent Chrome, but fails
|
|
|
|
* eg. in Safari 11.0 or node.js 4.8.3 and therefore grunt uglify!
|
|
|
|
* Server-side will fail in that case because it uses the full regexp.
|
2014-01-16 19:10:06 +01:00
|
|
|
*/
|
2018-02-05 17:01:15 +01:00
|
|
|
EMAIL_PREG: new RegExp(/^(([^\042',<][^,<]+|\042[^\042]+\042|\'[^\']+\'|"(?:[^"\\]|\\.)*")\s?<)?[^\x00-\x20()<>@,;:\042\[\]\x80-\xff]+@([a-z0-9ÄÖÜäöüß](|[a-z0-9ÄÖÜäöüß_-]*[a-z0-9ÄÖÜäöüß])\.)+[a-z]{2,}>?$/i),
|
2013-04-13 21:00:13 +02:00
|
|
|
/**
|
|
|
|
* @memberOf et2_url
|
|
|
|
*/
|
2011-08-26 00:42:07 +02:00
|
|
|
createInputWidget: function() {
|
2016-06-02 16:51:15 +02:00
|
|
|
this.input = jQuery(document.createElement("input"))
|
2011-08-26 00:42:07 +02:00
|
|
|
.blur(this,this.validate)
|
|
|
|
.blur(this,function(e){e.data.set_value(e.data.getValue());});
|
|
|
|
|
|
|
|
this._button = null;
|
|
|
|
|
|
|
|
if(this.size) {
|
|
|
|
this.set_size(this.size);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setDOMNode(this.input[0]);
|
|
|
|
},
|
|
|
|
|
|
|
|
destroy: function() {
|
|
|
|
if(this.input) {
|
|
|
|
this.input.unbind();
|
|
|
|
}
|
|
|
|
this._button = null;
|
2013-07-20 19:20:55 +02:00
|
|
|
this._super.apply(this);
|
2011-08-26 00:42:07 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Override parent to update href of 'button'
|
2014-01-27 10:48:43 +01:00
|
|
|
*
|
|
|
|
* @param _value value to set
|
2011-08-26 00:42:07 +02:00
|
|
|
*/
|
|
|
|
set_value: function(_value) {
|
|
|
|
this.update_button(_value);
|
|
|
|
this._super.apply(this, arguments);
|
|
|
|
},
|
|
|
|
|
|
|
|
update_button: function(_value) {
|
|
|
|
if(this.value == _value) return;
|
|
|
|
if(_value)
|
|
|
|
{
|
|
|
|
// Create button if it doesn't exist yet
|
|
|
|
if(this._button == null)
|
|
|
|
{
|
2016-06-02 16:51:15 +02:00
|
|
|
this._button = jQuery(document.createElement("a")).addClass("et2_url");
|
2013-10-11 16:35:13 +02:00
|
|
|
this.getSurroundings().insertDOMNode(this._button[0]);
|
2011-08-26 00:42:07 +02:00
|
|
|
this.getSurroundings().update();
|
|
|
|
}
|
|
|
|
this._button.removeClass("url phone email").removeAttr("href");
|
2011-08-29 23:15:53 +02:00
|
|
|
_value = this.get_link(this._type, _value);
|
2011-08-26 00:42:07 +02:00
|
|
|
switch(this._type)
|
|
|
|
{
|
|
|
|
case "url":
|
|
|
|
// Silently use http if no protocol
|
|
|
|
this._button.attr("href", _value).attr("target", "_blank").addClass("url");
|
|
|
|
break;
|
|
|
|
case "url-phone":
|
2011-08-29 23:15:53 +02:00
|
|
|
if(_value) {
|
|
|
|
if(typeof _value == 'function')
|
|
|
|
{
|
|
|
|
this._button.click(this, _value).addClass("phone").show();
|
|
|
|
}
|
2014-01-10 17:19:05 +01:00
|
|
|
else
|
2011-08-29 23:15:53 +02:00
|
|
|
{
|
|
|
|
this._button.attr("href", _value).addClass("phone").show();
|
|
|
|
}
|
|
|
|
} else if (_value === false) {
|
2011-08-26 00:42:07 +02:00
|
|
|
// Can't make a good handler, hide button
|
|
|
|
this._button.hide();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case "url-email":
|
2011-08-29 23:15:53 +02:00
|
|
|
if(typeof _value == 'function')
|
2011-08-26 00:42:07 +02:00
|
|
|
{
|
2011-08-29 23:15:53 +02:00
|
|
|
this._button.click(this, _value).addClass("email");
|
2011-08-26 00:42:07 +02:00
|
|
|
}
|
2011-08-29 23:15:53 +02:00
|
|
|
else
|
2011-08-26 00:42:07 +02:00
|
|
|
{
|
|
|
|
this._button.attr("href", _value).addClass("email");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-08-26 01:00:44 +02:00
|
|
|
if(this._button) this._button.hide();
|
2011-10-12 18:37:56 +02:00
|
|
|
if(this._button && this.getSurroundings && this.getSurroundings().removeDOMNode)
|
2011-08-26 00:42:07 +02:00
|
|
|
{
|
2011-10-12 18:37:56 +02:00
|
|
|
this.getSurroundings().removeDOMNode(this._button[0]);
|
2011-08-26 00:42:07 +02:00
|
|
|
}
|
|
|
|
this._button = null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-08-29 23:15:53 +02:00
|
|
|
get_link: function(type, value) {
|
|
|
|
if(!value) return false;
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case "url":
|
|
|
|
// Silently use http if no protocol
|
|
|
|
if(value.indexOf("://") == -1) value = "http://"+value;
|
|
|
|
break;
|
|
|
|
case "url-phone":
|
|
|
|
// Clean number
|
|
|
|
value = value.replace('♥','').replace('(0)','');
|
|
|
|
value = value.replace(/[abc]/gi,2).replace(/[def]/gi,3).replace(/[ghi]/gi,4).replace(/[jkl]/gi,5).replace(/[mno]/gi,6);
|
|
|
|
value = value.replace(/[pqrs]/gi,7).replace(/[tuv]/gi,8).replace(/[wxyz]/gi,9);
|
2016-01-24 09:38:33 +01:00
|
|
|
// remove everything but numbers and plus, as telephon software might not like it
|
|
|
|
value = value.replace(/[^0-9+]/g, '');
|
2011-08-29 23:15:53 +02:00
|
|
|
|
2011-08-31 14:18:38 +02:00
|
|
|
// movile Webkit (iPhone, Android) have precedence over server configuration!
|
|
|
|
if (navigator.userAgent.indexOf('AppleWebKit') !== -1 &&
|
|
|
|
(navigator.userAgent.indexOf("iPhone") !== -1 || navigator.userAgent.indexOf("Android") !== -1) &&
|
|
|
|
value.indexOf("tel:") == -1)
|
|
|
|
{
|
2014-01-10 17:19:05 +01:00
|
|
|
value = "tel:"+value;
|
|
|
|
}
|
|
|
|
else if (this.egw().config("call_link"))
|
2011-08-31 14:18:38 +02:00
|
|
|
{
|
2014-01-18 10:29:32 +01:00
|
|
|
var link = this.egw().config("call_link")
|
2017-10-09 10:53:34 +02:00
|
|
|
// tel: links use no URL encoding according to rfc3966 section-5.1.4
|
|
|
|
.replace("%1", this.egw().config("call_link").substr(0, 4) == 'tel:' ?
|
|
|
|
value : encodeURIComponent(value))
|
2014-01-18 10:29:32 +01:00
|
|
|
.replace("%u",this.egw().user('account_lid'))
|
|
|
|
.replace("%t",this.egw().user('account_phone'));
|
|
|
|
var popup = this.egw().config("call_popup");
|
2016-10-27 11:07:44 +02:00
|
|
|
value = function() { egw.open_link(link, '_phonecall', popup); };
|
2011-08-29 23:15:53 +02:00
|
|
|
}
|
2011-08-31 14:18:38 +02:00
|
|
|
else {
|
2011-08-29 23:15:53 +02:00
|
|
|
// Can't make a good handler
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case "url-email":
|
2013-10-07 11:48:17 +02:00
|
|
|
if(value.indexOf("mailto:") == -1)
|
2011-08-29 23:15:53 +02:00
|
|
|
{
|
2013-10-07 11:48:17 +02:00
|
|
|
value = "mailto:"+value;
|
2011-08-29 23:15:53 +02:00
|
|
|
}
|
2014-01-10 17:19:05 +01:00
|
|
|
if((this.egw().user('apps').mail || this.egw().user('apps').felamimail) &&
|
2014-03-06 11:42:37 +01:00
|
|
|
this.egw().preference('force_mailto','addressbook') != '1' )
|
2011-08-29 23:15:53 +02:00
|
|
|
{
|
2013-10-07 11:48:17 +02:00
|
|
|
return function() {egw.open_link(value);};
|
2011-08-29 23:15:53 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
},
|
|
|
|
|
2011-08-26 00:42:07 +02:00
|
|
|
validate: function(e) {
|
|
|
|
e.data.hideMessage();
|
|
|
|
|
|
|
|
if(e.data._super) {
|
|
|
|
e.data._super.apply(this, arguments);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check value, and correct if possible
|
|
|
|
var value = jQuery.trim(e.data.getValue());
|
|
|
|
if(value == "") return;
|
|
|
|
switch(e.data._type) {
|
|
|
|
case "url":
|
|
|
|
if(value.indexOf("://") == -1) {
|
|
|
|
e.data.set_value("http://"+value);
|
2012-03-23 00:16:14 +01:00
|
|
|
e.data.showMessage(e.data.egw().lang("Protocol is required"), "hint", true);
|
2011-08-26 00:42:07 +02:00
|
|
|
}
|
|
|
|
break;
|
2013-07-30 16:16:47 +02:00
|
|
|
case "url-email":
|
2014-01-10 17:19:05 +01:00
|
|
|
if(!e.data.EMAIL_PREG.test(value) ||
|
2013-10-11 16:35:13 +02:00
|
|
|
// If they use Text <email>, make sure the <> match
|
|
|
|
(value.indexOf("<") > 0 && value.indexOf(">") != value.length-1) ||
|
|
|
|
(value.indexOf(">") > 0 && value.indexOf("<") < 0)
|
|
|
|
)
|
2013-07-30 16:16:47 +02:00
|
|
|
{
|
|
|
|
e.data.showMessage("Invalid email","validation_error",true);
|
|
|
|
}
|
2011-08-26 00:42:07 +02:00
|
|
|
}
|
2014-03-12 19:48:59 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
attachToDOM: function()
|
|
|
|
{
|
|
|
|
this._super.apply(this, arguments);
|
|
|
|
|
|
|
|
if (this.input[0].parentNode) jQuery(this.input[0].parentNode).addClass('et2_url_span');
|
2011-08-26 00:42:07 +02:00
|
|
|
}
|
2016-02-29 21:40:43 +01:00
|
|
|
});}).call(this);
|
2011-08-26 00:42:07 +02:00
|
|
|
et2_register_widget(et2_url, ["url", "url-email", "url-phone"]);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* et2_url_ro is the readonly implementation of the url, email & phone.
|
|
|
|
* It renders things as links, when possible
|
2014-01-10 17:19:05 +01:00
|
|
|
*
|
2013-04-13 21:00:13 +02:00
|
|
|
* @augments et2_valueWidget
|
2011-08-26 00:42:07 +02:00
|
|
|
*/
|
2016-02-29 21:40:43 +01:00
|
|
|
var et2_url_ro = (function(){ "use strict"; return et2_valueWidget.extend([et2_IDetachedDOM],
|
2013-04-13 21:00:13 +02:00
|
|
|
{
|
2014-08-29 16:56:14 +02:00
|
|
|
attributes: {
|
|
|
|
"contact_plus": {
|
|
|
|
"name": "Add contact button",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": false,
|
|
|
|
"description": "Allow to add email as contact to addressbook"
|
2016-08-18 18:56:52 +02:00
|
|
|
},
|
|
|
|
"full_email": {
|
|
|
|
"name": "Show full email address",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": true,
|
|
|
|
"description": "Allow to show full email address if ture otherwise show only name"
|
2014-08-29 16:56:14 +02:00
|
|
|
}
|
|
|
|
},
|
2014-09-09 10:31:59 +02:00
|
|
|
|
2013-04-13 21:00:13 +02:00
|
|
|
/**
|
|
|
|
* Constructor
|
2014-01-10 17:19:05 +01:00
|
|
|
*
|
2013-04-13 21:00:13 +02:00
|
|
|
* @memberOf et2_url_ro
|
|
|
|
*/
|
2011-08-26 00:42:07 +02:00
|
|
|
init: function() {
|
|
|
|
this._super.apply(this, arguments);
|
|
|
|
|
|
|
|
this.value = "";
|
2016-06-02 16:51:15 +02:00
|
|
|
this.span = jQuery(document.createElement("a"))
|
2011-08-26 00:42:07 +02:00
|
|
|
.addClass("et2_textbox readonly");
|
2016-05-27 15:03:46 +02:00
|
|
|
// Do not a tag if no call_link is set and not in mobile, empty a tag may conflict
|
|
|
|
// with some browser telephony addons (eg. telify in FF)
|
|
|
|
if (!egw.config('call_link') && this._type == 'url-phone' && !egwIsMobile()){
|
|
|
|
this.span = jQuery(document.createElement("span"))
|
|
|
|
.addClass("et2_textbox readonly");
|
|
|
|
}
|
2014-03-27 00:25:43 +01:00
|
|
|
if(this._type == 'url-email')
|
|
|
|
{
|
|
|
|
this.span.addClass('et2_email');
|
|
|
|
}
|
2011-08-26 00:42:07 +02:00
|
|
|
this.setDOMNode(this.span[0]);
|
|
|
|
},
|
|
|
|
|
|
|
|
set_value: function(_value) {
|
|
|
|
this.value = _value;
|
|
|
|
|
2011-08-29 23:15:53 +02:00
|
|
|
var link = et2_url.prototype.get_link(this._type, _value);
|
|
|
|
|
2014-01-10 17:19:05 +01:00
|
|
|
if(!link)
|
2011-08-29 23:15:53 +02:00
|
|
|
{
|
|
|
|
this.span.text(_value);
|
2013-11-27 17:42:37 +01:00
|
|
|
this.span.removeAttr("href");
|
2011-08-29 23:15:53 +02:00
|
|
|
return;
|
|
|
|
}
|
2011-08-26 00:42:07 +02:00
|
|
|
this.span.text(_value);
|
|
|
|
switch(this._type) {
|
|
|
|
case "url":
|
2011-08-29 23:15:53 +02:00
|
|
|
this.span.attr("href", link).attr("target", "_blank");
|
2011-08-26 00:42:07 +02:00
|
|
|
break;
|
|
|
|
case "url-phone":
|
2011-08-29 23:15:53 +02:00
|
|
|
if(typeof link == 'function')
|
|
|
|
{
|
2013-12-02 17:24:24 +01:00
|
|
|
this.span.off('click.et2_url');
|
|
|
|
this.span.on('click.et2_url', link);
|
2013-10-08 12:08:09 +02:00
|
|
|
this.span.attr("href", "#");
|
2011-08-29 23:15:53 +02:00
|
|
|
}
|
2013-02-05 13:50:20 +01:00
|
|
|
else if (link)
|
2011-08-29 23:15:53 +02:00
|
|
|
{
|
|
|
|
this.span.attr("href", link);
|
2011-08-26 00:42:07 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case "url-email":
|
2011-08-29 23:15:53 +02:00
|
|
|
if(typeof link == 'function')
|
|
|
|
{
|
2013-12-02 17:24:24 +01:00
|
|
|
this.span.off('click.et2_url');
|
|
|
|
this.span.on('click.et2_url', link);
|
2013-10-07 12:05:51 +02:00
|
|
|
this.span.removeAttr("href");
|
2011-08-29 23:15:53 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.span.attr("href", link);
|
2013-10-07 11:48:17 +02:00
|
|
|
if(!this.span.attr("target"))
|
|
|
|
{
|
|
|
|
this.span.attr("target", "_blank");
|
|
|
|
}
|
2011-08-29 23:15:53 +02:00
|
|
|
}
|
2016-03-18 17:44:51 +01:00
|
|
|
// wrap email address if there's a name
|
2016-08-18 18:56:52 +02:00
|
|
|
if (this.span.text() && this.span.text().split("<") && this.options.full_email)
|
2016-01-26 16:36:16 +01:00
|
|
|
{
|
|
|
|
var val = this.span.text().split("<");
|
|
|
|
val = val[0] != ""? val[0]: val[2];
|
2016-02-29 21:40:43 +01:00
|
|
|
|
2016-01-26 16:36:16 +01:00
|
|
|
// need to preserve the original value somehow
|
|
|
|
// as it's been used for add contact plus feature
|
|
|
|
this.span.attr('title',_value);
|
2016-03-19 17:16:59 +01:00
|
|
|
|
2016-01-26 16:36:16 +01:00
|
|
|
this.span.text(val.replace(/"/g,''));
|
2018-08-03 16:15:04 +02:00
|
|
|
this.span.append("<span class='noemail'>"+
|
2016-03-18 17:44:51 +01:00
|
|
|
_value.replace(val,'')
|
|
|
|
.replace(/</g, '<')
|
|
|
|
.replace(/>/g, '>')
|
|
|
|
+"</span>");
|
2016-02-29 21:40:43 +01:00
|
|
|
|
2016-01-26 16:36:16 +01:00
|
|
|
}
|
2016-02-29 21:40:43 +01:00
|
|
|
|
2014-09-01 12:02:18 +02:00
|
|
|
// Add contact_plus button
|
|
|
|
if (this.options.contact_plus)
|
|
|
|
{
|
|
|
|
// If user doesn't have access to addressbook, stop
|
|
|
|
if(!egw.app('addressbook')) return;
|
|
|
|
|
|
|
|
// Bind onmouseenter event on <a> tag in order to add contact plus
|
2018-02-12 18:33:24 +01:00
|
|
|
// Need to keep span & value so it works inside nextmatch
|
2018-02-08 21:19:26 +01:00
|
|
|
this.span.on ('mouseenter', jQuery.proxy(function (event) {
|
2018-02-20 18:32:04 +01:00
|
|
|
event.stopImmediatePropagation();
|
2018-02-12 18:33:24 +01:00
|
|
|
this.widget._add_contact_tooltip.call(this, et2_url_ro.email_cache[this.value]);
|
2018-02-20 18:32:04 +01:00
|
|
|
if(typeof et2_url_ro.email_cache[this.value] === 'undefined')
|
|
|
|
{
|
|
|
|
// Ask server if we know this email
|
|
|
|
this.widget.egw().jsonq('EGroupware\\Api\\Etemplate\\Widget\\Url::ajax_contact',
|
|
|
|
this.value, this.widget._add_contact_tooltip, this
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},{widget: this, span: this.span, value: this.value}));
|
2014-09-01 12:02:18 +02:00
|
|
|
}
|
2011-08-26 00:42:07 +02:00
|
|
|
break;
|
|
|
|
}
|
2012-07-24 21:59:55 +02:00
|
|
|
},
|
|
|
|
|
2018-02-08 21:19:26 +01:00
|
|
|
/**
|
|
|
|
* Add a button to add the email address as a contact
|
|
|
|
*
|
|
|
|
* @param {boolean} email_exists True, or else nothing happens
|
|
|
|
*/
|
|
|
|
_add_contact_tooltip: function(email_exists)
|
|
|
|
{
|
2018-02-12 18:33:24 +01:00
|
|
|
var value = this.value || this.widget.value || null;
|
|
|
|
et2_url_ro.email_cache[value] = email_exists;
|
2018-02-08 21:19:26 +01:00
|
|
|
|
2018-02-12 18:33:24 +01:00
|
|
|
// Close all the others
|
|
|
|
jQuery('.et2_email').each(function() {
|
|
|
|
if(jQuery(this).tooltip('instance')) {
|
|
|
|
jQuery(this).tooltip('close');
|
|
|
|
}
|
|
|
|
});
|
2018-02-20 18:32:04 +01:00
|
|
|
|
|
|
|
if(email_exists || !this.span.is(':hover')) return;
|
|
|
|
|
2018-02-08 21:19:26 +01:00
|
|
|
this.span.tooltip({
|
|
|
|
items: 'a.et2_email',
|
|
|
|
position: {my:"right top", at:"left top", collision:"flipfit"},
|
|
|
|
tooltipClass: "et2_email_popup",
|
|
|
|
content: function()
|
|
|
|
{
|
|
|
|
// Here we could do all sorts of things
|
|
|
|
var extra = {
|
|
|
|
'presets[email]': jQuery(this).attr('title') ? jQuery(this).attr('title') : jQuery(this).text()
|
|
|
|
};
|
|
|
|
|
|
|
|
return jQuery('<a href="#" class= "et2_url_email_contactPlus" title="'+egw.lang('Add a new contact')+'"><img src="'
|
2018-02-20 18:32:04 +01:00
|
|
|
+ (typeof email_exists === 'undefined' ? egw.image("loading") : egw.image("new")) +'"/></a>')
|
2018-02-08 21:19:26 +01:00
|
|
|
.on('click', function() {
|
|
|
|
egw.open('','addressbook','add',extra);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
close: function( event, ui )
|
|
|
|
{
|
|
|
|
ui.tooltip.hover(
|
|
|
|
function () {
|
|
|
|
jQuery(this).stop(true).fadeTo(400, 1);
|
|
|
|
//.fadeIn("slow"); // doesn't work because of stop()
|
|
|
|
},
|
|
|
|
function () {
|
|
|
|
jQuery(this).fadeOut("400", function(){ jQuery(this).remove();});
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.tooltip("open");
|
2018-02-20 18:32:04 +01:00
|
|
|
|
|
|
|
jQuery('.egwGridView_scrollarea').one('scroll', jQuery.proxy(function() {
|
|
|
|
if(this.tooltip("instance"))
|
|
|
|
{
|
|
|
|
this.tooltip('destroy');
|
|
|
|
}
|
|
|
|
}, this.span));
|
|
|
|
|
2018-02-08 21:19:26 +01:00
|
|
|
},
|
|
|
|
|
2012-07-24 21:59:55 +02:00
|
|
|
/**
|
|
|
|
* Code for implementing et2_IDetachedDOM
|
2014-01-27 10:48:43 +01:00
|
|
|
*
|
|
|
|
* @param {array} _attrs array to add further attributes to
|
2012-07-24 21:59:55 +02:00
|
|
|
*/
|
|
|
|
getDetachedAttributes: function(_attrs)
|
|
|
|
{
|
2017-08-14 19:21:24 +02:00
|
|
|
_attrs.push("value", "class", "statustext");
|
2012-07-24 21:59:55 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
getDetachedNodes: function()
|
|
|
|
{
|
|
|
|
return [this.span[0]];
|
|
|
|
},
|
2011-08-26 00:42:07 +02:00
|
|
|
|
2012-07-24 21:59:55 +02:00
|
|
|
setDetachedAttributes: function(_nodes, _values)
|
|
|
|
{
|
|
|
|
// Update the properties
|
|
|
|
this.span = jQuery(_nodes[0]);
|
|
|
|
if (typeof _values["value"] != "undefined")
|
|
|
|
{
|
|
|
|
this.set_value(_values["value"]);
|
|
|
|
}
|
|
|
|
if (typeof _values["class"] != "undefined")
|
2013-10-07 12:05:51 +02:00
|
|
|
{
|
2014-03-27 00:25:43 +01:00
|
|
|
_nodes[0].setAttribute("class", _values["class"]);
|
2013-10-07 12:05:51 +02:00
|
|
|
}
|
2017-08-14 19:21:24 +02:00
|
|
|
|
|
|
|
// Set to original status text if not set for this row
|
|
|
|
this.span.attr('title',_values.statustext ? _values.statustext : this.options.statustext);
|
2012-07-24 21:59:55 +02:00
|
|
|
}
|
2016-02-29 21:40:43 +01:00
|
|
|
});}).call(this);
|
2018-02-08 21:19:26 +01:00
|
|
|
et2_url_ro.email_cache = [];
|
2016-02-29 21:40:43 +01:00
|
|
|
et2_register_widget(et2_url_ro, ["url_ro", "url-email_ro", "url-phone_ro"]);
|