1 _kiwi
.view
.MemberList
= Backbone
.View
.extend({
4 "click .nick": "nickClick",
5 "click .channel_info": "channelInfoClick"
8 initialize: function (options
) {
9 this.model
.bind('all', this.render
, this);
10 $(this.el
).appendTo('#kiwi .memberlists');
15 this.model
.forEach(function (member
) {
16 member
.view
.$el
.data('member', member
);
17 $this.append(member
.view
.$el
);
21 nickClick: function (event
) {
22 var $target
= $(event
.currentTarget
).parent('li'),
23 member
= $target
.data('member'),
25 are_we_an_op
= !!this.model
.getByNick(_kiwi
.app
.connections
.active_connection
.get('nick')).get('is_op');
27 userbox
= new _kiwi
.view
.UserBox();
28 userbox
.setTargets(member
, this.model
.channel
);
29 userbox
.displayOpItems(are_we_an_op
);
31 var menu
= new _kiwi
.view
.MenuBox(member
.get('nick') || 'User');
32 menu
.addItem('userbox', userbox
.$el
);
33 menu
.showFooter(false);
36 // Position the userbox + menubox
39 m_bottom
= t
+ menu
.$el
.outerHeight(), // Where the bottom of menu will be
40 memberlist_bottom
= this.$el
.parent().offset().top
+ this.$el
.parent().outerHeight(),
42 m_right
= l
+ menu
.$el
.outerWidth(), // Where the left of menu will be
43 memberlist_right
= this.$el
.parent().offset().left
+ this.$el
.parent().outerWidth();
45 // If the bottom of the userbox is going to be too low.. raise it
46 if (m_bottom
> memberlist_bottom
){
47 t
= memberlist_bottom
- menu
.$el
.outerHeight();
50 // If the top of the userbox is going to be too high.. lower it
55 // If the right of the userbox is going off screen.. bring it in
56 if (m_right
> memberlist_right
){
57 l
= memberlist_right
- menu
.$el
.outerWidth();
60 // Set the new positon
69 channelInfoClick: function(event
) {
70 new _kiwi
.model
.ChannelInfo({channel
: this.model
.channel
});
75 $('#kiwi .memberlists').children().removeClass('active');
76 $(this.el
).addClass('active');