Add new attribute to url-email widget in order to be able to add contact+ button to each email address.

This commit is contained in:
Hadi Nategh 2014-08-29 14:56:14 +00:00
parent a418ac8646
commit 02453109d1
2 changed files with 60 additions and 0 deletions

View File

@ -238,6 +238,15 @@ et2_register_widget(et2_url, ["url", "url-email", "url-phone"]);
*/
var et2_url_ro = et2_valueWidget.extend([et2_IDetachedDOM],
{
attributes: {
"contact_plus": {
"name": "Add contact button",
"type": "boolean",
"default": false,
"description": "Allow to add email as contact to addressbook"
}
},
/**
* Constructor
*
@ -330,6 +339,51 @@ var et2_url_ro = et2_valueWidget.extend([et2_IDetachedDOM],
{
_nodes[0].setAttribute("class", _values["class"]);
}
// Add contact_plus button
if (this.options.contact_plus && this._type == "url-email" )
{
// 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
this.span.on ({
mouseenter: function (event)
{
event.stopImmediatePropagation();
var self = this;
jQuery(this).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).text()
};
return jQuery('<a href="#" title="'+egw.lang('Add a new contact')+'"><img src="'+egw.image("new") +'" style="height:12px;width:12px"/></a>')
.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");
},
});
}
}
});
et2_register_widget(et2_url_ro, ["url_ro", "url-email_ro", "url-phone_ro"]);

View File

@ -162,6 +162,12 @@ a.et2_url.phone {
a.et2_url.url {
background-image: url(images/url.png);
}
.et2_email_popup {
border:0 !important;
padding: 0 !important;
box-shadow: none !important;
background: transparent !important;
}
/**
* Button widget - text only, and icon
*/