1 _kiwi
.view
.Channel
= _kiwi
.view
.Panel
.extend({
3 var parent_events
= _kiwi
.view
.Panel
.prototype.events
;
5 if(_
.isFunction(parent_events
)){
6 parent_events
= parent_events();
8 return _
.extend({}, parent_events
, {
9 'click .msg .nick' : 'nickClick'
13 initialize: function (options
) {
14 this.initializePanel(options
);
15 this.model
.bind('change:topic', this.topic
, this);
17 this.model
.get('members').bind('add', function (member
) {
18 if (member
.get('nick') === that
.collection
.network
.get('nick')) {
19 this.view
.$el
.find('.initial_loader').slideUp(function () {
25 // Only show the loader if this is a channel (ie. not a query)
26 if (this.model
.isChannel()) {
27 this.$el
.append('<div class="initial_loader" style="margin:1em;text-align:center;">Joining channel.. <span class="loader"></span></div>');
31 // Override the existing newMsg() method to remove the joining channel loader
33 return this.constructor.__super__
.newMsg
.apply(this, arguments
);
36 topic: function (topic
) {
37 if (typeof topic
!== 'string' || !topic
) {
38 topic
= this.model
.get("topic");
41 this.model
.addMsg('', '== Topic for ' + this.model
.get('name') + ' is: ' + topic
, 'topic');
43 // If this is the active channel then update the topic bar
44 if (_kiwi
.app
.panels().active
=== this) {
45 _kiwi
.app
.topicbar
.setCurrentTopic(this.model
.get("topic"));
49 // Click on a nickname
50 nickClick: function (event
) {
51 var nick
= $(event
.currentTarget
).text(),
52 members
= this.model
.get('members'),
53 member
, query
, userbox
, menubox
;
56 member
= members
.getByNick(nick
);
58 userbox
= new _kiwi
.view
.UserBox();
59 userbox
.member
= member
;
60 userbox
.channel
= this.model
;
62 if (!member
.get('is_op')) {
63 userbox
.$el
.children('.if_op').remove();
65 menubox
= new _kiwi
.view
.MenuBox(member
.get('nick') || 'User');
66 menubox
.addItem('userbox', userbox
.$el
);
69 // Position the userbox + menubox
72 m_bottom
= t
+ menubox
.$el
.outerHeight(), // Where the bottom of menu will be
73 memberlist_bottom
= this.$el
.parent().offset().top
+ this.$el
.parent().outerHeight();
75 // If the bottom of the userbox is going to be too low.. raise it
76 if (m_bottom
> memberlist_bottom
){
77 t
= memberlist_bottom
- menubox
.$el
.outerHeight();
80 // Set the new positon