From 76d4050cd0431bc48ea51927f4289735482c266f Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sun, 25 Oct 2020 15:39:55 +0100 Subject: [PATCH] Renamed the Ajax/Dialog `CallbackObject` --- .../install/files/ts/WoltLabSuite/Core/Ajax.ts | 6 +++--- .../files/ts/WoltLabSuite/Core/Ajax/Data.ts | 4 ++-- .../files/ts/WoltLabSuite/Core/BackgroundQueue.ts | 4 ++-- .../files/ts/WoltLabSuite/Core/Ui/Confirmation.ts | 4 ++-- .../files/ts/WoltLabSuite/Core/Ui/Dialog.ts | 14 +++++++------- .../files/ts/WoltLabSuite/Core/Ui/Dialog/Data.ts | 2 +- .../files/ts/WoltLabSuite/Core/Ui/Page/JumpTo.ts | 4 ++-- .../files/ts/WoltLabSuite/Core/Ui/Suggestion.ts | 4 ++-- .../files/ts/WoltLabSuite/Core/Ui/User/List.ts | 4 ++-- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax.ts index 18630a7fc1..d9da0e17d3 100644 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax.ts +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax.ts @@ -9,7 +9,7 @@ */ import AjaxRequest from './Ajax/Request'; -import { CallbackObject, CallbackSuccess, CallbackFailure, RequestData, RequestOptions } from './Ajax/Data'; +import { AjaxCallbackObject, CallbackSuccess, CallbackFailure, RequestData, RequestOptions } from './Ajax/Data'; const _cache = new WeakMap(); @@ -17,7 +17,7 @@ const _cache = new WeakMap(); * Shorthand function to perform a request against the WCF-API with overrides * for success and failure callbacks. */ -export function api(callbackObject: CallbackObject, data?: RequestData, success?: CallbackSuccess, failure?: CallbackFailure): AjaxRequest { +export function api(callbackObject: AjaxCallbackObject, data?: RequestData, success?: CallbackSuccess, failure?: CallbackFailure): AjaxRequest { if (typeof data !== 'object') data = {}; let request = _cache.get(callbackObject); @@ -84,7 +84,7 @@ export function apiOnce(options: RequestOptions): void { /** * Returns the request object used for an earlier call to `api()`. */ -export function getRequestObject(callbackObject: CallbackObject): AjaxRequest { +export function getRequestObject(callbackObject: AjaxCallbackObject): AjaxRequest { if (!_cache.has(callbackObject)) { throw new Error('Expected a previously used callback object, provided object is unknown.'); } diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax/Data.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax/Data.ts index af44f74df2..e114b36ad1 100644 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax/Data.ts +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax/Data.ts @@ -34,7 +34,7 @@ export type CallbackSuccess = (data: ResponseData | DatabaseObjectActionResponse export type CallbackUploadProgress = (event: ProgressEvent) => void; export type CallbackSetup = () => RequestOptions; -export interface CallbackObject { +export interface AjaxCallbackObject { _ajaxFailure?: CallbackFailure; _ajaxFinalize?: CallbackFinalize; _ajaxProgress?: CallbackProgress; @@ -66,5 +66,5 @@ export interface RequestOptions { progress?: CallbackProgress, uploadProgress?: CallbackUploadProgress, - callbackObject?: CallbackObject | null, + callbackObject?: AjaxCallbackObject | null, } diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/BackgroundQueue.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/BackgroundQueue.ts index 662cd0c238..e56cd0b2cb 100644 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/BackgroundQueue.ts +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/BackgroundQueue.ts @@ -8,9 +8,9 @@ */ import * as Ajax from './Ajax'; -import { CallbackObject, RequestOptions, ResponseData } from './Ajax/Data'; +import { AjaxCallbackObject, RequestOptions, ResponseData } from './Ajax/Data'; -class BackgroundQueue implements CallbackObject { +class BackgroundQueue implements AjaxCallbackObject { private _invocations = 0; private _isBusy = false; private readonly _url: string; diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Confirmation.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Confirmation.ts index db0c2899ac..dd25657125 100644 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Confirmation.ts +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Confirmation.ts @@ -11,9 +11,9 @@ import * as Core from '../Core'; import * as Language from '../Language'; import UiDialog from './Dialog'; -import { CallbackObject } from './Dialog/Data'; +import { DialogCallbackObject } from './Dialog/Data'; -class UiConfirmation implements CallbackObject { +class UiConfirmation implements DialogCallbackObject { private _active = false; private parameters: CallbackParameters; diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Dialog.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Dialog.ts index b5e31edb1e..67e5215598 100644 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Dialog.ts +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Dialog.ts @@ -12,7 +12,7 @@ import * as Core from '../Core'; import DomChangeListener from '../Dom/Change/Listener'; import * as UiScreen from './Screen'; import DomUtil from '../Dom/Util'; -import { CallbackObject, DialogData, DialogId, DialogOptions, DialogHtml, AjaxInitialization } from './Dialog/Data'; +import { DialogCallbackObject, DialogData, DialogId, DialogOptions, DialogHtml, AjaxInitialization } from './Dialog/Data'; import * as Language from '../Language'; import * as Environment from '../Environment'; import * as EventHandler from '../Event/Handler'; @@ -22,8 +22,8 @@ let _callbackFocus: (event: FocusEvent) => void; let _container: HTMLElement; const _dialogs = new Map(); let _dialogFullHeight = false; -const _dialogObjects = new WeakMap(); -const _dialogToObject = new Map(); +const _dialogObjects = new WeakMap(); +const _dialogToObject = new Map(); let _focusedBeforeDialog: Element | null; let _keyupListener: (event: KeyboardEvent) => boolean; const _validCallbacks = ['onBeforeClose', 'onClose', 'onShow']; @@ -129,7 +129,7 @@ export = { /** * Opens the dialog and implicitly creates it on first usage. */ - open(callbackObject: CallbackObject, html?: DialogHtml): DialogData | object { + open(callbackObject: DialogCallbackObject, html?: DialogHtml): DialogData | object { let dialogData = _dialogObjects.get(callbackObject); if (dialogData && Core.isPlainObject(dialogData)) { // dialog already exists @@ -718,7 +718,7 @@ export = { }); if (isValid) { - const callbackObject = _dialogToObject.get(id) as CallbackObject; + const callbackObject = _dialogToObject.get(id) as DialogCallbackObject; if (typeof callbackObject._dialogSubmit === 'function') { callbackObject._dialogSubmit(); } @@ -830,7 +830,7 @@ export = { * * @param {Object} callbackObject the same object that was used to invoke `_dialogSetup()` on first call */ - destroy(callbackObject: CallbackObject): void { + destroy(callbackObject: DialogCallbackObject): void { if (typeof callbackObject !== 'object') { throw new TypeError("Expected the callback object as parameter."); } @@ -881,7 +881,7 @@ interface DialogInternalData { type ElementId = string; -type ElementIdOrCallbackObject = CallbackObject | ElementId; +type ElementIdOrCallbackObject = DialogCallbackObject | ElementId; interface InternalDialogOptions extends DialogOptions { backdropCloseOnClick: boolean; diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Dialog/Data.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Dialog/Data.ts index 021c361c60..14aeb47390 100644 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Dialog/Data.ts +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Dialog/Data.ts @@ -2,7 +2,7 @@ import { RequestPayload, ResponseData } from '../../Ajax/Data'; export type DialogHtml = DocumentFragment | string | null; -export interface CallbackObject { +export interface DialogCallbackObject { _dialogSetup: () => DialogSettings; _dialogSubmit?: () => void; } diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Page/JumpTo.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Page/JumpTo.ts index 066ada6b05..17adb65c49 100644 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Page/JumpTo.ts +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Page/JumpTo.ts @@ -7,11 +7,11 @@ * @module WoltLabSuite/Core/Ui/Page/JumpTo */ -import { CallbackObject, DialogSettings } from '../Dialog/Data'; +import { DialogCallbackObject, DialogSettings } from '../Dialog/Data'; import * as Language from '../../Language'; import UiDialog from '../Dialog'; -class UiPageJumpTo implements CallbackObject { +class UiPageJumpTo implements DialogCallbackObject { private activeElement: HTMLElement; private description: HTMLElement; private elements = new Map(); diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Suggestion.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Suggestion.ts index ac4e5eea89..6917d8a0b3 100644 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Suggestion.ts +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Suggestion.ts @@ -10,14 +10,14 @@ import * as Ajax from '../Ajax'; import * as Core from '../Core'; import { - CallbackObject, + AjaxCallbackObject, DatabaseObjectActionPayload, DatabaseObjectActionResponse, RequestPayload, } from '../Ajax/Data'; import UiDropdownSimple from './Dropdown/Simple'; -class UiSuggestion implements CallbackObject { +class UiSuggestion implements AjaxCallbackObject { private readonly ajaxPayload: DatabaseObjectActionPayload; private readonly callbackSelect: CallbackSelect; private dropdownMenu: HTMLElement | null = null; diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/User/List.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/User/List.ts index 1162949a56..764730b649 100644 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/User/List.ts +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/User/List.ts @@ -12,8 +12,8 @@ import * as Core from '../../Core'; import DomUtil from '../../Dom/Util'; import UiDialog from '../Dialog'; import UiPagination from '../Pagination'; -import { CallbackObject as AjaxCallbackObject, DatabaseObjectActionResponse, RequestOptions } from '../../Ajax/Data'; -import { CallbackObject as DialogCallbackObject, DialogData, DialogSettings } from '../Dialog/Data'; +import { AjaxCallbackObject, DatabaseObjectActionResponse, RequestOptions } from '../../Ajax/Data'; +import { DialogCallbackObject, DialogData, DialogSettings } from '../Dialog/Data'; /** * @constructor -- 2.20.1