Optimize javascript code
authorJoshua Rüsweg <ruesweg@woltlab.com>
Fri, 24 May 2019 13:59:24 +0000 (15:59 +0200)
committerJoshua Rüsweg <ruesweg@woltlab.com>
Fri, 24 May 2019 14:02:40 +0000 (16:02 +0200)
See #2508

wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Reaction/Handler.js

index 90ac4883b4dcaee1cbf554dbd7d30f2301490059..f498d2454632a3867ad9feaaae693734f7329c18 100644 (file)
@@ -139,7 +139,7 @@ define(
                         * @param       {Element}       element
                         */
                        _enableMobileView: function(element) {
-                               var messageFooterGroup = element.parentElement.parentElement.parentElement;
+                               var messageFooterGroup = element.closest('.messageFooterGroup');
                                
                                elShow(elBySel('.mobileReactButton', messageFooterGroup));
                        },
@@ -150,7 +150,7 @@ define(
                         * @param       {Element}       element
                         */
                        _disableMobileView: function(element) {
-                               var messageFooterGroup = element.parentElement.parentElement.parentElement;
+                               var messageFooterGroup = element.closest('.messageFooterGroup');
                                
                                elHide(elBySel('.mobileReactButton', messageFooterGroup));
                        },
@@ -162,7 +162,7 @@ define(
                         * @param       {int}           objectID
                         */
                        _setupMobileView: function(element, objectID) {
-                               var messageFooterGroup = element.parentElement.parentElement.parentElement;
+                               var messageFooterGroup = element.closest('.messageFooterGroup');
                                
                                var button = elCreate('button');
                                button.classList = 'mobileReactButton';