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