]>
jfr.im git - irc/quakenet/qwebirc.git/blob - js/ui/mochaui.js
1 qwebirc
.ui
.MochaUI
= new Class({
2 Extends: qwebirc
.ui
.NewLoginUI
,
3 initialize: function(parentElement
, theme
) {
4 this.parent(parentElement
, qwebirc
.ui
.MochaUI
.Window
, "mochaui");
6 this.parentElement
= parentElement
;
8 window
.addEvent("domready", function() {
9 /* determine input size */
10 var l
= new Element("input", {styles: {border: 0}});
11 this.parentElement
.appendChild(l
);
12 this.inputHeight
= l
.getSize().y
;
13 this.parentElement
.removeChild(l
);
15 MochaUI
.Desktop
= new MochaUI
.Desktop();
16 MochaUI
.Dock
= new MochaUI
.Dock({
20 MochaUI
.Modal
= new MochaUI
.Modal();
21 MochaUI
.options
.useEffects
= false;
24 window
.addEvent("unload", function() {
26 MochaUI
.garbageCleanUp();
29 postInitialize: function() {
31 this.tabs
= new Element("div");
32 this.tabs
.addClass("tabbar");
34 this.parentElement
.appendChild(this.tabs
);
36 this.container
= new Element("div");
37 this.container
.addClass("container");
39 this.parentElement
.appendChild(this.container
);
41 var form
= new Element("form");
42 var inputbox
= new Element("input");
43 inputbox
.addClass("input");
45 form
.addEvent("submit", function(e
) {
48 this.getActiveWindow().client
.exec(inputbox
.value
);
51 this.parentElement
.appendChild(form
);
52 form
.appendChild(inputbox
);
57 qwebirc
.ui
.MochaUI
.Window
= new Class({
58 Extends: qwebirc
.ui
.Window
,
60 initialize: function(parentObject
, client
, type
, name
) {
61 this.parent(parentObject
, client
, type
, name
);
63 this.lines
= new Element("div", {styles: {overflow: "auto", "width": "90"}});
65 var toolbar
= (type
!= qwebirc
.ui
.WINDOW_CUSTOM
) && (type
!= qwebirc
.ui
.WINDOW_CONNECT
);
68 this.form
= new Element("form");
69 this.inputbox
= new Element("input", {styles: {border: 0, width: "100%"}});
70 this.inputbox
.addClass("input");
72 this.inputbox
.addEvent("focus", function() {
73 /* TODO: bring to top */
75 //alert(this.windowObject.windowEl);
76 //MochaUI.focusWindow.pass(this.windowObject.windowEl, this.windowObject);
77 //this.windowObject.focusWindow();
78 this.parentObject
.selectWindow(this);
81 this.form
.addEvent("submit", function(e
) {
84 this.client
.exec(this.inputbox
.value
);
85 this.inputbox
.value
= "";
87 //this.container.appendChild(form);
88 this.form
.appendChild(this.inputbox
);
96 container: $("pageWrapper"),
97 toolbarHeight: parentObject
.inputHeight
,
98 toolbarPosition: "bottom",
101 toolbarLoadMethod: "html",
104 addClass: "hidenewwin",
105 onFocus: function() {
106 parentObject
.selectWindow(this);
108 onClose: function() {
109 if(type
== qwebirc
.ui
.WINDOW_CHANNEL
)
110 this.client
.exec("/PART " + name
);
115 prefs
.toolbar
= toolbar
;
116 prefs
.closable
= type
!= qwebirc
.ui
.WINDOW_STATUS
&& type
!= qwebirc
.ui
.WINDOW_CONNECT
;
119 /* var oldIndexLevel = MochaUI.Windows.indexLevel;
122 var oldfocus = MochaUI.focusWindow;
124 MochaUI.Windows.indexLevel = 0;
125 MochaUI.focusWindow = null;
128 var nw
= new MochaUI
.Window(prefs
);
132 MochaUI.Windows.indexLevel = oldIndexLevel;
133 MochaUI.focusWindow = oldfocus;
138 var toolbar
= $(nw
.options
.id
+ "_toolbar");
139 toolbar
.appendChild(this.form
);
141 this.titleText
= $(nw
.options
.id
+ "_title");
142 this.tabText
= $(nw
.options
.id
+ "_dockTabText");
144 /*alert(toolbar.parentNode.getStyle("background"));*/
145 /*this.inputbox.setStyle("background", toolbar.parentNode.getStyle("background"));*/
146 this.windowObject
= nw
;
148 this.scroller
= this.lines
.parentNode
.parentNode
;
152 if(type == WINDOW_CHANNEL) {
153 this.nicklist = new Element("div");
154 this.nicklist.addClass("nicklist");
156 this.outerContainer.appendChild(this.nicklist);
159 var innerContainer = new Element("div");
160 innerContainer.addClass("innercontainer");
161 this.outerContainer.appendChild(innerContainer);
163 if(type == WINDOW_CHANNEL) {
164 this.topic = new Element("div");
165 this.topic.addClass("topic");
166 innerContainer.appendChild(this.topic);
170 updateNickList: function(nicks
) {
174 var n
= this.nicklist
;
176 n
.removeChild(n
.firstChild
);
178 nicks
.each(function(nick
) {
179 var e
= new Element("div");
181 e
.appendChild(document
.createTextNode(nick
));
184 updateTopic: function(topic
) {
190 t
.removeChild(t
.firstChild
);
192 qwebirc
.ui
.Colourise(topic
, t
);
194 addLine: function(type
, line
, colour
) {
195 var e
= new Element("div");
198 e
.setStyles({"background": colour
});
199 } else if(this.lastcolour
) {
200 e
.addClass("linestyle1");
202 e
.addClass("linestyle2");
204 this.lastcolour
= !this.lastcolour
;
206 this.parent(type
, line
, colour
, e
, this.lines
);
212 this.inputbox
.focus();
214 setHilighted: function(state
) {
218 this.titleText
.setStyle("color", "#ff0000");
219 this.tabText
.setStyle("background-color", "#ff0000");
220 this.tabText
.setStyle("color", "#000000");
222 this.titleText
.setStyle("color", null);
223 this.tabText
.setStyle("background-color", null);
224 this.tabText
.setStyle("color", null);
230 MochaUI
.closeWindow(this.window
.windowEl
);