]>
Commit | Line | Data |
---|---|---|
cfd8616d CP |
1 | var QMochaUIWindow = new Class({ |
2 | Extends: UIWindow, | |
3 | ||
4 | initialize: function(parentObject, client, type, name) { | |
5 | this.parent(parentObject, client, type, name); | |
6 | ||
7 | this.lines = new Element("div", {styles: {overflow: "auto", "width": "90"}}); | |
8 | ||
9 | this.form = new Element("form"); | |
10 | this.inputbox = new Element("input", {styles: {border: 0, width: "100%"}}); | |
11 | this.inputbox.addClass("input"); | |
12 | ||
13 | this.form.addEvent("submit", function(e) { | |
14 | new Event(e).stop(); | |
15 | ||
16 | this.client.exec(this.inputbox.value); | |
17 | this.inputbox.value = ""; | |
18 | }.bind(this)); | |
19 | //this.container.appendChild(form); | |
20 | this.form.appendChild(this.inputbox); | |
21 | ||
22 | var prefs = { | |
23 | width: 500, | |
24 | height: 400, | |
25 | title: name, | |
26 | footerHeight: 0, | |
27 | toolbar: true, | |
28 | container: $("pageWrapper"), | |
29 | toolbarHeight: parentObject.inputHeight, | |
30 | toolbarPosition: "bottom", | |
31 | toolbarContent: "", | |
32 | content: this.lines, | |
33 | onFocus: function() { | |
34 | parentObject.selectWindow(this); | |
35 | }.bind(this), | |
36 | onClose: function() { | |
37 | if(type == WINDOW_CHANNEL) | |
38 | this.client.exec("/PART " + name); | |
39 | ||
40 | this.close(); | |
41 | }.bind(this) | |
42 | }; | |
43 | ||
44 | if(type == WINDOW_STATUS) | |
45 | prefs.closable = false; | |
46 | ||
47 | var nw = new MochaUI.Window(prefs); | |
48 | /* HACK */ | |
49 | var toolbar = $(nw.options.id + "_toolbar"); | |
50 | toolbar.appendChild(this.form); | |
51 | ||
52 | return; | |
53 | /* | |
54 | if(type == WINDOW_CHANNEL) { | |
55 | this.nicklist = new Element("div"); | |
56 | this.nicklist.addClass("nicklist"); | |
57 | ||
58 | this.outerContainer.appendChild(this.nicklist); | |
59 | } | |
60 | ||
61 | var innerContainer = new Element("div"); | |
62 | innerContainer.addClass("innercontainer"); | |
63 | this.outerContainer.appendChild(innerContainer); | |
64 | ||
65 | if(type == WINDOW_CHANNEL) { | |
66 | this.topic = new Element("div"); | |
67 | this.topic.addClass("topic"); | |
68 | innerContainer.appendChild(this.topic); | |
69 | } | |
70 | */ | |
71 | }, | |
72 | updateNickList: function(nicks) { | |
73 | this.parent(nicks); | |
74 | ||
75 | return; | |
76 | var n = this.nicklist; | |
77 | while(n.firstChild) | |
78 | n.removeChild(n.firstChild); | |
79 | ||
80 | nicks.each(function(nick) { | |
81 | var e = new Element("div"); | |
82 | n.appendChild(e); | |
83 | e.appendChild(document.createTextNode(nick)); | |
84 | }); | |
85 | }, | |
86 | updateTopic: function(topic) { | |
87 | this.parent(topic); | |
88 | return; | |
89 | var t = this.topic; | |
90 | ||
91 | while(t.firstChild) | |
92 | t.removeChild(t.firstChild); | |
93 | ||
94 | Colourise(topic, t); | |
95 | }, | |
96 | addLine: function(type, line, colour) { | |
97 | this.parent(type, line, colour); | |
98 | ||
99 | var e = new Element("div"); | |
100 | ||
101 | if(colour) { | |
102 | e.setStyles({"background": colour}); | |
103 | } else if(this.lastcolour) { | |
104 | e.addClass("linestyle1"); | |
105 | } else { | |
106 | e.addClass("linestyle2"); | |
107 | } | |
108 | ||
109 | if(type) | |
110 | line = this.parentObject.theme.message(type, line); | |
111 | ||
112 | Colourise(IRCTimestamp(new Date()) + " " + line, e); | |
113 | ||
114 | this.lastcolour = !this.lastcolour; | |
115 | ||
116 | var prev = this.lines.getScroll(); | |
117 | var prevbottom = this.lines.getScrollSize().y; | |
118 | var prevsize = this.lines.getSize(); | |
119 | this.lines.appendChild(e); | |
120 | ||
121 | //if(prev.y + prevsize.y == prevbottom) | |
122 | this.lines.scrollTo(prev.x, this.lines.getScrollSize().y); | |
123 | ||
124 | if(!this.active) | |
125 | this.lines.showLoadingIcon(); | |
126 | } | |
127 | }); | |
128 | ||
129 | var QMochaUI = new Class({ | |
130 | Extends: UI, | |
131 | initialize: function(parentElement, theme) { | |
132 | this.parent(parentElement, QMochaUIWindow, "mochaui"); | |
133 | this.theme = theme; | |
134 | this.parentElement = parentElement; | |
135 | ||
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); | |
142 | ||
143 | MochaUI.Desktop = new MochaUI.Desktop(); | |
144 | MochaUI.Dock = new MochaUI.Dock(); | |
145 | MochaUI.Modal = new MochaUI.Modal(); | |
146 | MochaUI.options.useEffects = false; | |
147 | }.bind(this)); | |
148 | ||
149 | window.addEvent("unload", function() { | |
150 | if(MochaUI) | |
151 | MochaUI.garbageCleanUp(); | |
152 | }); | |
153 | }, | |
154 | postInitialize: function() { | |
155 | return; | |
156 | this.tabs = new Element("div"); | |
157 | this.tabs.addClass("tabbar"); | |
158 | ||
159 | this.parentElement.appendChild(this.tabs); | |
160 | ||
161 | this.container = new Element("div"); | |
162 | this.container.addClass("container"); | |
163 | ||
164 | this.parentElement.appendChild(this.container); | |
165 | ||
166 | var form = new Element("form"); | |
167 | var inputbox = new Element("input"); | |
168 | inputbox.addClass("input"); | |
169 | ||
170 | form.addEvent("submit", function(e) { | |
171 | new Event(e).stop(); | |
172 | ||
173 | this.getActiveWindow().client.exec(inputbox.value); | |
174 | inputbox.value = ""; | |
175 | }.bind(this)); | |
176 | this.parentElement.appendChild(form); | |
177 | form.appendChild(inputbox); | |
178 | inputbox.focus(); | |
179 | }, | |
180 | loginBox: function(callbackfn, intialNickname, initialChannels) { | |
181 | this.parent(function(options) { | |
182 | this.postInitialize(); | |
183 | callbackfn(options); | |
184 | }.bind(this), intialNickname, initialChannels); | |
185 | } | |
186 | }); |