]>
jfr.im git - irc/quakenet/qwebirc.git/blob - js/ui/swmui.js
a9345633d783793cf3064657c30baafe4c52ba30
1 var SWMUIWindow
= new Class({
4 initialize: function(parentObject
, client
, type
, name
) {
5 this.parent(parentObject
, client
, type
, name
);
6 this.contentPanel
= new SWMPanel(parentObject
.mainPanel
.element
, true);
7 this.contentPanel
.element
.addClass("content");
8 this.contentPanel
.element
.setStyle("overflow", "auto");
10 if(type
== WINDOW_CHANNEL
) {
11 this.nickList
= new SWMPanel(this.contentPanel
.element
);
12 this.nickList
.anchor
= SWM_ANCHOR_RIGHT
;
13 this.nickList
.element
.setStyle("overflow", "auto");
14 this.nickList
.element
.addClass("nicklist");
17 if(type
== WINDOW_CHANNEL
) {
18 this.topic
= new SWMPanel(this.contentPanel
.element
);
19 this.topic
.anchor
= SWM_ANCHOR_TOP
;
20 this.topic
.element
.addClass("topic");
23 this.lines
= new SWMPanel(this.contentPanel
.element
);
24 this.lines
.element
.setStyle("overflow", "auto");
26 this.tab
= new Element("span");
27 this.tab
.addClass("tab");
29 this.tab
.appendText(name
);
30 this.tab
.addEvent("click", function() {
31 parentObject
.selectWindow(this);
34 parentObject
.tabPanel
.element
.appendChild(this.tab
);
35 parentObject
.resize();
37 if(type
!= WINDOW_STATUS
) {
38 tabclose
= new Element("span");
39 tabclose
.addClass("tabclose");
40 tabclose
.addEvent("click", function(e
) {
43 if(type
== WINDOW_CHANNEL
)
44 this.client
.exec("/PART " + name
);
48 tabclose
.set("text", "X");
49 this.tab
.appendChild(tabclose
);
52 updateNickList: function(nicks
) {
55 var n
= this.nickList
.element
;
57 n
.removeChild(n
.firstChild
);
59 nicks
.each(function(nick
) {
60 var e
= new Element("div");
62 e
.appendChild(document
.createTextNode(nick
));
65 this.parentObject
.resize();
67 updateTopic: function(topic
) {
69 var t
= this.topic
.element
;
72 t
.removeChild(t
.firstChild
);
76 this.parentObject
.resize();
81 this.contentPanel
.setHidden(false);
82 this.parentObject
.resize();
83 this.tab
.removeClass("tab-highlighted");
84 this.tab
.removeClass("tab-unselected");
85 this.tab
.addClass("tab-selected");
87 deselect: function() {
90 this.contentPanel
.setHidden(true);
91 this.parentObject
.resize();
92 this.tab
.removeClass("tab-selected");
93 this.tab
.addClass("tab-unselected");
98 this.parentObject
.mainPanel
.element
.removeChild(this.contentPanel
.element
);
99 this.parentObject
.tabPanel
.element
.removeChild(this.tab
);
101 addLine: function(type
, line
, colour
) {
102 this.parent(type
, line
, colour
);
104 var e
= new Element("div");
107 e
.setStyles({"background": colour
});
108 } else if(this.lastcolour
) {
109 e
.addClass("linestyle1");
111 e
.addClass("linestyle2");
115 line
= this.parentObject
.theme
.message(type
, line
);
117 Colourise(IRCTimestamp(new Date()) + " " + line
, e
);
119 this.lastcolour
= !this.lastcolour
;
121 var prev
= this.lines
.element
.getScroll();
122 var prevbottom
= this.lines
.element
.getScrollSize().y
;
123 var prevsize
= this.lines
.element
.getSize();
124 this.lines
.element
.appendChild(e
);
126 if(prev
.y
+ prevsize
.y
== prevbottom
)
127 this.lines
.element
.scrollTo(prev
.x
, this.lines
.element
.getScrollSize().y
);
130 this.tab
.addClass("tab-highlighted");
134 var SWMUI
= new Class({
136 initialize: function(parentElement
, theme
) {
137 this.parent(parentElement
, SWMUIWindow
, "swmui");
138 this.parentElement
= parentElement
;
141 postInitialize: function() {
142 this.tabPanel
= new SWMPanel(this.parentElement
);
143 this.tabPanel
.anchor
= SWM_ANCHOR_TOP
;
144 this.tabPanel
.element
.addClass("tabs");
146 this.mainPanel
= new SWMPanel(this.parentElement
);
147 this.mainPanel
.element
.addClass("main");
149 this.entryPanel
= new SWMPanel(this.parentElement
);
150 this.entryPanel
.anchor
= SWM_ANCHOR_BOTTOM
;
151 this.entryPanel
.element
.addClass("entry");
153 var form
= new Element("form");
155 var inputbox
= new Element("input");
157 window
.addEvent("resize", function() {
158 var s
= this.entryPanel
.element
.getSize().x
- 4;
159 inputbox
.setStyle("width", s
+ "px");
162 form
.addEvent("submit", function(e
) {
165 this.getActiveWindow().client
.exec(inputbox
.value
);
169 this.entryPanel
.element
.appendChild(form
);
170 form
.appendChild(inputbox
);
176 window
.fireEvent("resize");
178 loginBox: function(callback
, initialNickname
, initialChannels
) {
179 var box
= new Element("div");
180 this.parentElement
.appendChild(box
);
182 var header
= new Element("h1");
183 header
.set("text", "qwebirc");
184 box
.appendChild(header
);
186 var form
= new Element("form");
187 box
.appendChild(form
);
189 var boxtable
= new Element("table");
190 form
.appendChild(boxtable
);
192 var tbody
= new Element("tbody");
193 boxtable
.appendChild(tbody
); /* stupid IE */
195 function createRow(label
, e2
) {
196 var r
= new Element("tr");
197 tbody
.appendChild(r
);
199 var d1
= new Element("td");
201 d1
.set("text", label
);
204 var d2
= new Element("td");
210 var nick
= new Element("input");
211 createRow("Nickname:", nick
);
212 var chan
= new Element("input");
213 createRow("Channels (comma seperated):", chan
);
215 var connbutton
= new Element("input", {"type": "submit"});
216 connbutton
.set("value", "Connect");
217 createRow(undefined, connbutton
)
219 form
.addEvent("submit", function(e
) {
221 var nickname
= nick
.value
;
222 var chans
= chan
.value
;
223 if(chans
== "#") /* sorry channel "#" :P */
227 alert("You must supply a nickname.");
232 this.parentElement
.removeChild(box
);
233 this.postInitialize();
234 callback({"nickname": nickname
, "autojoin": chans
});
237 nick
.set("value", initialNickname
);
238 chan
.set("value", initialChannels
);