Plugin hook for nick list click
authorDarren <darren@darrenwhitlen.com>
Fri, 28 Nov 2014 09:59:54 +0000 (09:59 +0000)
committerDarren <darren@darrenwhitlen.com>
Fri, 28 Nov 2014 09:59:54 +0000 (09:59 +0000)
client/src/views/memberlist.js

index 8fa6e8a18ef211fac81e1280ef4c189bc8684a45..817d84bd88517a5a4529d57f431514676bf12bc9 100644 (file)
@@ -39,7 +39,16 @@ _kiwi.view.MemberList = Backbone.View.extend({
 
     nickClick: function (event) {
         var $target = $(event.currentTarget).parent('li'),
-            member = $target.data('member'),
+            member = $target.data('member');
+
+        _kiwi.global.events.emit('nicklist:select', {target: $target, member: member})
+        .then(_.bind(this.openUserMenuForItem, this, $target));
+    },
+
+
+    // Open a user menu for the given userlist item (<li>)
+    openUserMenuForItem: function($target) {
+        var member = $target.data('member'),
             userbox,
             are_we_an_op = !!this.model.getByNick(_kiwi.app.connections.active_connection.get('nick')).get('is_op');
 
@@ -55,10 +64,11 @@ _kiwi.view.MemberList = Backbone.View.extend({
         .then(_.bind(function() {
             menu.show();
 
-            var t = event.pageY,
+            var target_offset = $target.offset(),
+                t = target_offset.top,
                 m_bottom = t + menu.$el.outerHeight(),  // Where the bottom of menu will be
                 memberlist_bottom = this.$el.parent().offset().top + this.$el.parent().outerHeight(),
-                l = event.pageX,
+                l = target_offset.left,
                 m_right = l + menu.$el.outerWidth(),  // Where the left of menu will be
                 memberlist_right = this.$el.parent().offset().left + this.$el.parent().outerWidth();
 
@@ -90,7 +100,6 @@ _kiwi.view.MemberList = Backbone.View.extend({
             menu.dispose();
             menu = null;
         }, this));
-
     },