]> jfr.im git - irc/quakenet/qwebirc.git/blob - js/ui/uglyui.js
Rework old UI's to support custom/connect windows.
[irc/quakenet/qwebirc.git] / js / ui / uglyui.js
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 && type != WINDOW_CONNECT) {
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.addClass("tab-selected");
88 this.parentObject.showInput(this.type != WINDOW_CONNECT && this.type != WINDOW_CUSTOM);
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 var e = new Element("div");
105
106 if(colour) {
107 e.setStyles({"background": colour});
108 } else if(this.lastcolour) {
109 e.addClass("linestyle1");
110 } else {
111 e.addClass("linestyle2");
112 }
113 this.lastcolour = !this.lastcolour;
114
115 this.parent(type, line, colour, e);
116 },
117 setHilighted: function(state) {
118 this.parent(state);
119
120 if(state) {
121 this.tab.addClass("tab-highlighted");
122 } else {
123 this.tab.removeClass("tab-highlighted");
124 }
125 }
126 });
127
128 var UglyUI = new Class({
129 Extends: NewLoginUI,
130 initialize: function(parentElement, theme) {
131 this.parent(parentElement, UglyUIWindow, "uglyui");
132 this.theme = theme;
133 this.parentElement = parentElement;
134 },
135 postInitialize: function() {
136 this.tabs = new Element("div");
137 this.tabs.addClass("tabbar");
138
139 this.parentElement.appendChild(this.tabs);
140
141 this.container = new Element("div");
142 this.container.addClass("container");
143
144 this.parentElement.appendChild(this.container);
145
146 var form = new Element("form");
147 this.form = form;
148
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));
158 this.parentElement.appendChild(form);
159 form.appendChild(inputbox);
160 inputbox.focus();
161 },
162 showInput: function(state) {
163 this.form.setStyle("display", state?"block":"none");
164 }
165 });
166