mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-26 01:43:47 +01:00
* Api - Check if email address is known before offering 'Add as contact' button
This commit is contained in:
parent
9c3882b4e8
commit
c67560049c
@ -354,12 +354,37 @@ var et2_url_ro = (function(){ "use strict"; return et2_valueWidget.extend([et2_I
|
|||||||
if(!egw.app('addressbook')) return;
|
if(!egw.app('addressbook')) return;
|
||||||
|
|
||||||
// Bind onmouseenter event on <a> tag in order to add contact plus
|
// Bind onmouseenter event on <a> tag in order to add contact plus
|
||||||
this.span.on ({
|
this.span.on ('mouseenter', jQuery.proxy(function (event) {
|
||||||
mouseenter: function (event)
|
|
||||||
{
|
|
||||||
event.stopImmediatePropagation();
|
event.stopImmediatePropagation();
|
||||||
var self = this;
|
if(typeof et2_url_ro.email_cache[this.value] === 'undefined')
|
||||||
jQuery(this).tooltip({
|
{
|
||||||
|
// Ask server if we know this email
|
||||||
|
this.egw().jsonq('EGroupware\\Api\\Etemplate\\Widget\\Url::ajax_contact',
|
||||||
|
this.value, this._add_contact_tooltip, this
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this._add_contact_tooltip(et2_url_ro.email_cache[this.value]);
|
||||||
|
}
|
||||||
|
},this));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
et2_url_ro.email_cache[this.value] = email_exists;
|
||||||
|
|
||||||
|
if(email_exists) return;
|
||||||
|
|
||||||
|
this.span.tooltip({
|
||||||
items: 'a.et2_email',
|
items: 'a.et2_email',
|
||||||
position: {my:"right top", at:"left top", collision:"flipfit"},
|
position: {my:"right top", at:"left top", collision:"flipfit"},
|
||||||
tooltipClass: "et2_email_popup",
|
tooltipClass: "et2_email_popup",
|
||||||
@ -390,11 +415,6 @@ var et2_url_ro = (function(){ "use strict"; return et2_valueWidget.extend([et2_I
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.tooltip("open");
|
.tooltip("open");
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -429,4 +449,5 @@ var et2_url_ro = (function(){ "use strict"; return et2_valueWidget.extend([et2_I
|
|||||||
this.span.attr('title',_values.statustext ? _values.statustext : this.options.statustext);
|
this.span.attr('title',_values.statustext ? _values.statustext : this.options.statustext);
|
||||||
}
|
}
|
||||||
});}).call(this);
|
});}).call(this);
|
||||||
|
et2_url_ro.email_cache = [];
|
||||||
et2_register_widget(et2_url_ro, ["url_ro", "url-email_ro", "url-phone_ro"]);
|
et2_register_widget(et2_url_ro, ["url_ro", "url-email_ro", "url-phone_ro"]);
|
||||||
|
@ -128,4 +128,16 @@ class Url extends Etemplate\Widget
|
|||||||
//error_log(__METHOD__."() $form_name: ".array2string($value_in).' --> '.array2string($value));
|
//error_log(__METHOD__."() $form_name: ".array2string($value_in).' --> '.array2string($value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle ajax searches for existing contact based on email
|
||||||
|
*
|
||||||
|
* @return boolean email exists or not
|
||||||
|
*/
|
||||||
|
public static function ajax_contact($email)
|
||||||
|
{
|
||||||
|
$result = $GLOBALS['egw']->contacts->search($email);
|
||||||
|
|
||||||
|
\EGroupware\Api\Json\Response::data($result ? true : false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user