1 _kiwi
.view
.MemberList
= Backbone
.View
.extend({
4 "click .nick": "nickClick"
6 initialize: function (options
) {
7 this.model
.bind('all', this.render
, this);
8 $(this.el
).appendTo('#kiwi .memberlists');
13 this.model
.forEach(function (member
) {
14 $this.append(member
.view
.el
);
18 nickClick: function (event
) {
19 var $target
= $(event
.currentTarget
).parent('li'),
20 member
= $target
.data('member'),
23 event
.stopPropagation();
25 // If the userbox already exists here, hide it
26 if ($target
.find('.userbox').length
> 0) {
27 $('.userbox', this.$el
).remove();
31 userbox
= new _kiwi
.view
.UserBox();
32 userbox
.member
= member
;
33 userbox
.channel
= this.model
.channel
;
35 if (!this.model
.getByNick(_kiwi
.app
.connections
.active_connection
.get('nick')).get('is_op')) {
36 userbox
.$el
.children('.if_op').remove();
39 var menu
= new _kiwi
.view
.MenuBox(member
.get('nick') || 'User');
40 menu
.addItem('userbox', userbox
.$el
);
43 // Position the userbox + menubox
46 m_bottom
= t
+ menu
.$el
.outerHeight(), // Where the bottom of menu will be
47 memberlist_bottom
= this.$el
.parent().offset().top
+ this.$el
.parent().outerHeight();
49 // If the bottom of the userbox is going to be too low.. raise it
50 if (m_bottom
> memberlist_bottom
){
51 t
= memberlist_bottom
- menu
.$el
.outerHeight();
54 // Set the new positon
56 left
: _kiwi
.app
.view
.$el
.width() - menu
.$el
.outerWidth() - 20,
62 $('#kiwi .memberlists').children().removeClass('active');
63 $(this.el
).addClass('active');