_kiwi.view.MemberList = Backbone.View.extend({
- tagName: "ul",
+ tagName: "div",
events: {
"click .nick": "nickClick",
"click .channel_info": "channelInfoClick"
initialize: function (options) {
this.model.bind('all', this.render, this);
- $(this.el).appendTo('#kiwi .memberlists');
+ this.$el.appendTo('#kiwi .memberlists');
+
+ // Holds meta data. User counts, etc
+ this.$meta = $('<div class="meta"></div>').appendTo(this.$el);
+
+ // The list for holding the nicks
+ this.$list = $('<ul></ul>').appendTo(this.$el);
},
render: function () {
- var $this = this.$el;
- $this.empty();
+ var that = this;
+
+ this.$list.empty();
this.model.forEach(function (member) {
member.view.$el.data('member', member);
- $this.append(member.view.$el);
+ that.$list.append(member.view.$el);
});
+
+ // User count
+ if(this.model.channel.isActive()) {
+ this.renderMeta();
+ }
+
return this;
},
+
+ renderMeta: function() {
+ var members_count = this.model.length + ' ' + translateText('client_applets_chanlist_users');
+ this.$meta.text(members_count);
+ },
+
nickClick: function (event) {
var $target = $(event.currentTarget).parent('li'),
member = $target.data('member'),
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})
+ .then(_.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(),
left: l,
top: t
});
- }).call(this);
+
+ }, this))
+ .prevented(_.bind(function() {
+ userbox = null;
+
+ menu.dispose();
+ menu = null;
+ }, this));
+
},
show: function () {
$('#kiwi .memberlists').children().removeClass('active');
$(this.el).addClass('active');
+
+ this.renderMeta();
}
});
\ No newline at end of file