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