From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../addrbook/content/vcard-edit/nickname.mjs | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 comm/mail/components/addrbook/content/vcard-edit/nickname.mjs (limited to 'comm/mail/components/addrbook/content/vcard-edit/nickname.mjs') diff --git a/comm/mail/components/addrbook/content/vcard-edit/nickname.mjs b/comm/mail/components/addrbook/content/vcard-edit/nickname.mjs new file mode 100644 index 0000000000..3622b28997 --- /dev/null +++ b/comm/mail/components/addrbook/content/vcard-edit/nickname.mjs @@ -0,0 +1,59 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at http://mozilla.org/MPL/2.0/. */ + +const lazy = {}; +ChromeUtils.defineModuleGetter( + lazy, + "VCardPropertyEntry", + "resource:///modules/VCardUtils.jsm" +); + +/** + * @implements {VCardPropertyEntryView} + * @see RFC6350 NICKNAME + */ +export class VCardNickNameComponent extends HTMLElement { + /** @type {VCardPropertyEntry} */ + vCardPropertyEntry; + /** @type {HTMLElement} */ + nickNameEl; + + constructor() { + super(); + let template = document.getElementById("template-vcard-edit-nickname"); + let clonedTemplate = template.content.cloneNode(true); + this.appendChild(clonedTemplate); + } + + static newVCardPropertyEntry() { + return new lazy.VCardPropertyEntry("nickname", {}, "text", ""); + } + + connectedCallback() { + if (this.isConnected) { + this.nickNameEl = this.querySelector("#vCardNickName"); + this.fromVCardPropertyEntryToUI(); + } + } + + disconnectedCallback() { + if (!this.isConnected) { + this.nickNameEl = null; + this.vCardPropertyEntry = null; + } + } + + fromVCardPropertyEntryToUI() { + this.nickNameEl.value = this.vCardPropertyEntry.value; + } + + fromUIToVCardPropertyEntry() { + this.vCardPropertyEntry.value = this.nickNameEl.value; + } + + valueIsEmpty() { + return this.vCardPropertyEntry.value === ""; + } +} +customElements.define("vcard-nickname", VCardNickNameComponent); -- cgit v1.2.3