Client: Hide userbox on second click #113
authorDarren <darren@darrenwhitlen.com>
Tue, 1 Jan 2013 23:24:33 +0000 (23:24 +0000)
committerDarren <darren@darrenwhitlen.com>
Tue, 1 Jan 2013 23:24:33 +0000 (23:24 +0000)
client/assets/dev/view.js

index 6a09edd259964a1763d7a942931242ae7bb84d9e..0cd61c6c58f50db2aefea23b67c2ddaa501a556a 100644 (file)
@@ -21,13 +21,23 @@ _kiwi.view.MemberList = Backbone.View.extend({
         });\r
     },\r
     nickClick: function (x) {\r
-        var target = $(x.currentTarget).parent('li'),\r
-            member = target.data('member'),\r
-            userbox = new _kiwi.view.UserBox();\r
+        var $target = $(x.currentTarget).parent('li'),\r
+            member = $target.data('member'),\r
+            userbox;\r
         \r
+        // If the userbox already exists here, hide it\r
+        if ($target.find('.userbox').length > 0) {\r
+            $('.userbox', this.$el).remove();\r
+            return;\r
+        }\r
+\r
+        userbox = new _kiwi.view.UserBox();\r
         userbox.member = member;\r
+\r
+        // Remove any existing userboxes\r
         $('.userbox', this.$el).remove();\r
-        target.append(userbox.$el);\r
+        \r
+        $target.append(userbox.$el);\r
     },\r
     show: function () {\r
         $('#memberlists').children().removeClass('active');\r