From a897be3a7b7e2e2bd44555301390607ff62d389a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Joshua=20R=C3=BCsweg?= Date: Thu, 12 Aug 2021 09:23:30 +0200 Subject: [PATCH] Rename `Ui/Object/Action/Toogle` to `Toggle` (#4450) --- ts/WoltLabSuite/Core/Bootstrap.ts | 2 +- .../Core/Ui/Object/Action/Toggle.ts | 35 +++++++++++++++++++ .../Core/Ui/Object/Action/Toogle.ts | 34 +++--------------- .../files/js/WoltLabSuite/Core/Bootstrap.js | 2 +- .../Core/Ui/Object/Action/Toggle.js | 35 +++++++++++++++++++ .../Core/Ui/Object/Action/Toogle.js | 32 +++-------------- 6 files changed, 81 insertions(+), 59 deletions(-) create mode 100644 ts/WoltLabSuite/Core/Ui/Object/Action/Toggle.ts create mode 100644 wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Object/Action/Toggle.js diff --git a/ts/WoltLabSuite/Core/Bootstrap.ts b/ts/WoltLabSuite/Core/Bootstrap.ts index 27ce26f39e..cab8f249db 100644 --- a/ts/WoltLabSuite/Core/Bootstrap.ts +++ b/ts/WoltLabSuite/Core/Bootstrap.ts @@ -29,7 +29,7 @@ import * as UiPassword from "./Ui/Password"; import * as UiEmpty from "./Ui/Empty"; import * as UiObjectAction from "./Ui/Object/Action"; import * as UiObjectActionDelete from "./Ui/Object/Action/Delete"; -import * as UiObjectActionToggle from "./Ui/Object/Action/Toogle"; +import * as UiObjectActionToggle from "./Ui/Object/Action/Toggle"; // perfectScrollbar does not need to be bound anywhere, it just has to be loaded for WCF.js import "perfect-scrollbar"; diff --git a/ts/WoltLabSuite/Core/Ui/Object/Action/Toggle.ts b/ts/WoltLabSuite/Core/Ui/Object/Action/Toggle.ts new file mode 100644 index 0000000000..88f9e76d39 --- /dev/null +++ b/ts/WoltLabSuite/Core/Ui/Object/Action/Toggle.ts @@ -0,0 +1,35 @@ +/** + * Reacts to objects being toggled. + * + * @author Matthias Schmidt + * @copyright 2001-2021 WoltLab GmbH + * @license GNU Lesser General Public License + * @module WoltLabSuite/Core/Ui/Object/Action/Toggle + */ + +import * as Language from "../../../Language"; +import UiObjectActionHandler from "./Handler"; +import { ObjectActionData } from "../Data"; + +function toggleObject(data: ObjectActionData): void { + const actionElement = data.objectElement.querySelector('.jsObjectAction[data-object-action="toggle"]') as HTMLElement; + if (!actionElement || actionElement.dataset.objectActionHandler) { + return; + } + + if (actionElement.classList.contains("fa-square-o")) { + actionElement.classList.replace("fa-square-o", "fa-check-square-o"); + + const newTitle = actionElement.dataset.disableTitle || Language.get("wcf.global.button.disable"); + actionElement.title = newTitle; + } else { + actionElement.classList.replace("fa-check-square-o", "fa-square-o"); + + const newTitle = actionElement.dataset.enableTitle || Language.get("wcf.global.button.enable"); + actionElement.title = newTitle; + } +} + +export function setup(): void { + new UiObjectActionHandler("toggle", ["enable", "disable"], toggleObject); +} diff --git a/ts/WoltLabSuite/Core/Ui/Object/Action/Toogle.ts b/ts/WoltLabSuite/Core/Ui/Object/Action/Toogle.ts index 88f9e76d39..150e454fc0 100644 --- a/ts/WoltLabSuite/Core/Ui/Object/Action/Toogle.ts +++ b/ts/WoltLabSuite/Core/Ui/Object/Action/Toogle.ts @@ -1,35 +1,9 @@ /** - * Reacts to objects being toggled. - * - * @author Matthias Schmidt + * @author Joshua Ruesweg * @copyright 2001-2021 WoltLab GmbH * @license GNU Lesser General Public License - * @module WoltLabSuite/Core/Ui/Object/Action/Toggle + * @module WoltLabSuite/Core/Ui/Object/Action/Toogle + * @deprecated Use the Module WoltLabSuite/Core/Ui/Object/Action/Toggle instead. */ -import * as Language from "../../../Language"; -import UiObjectActionHandler from "./Handler"; -import { ObjectActionData } from "../Data"; - -function toggleObject(data: ObjectActionData): void { - const actionElement = data.objectElement.querySelector('.jsObjectAction[data-object-action="toggle"]') as HTMLElement; - if (!actionElement || actionElement.dataset.objectActionHandler) { - return; - } - - if (actionElement.classList.contains("fa-square-o")) { - actionElement.classList.replace("fa-square-o", "fa-check-square-o"); - - const newTitle = actionElement.dataset.disableTitle || Language.get("wcf.global.button.disable"); - actionElement.title = newTitle; - } else { - actionElement.classList.replace("fa-check-square-o", "fa-square-o"); - - const newTitle = actionElement.dataset.enableTitle || Language.get("wcf.global.button.enable"); - actionElement.title = newTitle; - } -} - -export function setup(): void { - new UiObjectActionHandler("toggle", ["enable", "disable"], toggleObject); -} +export { setup } from "./Toggle"; diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Bootstrap.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Bootstrap.js index 94204ea920..ee61215c8d 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Bootstrap.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Bootstrap.js @@ -8,7 +8,7 @@ * @license GNU Lesser General Public License * @module WoltLabSuite/Core/Bootstrap */ -define(["require", "exports", "tslib", "./Core", "./Date/Picker", "./Date/Time/Relative", "./Devtools", "./Dom/Change/Listener", "./Environment", "./Event/Handler", "./Language", "./StringUtil", "./Ui/Dialog", "./Ui/Dropdown/Simple", "./Ui/Mobile", "./Ui/Page/Action", "./Ui/TabMenu", "./Ui/Tooltip", "./Ui/Page/JumpTo", "./Ui/Password", "./Ui/Empty", "./Ui/Object/Action", "./Ui/Object/Action/Delete", "./Ui/Object/Action/Toogle", "perfect-scrollbar"], function (require, exports, tslib_1, Core, Picker_1, DateTimeRelative, Devtools_1, Listener_1, Environment, EventHandler, Language, StringUtil, Dialog_1, Simple_1, UiMobile, UiPageAction, UiTabMenu, UiTooltip, UiPageJumpTo, UiPassword, UiEmpty, UiObjectAction, UiObjectActionDelete, UiObjectActionToggle) { +define(["require", "exports", "tslib", "./Core", "./Date/Picker", "./Date/Time/Relative", "./Devtools", "./Dom/Change/Listener", "./Environment", "./Event/Handler", "./Language", "./StringUtil", "./Ui/Dialog", "./Ui/Dropdown/Simple", "./Ui/Mobile", "./Ui/Page/Action", "./Ui/TabMenu", "./Ui/Tooltip", "./Ui/Page/JumpTo", "./Ui/Password", "./Ui/Empty", "./Ui/Object/Action", "./Ui/Object/Action/Delete", "./Ui/Object/Action/Toggle", "perfect-scrollbar"], function (require, exports, tslib_1, Core, Picker_1, DateTimeRelative, Devtools_1, Listener_1, Environment, EventHandler, Language, StringUtil, Dialog_1, Simple_1, UiMobile, UiPageAction, UiTabMenu, UiTooltip, UiPageJumpTo, UiPassword, UiEmpty, UiObjectAction, UiObjectActionDelete, UiObjectActionToggle) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.setup = void 0; diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Object/Action/Toggle.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Object/Action/Toggle.js new file mode 100644 index 0000000000..be21238d70 --- /dev/null +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Object/Action/Toggle.js @@ -0,0 +1,35 @@ +/** + * Reacts to objects being toggled. + * + * @author Matthias Schmidt + * @copyright 2001-2021 WoltLab GmbH + * @license GNU Lesser General Public License + * @module WoltLabSuite/Core/Ui/Object/Action/Toggle + */ +define(["require", "exports", "tslib", "../../../Language", "./Handler"], function (require, exports, tslib_1, Language, Handler_1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.setup = void 0; + Language = tslib_1.__importStar(Language); + Handler_1 = tslib_1.__importDefault(Handler_1); + function toggleObject(data) { + const actionElement = data.objectElement.querySelector('.jsObjectAction[data-object-action="toggle"]'); + if (!actionElement || actionElement.dataset.objectActionHandler) { + return; + } + if (actionElement.classList.contains("fa-square-o")) { + actionElement.classList.replace("fa-square-o", "fa-check-square-o"); + const newTitle = actionElement.dataset.disableTitle || Language.get("wcf.global.button.disable"); + actionElement.title = newTitle; + } + else { + actionElement.classList.replace("fa-check-square-o", "fa-square-o"); + const newTitle = actionElement.dataset.enableTitle || Language.get("wcf.global.button.enable"); + actionElement.title = newTitle; + } + } + function setup() { + new Handler_1.default("toggle", ["enable", "disable"], toggleObject); + } + exports.setup = setup; +}); diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Object/Action/Toogle.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Object/Action/Toogle.js index be21238d70..efea43ea9d 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Object/Action/Toogle.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Object/Action/Toogle.js @@ -1,35 +1,13 @@ /** - * Reacts to objects being toggled. - * - * @author Matthias Schmidt + * @author Joshua Ruesweg * @copyright 2001-2021 WoltLab GmbH * @license GNU Lesser General Public License - * @module WoltLabSuite/Core/Ui/Object/Action/Toggle + * @module WoltLabSuite/Core/Ui/Object/Action/Toogle + * @deprecated Use the Module WoltLabSuite/Core/Ui/Object/Action/Toggle instead. */ -define(["require", "exports", "tslib", "../../../Language", "./Handler"], function (require, exports, tslib_1, Language, Handler_1) { +define(["require", "exports", "./Toggle"], function (require, exports, Toggle_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.setup = void 0; - Language = tslib_1.__importStar(Language); - Handler_1 = tslib_1.__importDefault(Handler_1); - function toggleObject(data) { - const actionElement = data.objectElement.querySelector('.jsObjectAction[data-object-action="toggle"]'); - if (!actionElement || actionElement.dataset.objectActionHandler) { - return; - } - if (actionElement.classList.contains("fa-square-o")) { - actionElement.classList.replace("fa-square-o", "fa-check-square-o"); - const newTitle = actionElement.dataset.disableTitle || Language.get("wcf.global.button.disable"); - actionElement.title = newTitle; - } - else { - actionElement.classList.replace("fa-check-square-o", "fa-square-o"); - const newTitle = actionElement.dataset.enableTitle || Language.get("wcf.global.button.enable"); - actionElement.title = newTitle; - } - } - function setup() { - new Handler_1.default("toggle", ["enable", "disable"], toggleObject); - } - exports.setup = setup; + Object.defineProperty(exports, "setup", { enumerable: true, get: function () { return Toggle_1.setup; } }); }); -- 2.20.1