]>
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.tab
= new Element("a", {"href": "#"});
8 this.tab
.addClass("tab");
10 this.tab
.appendText(name
);
11 this.tab
.addEvent("click", function(e
) {
13 parentObject
.selectWindow(this);
16 parentObject
.tabs
.appendChild(this.tab
);
18 if(type
!= WINDOW_STATUS
) {
19 tabclose
= new Element("span");
20 tabclose
.addClass("tabclose");
21 tabclose
.addEvent("click", function(e
) {
24 if(type
== WINDOW_CHANNEL
)
25 this.client
.exec("/PART " + name
);
29 tabclose
.set("text", "X");
30 this.tab
.appendChild(tabclose
);
33 this.parentObject
.reflow();
35 this.window
= new Element("div");
36 this.window
.addClass("window");
37 parentObject
.container
.appendChild(this.window
);
39 this.lines
= new Element("div");
40 this.lines
.addClass("lines");
41 this.window
.appendChild(this.lines
);
43 var formdiv
= new Element("div");
44 this.window
.appendChild(formdiv
);
45 this.formdiv
= formdiv
;
47 var form
= new Element("form");
48 var inputbox
= new Element("input");
50 formdiv
.addClass("input");
52 form
.addEvent("submit", function(e
) {
55 this.historyExec(inputbox
.value
);
58 formdiv
.appendChild(form
);
59 form
.appendChild(inputbox
);
61 inputbox
.addEvent("keypress", function(e
) {
64 result
= this.commandhistory
.nextLine();
65 } else if(e
.key
== "down") {
66 result
= this.commandhistory
.prevLine();
74 inputbox
.value
= result
;
77 this.inputbox
= inputbox
;
81 var bottompos
= formdiv
.getSize().y
;
83 if(type
== WINDOW_CHANNEL
) {
84 this.topic
= new Element("div");
85 this.topic
.addClass("topic");
86 this.topic
.set("html", " ");
88 this.window
.appendChild(this.topic
);
90 this.nicklist
= new Element("div");
91 this.nicklist
.addClass("nicklist");
93 this.window
.appendChild(this.nicklist
);
96 this.lines
.addClass("lines");
97 if(type
== WINDOW_CHANNEL
) {
104 this.lines
.addEvent("scroll", function() {
105 this.scrolleddown
= this.scrolledDown();
108 window
.addEvent("resize", function() {
109 if(this.scrolleddown
)
110 this.scrollToBottom();
117 var bottompos
= this.formdiv
.getSize().y
;
119 if(this.type
== WINDOW_CHANNEL
) {
120 toppos
= this.topic
.getSize().y
;
122 this.nicklist
.setStyle("top", toppos
+ "px");
123 this.nicklist
.setStyle("bottom", (bottompos
- 1) + "px");
124 rightpos
= this.nicklist
.getSize().x
;
127 this.lines
.setStyle("top", toppos
+ "px");
128 this.lines
.setStyle("bottom", bottompos
+ "px");
129 this.lines
.setStyle("right", rightpos
+ "px");
131 updateNickList: function(nicks
) {
134 var n
= this.nicklist
;
136 n
.removeChild(n
.firstChild
);
138 nicks
.each(function(nick
) {
139 var e
= new Element("div");
141 e
.appendChild(document
.createTextNode(nick
));
144 updateTopic: function(topic
) {
150 t
.removeChild(t
.firstChild
);
153 Colourise("[" + topic
+ "]", t
);
155 var e
= new Element("div");
156 e
.set("text", "(no topic set)");
157 e
.addClass("emptytopic");
163 this.window
.removeClass("tab-invisible");
164 this.tab
.removeClass("tab-unselected");
165 this.tab
.addClass("tab-selected");
170 this.inputbox
.focus();
172 deselect: function() {
175 this.window
.addClass("tab-invisible");
176 this.tab
.removeClass("tab-selected");
177 this.tab
.addClass("tab-unselected");
182 this.parentObject
.container
.removeChild(this.window
);
183 this.parentObject
.tabs
.removeChild(this.tab
);
185 addLine: function(type
, line
, colour
) {
186 var e
= new Element("div");
189 e
.setStyles({"background": colour
});
190 } else if(this.lastcolour
) {
191 e
.addClass("linestyle1");
193 e
.addClass("linestyle2");
195 this.lastcolour
= !this.lastcolour
;
197 this.parent(type
, line
, colour
, e
);
199 setHilighted: function(state
) {
203 this.tab
.addClass("tab-hilighted");
205 this.tab
.removeClass("tab-hilighted");
210 var QUI
= new Class({
212 initialize: function(parentElement
, theme
) {
213 this.parent(parentElement
, QUIWindow
, "qui");
215 this.parentElement
= parentElement
;
218 var tabheight
= this.tabs
.getSize().y
;
219 this.container
.setStyle("top", tabheight
+ "px");
221 postInitialize: function() {
222 this.outerContainer
= new Element("div");
223 this.outerContainer
.addClass("outercontainer");
224 this.parentElement
.appendChild(this.outerContainer
);
226 this.tabs
= new Element("div");
227 this.tabs
.addClass("tabbar");
228 this.outerContainer
.appendChild(this.tabs
);
230 var tester
= new Element("span");
231 this.tabs
.appendChild(tester
);
233 this.tabheight
= this.tabs
.getSize().y
;
234 this.tabs
.removeChild(tester
);
236 this.container
= new Element("div");
237 this.container
.addClass("container");
238 this.outerContainer
.appendChild(this.container
);
240 loginBox: function(callbackfn
, intialNickname
, initialChannels
, autoConnect
, autoNick
) {
241 this.parent(function(options
) {
242 this.postInitialize();
244 }.bind(this), intialNickname
, initialChannels
, autoConnect
, autoNick
);