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