sortableNodes.each(function(index, node) {
$(node).wcfIdentify();
});
-
- new WCF.Sortable.List('categoryList', 'wcf\\data\\category\\CategoryAction', 0{if $objectType->getProcessor()->getMaximumNestingLevel() != -1}, {
- /**
- * Updates the sortable nodes after a sorting is started with
- * regard to their possibility to have child the currently sorted
- * category as a child category.
- */
- start: function(event, ui) {
- var sortedListItem = $(ui.item);
- var itemNestingLevel = sortedListItem.find('.sortableList:has(.sortableNode)').length;
-
- sortableNodes.each(function(index, node) {
- node = $(node);
-
- if (node.attr('id') != sortedListItem.attr('id')) {
- if (node.parents('.sortableList').length + itemNestingLevel >= {@$objectType->getProcessor()->getMaximumNestingLevel() + 1}) {
- node.addClass('sortableNoNesting');
- }
- else if (node.hasClass('sortableNoNesting')) {
- node.removeClass('sortableNoNesting');
+
+ require(['WoltLabSuite/Core/Ui/Sortable/List'], function (UiSortableList) {
+ new UiSortableList({
+ containerId: 'categoryList',
+ className: 'wcf\\data\\category\\CategoryAction',
+ options: {
+ {if $objectType->getProcessor()->getMaximumNestingLevel() != -1}
+ /**
+ * Updates the sortable nodes after a sorting is started with
+ * regard to their possibility to have child the currently sorted
+ * category as a child category.
+ */
+ start: function(event, ui) {
+ var sortedListItem = $(ui.item);
+ var itemNestingLevel = sortedListItem.find('.sortableList:has(.sortableNode)').length;
+
+ sortableNodes.each(function(index, node) {
+ node = $(node);
+
+ if (node.attr('id') != sortedListItem.attr('id')) {
+ if (node.parents('.sortableList').length + itemNestingLevel >= {@$objectType->getProcessor()->getMaximumNestingLevel() + 1}) {
+ node.addClass('sortableNoNesting');
+ }
+ else if (node.hasClass('sortableNoNesting')) {
+ node.removeClass('sortableNoNesting');
+ }
+ }
+ });
+ },
+
+ /**
+ * Updates the sortable nodes after a sorting is completed with
+ * regard to their possibility to have child categories.
+ */
+ stop: function(event, ui) {
+ sortableNodes.each(function(index, node) {
+ node = $(node);
+
+ if (node.parents('.sortableList').length == {@$objectType->getProcessor()->getMaximumNestingLevel() + 1}) {
+ node.addClass('sortableNoNesting');
+ }
+ else if (node.hasClass('sortableNoNesting')) {
+ node.removeClass('sortableNoNesting');
+ }
+ });
}
- }
- });
- },
-
- /**
- * Updates the sortable nodes after a sorting is completed with
- * regard to their possibility to have child categories.
- */
- stop: function(event, ui) {
- sortableNodes.each(function(index, node) {
- node = $(node);
-
- if (node.parents('.sortableList').length == {@$objectType->getProcessor()->getMaximumNestingLevel() + 1}) {
- node.addClass('sortableNoNesting');
- }
- else if (node.hasClass('sortableNoNesting')) {
- node.removeClass('sortableNoNesting');
- }
- });
- }
- }{/if});
+ {/if}
+ }
+ });
+ });
{/if}
});
</script>
</span>
<span class="statusDisplay buttons">
+ <span class="icon icon16 fa-arrows sortableNodeHandle"></span>
+
{if $objectType->getProcessor()->canEditCategory()}
<a href="{link controller=$editController application=$objectType->getProcessor()->getApplication() id=$category->categoryID title=$category->getTitle()}{/link}" title="{lang}wcf.global.button.edit{/lang}" class="jsTooltip"><span class="icon icon16 fa-pencil"></span></a>
{/if}
--- /dev/null
+/**
+ * Sortable lists with optimized handling per device sizes.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2016 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";
+
+ /**
+ * @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