Merge pull request #267 from M2Ys4U/jquery_upgrade
[KiwiIRC.git] / client / assets / src / views / channel.js
1 _kiwi.view.Channel = _kiwi.view.Panel.extend({
2 initialize: function (options) {
3 this.initializePanel(options);
4 this.model.bind('change:topic', this.topic, this);
5
6 // Only show the loader if this is a channel (ie. not a query)
7 if (this.model.isChannel()) {
8 this.$el.append('<div class="initial_loader" style="margin:1em;text-align:center;">Joining channel.. <span class="loader"></span></div>');
9 }
10 },
11
12 // Override the existing newMsg() method to remove the joining channel loader
13 newMsg: function () {
14 this.$el.find('.initial_loader').slideUp(function () {
15 $(this).remove();
16 });
17
18 return this.constructor.__super__.newMsg.apply(this, arguments);
19 },
20
21 topic: function (topic) {
22 if (typeof topic !== 'string' || !topic) {
23 topic = this.model.get("topic");
24 }
25
26 this.model.addMsg('', '== Topic for ' + this.model.get('name') + ' is: ' + topic, 'topic');
27
28 // If this is the active channel then update the topic bar
29 if (_kiwi.app.panels().active === this) {
30 _kiwi.app.topicbar.setCurrentTopic(this.model.get("topic"));
31 }
32 }
33 });