]>
jfr.im git - irc/quakenet/qwebirc.git/blob - js/ui/mochaui.js
1 var QMochaUIWindow
= new Class({
4 initialize: function(parentObject
, client
, type
, name
) {
5 this.parent(parentObject
, client
, type
, name
);
7 this.lines
= new Element("div", {styles: {overflow: "auto", "width": "90"}});
9 this.form
= new Element("form");
10 this.inputbox
= new Element("input", {styles: {border: 0, width: "100%"}});
11 this.inputbox
.addClass("input");
12 this.scrolltimeout
= null;
14 this.inputbox
.addEvent("focus", function() {
15 /* TODO: bring to top */
17 //alert(this.windowObject.windowEl);
18 //MochaUI.focusWindow.pass(this.windowObject.windowEl, this.windowObject);
19 //this.windowObject.focusWindow();
20 this.parentObject
.selectWindow(this);
23 this.form
.addEvent("submit", function(e
) {
26 this.client
.exec(this.inputbox
.value
);
27 this.inputbox
.value
= "";
29 //this.container.appendChild(form);
30 this.form
.appendChild(this.inputbox
);
38 container: $("pageWrapper"),
39 toolbarHeight: parentObject
.inputHeight
,
40 toolbarPosition: "bottom",
43 toolbarLoadMethod: "html",
46 parentObject
.selectWindow(this);
49 if(type
== WINDOW_CHANNEL
)
50 this.client
.exec("/PART " + name
);
51 if($defined(this.scrolltimeout
)) {
52 $clear(this.scrolltimeout
);
53 this.scrolltimeout
= null;
59 if(type
== WINDOW_STATUS
)
60 prefs
.closable
= false;
62 var nw
= new MochaUI
.Window(prefs
);
64 var toolbar
= $(nw
.options
.id
+ "_toolbar");
65 /*alert(toolbar.parentNode.getStyle("background"));*/
66 /*this.inputbox.setStyle("background", toolbar.parentNode.getStyle("background"));*/
67 toolbar
.appendChild(this.form
);
68 this.windowObject
= nw
;
72 if(type == WINDOW_CHANNEL) {
73 this.nicklist = new Element("div");
74 this.nicklist.addClass("nicklist");
76 this.outerContainer.appendChild(this.nicklist);
79 var innerContainer = new Element("div");
80 innerContainer.addClass("innercontainer");
81 this.outerContainer.appendChild(innerContainer);
83 if(type == WINDOW_CHANNEL) {
84 this.topic = new Element("div");
85 this.topic.addClass("topic");
86 innerContainer.appendChild(this.topic);
90 updateNickList: function(nicks
) {
94 var n
= this.nicklist
;
96 n
.removeChild(n
.firstChild
);
98 nicks
.each(function(nick
) {
99 var e
= new Element("div");
101 e
.appendChild(document
.createTextNode(nick
));
104 updateTopic: function(topic
) {
110 t
.removeChild(t
.firstChild
);
114 addLine: function(type
, line
, colour
) {
115 this.parent(type
, line
, colour
);
117 var e
= new Element("div");
120 e
.setStyles({"background": colour
});
121 } else if(this.lastcolour
) {
122 e
.addClass("linestyle1");
124 e
.addClass("linestyle2");
128 line
= this.parentObject
.theme
.message(type
, line
);
130 Colourise(IRCTimestamp(new Date()) + " " + line
, e
);
132 this.lastcolour
= !this.lastcolour
;
134 this.__scrollbottom(false, e
);
136 this.lines.showLoadingIcon();
139 __scrollbottom: function(timed
, element
) {
140 var pe
= this.lines
.parentNode
.parentNode
;
142 var prev
= pe
.getScroll();
143 var prevbottom
= pe
.getScrollSize().y
;
144 var prevsize
= pe
.getSize();
146 /* scroll in bursts, else the browser gets really slow */
148 this.lines
.appendChild(element
);
149 if(this.scrolltimeout
|| (prev
.y
+ prevsize
.y
== prevbottom
)) {
150 if(this.scrolltimeout
)
151 $clear(this.scrolltimeout
);
152 this.scrolltimeout
= this.__scrollbottom
.delay(10, this, true);
155 pe
.scrollTo(prev
.x
, pe
.getScrollSize().y
);
156 this.scrolltimeout
= null;
162 this.inputbox
.focus();
166 var QMochaUI
= new Class({
168 initialize: function(parentElement
, theme
) {
169 this.parent(parentElement
, QMochaUIWindow
, "mochaui");
171 this.parentElement
= parentElement
;
173 window
.addEvent("domready", function() {
174 /* determine input size */
175 var l
= new Element("input", {styles: {border: 0}});
176 this.parentElement
.appendChild(l
);
177 this.inputHeight
= l
.getSize().y
;
178 this.parentElement
.removeChild(l
);
180 MochaUI
.Desktop
= new MochaUI
.Desktop();
181 MochaUI
.Dock
= new MochaUI
.Dock({
185 MochaUI
.Modal
= new MochaUI
.Modal();
186 MochaUI
.options
.useEffects
= false;
189 window
.addEvent("unload", function() {
191 MochaUI
.garbageCleanUp();
194 postInitialize: function() {
196 this.tabs
= new Element("div");
197 this.tabs
.addClass("tabbar");
199 this.parentElement
.appendChild(this.tabs
);
201 this.container
= new Element("div");
202 this.container
.addClass("container");
204 this.parentElement
.appendChild(this.container
);
206 var form
= new Element("form");
207 var inputbox
= new Element("input");
208 inputbox
.addClass("input");
210 form
.addEvent("submit", function(e
) {
213 this.getActiveWindow().client
.exec(inputbox
.value
);
216 this.parentElement
.appendChild(form
);
217 form
.appendChild(inputbox
);
220 loginBox: function(callbackfn
, intialNickname
, initialChannels
) {
221 this.parent(function(options
) {
222 this.postInitialize();
224 }.bind(this), intialNickname
, initialChannels
);