/**
* Handles dismissible user notices.
*
- * @author Alexander Ebert
- * @copyright 2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @module WoltLabSuite/Core/Controller/Notice/Dismiss
+ * @author Alexander Ebert
+ * @copyright 2001-2019 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module WoltLabSuite/Core/Controller/Notice/Dismiss
*/
-define(['Ajax'], function (Ajax) {
+define(["require", "exports", "tslib", "../../Ajax"], function (require, exports, tslib_1, Ajax) {
"use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.setup = void 0;
+ Ajax = tslib_1.__importStar(Ajax);
/**
- * @exports WoltLabSuite/Core/Controller/Notice/Dismiss
+ * Initializes dismiss buttons.
*/
- var ControllerNoticeDismiss = {
- /**
- * Initializes dismiss buttons.
- */
- setup: function () {
- var buttons = elByClass('jsDismissNoticeButton');
- if (buttons.length) {
- var clickCallback = this._click.bind(this);
- for (var i = 0, length = buttons.length; i < length; i++) {
- buttons[i].addEventListener('click', clickCallback);
- }
- }
- },
- /**
- * Sends a request to dismiss a notice and removes it afterwards.
- */
- _click: function (event) {
- var button = event.currentTarget;
- Ajax.apiOnce({
- data: {
- actionName: 'dismiss',
- className: 'wcf\\data\\notice\\NoticeAction',
- objectIDs: [elData(button, 'object-id')]
- },
- success: function () {
- elRemove(button.parentNode);
- }
- });
- }
- };
- return ControllerNoticeDismiss;
+ function setup() {
+ document.querySelectorAll(".jsDismissNoticeButton").forEach((button) => {
+ button.addEventListener("click", (ev) => click(ev));
+ });
+ }
+ exports.setup = setup;
+ /**
+ * Sends a request to dismiss a notice and removes it afterwards.
+ */
+ function click(event) {
+ const button = event.currentTarget;
+ Ajax.apiOnce({
+ data: {
+ actionName: "dismiss",
+ className: "wcf\\data\\notice\\NoticeAction",
+ objectIDs: [button.dataset.objectId],
+ },
+ success: () => {
+ button.parentElement.remove();
+ },
+ });
+ }
});
+++ /dev/null
-/**
- * Handles dismissible user notices.
- *
- * @author Alexander Ebert
- * @copyright 2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @module WoltLabSuite/Core/Controller/Notice/Dismiss
- */
-define(['Ajax'], function(Ajax) {
- "use strict";
-
- /**
- * @exports WoltLabSuite/Core/Controller/Notice/Dismiss
- */
- var ControllerNoticeDismiss = {
- /**
- * Initializes dismiss buttons.
- */
- setup: function() {
- var buttons = elByClass('jsDismissNoticeButton');
-
- if (buttons.length) {
- var clickCallback = this._click.bind(this);
- for (var i = 0, length = buttons.length; i < length; i++) {
- buttons[i].addEventListener('click', clickCallback);
- }
- }
- },
-
- /**
- * Sends a request to dismiss a notice and removes it afterwards.
- */
- _click: function(event) {
- var button = event.currentTarget;
-
- Ajax.apiOnce({
- data: {
- actionName: 'dismiss',
- className: 'wcf\\data\\notice\\NoticeAction',
- objectIDs: [ elData(button, 'object-id') ]
- },
- success: function() {
- elRemove(button.parentNode);
- }
- });
- }
- };
-
- return ControllerNoticeDismiss;
-});
--- /dev/null
+/**
+ * Handles dismissible user notices.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2019 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module WoltLabSuite/Core/Controller/Notice/Dismiss
+ */
+
+import * as Ajax from "../../Ajax";
+
+/**
+ * Initializes dismiss buttons.
+ */
+export function setup(): void {
+ document.querySelectorAll(".jsDismissNoticeButton").forEach((button) => {
+ button.addEventListener("click", (ev) => click(ev));
+ });
+}
+
+/**
+ * Sends a request to dismiss a notice and removes it afterwards.
+ */
+function click(event: Event): void {
+ const button = event.currentTarget as HTMLElement;
+
+ Ajax.apiOnce({
+ data: {
+ actionName: "dismiss",
+ className: "wcf\\data\\notice\\NoticeAction",
+ objectIDs: [button.dataset.objectId!],
+ },
+ success: () => {
+ button.parentElement!.remove();
+ },
+ });
+}