From 2ce1c438e2924e9ea0547694bed5cba42d185041 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Joshua=20R=C3=BCsweg?= Date: Mon, 6 Aug 2018 16:40:20 +0200 Subject: [PATCH] Improve sorting of reaction types in js See #2508 --- .../js/WoltLabSuite/Core/Ui/Reaction/Handler.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Reaction/Handler.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Reaction/Handler.js index bf322088a8..a599e4221f 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Reaction/Handler.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Reaction/Handler.js @@ -305,13 +305,22 @@ define( _getSortedReactionTypes: function() { var sortedReactionTypes = []; + // convert our reaction type object to an array for (var key in REACTION_TYPES) { if (!REACTION_TYPES.hasOwnProperty(key)) continue; - var reactionType = REACTION_TYPES[key]; - - sortedReactionTypes[reactionType.showOrder] = reactionType; + sortedReactionTypes.push(REACTION_TYPES[key]); } + // sort the array + sortedReactionTypes.sort(function (a, b) { + if (a.showOrder > b.showOrder) { + return 1; + } + else { + return -1; + } + }); + return sortedReactionTypes; }, -- 2.20.1