{include file='__devtoolsLanguageChooser'}
+{if ENABLE_DEBUG_MODE && ENABLE_DEVELOPER_TOOLS}
+<script data-relocate="true">
+ require(["WoltLabSuite/Core/Devtools/Style/LiveReload"], (LiveReload) => LiveReload.watch());
+</script>
+{/if}
+
{js application='wcf' lib='jquery' hasTiny=true}
{js application='wcf' lib='jquery-ui' hasTiny=true}
{js application='wcf' lib='jquery-ui' file='touchPunch' bundle='WCF.Combined' hasTiny=true}
--- /dev/null
+/**
+ * Schedules a live reload of the style's CSS.
+ *
+ * @author Tim Duesterhus
+ * @copyright 2001-2021 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module WoltLabSuite/Core/Devtools/Style/LiveReload
+ */
+
+const channelName = "com.woltlab.wcf#DevTools/Style/LiveReload";
+
+type UpdateMessage = undefined;
+
+export function watch(): void {
+ if (!window.BroadcastChannel) {
+ return;
+ }
+
+ const channel = new BroadcastChannel(channelName);
+
+ channel.onmessage = (_ev: MessageEvent<UpdateMessage>) => {
+ const link: HTMLLinkElement | null = document.querySelector("head link[rel=stylesheet]");
+ if (!link) {
+ return;
+ }
+
+ const url = new URL(link.href);
+ url.searchParams.set("m", Math.trunc(Date.now() / 1_000).toString());
+
+ const newLink = document.createElement("link");
+ newLink.rel = "stylesheet";
+ newLink.addEventListener("load", () => {
+ link.remove();
+ });
+ newLink.addEventListener("error", () => {
+ newLink.remove();
+ });
+ newLink.href = url.toString();
+ link.insertAdjacentElement("afterend", newLink);
+ };
+}
+
+export function notify(): void {
+ if (!window.BroadcastChannel) {
+ return;
+ }
+
+ const channel = new BroadcastChannel(channelName);
+ channel.postMessage(undefined);
+}
{include file='formNotice'}
+{if $success|isset}
+<script data-relocate="true">
+ require(["WoltLabSuite/Core/Devtools/Style/LiveReload"], (LiveReload) => LiveReload.notify());
+</script>
+{/if}
+
<form method="post" action="{if $action == 'add'}{link controller='StyleAdd'}{/link}{else}{link controller='StyleEdit' id=$styleID}{/link}{/if}">
<div class="section tabMenuContainer" data-active="{$activeTabMenuItem}" data-store="activeTabMenuItem" id="styleTabMenuContainer">
<nav class="tabMenu">
{if $success|isset}
<p class="success">{lang}wcf.global.success{/lang}</p>
+
+ <script data-relocate="true">
+ require(["WoltLabSuite/Core/Devtools/Style/LiveReload"], (LiveReload) => LiveReload.notify());
+ </script>
{/if}
<form method="post" action="{link controller='StyleGlobalValues'}{/link}">
--- /dev/null
+/**
+ * Schedules a live reload of the style's CSS.
+ *
+ * @author Tim Duesterhus
+ * @copyright 2001-2021 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module WoltLabSuite/Core/Devtools/Style/LiveReload
+ */
+define(["require", "exports"], function (require, exports) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.notify = exports.watch = void 0;
+ const channelName = "com.woltlab.wcf#DevTools/Style/LiveReload";
+ function watch() {
+ if (!window.BroadcastChannel) {
+ return;
+ }
+ const channel = new BroadcastChannel(channelName);
+ channel.onmessage = (_ev) => {
+ const link = document.querySelector("head link[rel=stylesheet]");
+ if (!link) {
+ return;
+ }
+ const url = new URL(link.href);
+ url.searchParams.set("m", Math.trunc(Date.now() / 1000).toString());
+ const newLink = document.createElement("link");
+ newLink.rel = "stylesheet";
+ newLink.addEventListener("load", () => {
+ link.remove();
+ });
+ newLink.addEventListener("error", () => {
+ newLink.remove();
+ });
+ newLink.href = url.toString();
+ link.insertAdjacentElement("afterend", newLink);
+ };
+ }
+ exports.watch = watch;
+ function notify() {
+ if (!window.BroadcastChannel) {
+ return;
+ }
+ const channel = new BroadcastChannel(channelName);
+ channel.postMessage(undefined);
+ }
+ exports.notify = notify;
+});