From ad2b783f171ec937bdfded3426a041c1457496c0 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sun, 9 Oct 2016 14:07:35 +0200 Subject: [PATCH] Disabled attachment sorting on non-desktop It doesn't play out well on mobile/touch and has a very limited use. --- wcfsetup/install/files/js/WCF.Attachment.js | 61 +++++++++++---------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/wcfsetup/install/files/js/WCF.Attachment.js b/wcfsetup/install/files/js/WCF.Attachment.js index 4a513ad6d4..e40c1033a1 100644 --- a/wcfsetup/install/files/js/WCF.Attachment.js +++ b/wcfsetup/install/files/js/WCF.Attachment.js @@ -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)); } } }); -- 2.20.1