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