]>
Commit | Line | Data |
---|---|---|
96f28062 CP |
1 | qwebirc.ui.HILIGHT_NONE = 0; |
2 | qwebirc.ui.HILIGHT_ACTIVITY = 1; | |
3 | qwebirc.ui.HILIGHT_SPEECH = 2; | |
4 | qwebirc.ui.HILIGHT_US = 3; | |
5 | ||
e20e5a6b | 6 | qwebirc.ui.Window = new Class({ |
94b18192 CP |
7 | Implements: [Events], |
8 | initialize: function(parentObject, client, type, name, identifier) { | |
9 | this.parentObject = parentObject; | |
10 | this.type = type; | |
11 | this.name = name; | |
12 | this.active = false; | |
13 | this.client = client; | |
14 | this.identifier = identifier; | |
96f28062 | 15 | this.hilighted = qwebirc.ui.HILIGHT_NONE; |
381fddfd | 16 | this.scrolltimer = null; |
9b63b053 | 17 | this.commandhistory = this.parentObject.commandhistory; |
25be5960 | 18 | this.scrolleddown = true; |
52090a1f | 19 | this.lastNickHash = {}; |
9b63b053 | 20 | //new CommandHistory(); |
94b18192 CP |
21 | }, |
22 | updateNickList: function(nicks) { | |
23 | }, | |
1f06a70a | 24 | updateTopic: function(topic, element) { |
2cd9e32d | 25 | qwebirc.ui.Colourise("[" + topic + "]", element, this.client.exec, this.parentObject.urlDispatcher.bind(this.parentObject), this); |
94b18192 CP |
26 | }, |
27 | close: function() { | |
381fddfd CP |
28 | if($defined(this.scrolltimer)) { |
29 | $clear(this.scrolltimer); | |
30 | this.scrolltimer = null; | |
31 | } | |
32 | ||
94b18192 CP |
33 | this.parentObject.__closed(this); |
34 | this.fireEvent("close", this); | |
35 | }, | |
36 | select: function() { | |
37 | this.active = true; | |
38 | this.parentObject.__setActiveWindow(this); | |
381fddfd | 39 | if(this.hilighted) |
96f28062 | 40 | this.setHilighted(qwebirc.ui.HILIGHT_NONE); |
7c633700 | 41 | if(this.scrolleddown) |
25be5960 | 42 | this.scrollToBottom(); |
94b18192 CP |
43 | }, |
44 | deselect: function() { | |
7c633700 | 45 | if(!this.parentObject.singleWindow) |
25be5960 | 46 | this.scrolleddown = this.scrolledDown(); |
7c633700 CP |
47 | if($defined(this.scrolltimer)) { |
48 | $clear(this.scrolltimer); | |
49 | this.scrolltimer = null; | |
50 | } | |
51 | ||
94b18192 CP |
52 | this.active = false; |
53 | }, | |
30bd2620 | 54 | addLine: function(type, line, colour, element) { |
96f28062 CP |
55 | var hilight = qwebirc.ui.HILIGHT_NONE; |
56 | if(type) { | |
57 | hilight = qwebirc.ui.HILIGHT_ACTIVITY; | |
58 | ||
59 | if(type.match(/(NOTICE|ACTION|MSG)$/)) { | |
60 | if(this.type == qwebirc.ui.WINDOW_QUERY) { | |
61 | hilight = qwebirc.ui.HILIGHT_US | |
62 | } else if(!type.match(/^OUR/) && this.client.hilightController.match(line["m"])) { | |
63 | hilight = qwebirc.ui.HILIGHT_US; | |
64 | } else { | |
65 | hilight = qwebirc.ui.HILIGHT_SPEECH; | |
66 | } | |
67 | } | |
68 | } | |
69 | ||
70 | if(!this.active && (hilight != qwebirc.ui.HILIGHT_NONE)) | |
71 | this.setHilighted(hilight); | |
72 | ||
381fddfd | 73 | if(type) |
96f28062 | 74 | line = this.parentObject.theme.message(type, line, hilight == qwebirc.ui.HILIGHT_US); |
381fddfd | 75 | |
2cd9e32d | 76 | qwebirc.ui.Colourise(qwebirc.irc.IRCTimestamp(new Date()) + " " + line, element, this.client.exec, this.parentObject.urlDispatcher.bind(this.parentObject), this); |
381fddfd | 77 | this.scrollAdd(element); |
94b18192 CP |
78 | }, |
79 | errorMessage: function(message) { | |
80 | this.addLine("", message, "red"); | |
381fddfd CP |
81 | }, |
82 | setHilighted: function(state) { | |
96f28062 CP |
83 | if(state == qwebirc.ui.HILIGHT_NONE || state >= this.hilighted) |
84 | this.hilighted = state; | |
381fddfd | 85 | }, |
25be5960 | 86 | scrolledDown: function() { |
7c633700 CP |
87 | if(this.scrolltimer) |
88 | return true; | |
89 | ||
381fddfd | 90 | var parent = this.lines; |
381fddfd | 91 | |
381fddfd CP |
92 | var prev = parent.getScroll(); |
93 | var prevbottom = parent.getScrollSize().y; | |
94 | var prevsize = parent.getSize(); | |
25be5960 | 95 | |
fccb1dac CP |
96 | /* fixes an IE bug */ |
97 | if(prevbottom < prevsize.y) | |
98 | prevbottom = prevsize.y; | |
99 | ||
7c633700 CP |
100 | return prev.y + prevsize.y == prevbottom; |
101 | }, | |
25be5960 | 102 | scrollToBottom: function() { |
7c633700 CP |
103 | var parent = this.lines; |
104 | var scrollparent = parent; | |
105 | ||
106 | if($defined(this.scroller)) | |
107 | scrollparent = this.scroller; | |
108 | ||
109 | scrollparent.scrollTo(parent.getScroll().x, parent.getScrollSize().y); | |
110 | }, | |
111 | scrollAdd: function(element) { | |
112 | var parent = this.lines; | |
381fddfd CP |
113 | |
114 | /* scroll in bursts, else the browser gets really slow */ | |
115 | if($defined(element)) { | |
25be5960 | 116 | var sd = this.scrolledDown(); |
381fddfd | 117 | parent.appendChild(element); |
7c633700 | 118 | if(sd) { |
381fddfd CP |
119 | if(this.scrolltimer) |
120 | $clear(this.scrolltimer); | |
7c633700 | 121 | this.scrolltimer = this.scrollAdd.delay(50, this, [null]); |
381fddfd CP |
122 | } |
123 | } else { | |
25be5960 | 124 | this.scrollToBottom(); |
381fddfd CP |
125 | this.scrolltimer = null; |
126 | } | |
9b63b053 | 127 | }, |
52090a1f CP |
128 | updateNickList: function(nicks) { |
129 | var nickHash = {}; | |
130 | var added = []; | |
131 | var lnh = this.lastNickHash; | |
132 | ||
133 | for(var i=0;i<nicks.length;i++) { | |
134 | var n = nicks[i]; | |
135 | var l = lnh[n]; | |
136 | if(!l) { | |
137 | l = this.nickListAdd(n, i); | |
138 | if(!l) | |
139 | l = 1; | |
140 | } | |
141 | nickHash[n] = l; | |
142 | } | |
143 | ||
144 | for(var k in lnh) | |
145 | if(!nickHash[k]) | |
146 | this.nickListRemove(k, lnh[k]); | |
147 | ||
148 | this.lastNickHash = nickHash; | |
149 | }, | |
150 | nickListAdd: function(position, nick) { | |
151 | }, | |
152 | nickListRemove: function(nick, stored) { | |
153 | }, | |
9b63b053 CP |
154 | historyExec: function(line) { |
155 | this.commandhistory.addLine(line); | |
156 | this.client.exec(line); | |
94b18192 CP |
157 | } |
158 | }); |