]>
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");
13 this.form
.addEvent("submit", function(e
) {
16 this.client
.exec(this.inputbox
.value
);
17 this.inputbox
.value
= "";
19 //this.container.appendChild(form);
20 this.form
.appendChild(this.inputbox
);
28 container: $("pageWrapper"),
29 toolbarHeight: parentObject
.inputHeight
,
30 toolbarPosition: "bottom",
34 parentObject
.selectWindow(this);
37 if(type
== WINDOW_CHANNEL
)
38 this.client
.exec("/PART " + name
);
44 if(type
== WINDOW_STATUS
)
45 prefs
.closable
= false;
47 var nw
= new MochaUI
.Window(prefs
);
49 var toolbar
= $(nw
.options
.id
+ "_toolbar");
50 toolbar
.appendChild(this.form
);
54 if(type == WINDOW_CHANNEL) {
55 this.nicklist = new Element("div");
56 this.nicklist.addClass("nicklist");
58 this.outerContainer.appendChild(this.nicklist);
61 var innerContainer = new Element("div");
62 innerContainer.addClass("innercontainer");
63 this.outerContainer.appendChild(innerContainer);
65 if(type == WINDOW_CHANNEL) {
66 this.topic = new Element("div");
67 this.topic.addClass("topic");
68 innerContainer.appendChild(this.topic);
72 updateNickList: function(nicks
) {
76 var n
= this.nicklist
;
78 n
.removeChild(n
.firstChild
);
80 nicks
.each(function(nick
) {
81 var e
= new Element("div");
83 e
.appendChild(document
.createTextNode(nick
));
86 updateTopic: function(topic
) {
92 t
.removeChild(t
.firstChild
);
96 addLine: function(type
, line
, colour
) {
97 this.parent(type
, line
, colour
);
99 var e
= new Element("div");
102 e
.setStyles({"background": colour
});
103 } else if(this.lastcolour
) {
104 e
.addClass("linestyle1");
106 e
.addClass("linestyle2");
110 line
= this.parentObject
.theme
.message(type
, line
);
112 Colourise(IRCTimestamp(new Date()) + " " + line
, e
);
114 this.lastcolour
= !this.lastcolour
;
116 var pe
= this.lines
.parentNode
.parentNode
;
118 var prev
= pe
.getScroll();
119 var prevbottom
= pe
.getScrollSize().y
;
120 var prevsize
= pe
.getSize();
121 this.lines
.appendChild(e
);
123 if(prev
.y
+ prevsize
.y
== prevbottom
)
124 pe
.scrollTo(prev
.x
, pe
.getScrollSize().y
);
127 this.lines
.showLoadingIcon();
131 var QMochaUI
= new Class({
133 initialize: function(parentElement
, theme
) {
134 this.parent(parentElement
, QMochaUIWindow
, "mochaui");
136 this.parentElement
= parentElement
;
138 window
.addEvent("domready", function() {
139 /* determine input size */
140 var l
= new Element("input", {styles: {border: 0}});
141 this.parentElement
.appendChild(l
);
142 this.inputHeight
= l
.getSize().y
;
143 this.parentElement
.removeChild(l
);
145 MochaUI
.Desktop
= new MochaUI
.Desktop();
146 MochaUI
.Dock
= new MochaUI
.Dock({
150 MochaUI
.Modal
= new MochaUI
.Modal();
151 MochaUI
.options
.useEffects
= false;
154 window
.addEvent("unload", function() {
156 MochaUI
.garbageCleanUp();
159 postInitialize: function() {
161 this.tabs
= new Element("div");
162 this.tabs
.addClass("tabbar");
164 this.parentElement
.appendChild(this.tabs
);
166 this.container
= new Element("div");
167 this.container
.addClass("container");
169 this.parentElement
.appendChild(this.container
);
171 var form
= new Element("form");
172 var inputbox
= new Element("input");
173 inputbox
.addClass("input");
175 form
.addEvent("submit", function(e
) {
178 this.getActiveWindow().client
.exec(inputbox
.value
);
181 this.parentElement
.appendChild(form
);
182 form
.appendChild(inputbox
);
185 loginBox: function(callbackfn
, intialNickname
, initialChannels
) {
186 this.parent(function(options
) {
187 this.postInitialize();
189 }.bind(this), intialNickname
, initialChannels
);