]>
jfr.im git - irc/quakenet/qwebirc.git/blob - js/ui/baseuiwindow.js
1 qwebirc
.ui
.Window
= new Class({
3 initialize: function(parentObject
, client
, type
, name
, identifier
) {
4 this.parentObject
= parentObject
;
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();
16 updateNickList: function(nicks
) {
18 updateTopic: function(topic
, element
) {
19 qwebirc
.ui
.Colourise("[" + topic
+ "]", element
, this.client
.exec
, this.parentObject
.urlDispatcher
.bind(this.parentObject
), this);
22 if($defined(this.scrolltimer
)) {
23 $clear(this.scrolltimer
);
24 this.scrolltimer
= null;
27 this.parentObject
.__closed(this);
28 this.fireEvent("close", this);
32 this.parentObject
.__setActiveWindow(this);
34 this.setHilighted(false);
36 this.scrollToBottom();
38 deselect: function() {
39 if(!this.parentObject
.singleWindow
)
40 this.scrolleddown
= this.scrolledDown();
41 if($defined(this.scrolltimer
)) {
42 $clear(this.scrolltimer
);
43 this.scrolltimer
= null;
48 addLine: function(type
, line
, colour
, element
) {
49 if(!this.active
&& !this.hilighted
)
50 this.setHilighted(true);
52 line
= this.parentObject
.theme
.message(type
, line
);
54 qwebirc
.ui
.Colourise(qwebirc
.irc
.IRCTimestamp(new Date()) + " " + line
, element
, this.client
.exec
, this.parentObject
.urlDispatcher
.bind(this.parentObject
), this);
56 this.scrollAdd(element
);
58 errorMessage: function(message
) {
59 this.addLine("", message
, "red");
61 setHilighted: function(state
) {
62 this.hilighted
= state
;
64 scrolledDown: function() {
68 var parent
= this.lines
;
70 var prev
= parent
.getScroll();
71 var prevbottom
= parent
.getScrollSize().y
;
72 var prevsize
= parent
.getSize();
75 if(prevbottom
< prevsize
.y
)
76 prevbottom
= prevsize
.y
;
78 return prev
.y
+ prevsize
.y
== prevbottom
;
80 scrollToBottom: function() {
81 var parent
= this.lines
;
82 var scrollparent
= parent
;
84 if($defined(this.scroller
))
85 scrollparent
= this.scroller
;
87 scrollparent
.scrollTo(parent
.getScroll().x
, parent
.getScrollSize().y
);
89 scrollAdd: function(element
) {
90 var parent
= this.lines
;
92 /* scroll in bursts, else the browser gets really slow */
93 if($defined(element
)) {
94 var sd
= this.scrolledDown();
95 parent
.appendChild(element
);
98 $clear(this.scrolltimer
);
99 this.scrolltimer
= this.scrollAdd
.delay(50, this, [null]);
102 this.scrollToBottom();
103 this.scrolltimer
= null;
106 historyExec: function(line
) {
107 this.commandhistory
.addLine(line
);
108 this.client
.exec(line
);