]>
jfr.im git - irc/quakenet/qwebirc.git/blob - js/ui/qui.js
1 var QJSUI
= new Class({
2 initialize: function(class_
, parent
, sizer
) {
4 this.sizer
= $defined(sizer
)?sizer:parent
;
8 window
.addEvent("resize", function() {
10 this.reflow
.delay(100, this);
13 create: function(class_
) {
14 var XE = function(classes
) {
15 var l
= new Element("div");
17 l
.addClass("dynamicpanel");
19 classes
.split(" ").each(function(x
) {
23 this.parent
.appendChild(l
);
27 this.top
= XE("widepanel topboundpanel");
28 this.topic
= XE("widepanel");
29 this.middle
= XE("leftboundpanel");
30 this.right
= XE("rightboundpanel");
31 this.bottom
= XE("bottomboundpanel widepanel");
34 var bottom
= this.bottom
;
35 var middle
= this.middle
;
36 var right
= this.right
;
37 var topic
= this.topic
;
40 var topicsize
= topic
.getSize();
41 var topsize
= top
.getSize();
42 var rightsize
= right
.getSize();
43 var bottomsize
= bottom
.getSize();
44 var docsize
= this.sizer
.getSize();
46 var mheight
= (docsize
.y
- topsize
.y
- bottomsize
.y
- topicsize
.y
);
47 var mwidth
= (docsize
.x
- rightsize
.x
);
49 topic
.setStyle("top", topsize
.y
+ "px");
51 middle
.setStyle("top", (topsize
.y
+ topicsize
.y
) + "px");
53 middle
.setStyle("height", mheight
+ "px");
54 right
.setStyle("height", mheight
+ "px");
58 middle
.setStyle("width", mwidth
+ "px");
62 right
.setStyle("top", (topsize
.y
+ topicsize
.y
) + "px");
63 right
.setStyle("left", mwidth
+ "px");
65 bottom
.setStyle("top", (docsize
.y
- bottomsize
.y
) + "px");
67 showChannel: function(state
) {
72 this.right
.setStyle("display", display
);
73 this.topic
.setStyle("display", display
);
74 //this.reflow.delay(0, this);
78 var QUIWindow
= new Class({
81 initialize: function(parentObject
, client
, type
, name
) {
82 this.parent(parentObject
, client
, type
, name
);
84 this.tab
= new Element("a", {"href": "#"});
85 this.tab
.addClass("tab");
86 parentObject
.tabs
.appendChild(this.tab
);
88 this.tab
.appendText(name
);
89 this.tab
.addEvent("click", function(e
) {
91 parentObject
.selectWindow(this);
94 if(type
!= WINDOW_STATUS
) {
95 tabclose
= new Element("span");
96 tabclose
.addClass("tabclose");
97 tabclose
.addEvent("click", function(e
) {
100 if(type
== WINDOW_CHANNEL
)
101 this.client
.exec("/PART " + name
);
105 tabclose
.set("text", "X");
106 if(BrowserVersion() == "ie7" || BrowserVersion() == "ie6") {
108 tabclose
.setStyle("padding", "2px");
109 tabclose
.setStyle("vertical-align", "top");
111 this.tab
.appendChild(tabclose
);
114 this.lines
= new Element("div");
115 this.lines
.addClass("lines");
116 this.lines
.addClass("tab-invisible");
117 parentObject
.lines
.appendChild(this.lines
);
118 this.lines
.addEvent("scroll", function() {
119 this.scrolleddown
= this.scrolledDown();
122 if(type
== WINDOW_CHANNEL
) {
123 this.topic
= new Element("div");
124 this.topic
.addClass("topic");
125 this.topic
.addClass("tab-invisible");
126 this.topic
.set("html", " ");
127 parentObject
.topic
.appendChild(this.topic
);
129 this.nicklist
= new Element("div");
130 this.nicklist
.addClass("nicklist");
131 this.nicklist
.addClass("tab-invisible");
132 parentObject
.nicklist
.appendChild(this.nicklist
);
135 if(type
== WINDOW_CHANNEL
) {
136 this.updateTopic("");
142 this.parentObject
.reflow();
144 onResize: function() {
145 if(this.scrolleddown
)
146 this.scrollToBottom();
148 updateNickList: function(nicks
) {
151 var n
= this.nicklist
;
153 n
.removeChild(n
.firstChild
);
155 nicks
.each(function(nick
) {
156 var e
= new Element("div");
158 e
.appendChild(document
.createTextNode(nick
));
161 updateTopic: function(topic
) {
167 t
.removeChild(t
.firstChild
);
170 Colourise("[" + topic
+ "]", t
);
172 var e
= new Element("div");
173 e
.set("text", "(no topic set)");
174 e
.addClass("emptytopic");
179 showChannel: function() {
180 this.parentObject
.qjsui
.showChannel($defined(this.nicklist
));
184 this.tab
.removeClass("tab-unselected");
185 this.tab
.addClass("tab-selected");
187 this.lines
.removeClass("tab-invisible");
189 this.nicklist
.removeClass("tab-invisible");
190 this.topic
.removeClass("tab-invisible");
195 this.parentObject
.inputbox
.focus();
197 deselect: function() {
200 this.lines
.addClass("tab-invisible");
202 this.nicklist
.addClass("tab-invisible");
203 this.topic
.addClass("tab-invisible");
205 this.tab
.removeClass("tab-selected");
206 this.tab
.addClass("tab-unselected");
208 //this.showChannel();
213 this.parentObject
.lines
.removeChild(this.lines
);
215 this.parentObject
.nicklist
.removeChild(this.nicklist
);
216 this.parentObject
.topic
.removeChild(this.topic
);
218 this.parentObject
.tabs
.removeChild(this.tab
);
220 addLine: function(type
, line
, colour
) {
221 var e
= new Element("div");
224 e
.setStyles({"background": colour
});
225 } else if(this.lastcolour
) {
226 e
.addClass("linestyle1");
228 e
.addClass("linestyle2");
230 this.lastcolour
= !this.lastcolour
;
232 this.parent(type
, line
, colour
, e
);
234 setHilighted: function(state
) {
238 this.tab
.addClass("tab-hilighted");
240 this.tab
.removeClass("tab-hilighted");
245 var QUI
= new Class({
247 initialize: function(parentElement
, theme
) {
248 this.parent(parentElement
, QUIWindow
, "qui");
250 this.parentElement
= parentElement
;
256 postInitialize: function() {
257 this.qjsui
= new QJSUI("qwebirc-qui", this.parentElement
, document
);
259 this.qjsui
.top
.addClass("tabbar");
261 this.qjsui
.bottom
.addClass("input");
262 this.qjsui
.right
.addClass("nicklist");
263 this.qjsui
.topic
.addClass("topic");
264 this.qjsui
.middle
.addClass("lines");
266 this.tabs
= this.qjsui
.top
;
267 this.topic
= this.qjsui
.topic
;
268 this.lines
= this.qjsui
.middle
;
269 this.nicklist
= this.qjsui
.right
;
270 this.input
= this.qjsui
.bottom
;
274 createInput: function() {
275 var form
= new Element("form");
276 this.input
.appendChild(form
);
277 form
.addClass("input");
279 var inputbox
= new Element("input");
280 form
.appendChild(inputbox
);
281 this.inputbox
= inputbox
;
283 form
.addEvent("submit", function(e
) {
286 if(inputbox
.value
== "")
289 this.getActiveWindow().historyExec(inputbox
.value
);
293 inputbox
.addEvent("keydown", function(e
) {
295 var cvalue
= inputbox
.value
;
298 resultfn
= this.commandhistory
.upLine
;
299 } else if(e
.key
== "down") {
300 resultfn
= this.commandhistory
.downLine
;
305 if((cvalue
!= "") && (this.lastcvalue
!= cvalue
))
306 this.commandhistory
.addLine(cvalue
, true);
308 var result
= resultfn
.bind(this.commandhistory
)();
313 this.lastcvalue
= result
;
315 inputbox
.value
= result
;
319 loginBox: function(callbackfn
, intialNickname
, initialChannels
, autoConnect
, autoNick
) {
320 this.parent(function(options
) {
321 this.postInitialize();
323 }.bind(this), intialNickname
, initialChannels
, autoConnect
, autoNick
);