]>
Commit | Line | Data |
---|---|---|
9e769c12 CP |
1 | var UglyUIWindow = 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"); | |
381fddfd | 86 | this.tab.removeClass("tab-unselected"); |
9e769c12 CP |
87 | this.tab.addClass("tab-selected"); |
88 | }, | |
89 | deselect: function() { | |
90 | this.parent(); | |
91 | ||
92 | this.outerContainer.addClass("tab-invisible"); | |
93 | this.tab.removeClass("tab-selected"); | |
94 | this.tab.addClass("tab-unselected"); | |
95 | }, | |
96 | close: function() { | |
97 | this.parent(); | |
98 | ||
99 | this.parentObject.container.removeChild(this.outerContainer); | |
100 | this.parentObject.tabs.removeChild(this.tab); | |
101 | }, | |
102 | addLine: function(type, line, colour) { | |
9e769c12 CP |
103 | var e = new Element("div"); |
104 | ||
105 | if(colour) { | |
d65fe45f | 106 | e.setStyles({"background": colour}); |
9e769c12 CP |
107 | } else if(this.lastcolour) { |
108 | e.addClass("linestyle1"); | |
109 | } else { | |
110 | e.addClass("linestyle2"); | |
111 | } | |
9e769c12 CP |
112 | this.lastcolour = !this.lastcolour; |
113 | ||
381fddfd CP |
114 | this.parent(type, line, colour, e); |
115 | }, | |
116 | setHilighted: function(state) { | |
117 | this.parent(state); | |
9e769c12 | 118 | |
381fddfd | 119 | if(state) { |
9e769c12 | 120 | this.tab.addClass("tab-highlighted"); |
381fddfd CP |
121 | } else { |
122 | this.tab.removeClass("tab-highlighted"); | |
123 | } | |
9e769c12 CP |
124 | } |
125 | }); | |
126 | ||
127 | var UglyUI = new Class({ | |
128 | Extends: UI, | |
129 | initialize: function(parentElement, theme) { | |
130 | this.parent(parentElement, UglyUIWindow, "uglyui"); | |
9e769c12 | 131 | this.theme = theme; |
4656ff82 CP |
132 | this.parentElement = parentElement; |
133 | }, | |
134 | postInitialize: function() { | |
9e769c12 CP |
135 | this.tabs = new Element("div"); |
136 | this.tabs.addClass("tabbar"); | |
137 | ||
4656ff82 | 138 | this.parentElement.appendChild(this.tabs); |
9e769c12 CP |
139 | |
140 | this.container = new Element("div"); | |
141 | this.container.addClass("container"); | |
142 | ||
4656ff82 | 143 | this.parentElement.appendChild(this.container); |
9e769c12 CP |
144 | |
145 | var form = new Element("form"); | |
146 | var inputbox = new Element("input"); | |
147 | inputbox.addClass("input"); | |
148 | ||
149 | form.addEvent("submit", function(e) { | |
150 | new Event(e).stop(); | |
151 | ||
152 | this.getActiveWindow().client.exec(inputbox.value); | |
153 | inputbox.value = ""; | |
154 | }.bind(this)); | |
4656ff82 | 155 | this.parentElement.appendChild(form); |
9e769c12 CP |
156 | form.appendChild(inputbox); |
157 | inputbox.focus(); | |
4656ff82 | 158 | }, |
d65fe45f | 159 | loginBox: function(callbackfn, intialNickname, initialChannels) { |
4656ff82 CP |
160 | this.parent(function(options) { |
161 | this.postInitialize(); | |
162 | callbackfn(options); | |
d65fe45f | 163 | }.bind(this), intialNickname, initialChannels); |
9e769c12 | 164 | } |
4656ff82 CP |
165 | }); |
166 |