]>
jfr.im git - irc/quakenet/qwebirc.git/blob - js/ui/qui.js
3 var INPUT_BORDER_SIZE
= 2;
4 var TOPIC_BORDER_SIZE
= 5;
6 var QUIWindow
= new Class({
9 initialize: function(parentObject
, client
, type
, name
) {
10 this.parent(parentObject
, client
, type
, name
);
12 this.tab
= new Element("a", {"href": "#"});
13 this.tab
.addClass("tab");
14 parentObject
.tabs
.appendChild(this.tab
);
16 this.tab
.appendText(name
);
17 this.tab
.addEvent("click", function(e
) {
19 parentObject
.selectWindow(this);
22 if(type
!= WINDOW_STATUS
) {
23 tabclose
= new Element("span");
24 tabclose
.addClass("tabclose");
25 tabclose
.addEvent("click", function(e
) {
28 if(type
== WINDOW_CHANNEL
)
29 this.client
.exec("/PART " + name
);
33 tabclose
.set("text", "X");
34 if(BrowserVersion() == "ie7" || BrowserVersion() == "ie6") {
36 tabclose
.setStyle("padding", "2px");
37 tabclose
.setStyle("vertical-align", "top");
39 this.tab
.appendChild(tabclose
);
42 this.parentObject
.reflow();
44 this.window
= new Element("div");
45 this.window
.addClass("window");
46 parentObject
.container
.appendChild(this.window
);
48 this.lines
= new Element("div");
49 this.lines
.addClass("lines");
50 this.window
.appendChild(this.lines
);
52 var formdiv
= new Element("div");
53 this.window
.appendChild(formdiv
);
54 this.formdiv
= formdiv
;
56 var form
= new Element("form");
57 var inputbox
= new Element("input");
59 formdiv
.addClass("input");
61 form
.addEvent("submit", function(e
) {
64 this.historyExec(inputbox
.value
);
67 formdiv
.appendChild(form
);
68 form
.appendChild(inputbox
);
70 inputbox
.addEvent("keypress", function(e
) {
73 result
= this.commandhistory
.nextLine();
74 } else if(e
.key
== "down") {
75 result
= this.commandhistory
.prevLine();
83 inputbox
.value
= result
;
86 this.inputbox
= inputbox
;
87 if(BrowserVersion() == "ie7") {
89 this.formdiv
.setStyle("bottom", "0px");
91 if(type
== WINDOW_CHANNEL
) {
92 this.topic
= new Element("div");
93 this.topic
.addClass("topic");
94 this.topic
.set("html", " ");
96 this.window
.appendChild(this.topic
);
98 this.nicklist
= new Element("div");
99 this.nicklist
.addClass("nicklist");
101 this.window
.appendChild(this.nicklist
);
103 this.lines
.addClass("lines");
104 if(type
== WINDOW_CHANNEL
) {
106 this.updateTopic("");
111 this.lines
.addEvent("scroll", function() {
112 this.scrolleddown
= this.scrolledDown();
115 onResize: function() {
116 if(this.scrolleddown
)
117 this.scrollToBottom();
123 var bottompos
= this.formdiv
.getSize().y
;
124 var bv
= BrowserVersion();
126 if(this.type
== WINDOW_CHANNEL
) {
127 toppos
= this.topic
.getSize().y
;
129 this.nicklist
.setStyle("top", toppos
+ "px");
130 this.nicklist
.setStyle("bottom", (bottompos
- 1) + "px");
131 rightpos
= this.nicklist
.getSize().x
;
134 this.lines
.setStyle("top", toppos
+ "px");
137 var w
= this.window
.getSize().x
;
139 this.reflow
.delay(1, this);
142 if(this.type
== WINDOW_CHANNEL
)
143 this.topic
.setStyle("width", (w
- TOPIC_BORDER_SIZE
) + "px");
144 this.formdiv
.setStyle("width", (w
- 2 * INPUT_BORDER_SIZE
) + "px");
145 this.lines
.setStyle("width", (w
- rightpos
) + "px");
147 this.lines
.setStyle("right", rightpos
+ "px");
150 if(bv
== "ie7" || bv
== "ie6") {
151 var winheight
= this.window
.getSize().y
;
153 this.reflow
.delay(1, this);
156 this.lines
.setStyle("height", (winheight
- toppos
- bottompos
) + "px");
157 this.formdiv
.setStyle("top", (winheight
- bottompos
) + "px");
158 if(this.type
== WINDOW_CHANNEL
&& (bv
== "ie6"))
159 this.nicklist
.setStyle("height", (winheight
- toppos
- bottompos
) + "px");
161 this.lines
.setStyle("bottom", bottompos
+ "px");
164 updateNickList: function(nicks
) {
167 var n
= this.nicklist
;
169 n
.removeChild(n
.firstChild
);
171 nicks
.each(function(nick
) {
172 var e
= new Element("div");
174 e
.appendChild(document
.createTextNode(nick
));
177 updateTopic: function(topic
) {
183 t
.removeChild(t
.firstChild
);
186 Colourise("[" + topic
+ "]", t
);
188 var e
= new Element("div");
189 e
.set("text", "(no topic set)");
190 e
.addClass("emptytopic");
196 this.window
.removeClass("tab-invisible");
197 this.tab
.removeClass("tab-unselected");
198 this.tab
.addClass("tab-selected");
203 this.inputbox
.focus();
205 deselect: function() {
208 this.window
.addClass("tab-invisible");
209 this.tab
.removeClass("tab-selected");
210 this.tab
.addClass("tab-unselected");
215 this.parentObject
.container
.removeChild(this.window
);
216 this.parentObject
.tabs
.removeChild(this.tab
);
218 addLine: function(type
, line
, colour
) {
219 var e
= new Element("div");
222 e
.setStyles({"background": colour
});
223 } else if(this.lastcolour
) {
224 e
.addClass("linestyle1");
226 e
.addClass("linestyle2");
228 this.lastcolour
= !this.lastcolour
;
230 this.parent(type
, line
, colour
, e
);
232 setHilighted: function(state
) {
236 this.tab
.addClass("tab-hilighted");
238 this.tab
.removeClass("tab-hilighted");
243 var QUI
= new Class({
245 initialize: function(parentElement
, theme
) {
246 if(BrowserVersion() == "ie6") {
247 if((parentElement
.getStyle("top") == "0px") && (parentElement
.getStyle("bottom") == "0px")) {
248 parentElement
.setStyle("top", null);
249 parentElement
.setStyle("height", "100%");
252 this.parent(parentElement
, QUIWindow
, "qui");
254 this.parentElement
= parentElement
;
257 var tabheight
= this.tabs
.getSize().y
;
258 var bv
= BrowserVersion();
259 if(bv
== "ie7" || bv
== "ie6")
260 tabheight
= tabheight
- 2 * BORDER_SIZE
;
261 this.xcontainer
.setStyle("top", tabheight
+ "px");
262 if(bv
== "ie7" || bv
== "ie6") {
263 this.xcontainer
.setStyle("bottom", "");
264 this.xcontainer
.setStyle("height", (this.parentElement
.getSize().y
- (tabheight
)) + "px");
267 postInitialize: function() {
268 this.outerContainer
= new Element("div");
269 this.outerContainer
.addClass("outercontainer");
270 this.parentElement
.appendChild(this.outerContainer
);
272 this.tabs
= new Element("div");
273 this.tabs
.addClass("tabbar");
274 this.outerContainer
.appendChild(this.tabs
);
276 this.container
= new Element("div");
277 this.container
.addClass("container");
278 this.outerContainer
.appendChild(this.container
);
280 //this.container.setStyle("background", "red");
281 //this.container.setStyle("border", "1px solid black");
283 this.xcontainer
= this.container
;
285 //this.container = new Element("div");
286 window
.addEvent("resize", function() {
289 for(i
=0;i
<this.windowArray
.length
;i
++)
290 this.windowArray
[i
].onResize();
293 loginBox: function(callbackfn
, intialNickname
, initialChannels
, autoConnect
, autoNick
) {
294 this.parent(function(options
) {
295 this.postInitialize();
297 }.bind(this), intialNickname
, initialChannels
, autoConnect
, autoNick
);