]>
Commit | Line | Data |
---|---|---|
1 | var UIWindow = new Class({ | |
2 | Implements: [Events], | |
3 | initialize: function(parentObject, client, type, name, identifier) { | |
4 | this.parentObject = parentObject; | |
5 | this.type = type; | |
6 | this.name = name; | |
7 | this.active = false; | |
8 | this.client = client; | |
9 | this.identifier = identifier; | |
10 | this.hilighted = false; | |
11 | this.scrolltimer = null; | |
12 | this.commandhistory = this.parentObject.commandhistory; | |
13 | //new CommandHistory(); | |
14 | }, | |
15 | updateNickList: function(nicks) { | |
16 | }, | |
17 | updateTopic: function(topic) { | |
18 | }, | |
19 | close: function() { | |
20 | if($defined(this.scrolltimer)) { | |
21 | $clear(this.scrolltimer); | |
22 | this.scrolltimer = null; | |
23 | } | |
24 | ||
25 | this.parentObject.__closed(this); | |
26 | this.fireEvent("close", this); | |
27 | }, | |
28 | select: function() { | |
29 | this.active = true; | |
30 | this.parentObject.__setActiveWindow(this); | |
31 | if(this.hilighted) | |
32 | this.setHilighted(false); | |
33 | }, | |
34 | deselect: function() { | |
35 | this.active = false; | |
36 | }, | |
37 | addLine: function(type, line, colour, element, parent, scrollparent) { | |
38 | if(!this.active && !this.hilighted) | |
39 | this.setHilighted(true); | |
40 | ||
41 | if(type) | |
42 | line = this.parentObject.theme.message(type, line); | |
43 | ||
44 | Colourise(IRCTimestamp(new Date()) + " " + line, element); | |
45 | ||
46 | this.scrollAdd(element); | |
47 | }, | |
48 | errorMessage: function(message) { | |
49 | this.addLine("", message, "red"); | |
50 | }, | |
51 | setHilighted: function(state) { | |
52 | this.hilighted = state; | |
53 | }, | |
54 | scrollAdd: function(element) { | |
55 | var parent = this.lines; | |
56 | var scrollparent = parent; | |
57 | ||
58 | if($defined(this.scroller)) | |
59 | scrollparent = this.scroller; | |
60 | ||
61 | var prev = parent.getScroll(); | |
62 | var prevbottom = parent.getScrollSize().y; | |
63 | var prevsize = parent.getSize(); | |
64 | ||
65 | /* scroll in bursts, else the browser gets really slow */ | |
66 | if($defined(element)) { | |
67 | parent.appendChild(element); | |
68 | if(this.scrolltimer || (prev.y + prevsize.y == prevbottom)) { | |
69 | if(this.scrolltimer) | |
70 | $clear(this.scrolltimer); | |
71 | this.scrolltimer = this.scrollAdd.delay(50, this, [null, null]); | |
72 | } | |
73 | } else { | |
74 | scrollparent.scrollTo(prev.x, parent.getScrollSize().y); | |
75 | this.scrolltimer = null; | |
76 | } | |
77 | }, | |
78 | historyExec: function(line) { | |
79 | this.commandhistory.addLine(line); | |
80 | this.client.exec(line); | |
81 | } | |
82 | }); |