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