diff --git a/etemplate/js/et2_widget_url.js b/etemplate/js/et2_widget_url.js index ae9b98f139..f0b35f011a 100644 --- a/etemplate/js/et2_widget_url.js +++ b/etemplate/js/et2_widget_url.js @@ -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 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('') + .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"]); \ No newline at end of file diff --git a/etemplate/templates/default/etemplate2.css b/etemplate/templates/default/etemplate2.css index f6e51f83d9..d306619065 100644 --- a/etemplate/templates/default/etemplate2.css +++ b/etemplate/templates/default/etemplate2.css @@ -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 */