Disabled attachment sorting on non-desktop
authorAlexander Ebert <ebert@woltlab.com>
Sun, 9 Oct 2016 12:07:35 +0000 (14:07 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 9 Oct 2016 12:07:40 +0000 (14:07 +0200)
It doesn't play out well on mobile/touch and has a very limited use.

wcfsetup/install/files/js/WCF.Attachment.js

index 4a513ad6d46ecb59815dc590d29e5795ee1b0a7b..e40c1033a1df9d471208ed95bd0798753e4faa42 100644 (file)
@@ -493,37 +493,40 @@ WCF.Attachment.Upload = WCF.Upload.extend({
                if (!this._fileListSelector.hasClass('sortableList')) {
                        this._fileListSelector.addClass('sortableList');
                        
-                       var self = this;
-                       new WCF.Sortable.List(this._fileListSelector.parent().wcfIdentify(), '', 0, {
-                               axis: false,
-                               items: 'li.sortableAttachment',
-                               toleranceElement: null,
-                               start: function (event, ui) {
-                                       ui.placeholder[0].style.setProperty('height', ui.helper[0].offsetHeight + 'px', '');
-                               },
-                               update: function(event, ui) {
-                                       var $attachmentIDs = [ ];
-                                       self._fileListSelector.children('li:not(.uploadFailed)').each(function(index, listItem) {
-                                               $attachmentIDs.push($(listItem).data('objectID'));
-                                       });
-                                       
-                                       if ($attachmentIDs.length) {
-                                               new WCF.Action.Proxy({
-                                                       autoSend: true,
-                                                       data: {
-                                                               actionName: 'updatePosition',
-                                                               className: 'wcf\\data\\attachment\\AttachmentAction',
-                                                               parameters: {
-                                                                       attachmentIDs: $attachmentIDs,
-                                                                       objectID: self._objectID,
-                                                                       objectType: self._objectType,
-                                                                       tmpHash: self._tmpHash
-                                                               }
+                       require(['Environment'], (function (Environment) {
+                               if (Environment.platform() === 'desktop') {
+                                       new WCF.Sortable.List(this._fileListSelector.parent().wcfIdentify(), '', 0, {
+                                               axis: false,
+                                               items: 'li.sortableAttachment',
+                                               toleranceElement: null,
+                                               start: function (event, ui) {
+                                                       ui.placeholder[0].style.setProperty('height', ui.helper[0].offsetHeight + 'px', '');
+                                               },
+                                               update: (function() {
+                                                       var $attachmentIDs = [ ];
+                                                       this._fileListSelector.children('li:not(.uploadFailed)').each(function(index, listItem) {
+                                                               $attachmentIDs.push($(listItem).data('objectID'));
+                                                       });
+                                                       
+                                                       if ($attachmentIDs.length) {
+                                                               new WCF.Action.Proxy({
+                                                                       autoSend: true,
+                                                                       data: {
+                                                                               actionName: 'updatePosition',
+                                                                               className: 'wcf\\data\\attachment\\AttachmentAction',
+                                                                               parameters: {
+                                                                                       attachmentIDs: $attachmentIDs,
+                                                                                       objectID: this._objectID,
+                                                                                       objectType: this._objectType,
+                                                                                       tmpHash: this._tmpHash
+                                                                               }
+                                                                       }
+                                                               });
                                                        }
-                                               });
-                                       }
+                                               }).bind(this)
+                                       }, true);
                                }
-                       }, true);
+                       }).bind(this));
                }
        }
 });