]>
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
);
46 var form
= new Element("form");
47 var inputbox
= new Element("input");
49 formdiv
.addClass("input");
51 form
.addEvent("submit", function(e
) {
54 this.historyExec(inputbox
.value
);
57 formdiv
.appendChild(form
);
58 form
.appendChild(inputbox
);
60 inputbox
.addEvent("keypress", function(e
) {
63 result
= this.commandhistory
.nextLine();
64 } else if(e
.key
== "down") {
65 result
= this.commandhistory
.prevLine();
73 inputbox
.value
= result
;
76 this.inputbox
= inputbox
;
80 var bottompos
= formdiv
.getSize().y
;
82 if(type
== WINDOW_CHANNEL
) {
83 this.topic
= new Element("div");
84 this.topic
.addClass("topic");
85 this.topic
.set("html", " ");
86 this.topic
.setStyle("right", "0px");
87 this.window
.appendChild(this.topic
);
89 toppos
= this.topic
.getSize().y
;
91 this.nicklist
= new Element("div");
92 this.nicklist
.addClass("nicklist");
93 this.nicklist
.setStyle("top", toppos
+ "px");
94 this.nicklist
.setStyle("bottom", (bottompos
- 1) + "px");
96 this.window
.appendChild(this.nicklist
);
97 rightpos
= this.nicklist
.getSize().x
;
100 this.lines
.setStyle("top", toppos
+ "px");
101 this.lines
.setStyle("bottom", bottompos
+ "px");
102 this.lines
.setStyle("right", rightpos
+ "px");
103 this.lines
.addClass("lines");
105 this.lines
.addEvent("scroll", function() {
106 this.scrolleddown
= this.scrolledDown();
109 window
.addEvent("resize", function() {
110 if(this.scrolleddown
)
111 this.scrollToBottom();
114 updateNickList: function(nicks
) {
117 var n
= this.nicklist
;
119 n
.removeChild(n
.firstChild
);
121 nicks
.each(function(nick
) {
122 var e
= new Element("div");
124 e
.appendChild(document
.createTextNode(nick
));
127 updateTopic: function(topic
) {
133 t
.removeChild(t
.firstChild
);
136 Colourise(topic
, "[" + topic
+ "]");
138 var e
= new Element("(no topic set)");
139 e
.addClass("emptytopic");
140 topic
.appendChild(e
);
144 this.window
.removeClass("tab-invisible");
145 this.tab
.removeClass("tab-unselected");
146 this.tab
.addClass("tab-selected");
149 this.inputbox
.focus();
151 deselect: function() {
154 this.window
.addClass("tab-invisible");
155 this.tab
.removeClass("tab-selected");
156 this.tab
.addClass("tab-unselected");
161 this.parentObject
.container
.removeChild(this.window
);
162 this.parentObject
.tabs
.removeChild(this.tab
);
164 addLine: function(type
, line
, colour
) {
165 var e
= new Element("div");
168 e
.setStyles({"background": colour
});
169 } else if(this.lastcolour
) {
170 e
.addClass("linestyle1");
172 e
.addClass("linestyle2");
174 this.lastcolour
= !this.lastcolour
;
176 this.parent(type
, line
, colour
, e
);
178 setHilighted: function(state
) {
182 this.tab
.addClass("tab-hilighted");
184 this.tab
.removeClass("tab-hilighted");
189 var QUI
= new Class({
191 initialize: function(parentElement
, theme
) {
192 this.parent(parentElement
, QUIWindow
, "qui");
194 this.parentElement
= parentElement
;
197 var tabheight
= this.tabs
.getSize().y
;
198 this.container
.setStyle("top", tabheight
+ "px");
200 postInitialize: function() {
201 this.outerContainer
= new Element("div");
202 this.outerContainer
.addClass("outercontainer");
203 this.parentElement
.appendChild(this.outerContainer
);
205 this.tabs
= new Element("div");
206 this.tabs
.addClass("tabbar");
207 this.outerContainer
.appendChild(this.tabs
);
209 var tester
= new Element("span");
210 this.tabs
.appendChild(tester
);
212 this.tabheight
= this.tabs
.getSize().y
;
213 this.tabs
.removeChild(tester
);
215 this.container
= new Element("div");
216 this.container
.addClass("container");
217 this.outerContainer
.appendChild(this.container
);
219 loginBox: function(callbackfn
, intialNickname
, initialChannels
, autoConnect
, autoNick
) {
220 this.parent(function(options
) {
221 this.postInitialize();
223 }.bind(this), intialNickname
, initialChannels
, autoConnect
, autoNick
);