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
});
11 addMsg: function (nick
, msg
, type
, opts
) {
12 var message_obj
, bs
, d
,
13 scrollback
= (parseInt(_kiwi
.global
.settings
.get('scrollback'), 10) || 250);
17 // Time defaults to now
18 if (!opts
|| typeof opts
.time
=== 'undefined') {
20 opts
.time
= d
.getHours().toString().lpad(2, "0") + ":" + d
.getMinutes().toString().lpad(2, "0") + ":" + d
.getSeconds().toString().lpad(2, "0");
23 // CSS style defaults to empty string
24 if (!opts
|| typeof opts
.style
=== 'undefined') {
28 // Run through the plugins
29 message_obj
= {"msg": msg
, "time": opts
.time
, "nick": nick
, "chan": this.get("name"), "type": type
, "style": opts
.style
};
30 //tmp = _kiwi.plugs.run('addmsg', message_obj);
35 // The CSS class (action, topic, notice, etc)
36 if (typeof message_obj
.type
!== "string") {
37 message_obj
.type
= '';
40 // Make sure we don't have NaN or something
41 if (typeof message_obj
.msg
!== "string") {
45 // Update the scrollback
46 bs
= this.get("scrollback");
49 // Keep the scrolback limited
50 if (bs
.length
> scrollback
) {
51 bs
.splice(scrollback
);
53 this.set({"scrollback": bs
}, {silent
: true});
55 this.trigger("msg", message_obj
);
59 clearMessages: function () {
60 this.set({'scrollback': []}, {silent
: true});
61 this.addMsg('', 'Window cleared');
66 closePanel: function () {
70 this.view
= undefined;
74 var members
= this.get('members');
77 this.unset('members');
80 _kiwi
.app
.panels
.remove(this);
85 // If closing the active panel, switch to the server panel
86 if (this.cid
=== _kiwi
.app
.panels
.active
.cid
) {
87 _kiwi
.app
.panels
.server
.view
.show();
91 // Alias to closePanel() for child objects to override
93 return this.closePanel();
96 isChannel: function () {
97 var channel_prefix
= _kiwi
.gateway
.get('channel_prefix'),
98 this_name
= this.get('name');
100 if (this.isApplet() || !this_name
) return false;
101 return (channel_prefix
.indexOf(this_name
[0]) > -1);
104 isApplet: function () {
105 return this.applet
? true : false;
108 isServer: function () {
109 return this.server
? true : false;
112 isActive: function () {
113 return (_kiwi
.app
.panels
.active
=== this);