dynamicColorScheme: {if $__wcf->getStyleHandler()->getColorScheme() === 'system'}true{else}false{/if},
endpointUserPopover: {if $__wcf->getSession()->getPermission('user.profile.canViewUserProfile')}'{link controller='UserPopover'}{/link}'{else}''{/if},
executeCronjobs: {if $executeCronjobs}'{link controller="CronjobPerform"}{/link}'{else}undefined{/if},
- defaultCoverPhoto: '{unsafe:$__wcf->styleHandler->getStyle()->getCoverPhotoUrl()|encodeJS}',
{if ENABLE_SHARE_BUTTONS}
{assign var='__shareProviders' value="\n"|explode:SHARE_BUTTONS_PROVIDERS}
shareButtonProviders: [
{if $user->canEditCoverPhoto()}
<ul class="userProfileManageCoverPhoto buttonGroup buttonList smallButtons">
<li>
- <button type="button" data-edit-cover-photo="{link controller="UserCoverPhoto" id=$user->userID}{/link}" class="button small">
+ <button type="button" data-edit-cover-photo="{link controller="UserCoverPhoto" id=$user->userID}{/link}" data-default-cover-photo="{$__wcf->styleHandler->getStyle()->getCoverPhotoUrl()}" class="button small">
{icon name='pencil'} {lang}wcf.user.coverPhoto.management{/lang}
</button>
</li>
export interface BoostrapOptions {
dynamicColorScheme: boolean;
enableMobileMenu: boolean;
- defaultCoverPhoto?: string;
pageMenuMainProvider: PageMenuMainProvider;
}
void import("./Component/Image/Viewer").then(({ setupLegacy }) => setupLegacy());
});
whenFirstSeen("[data-edit-cover-photo]", () => {
- void import("./Component/User/CoverPhoto").then(({ setup }) => setup(options.defaultCoverPhoto));
+ void import("./Component/User/CoverPhoto").then(({ setup }) => setup());
});
// Move the reCAPTCHA widget overlay to the `pageOverlayContainer`
registerUrl: string;
notificationLastReadTime: number;
};
- defaultCoverPhoto?: string;
dynamicColorScheme: boolean;
endpointUserPopover: string;
executeCronjobs: string | undefined;
dynamicColorScheme: options.dynamicColorScheme,
enableMobileMenu: true,
pageMenuMainProvider: new UiPageMenuMainFrontend(),
- defaultCoverPhoto: options.defaultCoverPhoto,
});
UiPageHeaderMenu.init();
import { fire as fireEvent } from "WoltLabSuite/Core/Event/Handler";
import { getPhrase } from "WoltLabSuite/Core/Language";
import DomUtil from "WoltLabSuite/Core/Dom/Util";
+import { unescapeHTML } from "WoltLabSuite/Core/StringUtil";
type ResponseGetForm = {
dialog: string;
title: string;
};
-async function editCoverPhoto(button: HTMLElement, defaultCoverPhoto?: string): Promise<void> {
+async function editCoverPhoto(button: HTMLElement): Promise<void> {
+ const defaultCoverPhoto = button.dataset.defaultCoverPhoto;
const json = (await prepareRequest(button.dataset.editCoverPhoto!).get().fetchAsJson()) as ResponseGetForm;
const dialog = dialogFactory().fromHtml(json.dialog).withoutControls();
const coverPhotoElement = getCoverPhotoElement();
dialog.addEventListener("afterClose", () => {
const file = dialog.querySelector<WoltlabCoreFile>("woltlab-core-file");
- const coverPhotoUrl = file?.link ?? defaultCoverPhoto;
+ const coverPhotoUrl = unescapeHTML(file?.link ?? defaultCoverPhoto ?? "");
+ const coverPhotoStyle = `url("${coverPhotoUrl}")`;
if (FormBuilderManager.hasForm(json.formId)) {
FormBuilderManager.unregisterForm(json.formId);
}
- if (oldCoverPhoto === coverPhotoUrl || oldCoverPhoto === `url("${coverPhotoUrl}")`) {
+ if (oldCoverPhoto === coverPhotoUrl || oldCoverPhoto === coverPhotoStyle) {
// nothing changed
return;
}
if (coverPhotoElement && coverPhotoUrl) {
- coverPhotoElement.style.setProperty("background-image", `url(${coverPhotoUrl})`, "");
+ coverPhotoElement.style.setProperty("background-image", coverPhotoStyle, "");
} else {
// ACP cover photo management
if (!coverPhotoElement && coverPhotoUrl) {
coverPhotoNotice!.parentElement!.appendChild(
DomUtil.createFragmentFromHtml(
- `<div id="coverPhotoPreview" style="background-image: url(${coverPhotoUrl});"></div>`,
+ `<div id="coverPhotoPreview" style="background-image: ${coverPhotoStyle};"></div>`,
),
);
coverPhotoNotice!.remove();
return document.querySelector<HTMLElement>(".userProfileCoverPhoto") ?? document.getElementById("coverPhotoPreview");
}
-export function setup(defaultCoverPhoto?: string): void {
+export function setup(): void {
wheneverFirstSeen("[data-edit-cover-photo]", (button) => {
button.addEventListener(
"click",
- promiseMutex(() => editCoverPhoto(button, defaultCoverPhoto)),
+ promiseMutex(() => editCoverPhoto(button)),
);
});
}
void new Promise((resolve_12, reject_12) => { require(["./Component/Image/Viewer"], resolve_12, reject_12); }).then(tslib_1.__importStar).then(({ setupLegacy }) => setupLegacy());
});
(0, LazyLoader_1.whenFirstSeen)("[data-edit-cover-photo]", () => {
- void new Promise((resolve_13, reject_13) => { require(["./Component/User/CoverPhoto"], resolve_13, reject_13); }).then(tslib_1.__importStar).then(({ setup }) => setup(options.defaultCoverPhoto));
+ void new Promise((resolve_13, reject_13) => { require(["./Component/User/CoverPhoto"], resolve_13, reject_13); }).then(tslib_1.__importStar).then(({ setup }) => setup());
});
// Move the reCAPTCHA widget overlay to the `pageOverlayContainer`
// when widget form elements are placed in a dialog.
dynamicColorScheme: options.dynamicColorScheme,
enableMobileMenu: true,
pageMenuMainProvider: new Frontend_1.default(),
- defaultCoverPhoto: options.defaultCoverPhoto,
});
UiPageHeaderMenu.init();
if (options.styleChanger) {
* @since 6.2
* @woltlabExcludeBundle all
*/
-define(["require", "exports", "tslib", "WoltLabSuite/Core/Helper/PromiseMutex", "WoltLabSuite/Core/Helper/Selector", "WoltLabSuite/Core/Component/Dialog", "WoltLabSuite/Core/Ajax/Backend", "WoltLabSuite/Core/Ui/Notification", "WoltLabSuite/Core/Form/Builder/Manager", "WoltLabSuite/Core/Event/Handler", "WoltLabSuite/Core/Language", "WoltLabSuite/Core/Dom/Util"], function (require, exports, tslib_1, PromiseMutex_1, Selector_1, Dialog_1, Backend_1, Notification_1, FormBuilderManager, Handler_1, Language_1, Util_1) {
+define(["require", "exports", "tslib", "WoltLabSuite/Core/Helper/PromiseMutex", "WoltLabSuite/Core/Helper/Selector", "WoltLabSuite/Core/Component/Dialog", "WoltLabSuite/Core/Ajax/Backend", "WoltLabSuite/Core/Ui/Notification", "WoltLabSuite/Core/Form/Builder/Manager", "WoltLabSuite/Core/Event/Handler", "WoltLabSuite/Core/Language", "WoltLabSuite/Core/Dom/Util", "WoltLabSuite/Core/StringUtil"], function (require, exports, tslib_1, PromiseMutex_1, Selector_1, Dialog_1, Backend_1, Notification_1, FormBuilderManager, Handler_1, Language_1, Util_1, StringUtil_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setup = setup;
FormBuilderManager = tslib_1.__importStar(FormBuilderManager);
Util_1 = tslib_1.__importDefault(Util_1);
- async function editCoverPhoto(button, defaultCoverPhoto) {
+ async function editCoverPhoto(button) {
+ const defaultCoverPhoto = button.dataset.defaultCoverPhoto;
const json = (await (0, Backend_1.prepareRequest)(button.dataset.editCoverPhoto).get().fetchAsJson());
const dialog = (0, Dialog_1.dialogFactory)().fromHtml(json.dialog).withoutControls();
const coverPhotoElement = getCoverPhotoElement();
const oldCoverPhoto = coverPhotoElement?.style.backgroundImage;
dialog.addEventListener("afterClose", () => {
const file = dialog.querySelector("woltlab-core-file");
- const coverPhotoUrl = file?.link ?? defaultCoverPhoto;
+ const coverPhotoUrl = (0, StringUtil_1.unescapeHTML)(file?.link ?? defaultCoverPhoto ?? "");
+ const coverPhotoStyle = `url("${coverPhotoUrl}")`;
if (FormBuilderManager.hasForm(json.formId)) {
FormBuilderManager.unregisterForm(json.formId);
}
- if (oldCoverPhoto === coverPhotoUrl || oldCoverPhoto === `url("${coverPhotoUrl}")`) {
+ if (oldCoverPhoto === coverPhotoUrl || oldCoverPhoto === coverPhotoStyle) {
// nothing changed
return;
}
if (coverPhotoElement && coverPhotoUrl) {
- coverPhotoElement.style.setProperty("background-image", `url(${coverPhotoUrl})`, "");
+ coverPhotoElement.style.setProperty("background-image", coverPhotoStyle, "");
}
else {
// ACP cover photo management
if (!coverPhotoElement && coverPhotoUrl) {
- coverPhotoNotice.parentElement.appendChild(Util_1.default.createFragmentFromHtml(`<div id="coverPhotoPreview" style="background-image: url(${coverPhotoUrl});"></div>`));
+ coverPhotoNotice.parentElement.appendChild(Util_1.default.createFragmentFromHtml(`<div id="coverPhotoPreview" style="background-image: ${coverPhotoStyle};"></div>`));
coverPhotoNotice.remove();
}
else if (coverPhotoElement && !coverPhotoUrl) {
function getCoverPhotoElement() {
return document.querySelector(".userProfileCoverPhoto") ?? document.getElementById("coverPhotoPreview");
}
- function setup(defaultCoverPhoto) {
+ function setup() {
(0, Selector_1.wheneverFirstSeen)("[data-edit-cover-photo]", (button) => {
- button.addEventListener("click", (0, PromiseMutex_1.promiseMutex)(() => editCoverPhoto(button, defaultCoverPhoto)));
+ button.addEventListener("click", (0, PromiseMutex_1.promiseMutex)(() => editCoverPhoto(button)));
});
}
});