From 2e72b12452a7aad1839c0ee07088d5e99d60a97a Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 7 Apr 2014 19:25:17 +0000 Subject: [PATCH] Only email addresses in mail app need the hover popup, so move it into mail app. --- etemplate/js/et2_widget_url.js | 41 +--------------------------------- mail/js/app.js | 37 +++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 41 deletions(-) diff --git a/etemplate/js/et2_widget_url.js b/etemplate/js/et2_widget_url.js index 73dac126a2..ae9b98f139 100644 --- a/etemplate/js/et2_widget_url.js +++ b/etemplate/js/et2_widget_url.js @@ -332,43 +332,4 @@ var et2_url_ro = et2_valueWidget.extend([et2_IDetachedDOM], } } }); -et2_register_widget(et2_url_ro, ["url_ro", "url-email_ro", "url-phone_ro"]); - -// Bind a mouseenter event once for every read-only email -$j(function() { - // If user doesn't have access to addressbook, stop - if(!egw.app('addressbook')) return; - - $j('body').on('mouseenter', 'a.et2_email', function() { - - // Disabled for addressbook links - no point, they'd already be a contact - if(this.id.indexOf('addressbook-') === 0) return; - - $j(this).tooltip({ - items: 'a.et2_email', - position: {my:"left top", at:"left bottom", collision:"flipfit"}, - tooltipClass: "et2_email_popup", - content: function() { - // Here we could do all sorts of things - var extra = { - 'presets[email]': $j(this).text() - }; - return $j(''+ egw.lang('Add a new contact') + '') - .on('click', function() { - egw.open('','addressbook','add',extra); - }); - }, - close: function( event, ui ) { - ui.tooltip.hover( - function () { - $j(this).stop(true).fadeTo(400, 1); - //.fadeIn("slow"); // doesn't work because of stop() - }, - function () { - $j(this).fadeOut("400", function(){ $j(this).remove(); }) - } - ); - } - }).tooltip("open"); - }); -}); \ No newline at end of file +et2_register_widget(et2_url_ro, ["url_ro", "url-email_ro", "url-phone_ro"]); \ No newline at end of file diff --git a/mail/js/app.js b/mail/js/app.js index 6e140d8178..6001203ae9 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -509,7 +509,7 @@ app.classes.mail = AppJS.extend( for(var i = 0; i < content.length; i++) { var value = content[i]; - var email = et2_createWidget('url-email',{value:value,readonly:true},widget); + var email = et2_createWidget('url-email',{id:widget.id+'_'+i, value:value,readonly:true},widget); email.loadingFinished(); } } @@ -2816,3 +2816,38 @@ app.classes.mail = AppJS.extend( this.egw.message('Not yet implemented ;-)'); } }); + +// Bind a mouseenter event once for every read-only email +$j(function() { + // If user doesn't have access to addressbook, stop + if(!egw.app('addressbook')) return; + + $j('body').on('mouseenter', 'a[id^="mail-"].et2_email', function() { + $j(this).tooltip({ + items: 'a.et2_email', + position: {my:"left top", at:"left bottom", collision:"flipfit"}, + tooltipClass: "et2_email_popup", + content: function() { + // Here we could do all sorts of things + var extra = { + 'presets[email]': $j(this).text() + }; + return $j(''+ egw.lang('Add a new contact') + '') + .on('click', function() { + egw.open('','addressbook','add',extra); + }); + }, + close: function( event, ui ) { + ui.tooltip.hover( + function () { + $j(this).stop(true).fadeTo(400, 1); + //.fadeIn("slow"); // doesn't work because of stop() + }, + function () { + $j(this).fadeOut("400", function(){ $j(this).remove(); }) + } + ); + } + }).tooltip("open"); + }); +}); \ No newline at end of file