]>
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
;
9 window
.addEvent("resize", function() {
11 this.reflow
.delay(100, this);
14 applyClasses: function(pos
, l
) {
15 l
.addClass("dynamicpanel");
17 l
.addClass(this.class_
);
19 l
.addClass("leftboundpanel");
20 } else if(pos
== "top") {
21 l
.addClass("topboundpanel");
22 l
.addClass("widepanel");
23 } else if(pos
== "topic") {
24 l
.addClass("widepanel");
25 } else if(pos
== "right") {
26 l
.addClass("rightboundpanel");
27 } else if(pos
== "bottom") {
28 l
.addClass("bottomboundpanel");
29 l
.addClass("widepanel");
33 var XE = function(pos
) {
34 var element
= new Element("div");
35 this.applyClasses(pos
, element
);
37 this.parent
.appendChild(element
);
42 this.topic
= XE("topic");
43 this.middle
= XE("middle");
44 this.right
= XE("right");
45 this.bottom
= XE("bottom");
48 var bottom
= this.bottom
;
49 var middle
= this.middle
;
50 var right
= this.right
;
51 var topic
= this.topic
;
54 var topicsize
= topic
.getSize();
55 var topsize
= top
.getSize();
56 var rightsize
= right
.getSize();
57 var bottomsize
= bottom
.getSize();
58 var docsize
= this.sizer
.getSize();
60 var mheight
= (docsize
.y
- topsize
.y
- bottomsize
.y
- topicsize
.y
);
61 var mwidth
= (docsize
.x
- rightsize
.x
);
63 topic
.setStyle("top", topsize
.y
+ "px");
65 middle
.setStyle("top", (topsize
.y
+ topicsize
.y
) + "px");
67 middle
.setStyle("height", mheight
+ "px");
68 right
.setStyle("height", mheight
+ "px");
72 middle
.setStyle("width", mwidth
+ "px");
76 right
.setStyle("top", (topsize
.y
+ topicsize
.y
) + "px");
77 right
.setStyle("left", mwidth
+ "px");
79 bottom
.setStyle("top", (docsize
.y
- bottomsize
.y
) + "px");
81 showChannel: function(state
) {
86 this.right
.setStyle("display", display
);
87 this.topic
.setStyle("display", display
);
88 //this.reflow.delay(0, this);
92 var QUIWindow
= new Class({
95 initialize: function(parentObject
, client
, type
, name
) {
96 this.parent(parentObject
, client
, type
, name
);
98 this.tab
= new Element("a", {"href": "#"});
99 this.tab
.addClass("tab");
100 parentObject
.tabs
.appendChild(this.tab
);
102 this.tab
.appendText(name
);
103 this.tab
.addEvent("click", function(e
) {
105 parentObject
.selectWindow(this);
108 if(type
!= WINDOW_STATUS
) {
109 tabclose
= new Element("span");
110 tabclose
.addClass("tabclose");
111 tabclose
.addEvent("click", function(e
) {
114 if(type
== WINDOW_CHANNEL
)
115 this.client
.exec("/PART " + name
);
119 tabclose
.set("text", "X");
120 if(BrowserVersion() == "ie7" || BrowserVersion() == "ie6") {
122 tabclose
.setStyle("padding", "2px");
123 tabclose
.setStyle("vertical-align", "top");
125 this.tab
.appendChild(tabclose
);
128 this.lines
= new Element("div");
129 //this.parentObject.qjsui.applyClasses("middle", lines);
131 this.lines
.addClass("lines");
132 this.lines
.addClass("tab-invisible");
133 parentObject
.lines
.appendChild(this.lines
);
134 this.lines
.addEvent("scroll", function() {
135 this.scrolleddown
= this.scrolledDown();
138 if(type
== WINDOW_CHANNEL
) {
139 this.topic
= new Element("div");
140 this.topic
.addClass("topic");
141 this.topic
.addClass("tab-invisible");
142 this.topic
.set("html", " ");
143 parentObject
.topic
.appendChild(this.topic
);
145 this.nicklist
= new Element("div");
146 this.nicklist
.addClass("nicklist");
147 this.nicklist
.addClass("tab-invisible");
148 parentObject
.nicklist
.appendChild(this.nicklist
);
151 if(type
== WINDOW_CHANNEL
) {
152 this.updateTopic("");
158 this.parentObject
.reflow();
160 onResize: function() {
161 if(this.scrolleddown
)
162 this.scrollToBottom();
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");
195 showChannel: function() {
196 this.parentObject
.qjsui
.showChannel($defined(this.nicklist
));
200 this.tab
.removeClass("tab-unselected");
201 this.tab
.addClass("tab-selected");
203 //this.parentObject.lines.parentNode.replaceChild(this.parentObject.lines, this.lines);
205 this.lines
.removeClass("tab-invisible");
207 this.nicklist
.removeClass("tab-invisible");
208 this.topic
.removeClass("tab-invisible");
213 this.parentObject
.inputbox
.focus();
215 deselect: function() {
218 this.lines
.addClass("tab-invisible");
220 this.nicklist
.addClass("tab-invisible");
221 this.topic
.addClass("tab-invisible");
223 this.tab
.removeClass("tab-selected");
224 this.tab
.addClass("tab-unselected");
226 //this.showChannel();
231 this.parentObject
.lines
.removeChild(this.lines
);
233 this.parentObject
.nicklist
.removeChild(this.nicklist
);
234 this.parentObject
.topic
.removeChild(this.topic
);
236 this.parentObject
.tabs
.removeChild(this.tab
);
238 addLine: function(type
, line
, colour
) {
239 var e
= new Element("div");
242 e
.setStyles({"background": colour
});
243 } else if(this.lastcolour
) {
244 e
.addClass("linestyle1");
246 e
.addClass("linestyle2");
248 this.lastcolour
= !this.lastcolour
;
250 this.parent(type
, line
, colour
, e
);
252 setHilighted: function(state
) {
256 this.tab
.addClass("tab-hilighted");
258 this.tab
.removeClass("tab-hilighted");
263 var QUI
= new Class({
265 initialize: function(parentElement
, theme
) {
266 this.parent(parentElement
, QUIWindow
, "qui");
268 this.parentElement
= parentElement
;
274 postInitialize: function() {
275 this.qjsui
= new QJSUI("qwebirc-qui", this.parentElement
, document
);
277 this.qjsui
.top
.addClass("tabbar");
279 this.qjsui
.bottom
.addClass("input");
280 this.qjsui
.right
.addClass("nicklist");
281 this.qjsui
.topic
.addClass("topic");
282 this.qjsui
.middle
.addClass("lines");
284 this.tabs
= this.qjsui
.top
;
285 this.topic
= this.qjsui
.topic
;
286 this.lines
= this.qjsui
.middle
;
287 this.nicklist
= this.qjsui
.right
;
288 this.input
= this.qjsui
.bottom
;
292 createInput: function() {
293 var form
= new Element("form");
294 this.input
.appendChild(form
);
295 form
.addClass("input");
297 var inputbox
= new Element("input");
298 form
.appendChild(inputbox
);
299 this.inputbox
= inputbox
;
301 form
.addEvent("submit", function(e
) {
304 if(inputbox
.value
== "")
307 this.getActiveWindow().historyExec(inputbox
.value
);
311 inputbox
.addEvent("keydown", function(e
) {
313 var cvalue
= inputbox
.value
;
316 resultfn
= this.commandhistory
.upLine
;
317 } else if(e
.key
== "down") {
318 resultfn
= this.commandhistory
.downLine
;
323 if((cvalue
!= "") && (this.lastcvalue
!= cvalue
))
324 this.commandhistory
.addLine(cvalue
, true);
326 var result
= resultfn
.bind(this.commandhistory
)();
331 this.lastcvalue
= result
;
333 inputbox
.value
= result
;
337 loginBox: function(callbackfn
, intialNickname
, initialChannels
, autoConnect
, autoNick
) {
338 this.parent(function(options
) {
339 this.postInitialize();
341 }.bind(this), intialNickname
, initialChannels
, autoConnect
, autoNick
);