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') {
19 d
= opts
.date
= new Date();
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
, "date": opts
.date
, "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");
50 // Keep the scrolback limited
51 if (bs
.length
> scrollback
) {
52 bs
.splice(scrollback
);
54 this.set({"scrollback": bs
}, {silent
: true});
57 this.trigger("msg", message_obj
);
61 clearMessages: function () {
62 this.set({'scrollback': []}, {silent
: true});
63 this.addMsg('', 'Window cleared');
68 closePanel: function () {
72 this.view
= undefined;
76 var members
= this.get('members');
79 this.unset('members');
82 this.get('panel_list').remove(this);
87 // If closing the active panel, switch to the server panel
88 if (this === _kiwi
.app
.panels().active
) {
89 _kiwi
.app
.connections
.active_connection
.panels
.server
.view
.show();
93 // Alias to closePanel() for child objects to override
95 return this.closePanel();
98 isChannel: function () {
99 var channel_prefix
= _kiwi
.gateway
.get('channel_prefix'),
100 this_name
= this.get('name');
102 if (this.isApplet() || !this_name
) return false;
103 return (channel_prefix
.indexOf(this_name
[0]) > -1);
106 isQuery: function () {
107 if (!this.isChannel() && !this.isApplet() && !this.isServer()) {
114 isApplet: function () {
115 return this.applet
? true : false;
118 isServer: function () {
119 return this.server
? true : false;
122 isActive: function () {
123 return (_kiwi
.app
.panels().active
=== this);