]>
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("span");
8 this.tab
.addClass("tab");
10 this.tab
.appendText(name
);
11 this.tab
.addEvent("click", function() {
12 parentObject
.selectWindow(this);
15 parentObject
.tabs
.appendChild(this.tab
);
17 if(type
!= WINDOW_STATUS
) {
18 tabclose
= new Element("span");
19 tabclose
.addClass("tabclose");
20 tabclose
.addEvent("click", function(e
) {
23 if(type
== WINDOW_CHANNEL
)
24 this.client
.exec("/PART " + name
);
28 tabclose
.set("text", "X");
29 this.tab
.appendChild(tabclose
);
32 this.parentObject
.reflow();
34 this.window
= new Element("div");
35 this.window
.addClass("window");
36 parentObject
.container
.appendChild(this.window
);
38 this.lines
= new Element("div");
39 this.lines
.addClass("lines");
40 this.window
.appendChild(this.lines
);
42 var formdiv
= new Element("div");
43 this.window
.appendChild(formdiv
);
45 var form
= new Element("form");
46 var inputbox
= new Element("input");
48 formdiv
.addClass("input");
50 form
.addEvent("submit", function(e
) {
53 this.historyExec(inputbox
.value
);
56 formdiv
.appendChild(form
);
57 form
.appendChild(inputbox
);
59 inputbox
.addEvent("keypress", function(e
) {
62 result
= this.commandhistory
.nextLine();
63 } else if(e
.key
== "down") {
64 result
= this.commandhistory
.prevLine();
72 inputbox
.value
= result
;
75 this.inputbox
= inputbox
;
79 var bottompos
= formdiv
.getSize().y
;
81 if(type
== WINDOW_CHANNEL
) {
82 this.nicklist
= new Element("div");
83 this.nicklist
.addClass("nicklist");
84 this.nicklist
.setStyle("bottom", (bottompos
- 1) + "px");
86 this.window
.appendChild(this.nicklist
);
87 rightpos
= this.nicklist
.getSize().x
;
89 this.topic
= new Element("div");
90 this.topic
.addClass("topic");
91 this.topic
.set("html", " ");
92 this.topic
.setStyle("right", rightpos
+ "px");
93 this.window
.appendChild(this.topic
);
95 toppos
= this.topic
.getSize().y
;
98 this.lines
.setStyle("top", toppos
+ "px");
99 this.lines
.setStyle("bottom", bottompos
+ "px");
100 this.lines
.setStyle("right", rightpos
+ "px");
101 this.lines
.addClass("lines");
103 this.lines
.addEvent("scroll", function() {
104 this.scrolleddown
= this.scrolledDown();
107 window
.addEvent("resize", function() {
108 if(this.scrolleddown
)
109 this.scrollToBottom();
112 updateNickList: function(nicks
) {
115 var n
= this.nicklist
;
117 n
.removeChild(n
.firstChild
);
119 nicks
.each(function(nick
) {
120 var e
= new Element("div");
122 e
.appendChild(document
.createTextNode(nick
));
125 updateTopic: function(topic
) {
131 t
.removeChild(t
.firstChild
);
136 this.window
.removeClass("tab-invisible");
137 this.tab
.removeClass("tab-unselected");
138 this.tab
.addClass("tab-selected");
141 this.inputbox
.focus();
143 deselect: function() {
146 this.window
.addClass("tab-invisible");
147 this.tab
.removeClass("tab-selected");
148 this.tab
.addClass("tab-unselected");
153 this.parentObject
.container
.removeChild(this.window
);
154 this.parentObject
.tabs
.removeChild(this.tab
);
156 addLine: function(type
, line
, colour
) {
157 var e
= new Element("div");
160 e
.setStyles({"background": colour
});
161 } else if(this.lastcolour
) {
162 e
.addClass("linestyle1");
164 e
.addClass("linestyle2");
166 this.lastcolour
= !this.lastcolour
;
168 this.parent(type
, line
, colour
, e
);
170 setHilighted: function(state
) {
174 this.tab
.addClass("tab-hilighted");
176 this.tab
.removeClass("tab-hilighted");
181 var QUI
= new Class({
183 initialize: function(parentElement
, theme
) {
184 this.parent(parentElement
, QUIWindow
, "qui");
186 this.parentElement
= parentElement
;
189 var tabheight
= this.tabs
.getSize().y
;
190 this.container
.setStyle("top", tabheight
+ "px");
192 postInitialize: function() {
193 this.outerContainer
= new Element("div");
194 this.outerContainer
.addClass("outercontainer");
195 this.parentElement
.appendChild(this.outerContainer
);
197 this.tabs
= new Element("div");
198 this.tabs
.addClass("tabbar");
199 this.outerContainer
.appendChild(this.tabs
);
201 var tester
= new Element("span");
202 this.tabs
.appendChild(tester
);
204 this.tabheight
= this.tabs
.getSize().y
;
205 this.tabs
.removeChild(tester
);
207 this.container
= new Element("div");
208 this.container
.addClass("container");
209 this.outerContainer
.appendChild(this.container
);
211 loginBox: function(callbackfn
, intialNickname
, initialChannels
) {
212 this.parent(function(options
) {
213 this.postInitialize();
215 }.bind(this), intialNickname
, initialChannels
);