]>
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 prev
= this.lines
.getScroll();
117 var prevbottom
= this.lines
.getScrollSize().y
;
118 var prevsize
= this.lines
.getSize();
119 this.lines
.appendChild(e
);
121 //if(prev.y + prevsize.y == prevbottom)
122 this.lines
.scrollTo(prev
.x
, this.lines
.getScrollSize().y
);
125 this.lines
.showLoadingIcon();
129 var QMochaUI
= new Class({
131 initialize: function(parentElement
, theme
) {
132 this.parent(parentElement
, QMochaUIWindow
, "mochaui");
134 this.parentElement
= parentElement
;
136 window
.addEvent("domready", function() {
137 /* determine input size */
138 var l
= new Element("input", {styles: {border: 0}});
139 this.parentElement
.appendChild(l
);
140 this.inputHeight
= l
.getSize().y
;
141 this.parentElement
.removeChild(l
);
143 MochaUI
.Desktop
= new MochaUI
.Desktop();
144 MochaUI
.Dock
= new MochaUI
.Dock({
145 dockPosition: 'bottom'
148 MochaUI
.Modal
= new MochaUI
.Modal();
149 MochaUI
.options
.useEffects
= false;
152 window
.addEvent("unload", function() {
154 MochaUI
.garbageCleanUp();
157 postInitialize: function() {
159 this.tabs
= new Element("div");
160 this.tabs
.addClass("tabbar");
162 this.parentElement
.appendChild(this.tabs
);
164 this.container
= new Element("div");
165 this.container
.addClass("container");
167 this.parentElement
.appendChild(this.container
);
169 var form
= new Element("form");
170 var inputbox
= new Element("input");
171 inputbox
.addClass("input");
173 form
.addEvent("submit", function(e
) {
176 this.getActiveWindow().client
.exec(inputbox
.value
);
179 this.parentElement
.appendChild(form
);
180 form
.appendChild(inputbox
);
183 loginBox: function(callbackfn
, intialNickname
, initialChannels
) {
184 this.parent(function(options
) {
185 this.postInitialize();
187 }.bind(this), intialNickname
, initialChannels
);