Etemplate - email widget tooltip - show loading while waiting for server response, remove tooltip if nextmatch scrolls

This commit is contained in:
nathangray 2018-02-20 10:32:04 -07:00
parent 56b40adb26
commit d76a08b434

View File

@ -357,6 +357,7 @@ var et2_url_ro = (function(){ "use strict"; return et2_valueWidget.extend([et2_I
// Need to keep span & value so it works inside nextmatch // Need to keep span & value so it works inside nextmatch
this.span.on ('mouseenter', jQuery.proxy(function (event) { this.span.on ('mouseenter', jQuery.proxy(function (event) {
event.stopImmediatePropagation(); event.stopImmediatePropagation();
this.widget._add_contact_tooltip.call(this, et2_url_ro.email_cache[this.value]);
if(typeof et2_url_ro.email_cache[this.value] === 'undefined') if(typeof et2_url_ro.email_cache[this.value] === 'undefined')
{ {
// Ask server if we know this email // Ask server if we know this email
@ -364,10 +365,6 @@ var et2_url_ro = (function(){ "use strict"; return et2_valueWidget.extend([et2_I
this.value, this.widget._add_contact_tooltip, this this.value, this.widget._add_contact_tooltip, this
); );
} }
else
{
this.widget._add_contact_tooltip.call(this, et2_url_ro.email_cache[this.value]);
}
},{widget: this, span: this.span, value: this.value})); },{widget: this, span: this.span, value: this.value}));
} }
break; break;
@ -384,14 +381,15 @@ var et2_url_ro = (function(){ "use strict"; return et2_valueWidget.extend([et2_I
var value = this.value || this.widget.value || null; var value = this.value || this.widget.value || null;
et2_url_ro.email_cache[value] = email_exists; et2_url_ro.email_cache[value] = email_exists;
if(email_exists) return;
// Close all the others // Close all the others
jQuery('.et2_email').each(function() { jQuery('.et2_email').each(function() {
if(jQuery(this).tooltip('instance')) { if(jQuery(this).tooltip('instance')) {
jQuery(this).tooltip('close'); jQuery(this).tooltip('close');
} }
}); });
if(email_exists || !this.span.is(':hover')) return;
this.span.tooltip({ this.span.tooltip({
items: 'a.et2_email', items: 'a.et2_email',
position: {my:"right top", at:"left top", collision:"flipfit"}, position: {my:"right top", at:"left top", collision:"flipfit"},
@ -404,7 +402,7 @@ var et2_url_ro = (function(){ "use strict"; return et2_valueWidget.extend([et2_I
}; };
return jQuery('<a href="#" class= "et2_url_email_contactPlus" title="'+egw.lang('Add a new contact')+'"><img src="' return jQuery('<a href="#" class= "et2_url_email_contactPlus" title="'+egw.lang('Add a new contact')+'"><img src="'
+egw.image("new") +'"/></a>') + (typeof email_exists === 'undefined' ? egw.image("loading") : egw.image("new")) +'"/></a>')
.on('click', function() { .on('click', function() {
egw.open('','addressbook','add',extra); egw.open('','addressbook','add',extra);
}); });
@ -423,6 +421,14 @@ var et2_url_ro = (function(){ "use strict"; return et2_valueWidget.extend([et2_I
} }
}) })
.tooltip("open"); .tooltip("open");
jQuery('.egwGridView_scrollarea').one('scroll', jQuery.proxy(function() {
if(this.tooltip("instance"))
{
this.tooltip('destroy');
}
}, this.span));
}, },
/** /**