/**
* Sortable lists with optimized handling per device sizes.
*
- * @author Alexander Ebert
- * @copyright 2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @module WoltLabSuite/Core/Ui/Sortable/List
+ * @author Alexander Ebert
+ * @copyright 2001-2019 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module WoltLabSuite/Core/Ui/Sortable/List
*/
-define(['Core', 'Ui/Screen'], function (Core, UiScreen) {
+define(["require", "exports", "tslib", "../../Core", "../Screen"], function (require, exports, tslib_1, Core, UiScreen) {
"use strict";
- if (!COMPILER_TARGET_DEFAULT) {
- var Fake = function () { };
- Fake.prototype = {
- init: function () { },
- _enable: function () { },
- _disable: function () { }
- };
- return Fake;
- }
- /**
- * @constructor
- */
- function UiSortableList(options) { this.init(options); }
- UiSortableList.prototype = {
+ Core = tslib_1.__importStar(Core);
+ UiScreen = tslib_1.__importStar(UiScreen);
+ class UiSortableList {
/**
* Initializes the sortable list controller.
- *
- * @param {Object} options initialization options for `WCF.Sortable.List`
*/
- init: function (options) {
+ constructor(opts) {
this._options = Core.extend({
- containerId: '',
- className: '',
+ containerId: "",
+ className: "",
offset: 0,
options: {},
isSimpleSorting: false,
- additionalParameters: {}
- }, options);
- UiScreen.on('screen-sm-md', {
- match: this._enable.bind(this, true),
- unmatch: this._disable.bind(this),
- setup: this._enable.bind(this, true)
+ additionalParameters: {},
+ }, opts);
+ UiScreen.on("screen-sm-md", {
+ match: () => this._enable(true),
+ unmatch: () => this._disable(),
+ setup: () => this._enable(true),
});
- UiScreen.on('screen-lg', {
- match: this._enable.bind(this, false),
- unmatch: this._disable.bind(this),
- setup: this._enable.bind(this, false)
+ UiScreen.on("screen-lg", {
+ match: () => this._enable(false),
+ unmatch: () => this._disable(),
+ setup: () => this._enable(false),
});
- },
+ }
/**
* Enables sorting with an optional sort handle.
- *
- * @param {boolean} hasHandle true if sort can only be started with the sort handle
- * @protected
*/
- _enable: function (hasHandle) {
- var options = this._options.options;
- if (hasHandle)
- options.handle = '.sortableNodeHandle';
+ _enable(hasHandle) {
+ const options = this._options.options;
+ if (hasHandle) {
+ options.handle = ".sortableNodeHandle";
+ }
new window.WCF.Sortable.List(this._options.containerId, this._options.className, this._options.offset, options, this._options.isSimpleSorting, this._options.additionalParameters);
- },
+ }
/**
* Disables sorting for registered containers.
- *
- * @protected
*/
- _disable: function () {
- window.jQuery('#' + this._options.containerId + ' .sortableList')[(this._options.isSimpleSorting ? 'sortable' : 'nestedSortable')]('destroy');
+ _disable() {
+ window
+ .jQuery(`#${this._options.containerId} .sortableList`)[this._options.isSimpleSorting ? "sortable" : "nestedSortable"]("destroy");
}
- };
+ }
+ Core.enableLegacyInheritance(UiSortableList);
return UiSortableList;
});
+++ /dev/null
-/**
- * Sortable lists with optimized handling per device sizes.
- *
- * @author Alexander Ebert
- * @copyright 2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @module WoltLabSuite/Core/Ui/Sortable/List
- */
-define(['Core', 'Ui/Screen'], function (Core, UiScreen) {
- "use strict";
-
- if (!COMPILER_TARGET_DEFAULT) {
- var Fake = function() {};
- Fake.prototype = {
- init: function() {},
- _enable: function() {},
- _disable: function() {}
- };
- return Fake;
- }
-
- /**
- * @constructor
- */
- function UiSortableList(options) { this.init(options); }
- UiSortableList.prototype = {
- /**
- * Initializes the sortable list controller.
- *
- * @param {Object} options initialization options for `WCF.Sortable.List`
- */
- init: function (options) {
- this._options = Core.extend({
- containerId: '',
- className: '',
- offset: 0,
- options: {},
- isSimpleSorting: false,
- additionalParameters: {}
- }, options);
-
- UiScreen.on('screen-sm-md', {
- match: this._enable.bind(this, true),
- unmatch: this._disable.bind(this),
- setup: this._enable.bind(this, true)
- });
-
- UiScreen.on('screen-lg', {
- match: this._enable.bind(this, false),
- unmatch: this._disable.bind(this),
- setup: this._enable.bind(this, false)
- });
- },
-
- /**
- * Enables sorting with an optional sort handle.
- *
- * @param {boolean} hasHandle true if sort can only be started with the sort handle
- * @protected
- */
- _enable: function (hasHandle) {
- var options = this._options.options;
- if (hasHandle) options.handle = '.sortableNodeHandle';
-
- new window.WCF.Sortable.List(
- this._options.containerId,
- this._options.className,
- this._options.offset,
- options,
- this._options.isSimpleSorting,
- this._options.additionalParameters
- );
- },
-
- /**
- * Disables sorting for registered containers.
- *
- * @protected
- */
- _disable: function () {
- window.jQuery('#' + this._options.containerId + ' .sortableList')[(this._options.isSimpleSorting ? 'sortable' : 'nestedSortable')]('destroy');
- }
- };
-
- return UiSortableList;
-});
\ No newline at end of file
--- /dev/null
+/**
+ * Sortable lists with optimized handling per device sizes.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2019 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module WoltLabSuite/Core/Ui/Sortable/List
+ */
+
+import * as Core from "../../Core";
+import * as UiScreen from "../Screen";
+
+interface UnknownObject {
+ [key: string]: unknown;
+}
+
+interface SortableListOptions {
+ containerId: string;
+ className: string;
+ offset: number;
+ options: UnknownObject;
+ isSimpleSorting: boolean;
+ additionalParameters: UnknownObject;
+}
+
+class UiSortableList {
+ protected readonly _options: SortableListOptions;
+
+ /**
+ * Initializes the sortable list controller.
+ */
+ constructor(opts: Partial<SortableListOptions>) {
+ this._options = Core.extend(
+ {
+ containerId: "",
+ className: "",
+ offset: 0,
+ options: {},
+ isSimpleSorting: false,
+ additionalParameters: {},
+ },
+ opts
+ ) as SortableListOptions;
+
+ UiScreen.on("screen-sm-md", {
+ match: () => this._enable(true),
+ unmatch: () => this._disable(),
+ setup: () => this._enable(true),
+ });
+
+ UiScreen.on("screen-lg", {
+ match: () => this._enable(false),
+ unmatch: () => this._disable(),
+ setup: () => this._enable(false),
+ });
+ }
+
+ /**
+ * Enables sorting with an optional sort handle.
+ */
+ protected _enable(hasHandle: boolean): void {
+ const options = this._options.options;
+ if (hasHandle) {
+ options.handle = ".sortableNodeHandle";
+ }
+
+ new window.WCF.Sortable.List(
+ this._options.containerId,
+ this._options.className,
+ this._options.offset,
+ options,
+ this._options.isSimpleSorting,
+ this._options.additionalParameters
+ );
+ }
+
+ /**
+ * Disables sorting for registered containers.
+ */
+ protected _disable(): void {
+ window
+ .jQuery(`#${this._options.containerId} .sortableList`)
+ [this._options.isSimpleSorting ? "sortable" : "nestedSortable"]("destroy");
+ }
+}
+
+Core.enableLegacyInheritance(UiSortableList);
+
+export = UiSortableList;