]>
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 | ||
6f2e4a37 | 44 | if(type != WINDOW_STATUS && type != WINDOW_CONNECT) { |
9e769c12 CP |
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 | 87 | this.tab.addClass("tab-selected"); |
6f2e4a37 | 88 | this.parentObject.showInput(this.type != WINDOW_CONNECT && this.type != WINDOW_CUSTOM); |
9e769c12 CP |
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) { | |
9e769c12 CP |
104 | var e = new Element("div"); |
105 | ||
106 | if(colour) { | |
d65fe45f | 107 | e.setStyles({"background": colour}); |
9e769c12 CP |
108 | } else if(this.lastcolour) { |
109 | e.addClass("linestyle1"); | |
110 | } else { | |
111 | e.addClass("linestyle2"); | |
112 | } | |
9e769c12 CP |
113 | this.lastcolour = !this.lastcolour; |
114 | ||
381fddfd CP |
115 | this.parent(type, line, colour, e); |
116 | }, | |
117 | setHilighted: function(state) { | |
118 | this.parent(state); | |
9e769c12 | 119 | |
381fddfd | 120 | if(state) { |
9e769c12 | 121 | this.tab.addClass("tab-highlighted"); |
381fddfd CP |
122 | } else { |
123 | this.tab.removeClass("tab-highlighted"); | |
124 | } | |
9e769c12 CP |
125 | } |
126 | }); | |
127 | ||
128 | var UglyUI = new Class({ | |
6f2e4a37 | 129 | Extends: NewLoginUI, |
9e769c12 CP |
130 | initialize: function(parentElement, theme) { |
131 | this.parent(parentElement, UglyUIWindow, "uglyui"); | |
9e769c12 | 132 | this.theme = theme; |
4656ff82 CP |
133 | this.parentElement = parentElement; |
134 | }, | |
135 | postInitialize: function() { | |
9e769c12 CP |
136 | this.tabs = new Element("div"); |
137 | this.tabs.addClass("tabbar"); | |
138 | ||
4656ff82 | 139 | this.parentElement.appendChild(this.tabs); |
9e769c12 CP |
140 | |
141 | this.container = new Element("div"); | |
142 | this.container.addClass("container"); | |
143 | ||
4656ff82 | 144 | this.parentElement.appendChild(this.container); |
9e769c12 CP |
145 | |
146 | var form = new Element("form"); | |
6f2e4a37 CP |
147 | this.form = form; |
148 | ||
9e769c12 CP |
149 | var inputbox = new Element("input"); |
150 | inputbox.addClass("input"); | |
151 | ||
152 | form.addEvent("submit", function(e) { | |
153 | new Event(e).stop(); | |
154 | ||
155 | this.getActiveWindow().client.exec(inputbox.value); | |
156 | inputbox.value = ""; | |
157 | }.bind(this)); | |
4656ff82 | 158 | this.parentElement.appendChild(form); |
9e769c12 CP |
159 | form.appendChild(inputbox); |
160 | inputbox.focus(); | |
4656ff82 | 161 | }, |
6f2e4a37 CP |
162 | showInput: function(state) { |
163 | this.form.setStyle("display", state?"block":"none"); | |
9e769c12 | 164 | } |
4656ff82 CP |
165 | }); |
166 |