]>
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 addClass: "hidenewwin",
48 parentObject
.selectWindow(this);
51 if(type
== WINDOW_CHANNEL
)
52 this.client
.exec("/PART " + name
);
53 if($defined(this.scrolltimeout
)) {
54 $clear(this.scrolltimeout
);
55 this.scrolltimeout
= null;
61 if(type
== WINDOW_STATUS
)
62 prefs
.closable
= false;
65 /* var oldIndexLevel = MochaUI.Windows.indexLevel;
68 var oldfocus = MochaUI.focusWindow;
70 MochaUI.Windows.indexLevel = 0;
71 MochaUI.focusWindow = null;
74 var nw
= new MochaUI
.Window(prefs
);
77 MochaUI.Windows.indexLevel = oldIndexLevel;
78 MochaUI.focusWindow = oldfocus;
82 var toolbar
= $(nw
.options
.id
+ "_toolbar");
83 this.titleText
= $(nw
.options
.id
+ "_title");
84 this.tabText
= $(nw
.options
.id
+ "_dockTabText");
86 /*alert(toolbar.parentNode.getStyle("background"));*/
87 /*this.inputbox.setStyle("background", toolbar.parentNode.getStyle("background"));*/
88 toolbar
.appendChild(this.form
);
89 this.windowObject
= nw
;
93 if(type == WINDOW_CHANNEL) {
94 this.nicklist = new Element("div");
95 this.nicklist.addClass("nicklist");
97 this.outerContainer.appendChild(this.nicklist);
100 var innerContainer = new Element("div");
101 innerContainer.addClass("innercontainer");
102 this.outerContainer.appendChild(innerContainer);
104 if(type == WINDOW_CHANNEL) {
105 this.topic = new Element("div");
106 this.topic.addClass("topic");
107 innerContainer.appendChild(this.topic);
111 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
);
135 addLine: function(type
, line
, colour
) {
136 this.parent(type
, line
, colour
);
138 var e
= new Element("div");
141 e
.setStyles({"background": colour
});
142 } else if(this.lastcolour
) {
143 e
.addClass("linestyle1");
145 e
.addClass("linestyle2");
149 line
= this.parentObject
.theme
.message(type
, line
);
151 Colourise(IRCTimestamp(new Date()) + " " + line
, e
);
153 this.lastcolour
= !this.lastcolour
;
155 this.__scrollbottom(false, e
);
158 this.__setAlert(true);
160 __setAlert: function(state
) {
162 this.titleText
.setStyle("color", "#ff0000");
163 this.tabText
.setStyle("background-color", "#ff0000");
164 this.tabText
.setStyle("color", "#000000");
166 this.titleText
.setStyle("color", null);
167 this.tabText
.setStyle("background-color", null);
168 this.tabText
.setStyle("color", null);
171 __scrollbottom: function(timed
, element
) {
172 var pe
= this.lines
.parentNode
.parentNode
;
174 var prev
= pe
.getScroll();
175 var prevbottom
= pe
.getScrollSize().y
;
176 var prevsize
= pe
.getSize();
178 /* scroll in bursts, else the browser gets really slow */
180 this.lines
.appendChild(element
);
181 if(this.scrolltimeout
|| (prev
.y
+ prevsize
.y
== prevbottom
)) {
182 if(this.scrolltimeout
)
183 $clear(this.scrolltimeout
);
184 this.scrolltimeout
= this.__scrollbottom
.delay(10, this, true);
187 pe
.scrollTo(prev
.x
, pe
.getScrollSize().y
);
188 this.scrolltimeout
= null;
194 this.__setAlert(false);
196 this.inputbox
.focus();
200 var QMochaUI
= new Class({
202 initialize: function(parentElement
, theme
) {
203 this.parent(parentElement
, QMochaUIWindow
, "mochaui");
205 this.parentElement
= parentElement
;
207 window
.addEvent("domready", function() {
208 /* determine input size */
209 var l
= new Element("input", {styles: {border: 0}});
210 this.parentElement
.appendChild(l
);
211 this.inputHeight
= l
.getSize().y
;
212 this.parentElement
.removeChild(l
);
214 MochaUI
.Desktop
= new MochaUI
.Desktop();
215 MochaUI
.Dock
= new MochaUI
.Dock({
219 MochaUI
.Modal
= new MochaUI
.Modal();
220 MochaUI
.options
.useEffects
= false;
223 window
.addEvent("unload", function() {
225 MochaUI
.garbageCleanUp();
228 postInitialize: function() {
230 this.tabs
= new Element("div");
231 this.tabs
.addClass("tabbar");
233 this.parentElement
.appendChild(this.tabs
);
235 this.container
= new Element("div");
236 this.container
.addClass("container");
238 this.parentElement
.appendChild(this.container
);
240 var form
= new Element("form");
241 var inputbox
= new Element("input");
242 inputbox
.addClass("input");
244 form
.addEvent("submit", function(e
) {
247 this.getActiveWindow().client
.exec(inputbox
.value
);
250 this.parentElement
.appendChild(form
);
251 form
.appendChild(inputbox
);
254 loginBox: function(callbackfn
, intialNickname
, initialChannels
) {
255 this.parent(function(options
) {
256 this.postInitialize();
258 }.bind(this), intialNickname
, initialChannels
);