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 member
.view
.$el
.data('member', member
);
15 $this.append(member
.view
.$el
);
19 nickClick: function (event
) {
20 var $target
= $(event
.currentTarget
).parent('li'),
21 member
= $target
.data('member'),
24 userbox
= new _kiwi
.view
.UserBox();
25 userbox
.member
= member
;
26 userbox
.channel
= this.model
.channel
;
28 if (!this.model
.getByNick(_kiwi
.app
.connections
.active_connection
.get('nick')).get('is_op')) {
29 userbox
.$el
.children('.if_op').remove();
32 var menu
= new _kiwi
.view
.MenuBox(member
.get('nick') || 'User');
33 menu
.addItem('userbox', userbox
.$el
);
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 // If the bottom of the userbox is going to be too low.. raise it
43 if (m_bottom
> memberlist_bottom
){
44 t
= memberlist_bottom
- menu
.$el
.outerHeight();
47 // Set the new positon
49 left
: _kiwi
.app
.view
.$el
.width() - menu
.$el
.outerWidth() - 20,
55 $('#kiwi .memberlists').children().removeClass('active');
56 $(this.el
).addClass('active');