]>
Commit | Line | Data |
---|---|---|
f4ae92cc CP |
1 | var QUIWindow = new Class({ |
2 | Extends: UIWindow, | |
3 | ||
4 | initialize: function(parentObject, client, type, name) { | |
5 | this.parent(parentObject, client, type, name); | |
6 | ||
7 | this.outerContainer = new Element("div"); | |
8 | this.outerContainer.addClass("outercontainer"); | |
9 | this.outerContainer.addClass("tab-invisible"); | |
10 | ||
11 | parentObject.container.appendChild(this.outerContainer); | |
12 | ||
13 | if(type == WINDOW_CHANNEL) { | |
14 | this.nicklist = new Element("div"); | |
15 | this.nicklist.addClass("nicklist"); | |
16 | ||
17 | this.outerContainer.appendChild(this.nicklist); | |
18 | } | |
19 | ||
20 | var innerContainer = new Element("div"); | |
21 | innerContainer.addClass("innercontainer"); | |
22 | this.outerContainer.appendChild(innerContainer); | |
23 | ||
24 | if(type == WINDOW_CHANNEL) { | |
25 | this.topic = new Element("div"); | |
26 | this.topic.addClass("topic"); | |
27 | innerContainer.appendChild(this.topic); | |
28 | } | |
29 | ||
30 | this.lines = new Element("div"); | |
31 | this.lines.addClass("lines"); | |
32 | innerContainer.appendChild(this.lines); | |
33 | ||
34 | this.tab = new Element("span"); | |
35 | this.tab.addClass("tab"); | |
36 | ||
37 | this.tab.appendText(name); | |
38 | this.tab.addEvent("click", function() { | |
39 | parentObject.selectWindow(this); | |
40 | }.bind(this)); | |
41 | ||
42 | parentObject.tabs.appendChild(this.tab); | |
43 | ||
44 | if(type != WINDOW_STATUS) { | |
45 | tabclose = new Element("span"); | |
46 | tabclose.addClass("tabclose"); | |
47 | tabclose.addEvent("click", function(e) { | |
48 | new Event(e).stop(); | |
49 | ||
50 | if(type == WINDOW_CHANNEL) | |
51 | this.client.exec("/PART " + name); | |
52 | ||
53 | this.close(); | |
54 | }.bind(this)); | |
55 | tabclose.set("text", "X"); | |
56 | this.tab.appendChild(tabclose); | |
57 | } | |
58 | }, | |
59 | updateNickList: function(nicks) { | |
60 | this.parent(nicks); | |
61 | ||
62 | var n = this.nicklist; | |
63 | while(n.firstChild) | |
64 | n.removeChild(n.firstChild); | |
65 | ||
66 | nicks.each(function(nick) { | |
67 | var e = new Element("div"); | |
68 | n.appendChild(e); | |
69 | e.appendChild(document.createTextNode(nick)); | |
70 | }); | |
71 | }, | |
72 | updateTopic: function(topic) { | |
73 | this.parent(topic); | |
74 | ||
75 | var t = this.topic; | |
76 | ||
77 | while(t.firstChild) | |
78 | t.removeChild(t.firstChild); | |
79 | ||
80 | Colourise(topic, t); | |
81 | }, | |
82 | select: function() { | |
83 | this.parent(); | |
84 | ||
85 | this.outerContainer.removeClass("tab-invisible"); | |
86 | this.tab.removeClass("tab-unselected"); | |
87 | this.tab.removeClass("tab-highlighted"); | |
88 | this.tab.addClass("tab-selected"); | |
89 | }, | |
90 | deselect: function() { | |
91 | this.parent(); | |
92 | ||
93 | this.outerContainer.addClass("tab-invisible"); | |
94 | this.tab.removeClass("tab-selected"); | |
95 | this.tab.addClass("tab-unselected"); | |
96 | }, | |
97 | close: function() { | |
98 | this.parent(); | |
99 | ||
100 | this.parentObject.container.removeChild(this.outerContainer); | |
101 | this.parentObject.tabs.removeChild(this.tab); | |
102 | }, | |
103 | addLine: function(type, line, colour) { | |
104 | this.parent(type, line, colour); | |
105 | ||
106 | var e = new Element("div"); | |
107 | ||
108 | if(colour) { | |
109 | e.setStyles({"background": colour}); | |
110 | } else if(this.lastcolour) { | |
111 | e.addClass("linestyle1"); | |
112 | } else { | |
113 | e.addClass("linestyle2"); | |
114 | } | |
115 | ||
116 | if(type) | |
117 | line = this.parentObject.theme.message(type, line); | |
118 | ||
119 | Colourise(IRCTimestamp(new Date()) + " " + line, e); | |
120 | ||
121 | this.lastcolour = !this.lastcolour; | |
122 | ||
123 | var prev = this.lines.getScroll(); | |
124 | var prevbottom = this.lines.getScrollSize().y; | |
125 | var prevsize = this.lines.getSize(); | |
126 | this.lines.appendChild(e); | |
127 | ||
128 | if(prev.y + prevsize.y == prevbottom) | |
129 | this.lines.scrollTo(prev.x, this.lines.getScrollSize().y); | |
130 | ||
131 | if(!this.active) | |
132 | this.tab.addClass("tab-highlighted"); | |
133 | } | |
134 | }); | |
135 | ||
136 | var QUI = new Class({ | |
137 | Extends: UI, | |
138 | initialize: function(parentElement, theme) { | |
ba47bd8b | 139 | this.parent(parentElement, QUIWindow, "qui"); |
f4ae92cc CP |
140 | this.theme = theme; |
141 | this.parentElement = parentElement; | |
142 | }, | |
143 | postInitialize: function() { | |
144 | this.tabs = new Element("div"); | |
145 | this.tabs.addClass("tabbar"); | |
146 | ||
147 | this.parentElement.appendChild(this.tabs); | |
148 | ||
149 | this.container = new Element("div"); | |
150 | this.container.addClass("container"); | |
151 | ||
152 | this.parentElement.appendChild(this.container); | |
153 | ||
154 | var form = new Element("form"); | |
155 | var inputbox = new Element("input"); | |
156 | inputbox.addClass("input"); | |
157 | ||
158 | form.addEvent("submit", function(e) { | |
159 | new Event(e).stop(); | |
160 | ||
161 | this.getActiveWindow().client.exec(inputbox.value); | |
162 | inputbox.value = ""; | |
163 | }.bind(this)); | |
164 | this.parentElement.appendChild(form); | |
165 | form.appendChild(inputbox); | |
166 | inputbox.focus(); | |
167 | }, | |
168 | loginBox: function(callbackfn, intialNickname, initialChannels) { | |
169 | this.parent(function(options) { | |
170 | this.postInitialize(); | |
171 | callbackfn(options); | |
172 | }.bind(this), intialNickname, initialChannels); | |
173 | } | |
174 | }); | |
175 |