Fix like handler if user cannot dislike
authorMatthias Schmidt <gravatronics@live.com>
Sun, 31 Jul 2016 08:03:44 +0000 (10:03 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 31 Jul 2016 08:03:44 +0000 (10:03 +0200)
wcfsetup/install/files/js/WoltLab/WCF/Ui/Like/Handler.js

index 5708adad516a8e4828389ac87c88647603b18923..1af428c35f265559ac45f060a47b082ed08b2958 100644 (file)
@@ -319,17 +319,20 @@ define(
                _updateActiveState: function(element) {
                        var data = this._containers.get(element);
                        
-                       var dislikeTarget = (this._options.markListItemAsActive) ? data.dislikeButton.parentNode : data.dislikeButton;
                        var likeTarget = (this._options.markListItemAsActive) ? data.likeButton.parentNode : data.likeButton;
-                       
-                       if (data.dislikeButton !== null) dislikeTarget.classList.remove('active');
                        likeTarget.classList.remove('active');
                        
                        if (data.liked === 1) {
                                likeTarget.classList.add('active');
                        }
-                       else if (data.liked === -1 && data.dislikeButton !== null) {
-                               dislikeTarget.classList.add('active');
+                       
+                       if (this._options.canDislike) {
+                               var dislikeTarget = (this._options.markListItemAsActive) ? data.dislikeButton.parentNode : data.dislikeButton;
+                               dislikeTarget.classList.remove('active');
+                               
+                               if (data.liked === -1) {
+                                       dislikeTarget.classList.add('active');
+                               }
                        }
                },