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 // Only show the loader if this is a channel (ie. not a query)
18 if (this.model
.isChannel()) {
19 this.$el
.append('<div class="initial_loader" style="margin:1em;text-align:center;">Joining channel.. <span class="loader"></span></div>');
23 // Override the existing newMsg() method to remove the joining channel loader
25 this.$el
.find('.initial_loader').slideUp(function () {
29 return this.constructor.__super__
.newMsg
.apply(this, arguments
);
32 topic: function (topic
) {
33 if (typeof topic
!== 'string' || !topic
) {
34 topic
= this.model
.get("topic");
37 this.model
.addMsg('', '== Topic for ' + this.model
.get('name') + ' is: ' + topic
, 'topic');
39 // If this is the active channel then update the topic bar
40 if (_kiwi
.app
.panels().active
=== this) {
41 _kiwi
.app
.topicbar
.setCurrentTopic(this.model
.get("topic"));
45 // Click on a nickname
46 nickClick: function (event
) {
47 var nick
= $(event
.currentTarget
).text(),
48 members
= this.model
.get('members'),
49 member
, query
, userbox
, menubox
;
52 member
= members
.getByNick(nick
);
54 userbox
= new _kiwi
.view
.UserBox();
55 userbox
.member
= member
;
56 userbox
.channel
= this.model
;
58 if (!member
.get('is_op')) {
59 userbox
.$el
.children('.if_op').remove();
61 menubox
= new _kiwi
.view
.MenuBox(member
.get('nick') || 'User');
62 menubox
.addItem('userbox', userbox
.$el
);
65 // Position the userbox + menubox
68 m_bottom
= t
+ menubox
.$el
.outerHeight(), // Where the bottom of menu will be
69 memberlist_bottom
= this.$el
.parent().offset().top
+ this.$el
.parent().outerHeight();
71 // If the bottom of the userbox is going to be too low.. raise it
72 if (m_bottom
> memberlist_bottom
){
73 t
= memberlist_bottom
- menubox
.$el
.outerHeight();
76 // Set the new positon