]> jfr.im git - irc/quakenet/qwebirc.git/blob - js/ui/uibase.js
Reorganise.
[irc/quakenet/qwebirc.git] / js / ui / uibase.js
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(windowClass) {
39 this.windows = {};
40 this.windowArray = [];
41 this.windowClass = windowClass;
42 },
43 newClient: function(client) {
44 this.windows[client] = {}
45 var w = this.newWindow(client, WINDOW_STATUS, "Status");
46 this.selectWindow(w);
47
48 return w;
49 },
50 newWindow: function(client, type, name) {
51 var identifier = name;
52 if(type == WINDOW_STATUS)
53 identifier = "";
54
55 var w = this.windows[client][identifier] = new this.windowClass(this, client, type, name, identifier);
56 this.windowArray.push(w);
57
58 return w;
59 },
60 getActiveWindow: function() {
61 return this.active;
62 },
63 __setActiveWindow: function(window) {
64 this.active = window;
65 },
66 selectWindow: function(window) {
67 if(this.active)
68 this.active.deselect();
69 window.select(); /* calls setActiveWindow */
70 },
71 __closed: function(window) {
72 if(window.active) {
73 this.active = undefined;
74 if(this.windowArray.length == 1) {
75 this.windowArray = [];
76 } else {
77 var index = this.windowArray.indexOf(window);
78 if(i == 0) {
79 this.selectWindow(this.windowArray[1]);
80 } else {
81 this.selectWindow(this.windowArray[index - 1]);
82 }
83
84 this.windowArray = this.windowArray.erase(window);
85 }
86 }
87
88 delete this.windows[window.client][window.identifier];
89 }
90 });