]>
Commit | Line | Data |
---|---|---|
daddcd5d CP |
1 | WINDOW_STATUS = 1;\r |
2 | WINDOW_QUERY = 2;\r | |
3 | WINDOW_CHANNEL = 3;\r | |
4 | \r | |
5 | var UIWindow = new Class({\r | |
4379a101 | 6 | Implements: [Events],\r |
daddcd5d CP |
7 | initialize: function(parentObject, client, type, name, identifier) {\r |
8 | this.parentObject = parentObject;\r | |
9 | this.type = type;\r | |
10 | this.name = name;\r | |
11 | this.active = false;\r | |
12 | this.client = client;\r | |
13 | this.identifier = identifier;\r | |
14 | },\r | |
15 | updateNickList: function(nicks) {\r | |
16 | },\r | |
17 | updateTopic: function(topic) {\r | |
18 | },\r | |
19 | close: function() {\r | |
20 | this.parentObject.__closed(this);\r | |
21 | this.fireEvent("close", this);\r | |
22 | },\r | |
23 | select: function() {\r | |
24 | this.active = true;\r | |
25 | this.parentObject.__setActiveWindow(this);\r | |
26 | },\r | |
27 | deselect: function() {\r | |
28 | this.active = false;\r | |
29 | },\r | |
30 | addLine: function(type, line, colour) {\r | |
31 | },\r | |
32 | errorMessage: function(message) {\r | |
33 | this.addLine("", message, "red");\r | |
34 | }\r | |
35 | });\r | |
daddcd5d CP |
36 | \r |
37 | var UI = new Class({\r | |
38 | initialize: function(windowClass) {\r | |
39 | this.windows = {};\r | |
40 | this.windowArray = [];\r | |
41 | this.windowClass = windowClass;\r | |
42 | },\r | |
43 | newClient: function(client) {\r | |
44 | this.windows[client] = {}\r | |
45 | var w = this.newWindow(client, WINDOW_STATUS, "Status");\r | |
46 | this.selectWindow(w);\r | |
47 | \r | |
48 | return w;\r | |
49 | },\r | |
50 | newWindow: function(client, type, name) {\r | |
51 | var identifier = name;\r | |
52 | if(type == WINDOW_STATUS)\r | |
53 | identifier = "";\r | |
54 | \r | |
4379a101 | 55 | var w = this.windows[client][identifier] = new this.windowClass(this, client, type, name, identifier);\r |
daddcd5d CP |
56 | this.windowArray.push(w);\r |
57 | \r | |
58 | return w;\r | |
59 | },\r | |
60 | getActiveWindow: function() {\r | |
61 | return this.active;\r | |
62 | },\r | |
63 | __setActiveWindow: function(window) {\r | |
64 | this.active = window;\r | |
65 | },\r | |
66 | selectWindow: function(window) {\r | |
67 | if(this.active)\r | |
68 | this.active.deselect();\r | |
69 | window.select(); /* calls setActiveWindow */\r | |
70 | },\r | |
71 | __closed: function(window) {\r | |
72 | if(window.active) {\r | |
73 | this.active = undefined;\r | |
4379a101 CP |
74 | if(this.windowArray.length == 1) {\r |
75 | this.windowArray = [];\r | |
76 | } else {\r | |
77 | var index = this.windowArray.indexOf(window);\r | |
78 | if(i == 0) {\r | |
79 | this.selectWindow(this.windowArray[1]);\r | |
80 | } else {\r | |
81 | this.selectWindow(this.windowArray[index - 1]);\r | |
daddcd5d | 82 | }\r |
4379a101 CP |
83 | \r |
84 | this.windowArray = this.windowArray.erase(window);\r | |
daddcd5d CP |
85 | }\r |
86 | }\r | |
87 | \r | |
88 | delete this.windows[window.client][window.identifier];\r | |
89 | }\r | |
90 | });\r |