]>
jfr.im git - irc/quakenet/qwebirc.git/blob - js/ui/qui.js
1 var QUIWindow
= new Class({
4 initialize: function(parentObject
, client
, type
, name
) {
5 this.parent(parentObject
, client
, type
, name
);
7 this.outerContainer
= new Element("div");
8 this.outerContainer
.addClass("outercontainer");
9 this.outerContainer
.addClass("tab-invisible");
11 parentObject
.container
.appendChild(this.outerContainer
);
13 if(type
== WINDOW_CHANNEL
) {
14 this.nicklist
= new Element("div");
15 this.nicklist
.addClass("nicklist");
17 this.outerContainer
.appendChild(this.nicklist
);
20 var innerContainer
= new Element("div");
21 innerContainer
.addClass("innercontainer");
22 this.outerContainer
.appendChild(innerContainer
);
24 if(type
== WINDOW_CHANNEL
) {
25 this.topic
= new Element("div");
26 this.topic
.addClass("topic");
27 innerContainer
.appendChild(this.topic
);
30 this.lines
= new Element("div");
31 this.lines
.addClass("lines");
32 innerContainer
.appendChild(this.lines
);
34 this.tab
= new Element("span");
35 this.tab
.addClass("tab");
37 this.tab
.appendText(name
);
38 this.tab
.addEvent("click", function() {
39 parentObject
.selectWindow(this);
42 parentObject
.tabs
.appendChild(this.tab
);
44 if(type
!= WINDOW_STATUS
) {
45 tabclose
= new Element("span");
46 tabclose
.addClass("tabclose");
47 tabclose
.addEvent("click", function(e
) {
50 if(type
== WINDOW_CHANNEL
)
51 this.client
.exec("/PART " + name
);
55 tabclose
.set("text", "X");
56 this.tab
.appendChild(tabclose
);
59 updateNickList: function(nicks
) {
62 var n
= this.nicklist
;
64 n
.removeChild(n
.firstChild
);
66 nicks
.each(function(nick
) {
67 var e
= new Element("div");
69 e
.appendChild(document
.createTextNode(nick
));
72 updateTopic: function(topic
) {
78 t
.removeChild(t
.firstChild
);
85 this.outerContainer
.removeClass("tab-invisible");
86 this.tab
.removeClass("tab-unselected");
87 this.tab
.removeClass("tab-highlighted");
88 this.tab
.addClass("tab-selected");
90 deselect: function() {
93 this.outerContainer
.addClass("tab-invisible");
94 this.tab
.removeClass("tab-selected");
95 this.tab
.addClass("tab-unselected");
100 this.parentObject
.container
.removeChild(this.outerContainer
);
101 this.parentObject
.tabs
.removeChild(this.tab
);
103 addLine: function(type
, line
, colour
) {
104 this.parent(type
, line
, colour
);
106 var e
= new Element("div");
109 e
.setStyles({"background": colour
});
110 } else if(this.lastcolour
) {
111 e
.addClass("linestyle1");
113 e
.addClass("linestyle2");
117 line
= this.parentObject
.theme
.message(type
, line
);
119 Colourise(IRCTimestamp(new Date()) + " " + line
, e
);
121 this.lastcolour
= !this.lastcolour
;
123 var prev
= this.lines
.getScroll();
124 var prevbottom
= this.lines
.getScrollSize().y
;
125 var prevsize
= this.lines
.getSize();
126 this.lines
.appendChild(e
);
128 if(prev
.y
+ prevsize
.y
== prevbottom
)
129 this.lines
.scrollTo(prev
.x
, this.lines
.getScrollSize().y
);
132 this.tab
.addClass("tab-highlighted");
136 var QUI
= new Class({
138 initialize: function(parentElement
, theme
) {
139 this.parent(parentElement
, QUIWindow
, "qui");
141 this.parentElement
= parentElement
;
143 postInitialize: function() {
144 this.tabs
= new Element("div");
145 this.tabs
.addClass("tabbar");
147 this.parentElement
.appendChild(this.tabs
);
149 this.container
= new Element("div");
150 this.container
.addClass("container");
152 this.parentElement
.appendChild(this.container
);
154 var form
= new Element("form");
155 var inputbox
= new Element("input");
156 inputbox
.addClass("input");
158 form
.addEvent("submit", function(e
) {
161 this.getActiveWindow().client
.exec(inputbox
.value
);
164 this.parentElement
.appendChild(form
);
165 form
.appendChild(inputbox
);
168 loginBox: function(callbackfn
, intialNickname
, initialChannels
) {
169 this.parent(function(options
) {
170 this.postInitialize();
172 }.bind(this), intialNickname
, initialChannels
);