1 /*jslint white:true, regexp: true, nomen: true, devel: true, undef: true, browser: true, continue: true, sloppy: true, forin: true, newcap: true, plusplus: true, maxerr: 50, indent: 4 */
6 kiwi
.view
.MemberList
= Backbone
.View
.extend({
9 "click .nick": "nickClick"
11 initialize: function (options
) {
12 $(this.el
).attr("id", 'kiwi_userlist_' + options
.name
);
13 this.model
.get("members").bind('change', this.render
, this);
16 var $this = $(this.el
);
18 this.model
.get("members").forEach(function (member
) {
19 $this.append('<li><a class="nick"><span class="prefix">' + user
.prefix
+ user
.nick
+ '</a></li>');
22 nickClick: function (x
) {
27 kiwi
.view
.Channel
= Backbone
.View
.extend({
29 className
: "messages",
31 "click .chan": "chanClick"
33 initialize: function (options
) {
34 this.htmlsafe_name
= 'chan_' + randomString(15);
35 $(this.el
).attr("id", 'kiwi_window_' + this.htmlsafe_name
).css('display', 'none');
36 this.el
= $(this.el
).appendTo('#panel1 .scroller')[0];
37 this.model
.bind('msg', this.newMsg
, this);
39 this.model
.set({"view": this}, {"silent": true});
42 var $this = $(this.el
);
44 this.model
.get("backscroll").forEach(this.newMsg
);
46 newMsg: function (msg
) {
47 var re
, line_msg
, $this = $(this.el
);
48 // Make the channels clickable
49 re
= new RegExp('\\B(' + kiwi
.gateway
.channel_prefix
+ '[^ ,.\\007]+)', 'g');
50 msg
.msg
= msg
.msg
.replace(re
, function (match
) {
51 return '<a class="chan">' + match
+ '</a>';
54 msg
.msg
= kiwi
.front
.formatIRCMsg(msg
.msg
);
56 // Build up and add the line
57 line_msg
= $('<div class="msg ' + msg
.type
+ '"><div class="time">' + msg
.time
+ '</div><div class="nick">' + msg
.nick
+ '</div><div class="text" style="' + msg
.style
+ '">' + msg
.msg
+ ' </div></div>');
58 $this.append(line_msg
);
60 if (this.msg_count
> 250) {
61 $('.msg:first', this.div
).remove();
65 chanClick: function (x
) {
69 $('#panel1 .scroller').children().css('display','none');
70 $(this.el
).css('display', 'block');
74 kiwi
.view
.Tabs
= Backbone
.View
.extend({
76 "click li": "tabClick"
78 initialize: function () {
79 this.model
.bind("add", this.addTab
, this);
80 this.model
.bind("remove", this.removeTab
, this);
81 this.model
.bind("reset", this.render
, this);
86 this.model
.forEach(function (tab
) {
87 var tabname
= $(tab
.get("view").el
).attr("id");
88 $('<li id="tab_' + tabname
+ '"><span>' + tab
.get("name") + '</span></li>').data('chan', tab
).appendTo($this)
91 addTab: function (tab
) {
92 var tabname
= $(tab
.get("view").el
).attr("id"),
94 $('<li id="tab_' + tabname
+ '"><span>' + tab
.get("name") + '</span></li>').data('chan', tab
).appendTo($this)
96 removeTab: function (tab
) {
97 $('#tab_' + $(tab
.get("view").el
).attr("id")).remove();
99 tabClick: function (e
) {
100 $(e
.currentTarget
).data('chan').view
.show();