]>
Commit | Line | Data |
---|---|---|
e20e5a6b | 1 | qwebirc.ui.SWMUI = new Class({ |
144ee52f | 2 | Extends: qwebirc.ui.RootUI, |
2cad083e CP |
3 | initialize: function(parentElement, theme, options) { |
4 | this.parent(parentElement, qwebirc.ui.SWMUI.Window, "swmui", options); | |
e20e5a6b CP |
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, | |
9e769c12 | 57 | |
f74802c5 CP |
58 | initialize: function(parentObject, client, type, name, identifier) { |
59 | this.parent(parentObject, client, type, name, identifier); | |
e20e5a6b | 60 | this.contentPanel = new qwebirc.ui.SWMUI.Panel(parentObject.mainPanel, true); |
18559d33 | 61 | this.contentPanel.addClass("content"); |
9e769c12 | 62 | |
e20e5a6b CP |
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; | |
18559d33 | 66 | this.nickList.addClass("nicklist"); |
9e769c12 | 67 | |
e20e5a6b CP |
68 | this.topic = new qwebirc.ui.SWMUI.Panel(this.contentPanel); |
69 | this.topic.anchor = qwebirc.ui.SWMUI.SWM_ANCHOR_TOP; | |
18559d33 | 70 | this.topic.addClass("topic"); |
9e769c12 CP |
71 | } |
72 | ||
e20e5a6b | 73 | this.xlines = new qwebirc.ui.SWMUI.Panel(this.contentPanel); |
381fddfd | 74 | this.lines = this.xlines.element; |
9e769c12 CP |
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 | ||
18559d33 | 84 | parentObject.tabPanel.appendChild(this.tab); |
9e769c12 CP |
85 | parentObject.resize(); |
86 | ||
e20e5a6b | 87 | if(type != qwebirc.ui.WINDOW_STATUS && type != qwebirc.ui.WINDOW_CONNECT) { |
9e769c12 CP |
88 | tabclose = new Element("span"); |
89 | tabclose.addClass("tabclose"); | |
90 | tabclose.addEvent("click", function(e) { | |
91 | new Event(e).stop(); | |
92 | ||
e20e5a6b | 93 | if(type == qwebirc.ui.WINDOW_CHANNEL) |
9e769c12 CP |
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 | ||
18559d33 | 105 | this.nickList.removeAllChildren(); |
9e769c12 CP |
106 | nicks.each(function(nick) { |
107 | var e = new Element("div"); | |
18559d33 | 108 | this.nickList.appendChild(e); |
9e769c12 | 109 | e.appendChild(document.createTextNode(nick)); |
18559d33 | 110 | }.bind(this)); |
9e769c12 CP |
111 | |
112 | this.parentObject.resize(); | |
113 | }, | |
114 | updateTopic: function(topic) { | |
115 | this.parent(topic); | |
9e769c12 | 116 | |
18559d33 | 117 | this.topic.removeAllChildren(); |
cad18909 | 118 | qwebirc.ui.Colourise(topic, this.topic.element); |
9e769c12 CP |
119 | |
120 | this.parentObject.resize(); | |
121 | }, | |
122 | select: function() { | |
123 | this.parent(); | |
124 | ||
125 | this.contentPanel.setHidden(false); | |
126 | this.parentObject.resize(); | |
9e769c12 CP |
127 | this.tab.removeClass("tab-unselected"); |
128 | this.tab.addClass("tab-selected"); | |
e20e5a6b | 129 | this.parentObject.showInput(this.type == qwebirc.ui.WINDOW_CONNECT || this.type == qwebirc.ui.WINDOW_CUSTOM); |
9e769c12 CP |
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 | ||
18559d33 CP |
142 | this.parentObject.mainPanel.removeChild(this.contentPanel.element); |
143 | this.parentObject.tabPanel.removeChild(this.tab); | |
9e769c12 CP |
144 | }, |
145 | addLine: function(type, line, colour) { | |
9e769c12 CP |
146 | var e = new Element("div"); |
147 | ||
148 | if(colour) { | |
65152b01 | 149 | e.setStyles({"background": colour}); |
9e769c12 CP |
150 | } else if(this.lastcolour) { |
151 | e.addClass("linestyle1"); | |
152 | } else { | |
153 | e.addClass("linestyle2"); | |
154 | } | |
155 | ||
9e769c12 | 156 | this.lastcolour = !this.lastcolour; |
18559d33 | 157 | |
381fddfd CP |
158 | this.parent(type, line, colour, e); |
159 | }, | |
160 | setHilighted: function(state) { | |
161 | this.parent(state); | |
18559d33 | 162 | |
381fddfd | 163 | if(state) { |
9e769c12 | 164 | this.tab.addClass("tab-highlighted"); |
381fddfd CP |
165 | } else { |
166 | this.tab.removeClass("tab-highlighted"); | |
167 | } | |
9e769c12 CP |
168 | } |
169 | }); |