]>
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 | this.scrolleddown = true; | |
14 | //new CommandHistory(); | |
15 | }, | |
16 | updateNickList: function(nicks) { | |
17 | }, | |
18 | updateTopic: function(topic) { | |
19 | }, | |
20 | close: function() { | |
21 | if($defined(this.scrolltimer)) { | |
22 | $clear(this.scrolltimer); | |
23 | this.scrolltimer = null; | |
24 | } | |
25 | ||
26 | this.parentObject.__closed(this); | |
27 | this.fireEvent("close", this); | |
28 | }, | |
29 | select: function() { | |
30 | this.active = true; | |
31 | this.parentObject.__setActiveWindow(this); | |
32 | if(this.hilighted) | |
33 | this.setHilighted(false); | |
34 | if(this.scrolleddown) | |
35 | this.scrollToBottom(); | |
36 | }, | |
37 | deselect: function() { | |
38 | if(!this.parentObject.singleWindow) | |
39 | this.scrolleddown = this.scrolledDown(); | |
40 | if($defined(this.scrolltimer)) { | |
41 | $clear(this.scrolltimer); | |
42 | this.scrolltimer = null; | |
43 | } | |
44 | ||
45 | this.active = false; | |
46 | }, | |
47 | addLine: function(type, line, colour, element) { | |
48 | if(!this.active && !this.hilighted) | |
49 | this.setHilighted(true); | |
50 | if(type) | |
51 | line = this.parentObject.theme.message(type, line); | |
52 | ||
53 | Colourise(IRCTimestamp(new Date()) + " " + line, element, this.client.exec, this.parentObject.urlDispatcher.bind(this.parentObject)); | |
54 | ||
55 | this.scrollAdd(element); | |
56 | }, | |
57 | errorMessage: function(message) { | |
58 | this.addLine("", message, "red"); | |
59 | }, | |
60 | setHilighted: function(state) { | |
61 | this.hilighted = state; | |
62 | }, | |
63 | scrolledDown: function() { | |
64 | if(this.scrolltimer) | |
65 | return true; | |
66 | ||
67 | var parent = this.lines; | |
68 | ||
69 | var prev = parent.getScroll(); | |
70 | var prevbottom = parent.getScrollSize().y; | |
71 | var prevsize = parent.getSize(); | |
72 | ||
73 | /* fixes an IE bug */ | |
74 | if(prevbottom < prevsize.y) | |
75 | prevbottom = prevsize.y; | |
76 | ||
77 | return prev.y + prevsize.y == prevbottom; | |
78 | }, | |
79 | scrollToBottom: function() { | |
80 | var parent = this.lines; | |
81 | var scrollparent = parent; | |
82 | ||
83 | if($defined(this.scroller)) | |
84 | scrollparent = this.scroller; | |
85 | ||
86 | scrollparent.scrollTo(parent.getScroll().x, parent.getScrollSize().y); | |
87 | }, | |
88 | scrollAdd: function(element) { | |
89 | var parent = this.lines; | |
90 | ||
91 | /* scroll in bursts, else the browser gets really slow */ | |
92 | if($defined(element)) { | |
93 | var sd = this.scrolledDown(); | |
94 | parent.appendChild(element); | |
95 | if(sd) { | |
96 | if(this.scrolltimer) | |
97 | $clear(this.scrolltimer); | |
98 | this.scrolltimer = this.scrollAdd.delay(50, this, [null]); | |
99 | } | |
100 | } else { | |
101 | this.scrollToBottom(); | |
102 | this.scrolltimer = null; | |
103 | } | |
104 | }, | |
105 | historyExec: function(line) { | |
106 | this.commandhistory.addLine(line); | |
107 | this.client.exec(line); | |
108 | } | |
109 | }); |