}
else {
element.dataset.value = time.toString();
- const format = isTimeOnly ? "formatTime" : "formatDate" + (isDateTime ? "Time" : "");
+ const format = isTimeOnly ? "formatTime" : isDateTime ? "formatDateTime" : "formatDate";
value = DateUtil[format](date);
}
}
*/
function isBoundaryElement(element, parent, type) {
let node = element;
- while ((node = node[`${type}Sibling`])) {
+ while ((node = node[type])) {
if (node.nodeType !== Node.TEXT_NODE || node.textContent.replace(/\u200B/, "") !== "") {
return false;
}
if (tmpElement === null && firstSelectedElement.parentElement === lastSelectedElement.parentElement) {
const parent = firstSelectedElement.parentElement;
if (parent.nodeName === "SPAN" && parent.style.getPropertyValue(property) !== "") {
- if (isBoundaryElement(firstSelectedElement, parent, "previous") &&
- isBoundaryElement(lastSelectedElement, parent, "next")) {
+ if (isBoundaryElement(firstSelectedElement, parent, "previousSibling") &&
+ isBoundaryElement(lastSelectedElement, parent, "nextSibling")) {
Util_1.default.unwrapChildNodes(parent);
}
}
let label = reason.nextElementSibling;
const phrase = "wcf.user." + this.actionName + ".reason.description";
label.textContent = Language.get(phrase);
- window[label.textContent === phrase ? "elHide" : "elShow"](label);
+ if (label.textContent === phrase) {
+ Util_1.default.hide(label);
+ }
+ else {
+ Util_1.default.show(label);
+ }
label = document.getElementById("wcfUiUserEditorNeverExpires").nextElementSibling;
label.textContent = Language.get("wcf.user." + this.actionName + ".neverExpires");
label = content.querySelector('label[for="wcfUiUserEditorExpires"]');
private readonly projectId: number;
private queue: PendingPip[] = [];
- constructor(projectId) {
+ constructor(projectId: number) {
this.projectId = projectId;
const restrictedSync = document.getElementById("syncShowOnlyMatches") as HTMLInputElement;
* @module WoltLabSuite/Core/Acp/Ui/Page/Add
*/
-import { DialogCallbackObject } from "../../../Ui/Dialog/Data";
+import { DialogCallbackObject, DialogCallbackSetup } from "../../../Ui/Dialog/Data";
import * as Language from "../../../Language";
import UiDialog from "../../../Ui/Dialog";
UiDialog.open(this);
}
- _dialogSetup() {
+ _dialogSetup(): ReturnType<DialogCallbackSetup> {
return {
id: "pageAddDialog",
options: {
value = "";
} else {
element.dataset.value = time.toString();
- const format = isTimeOnly ? "formatTime" : "formatDate" + (isDateTime ? "Time" : "");
+ const format = isTimeOnly ? "formatTime" : isDateTime ? "formatDateTime" : "formatDate";
value = DateUtil[format](date);
}
}
TagName,
}
+type SiblingType = "nextElementSibling" | "previousElementSibling";
+
const _test = new Map<Type, (...args: any[]) => boolean>([
[Type.None, () => true],
[Type.Selector, (element: Element, selector: string) => element.matches(selector)],
return null;
}
-function _getSibling(element: Element, siblingType: string, type: Type, value: string): Element | null {
+function _getSibling(element: Element, siblingType: SiblingType, type: Type, value: string): Element | null {
if (!(element instanceof Element)) {
throw new TypeError("Expected a valid element as first argument.");
}
[key: string]: any;
}
+export interface AjaxResponseReturnValues {
+ dialog: string;
+ formId: string;
+}
+
export type FormBuilderData = InternalFormBuilderData | Promise<InternalFormBuilderData>;
export interface FormBuilderDialogOptions {
closeCallback: () => void;
destroyOnClose: boolean;
dialog: DialogOptions;
- onSubmit: (FormBuilderData, HTMLButtonElement) => void;
+ onSubmit: (formData: FormBuilderData, submitButton: HTMLButtonElement) => void;
submitActionName?: string;
- successCallback: (AjaxResponseReturnValues) => void;
+ successCallback: (returnValues: AjaxResponseReturnValues) => void;
usesDboAction: boolean;
}
import * as Ajax from "../../Ajax";
import { AjaxCallbackObject, AjaxCallbackSetup, DatabaseObjectActionResponse, RequestOptions } from "../../Ajax/Data";
import * as FormBuilderManager from "./Manager";
-import { FormBuilderData, FormBuilderDialogOptions } from "./Data";
-
-interface AjaxResponseReturnValues {
- dialog: string;
- formId: string;
-}
+import { AjaxResponseReturnValues, FormBuilderData, FormBuilderDialogOptions } from "./Data";
interface AjaxResponse extends DatabaseObjectActionResponse {
returnValues: AjaxResponseReturnValues;
}
interface ValidationApi {
- throwError: (HTMLElement, string) => void;
+ throwError: (container: HTMLElement, message: string) => void;
}
interface ValidationData {
const maxVotes = ~~this.maxVotesField.value;
if (maxVotes && maxVotes > nonEmptyOptionCount) {
- data.api.throwError(this.maxVotesField.parentElement, Language.get("wcf.poll.maxVotes.error.invalid"));
+ data.api.throwError(this.maxVotesField.parentElement!, Language.get("wcf.poll.maxVotes.error.invalid"));
data.valid = false;
} else {
EventHandler.fire("com.woltlab.wcf.poll.editor", "validate", {
let highlighters = `<option value="">${Language.get("wcf.editor.code.highlighter.detect")}</option>
<option value="plain">${Language.get("wcf.editor.code.highlighter.plain")}</option>`;
- const values: Highlighter[] = this._editor.opts.woltlab.highlighters.map((highlighter) => {
+ const values: Highlighter[] = this._editor.opts.woltlab.highlighters.map((highlighter: string) => {
return [highlighter, PrismMeta[highlighter].title];
});
* of its parent, ignoring empty text nodes appearing between the
* element and the boundary.
*/
-function isBoundaryElement(element: HTMLElement, parent: HTMLElement, type: string): boolean {
- let node = element;
- while ((node = node[`${type}Sibling`])) {
+function isBoundaryElement(
+ element: HTMLElement,
+ parent: HTMLElement,
+ type: "previousSibling" | "nextSibling",
+): boolean {
+ let node: Node | null = element;
+ while ((node = node[type])) {
if (node.nodeType !== Node.TEXT_NODE || node.textContent!.replace(/\u200B/, "") !== "") {
return false;
}
const parent = firstSelectedElement.parentElement!;
if (parent.nodeName === "SPAN" && parent.style.getPropertyValue(property) !== "") {
if (
- isBoundaryElement(firstSelectedElement, parent, "previous") &&
- isBoundaryElement(lastSelectedElement, parent, "next")
+ isBoundaryElement(firstSelectedElement, parent, "previousSibling") &&
+ isBoundaryElement(lastSelectedElement, parent, "nextSibling")
) {
DomUtil.unwrapChildNodes(parent);
}
const _mql = new Map<string, MediaQueryData>();
let _scrollDisableCounter = 0;
-let _scrollOffsetFrom: string;
+let _scrollOffsetFrom: "body" | "documentElement";
let _scrollTop = 0;
let _pageOverlayCounter = 0;
});
}
-function scrollEnable(isSetup) {
+function scrollEnable(isSetup: boolean) {
_enableTabScroll = true;
_tabMenus.forEach((tabMenu) => {
const activeTab = tabMenu.getActiveTab();
_enableTabScroll = false;
}
-function scrollMenu(list, left, scrollLeft, scrollWidth, width, paddingRight) {
+function scrollMenu(
+ list: HTMLElement,
+ left: number,
+ scrollLeft: number,
+ scrollWidth: number,
+ width: number,
+ paddingRight: boolean,
+) {
// allow some padding to indicate overflow
if (paddingRight) {
left -= 15;
// new value is larger, we're scrolling towards the end
if (scrollLeft < left) {
- list.firstElementChild.style.setProperty("margin-left", `${scrollLeft - left}px`, "");
+ (list.firstElementChild as HTMLElement).style.setProperty("margin-left", `${scrollLeft - left}px`, "");
} else {
// new value is smaller, we're scrolling towards the start
list.style.setProperty("padding-left", `${scrollLeft - left}px`, "");
setTimeout(() => {
list.classList.remove("enableAnimation");
- list.firstElementChild.style.removeProperty("margin-left");
+ (list.firstElementChild as HTMLElement).style.removeProperty("margin-left");
list.style.removeProperty("padding-left");
list.scrollLeft = left;
}, 300);
let label = reason.nextElementSibling as HTMLElement;
const phrase = "wcf.user." + this.actionName + ".reason.description";
label.textContent = Language.get(phrase);
- window[label.textContent === phrase ? "elHide" : "elShow"](label);
+ if (label.textContent === phrase) {
+ DomUtil.hide(label);
+ } else {
+ DomUtil.show(label);
+ }
label = document.getElementById("wcfUiUserEditorNeverExpires")!.nextElementSibling as HTMLElement;
label.textContent = Language.get("wcf.user." + this.actionName + ".neverExpires");