Convert `Acp/Ui/CodeMirror/Page`
authorAlexander Ebert <ebert@woltlab.com>
Sat, 2 Jan 2021 15:36:11 +0000 (16:36 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 2 Jan 2021 15:36:11 +0000 (16:36 +0100)
wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/CodeMirror/Page.js
wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Ui/CodeMirror/Page.js [deleted file]
wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Ui/CodeMirror/Page.ts [new file with mode: 0644]

index 236aeaa097364910a86cb42dda6775c31f1ae505..a765c33cf2c8adf3751190e24a5a96fba47e9ebc 100644 (file)
@@ -1,18 +1,21 @@
-define(['WoltLabSuite/Core/Ui/Page/Search'], function (UiPageSearch) {
+define(["require", "exports", "tslib", "../../../Core", "../../../Ui/Page/Search"], function (require, exports, tslib_1, Core, UiPageSearch) {
     "use strict";
-    function AcpUiCodeMirrorPage(elementId) { this.init(elementId); }
-    AcpUiCodeMirrorPage.prototype = {
-        init: function (elementId) {
-            this._element = elById(elementId);
-            elById('codemirror-' + elementId + '-page').addEventListener('click', this._click.bind(this));
-        },
-        _click: function (event) {
+    Core = tslib_1.__importStar(Core);
+    UiPageSearch = tslib_1.__importStar(UiPageSearch);
+    class AcpUiCodeMirrorPage {
+        constructor(elementId) {
+            this.element = document.getElementById(elementId);
+            const insertButton = document.getElementById(`codemirror-${elementId}-page`);
+            insertButton.addEventListener("click", (ev) => this._click(ev));
+        }
+        _click(event) {
             event.preventDefault();
-            UiPageSearch.open(this._insert.bind(this));
-        },
-        _insert: function (pageID) {
-            this._element.codemirror.replaceSelection('{{ page="' + pageID + '" }}');
+            UiPageSearch.open((pageID) => this._insert(pageID));
+        }
+        _insert(pageID) {
+            this.element.codemirror.replaceSelection(`{{ page="${pageID}" }}`);
         }
-    };
+    }
+    Core.enableLegacyInheritance(AcpUiCodeMirrorPage);
     return AcpUiCodeMirrorPage;
 });
diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Ui/CodeMirror/Page.js b/wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Ui/CodeMirror/Page.js
deleted file mode 100644 (file)
index a85dfc8..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-define(['WoltLabSuite/Core/Ui/Page/Search'], function(UiPageSearch) {
-       "use strict";
-       
-       function AcpUiCodeMirrorPage(elementId) { this.init(elementId); }
-       AcpUiCodeMirrorPage.prototype = {
-               init: function(elementId) {
-                       this._element = elById(elementId);
-                       
-                       elById('codemirror-' + elementId + '-page').addEventListener('click', this._click.bind(this));
-               },
-               
-               _click: function (event) {
-                       event.preventDefault();
-                       
-                       UiPageSearch.open(this._insert.bind(this));
-               },
-               
-               _insert: function (pageID) {
-                       this._element.codemirror.replaceSelection('{{ page="' + pageID + '" }}');
-               }
-       };
-       
-       return AcpUiCodeMirrorPage;
-});
diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Ui/CodeMirror/Page.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Ui/CodeMirror/Page.ts
new file mode 100644 (file)
index 0000000..90f753f
--- /dev/null
@@ -0,0 +1,27 @@
+import * as Core from "../../../Core";
+import * as UiPageSearch from "../../../Ui/Page/Search";
+
+class AcpUiCodeMirrorPage {
+  private element: HTMLElement;
+
+  constructor(elementId: string) {
+    this.element = document.getElementById(elementId)!;
+
+    const insertButton = document.getElementById(`codemirror-${elementId}-page`)!;
+    insertButton.addEventListener("click", (ev) => this._click(ev));
+  }
+
+  private _click(event: MouseEvent): void {
+    event.preventDefault();
+
+    UiPageSearch.open((pageID) => this._insert(pageID));
+  }
+
+  _insert(pageID: string): void {
+    (this.element as any).codemirror.replaceSelection(`{{ page="${pageID}" }}`);
+  }
+}
+
+Core.enableLegacyInheritance(AcpUiCodeMirrorPage);
+
+export = AcpUiCodeMirrorPage;