usermenu:created plugin interface
authorDarren <darren@darrenwhitlen.com>
Wed, 4 Jun 2014 18:09:52 +0000 (19:09 +0100)
committerDarren <darren@darrenwhitlen.com>
Wed, 4 Jun 2014 18:09:52 +0000 (19:09 +0100)
client/src/views/memberlist.js

index 22721b0484257f456c6e9d025f171d7ca3290c6a..a5820873d8be4dbaca045a14c96560cfc3df1a90 100644 (file)
@@ -50,10 +50,11 @@ _kiwi.view.MemberList = Backbone.View.extend({
         var menu = new _kiwi.view.MenuBox(member.get('nick') || 'User');
         menu.addItem('userbox', userbox.$el);
         menu.showFooter(false);
-        menu.show();
 
-        // Position the userbox + menubox
-        (function() {
+        _kiwi.global.events.emit('usermenu:created', {menu: menu, userbox: userbox})
+        .done(_.bind(function() {
+            menu.show();
+
             var t = event.pageY,
                 m_bottom = t + menu.$el.outerHeight(),  // Where the bottom of menu will be
                 memberlist_bottom = this.$el.parent().offset().top + this.$el.parent().outerHeight(),
@@ -81,7 +82,15 @@ _kiwi.view.MemberList = Backbone.View.extend({
                 left: l,
                 top: t
             });
-        }).call(this);
+
+        }, this))
+        .prevented(_.bind(function() {
+            userbox = null;
+
+            menu.dispose();
+            menu = null;
+        }, this));
+
     },