]> jfr.im git - irc/quakenet/qwebirc.git/blame - js/ui/baseui.js
Use compiled versions.
[irc/quakenet/qwebirc.git] / js / ui / baseui.js
CommitLineData
daddcd5d
CP
1WINDOW_STATUS = 1;\r
2WINDOW_QUERY = 2;\r
3WINDOW_CHANNEL = 3;\r
4\r
5var 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
37var UI = new Class({\r
bed65087 38 initialize: function(parentElement, windowClass, uiName) {\r
daddcd5d
CP
39 this.windows = {};\r
40 this.windowArray = [];\r
41 this.windowClass = windowClass;\r
bed65087
CP
42 this.parentElement = parentElement;\r
43 this.parentElement.addClass("qwebirc");\r
44 this.parentElement.addClass("qwebirc-" + uiName);\r
daddcd5d
CP
45 },\r
46 newClient: function(client) {\r
47 this.windows[client] = {}\r
48 var w = this.newWindow(client, WINDOW_STATUS, "Status");\r
49 this.selectWindow(w);\r
50 \r
51 return w;\r
52 },\r
53 newWindow: function(client, type, name) {\r
54 var identifier = name;\r
55 if(type == WINDOW_STATUS)\r
56 identifier = "";\r
57 \r
4379a101 58 var w = this.windows[client][identifier] = new this.windowClass(this, client, type, name, identifier);\r
daddcd5d
CP
59 this.windowArray.push(w);\r
60 \r
61 return w;\r
62 },\r
63 getActiveWindow: function() {\r
64 return this.active;\r
65 },\r
66 __setActiveWindow: function(window) {\r
67 this.active = window;\r
68 },\r
69 selectWindow: function(window) {\r
70 if(this.active)\r
71 this.active.deselect();\r
72 window.select(); /* calls setActiveWindow */\r
73 },\r
74 __closed: function(window) {\r
75 if(window.active) {\r
76 this.active = undefined;\r
4379a101
CP
77 if(this.windowArray.length == 1) {\r
78 this.windowArray = [];\r
79 } else {\r
80 var index = this.windowArray.indexOf(window);\r
bed65087 81 if(index == 0) {\r
4379a101
CP
82 this.selectWindow(this.windowArray[1]);\r
83 } else {\r
84 this.selectWindow(this.windowArray[index - 1]);\r
daddcd5d 85 }\r
4379a101
CP
86 \r
87 this.windowArray = this.windowArray.erase(window);\r
daddcd5d
CP
88 }\r
89 }\r
90 \r
91 delete this.windows[window.client][window.identifier];\r
92 }\r
93});\r