Merge branch 'winston' of https://github.com/M2Ys4U/KiwiIRC into winston
[KiwiIRC.git] / client / src / models / panel.js
1 _kiwi.model.Panel = Backbone.Model.extend({
2 initialize: function (attributes) {
3 var name = this.get("name") || "";
4 this.view = new _kiwi.view.Panel({"model": this, "name": name});
5 this.set({
6 "scrollback": [],
7 "name": name
8 }, {"silent": true});
9 },
10
11 closePanel: function () {
12 if (this.view) {
13 this.view.unbind();
14 this.view.remove();
15 this.view = undefined;
16 delete this.view;
17 }
18
19 var members = this.get('members');
20 if (members) {
21 members.reset([]);
22 this.unset('members');
23 }
24
25 this.get('panel_list').remove(this);
26
27 this.unbind();
28 this.destroy();
29 },
30
31 // Alias to closePanel() for child objects to override
32 close: function () {
33 return this.closePanel();
34 },
35
36 isChannel: function () {
37 return false;
38 },
39
40 isQuery: function () {
41 return false;
42 },
43
44 isApplet: function () {
45 return false;
46 },
47
48 isServer: function () {
49 return false;
50 },
51
52 isActive: function () {
53 return (_kiwi.app.panels().active === this);
54 }
55 });