Adds possibility to update badges after javascript deletions
authorMatthias Schmidt <gravatronics@live.com>
Tue, 27 Dec 2011 14:14:57 +0000 (15:14 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Tue, 27 Dec 2011 14:14:57 +0000 (15:14 +0100)
wcfsetup/install/files/js/WCF.js

index 127fd1d58ea5279197cae6a83f54b2d60cb1f2cb..00d462af2c85b8d2fb0d3967d4feb52fe777d77a 100644 (file)
@@ -1204,19 +1204,22 @@ WCF.Action.SimpleProxy.prototype = {
  * 
  * @param      string          className
  * @param      jQuery          containerList
+ * @param      jQuery          badgeList
  */
-WCF.Action.Delete = function(className, containerList) { this.init(className, containerList); };
+WCF.Action.Delete = function(className, containerList, badgeList) { this.init(className, containerList, badgeList); };
 WCF.Action.Delete.prototype = {
        /**
         * Initializes 'delete'-Proxy.
         * 
         * @param       string          className
         * @param       jQuery          containerList
+        * @param       jQuery          badgeList
         */
-       init: function(className, containerList) {
+       init: function(className, containerList, badgeList) {
                if (!containerList.length) return;
                this.containerList = containerList;
                this.className = className;
+               this.badgeList = badgeList;
                
                // initialize proxy
                var options = {
@@ -1270,14 +1273,21 @@ WCF.Action.Delete.prototype = {
         */
        _success: function(data, textStatus, jqXHR) {
                // remove items
-               this.containerList.each(function(index, container) {
+               this.containerList.each($.proxy(function(index, container) {
                        var $objectID = $(container).find('.deleteButton').data('objectID');
                        if (WCF.inArray($objectID, data.objectIDs)) {
                                $(container).wcfBlindOut('up', function() {
                                        $(container).empty().remove();
                                }, container);
+                               
+                               // update badges
+                               if (this.badgeList) {
+                                       this.badgeList.each(function(innerIndex, badge) {
+                                               $(badge).html($(badge).html() - 1);
+                                       });
+                               }
                        }
-               });
+               }, this));
        }
 };