Only email addresses in mail app need the hover popup, so move it into mail app.

This commit is contained in:
Nathan Gray 2014-04-07 19:25:17 +00:00
parent 76357f3451
commit 2e72b12452
2 changed files with 37 additions and 41 deletions

View File

@ -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('<a href="#">'+ egw.lang('Add a new contact') + '</a>')
.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");
});
});
et2_register_widget(et2_url_ro, ["url_ro", "url-email_ro", "url-phone_ro"]);

View File

@ -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('<a href="#">'+ egw.lang('Add a new contact') + '</a>')
.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");
});
});