Fix soe of avatar issues:

- fix letter avatar not getting background
- fix default size
- fix letter avatar not being able to set existing src
This commit is contained in:
Hadi Nategh 2022-07-15 13:35:23 +02:00
parent 805ac7e830
commit 5f86313f46
3 changed files with 13 additions and 6 deletions

View File

@ -17,7 +17,7 @@ const ADD_ET2_PREFIX_REGEXP = '#<((/?)([vh]?box|date(-time[^\s]*|-duration|-sinc
const ADD_ET2_PREFIX_LAST_GROUP = 6; const ADD_ET2_PREFIX_LAST_GROUP = 6;
// unconditional of legacy add et2- prefix to this widgets // unconditional of legacy add et2- prefix to this widgets
const ADD_ET2_PREFIX_LEGACY_REGEXP = '#<(description|label|image|vfs-mime|vfs-uid|vfs-gid|link|link-[a-z]+|favorites)\s([^>]+)/>#m'; const ADD_ET2_PREFIX_LEGACY_REGEXP = '#<(description|label|avatar|lavatar|image|vfs-mime|vfs-uid|vfs-gid|link|link-[a-z]+|favorites)\s([^>]+)/>#m';
// switch evtl. set output-compression off, as we can't calculate a Content-Length header with transparent compression // switch evtl. set output-compression off, as we can't calculate a Content-Length header with transparent compression
ini_set('zlib.output_compression', 0); ini_set('zlib.output_compression', 0);

View File

@ -87,7 +87,7 @@ export class Et2Avatar extends Et2Widget(SlotMixin(SlAvatar)) implements et2_IDe
this.contact_id = ""; this.contact_id = "";
this.editable = false; this.editable = false;
this.crop = false; this.crop = false;
this.size = "3em"; this.size = "2.7em";
} }
/** /**
@ -318,7 +318,7 @@ export class Et2Avatar extends Et2Widget(SlotMixin(SlAvatar)) implements et2_IDe
*/ */
getDetachedAttributes(_attrs : string[]) getDetachedAttributes(_attrs : string[])
{ {
_attrs.push("contact_id", "label", "href"); _attrs.push("contact_id", "label", "href", "src");
} }
getDetachedNodes() getDetachedNodes()

View File

@ -65,12 +65,19 @@ export class Et2LAvatar extends Et2Avatar
{ {
super.updated(changedProperties); super.updated(changedProperties);
if (changedProperties.has("lname") || changedProperties.has("fname") || changedProperties.has("contact_id")) { if (changedProperties.has("lname") || changedProperties.has("fname") || changedProperties.has("contact_id") || changedProperties.has("src")) {
if (!this.src || !decodeURIComponent(this.src).match("lavatar=1") && (this.fname || this.lname) && this.contact_id) if (!this.src || decodeURIComponent(this.src).match("lavatar=1") && (this.fname || this.lname) && this.contact_id)
{ {
this.initials = Et2LAvatar.lavatar(this.fname, this.lname, this.contact_id).initials; let lavatar = Et2LAvatar.lavatar(this.fname, this.lname, this.contact_id);
this.initials = lavatar.initials;
this._baseNode.style.backgroundColor = lavatar.background;
}
else if (this.src)
{
this.image = this.src;
} }
} }
} }
/** /**