Bind onmouseenter event of add contact+ button on url-email set_value, as widget might be created by apps client side code, not directly loaded from xet file

This commit is contained in:
Hadi Nategh 2014-09-01 10:02:18 +00:00
parent db4d26482a
commit 312a914ce2

View File

@ -308,6 +308,51 @@ var et2_url_ro = et2_valueWidget.extend([et2_IDetachedDOM],
this.span.attr("target", "_blank");
}
}
// 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
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");
},
});
}
break;
}
},
@ -339,51 +384,7 @@ 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"]);