'wcf.message.share.socialMedia': '{jslang}wcf.message.share.socialMedia{/jslang}',
'wcf.message.share.copy': '{jslang}wcf.message.share.copy{/jslang}',
'wcf.message.share.copy.success': '{jslang}wcf.message.share.copy.success{/jslang}',
+ 'wcf.message.share.nativeShare': '{jslang}wcf.message.share.nativeShare{/jslang}',
'wcf.global.button.rss': '{jslang}wcf.global.button.rss{/jslang}',
'wcf.global.rss.copy': '{jslang}wcf.global.rss.copy{/jslang}',
'wcf.global.rss.copy.success': '{jslang}wcf.global.rss.copy.success{/jslang}',
const shareButtons = new WeakSet<HTMLElement>();
+const offerNativeSharing = window.navigator.share !== undefined;
+
/**
* Copies the contents of one of the share dialog's input elements to the clipboard.
*/
return "";
}
+/**
+ * Opens the native share menu.
+ */
+async function nativeShare(event: Event): Promise<void> {
+ event.preventDefault();
+
+ const button = event.currentTarget as HTMLButtonElement;
+
+ const shareOptions: ShareData = {
+ url: button.dataset.url!,
+ };
+ if (button.dataset.title) {
+ shareOptions.title = button.dataset.title;
+ }
+
+ await window.navigator.share(shareOptions);
+}
+
/**
* Opens the share dialog after clicking on the share button.
*/
`;
}
+ let nativeSharingElement = "";
+ if (offerNativeSharing) {
+ nativeSharingElement = `
+ <dl>
+ <dt></dt>
+ <dd>
+ <button class="shareDialogNativeButton" data-url="${StringUtil.escapeHTML(
+ target.href,
+ )}" data-title="${StringUtil.escapeHTML(target.dataset.linkTitle || "")}">${Language.get(
+ "wcf.message.share.nativeShare",
+ )}</button>
+ </dd>
+ </dl>
+ `;
+ }
+
const dialogContent = `
<div class="shareContentDialog">
${getDialogElements(target)}
${providerElement}
+ ${nativeSharingElement}
</div>
`;
dialogData.content
.querySelectorAll(".shareDialogCopyButton")
.forEach((el) => el.addEventListener("click", (ev) => copy(ev)));
+ if (offerNativeSharing) {
+ dialogData.content.querySelector(".shareDialogNativeButton")!.addEventListener("click", (ev) => nativeShare(ev));
+ }
if (providerButtons) {
UiMessageShare.init();
UiMessageShare = tslib_1.__importStar(UiMessageShare);
UiMessageShareProviders = tslib_1.__importStar(UiMessageShareProviders);
const shareButtons = new WeakSet();
+ const offerNativeSharing = window.navigator.share !== undefined;
/**
* Copies the contents of one of the share dialog's input elements to the clipboard.
*/
}
return "";
}
+ /**
+ * Opens the native share menu.
+ */
+ async function nativeShare(event) {
+ event.preventDefault();
+ const button = event.currentTarget;
+ const shareOptions = {
+ url: button.dataset.url,
+ };
+ if (button.dataset.title) {
+ shareOptions.title = button.dataset.title;
+ }
+ await window.navigator.share(shareOptions);
+ }
/**
* Opens the share dialog after clicking on the share button.
*/
<dt>${Language.get("wcf.message.share.socialMedia")}</dt>
<dd>${providerButtons}</dd>
</dl>
+ `;
+ }
+ let nativeSharingElement = "";
+ if (offerNativeSharing) {
+ nativeSharingElement = `
+ <dl>
+ <dt></dt>
+ <dd>
+ <button class="shareDialogNativeButton" data-url="${StringUtil.escapeHTML(target.href)}" data-title="${StringUtil.escapeHTML(target.dataset.linkTitle || "")}">${Language.get("wcf.message.share.nativeShare")}</button>
+ </dd>
+ </dl>
`;
}
const dialogContent = `
<div class="shareContentDialog">
${getDialogElements(target)}
${providerElement}
+ ${nativeSharingElement}
</div>
`;
const dialogData = Dialog_1.default.openStatic(dialogId, dialogContent, {
dialogData.content
.querySelectorAll(".shareDialogCopyButton")
.forEach((el) => el.addEventListener("click", (ev) => copy(ev)));
+ if (offerNativeSharing) {
+ dialogData.content.querySelector(".shareDialogNativeButton").addEventListener("click", (ev) => nativeShare(ev));
+ }
if (providerButtons) {
UiMessageShare.init();
}
<item name="wcf.message.share.socialMedia"><![CDATA[Social Media]]></item>
<item name="wcf.message.share.copy"><![CDATA[Code kopieren]]></item>
<item name="wcf.message.share.copy.success"><![CDATA[Der Code wurde erfolgreich kopiert.]]></item>
+ <item name="wcf.message.share.nativeShare"><![CDATA[Weitere Optionen]]></item>
<item name="wcf.message.smilies"><![CDATA[Smileys]]></item>
<item name="wcf.message.button.extendedReply"><![CDATA[Erweiterte Antwort]]></item>
<item name="wcf.message.button.extendedEdit"><![CDATA[Erweiterte Bearbeitung]]></item>
<item name="wcf.message.share.socialMedia"><![CDATA[Social Media]]></item>
<item name="wcf.message.share.copy"><![CDATA[Copy Code]]></item>
<item name="wcf.message.share.copy.success"><![CDATA[The code has been successfully copied.]]></item>
+ <item name="wcf.message.share.nativeShare"><![CDATA[More Options]]></item>
<item name="wcf.message.smilies"><![CDATA[Smilies]]></item>
<item name="wcf.message.button.extendedReply"><![CDATA[More Options]]></item>
<item name="wcf.message.button.extendedEdit"><![CDATA[More Options]]></item>