[Phpfreechat-svn] SF.net SVN: phpfreechat: [596] trunk/themes/default/templates/pfcgui.js.tpl.php
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-06-16 13:59:42
|
Revision: 596 Author: kerphi Date: 2006-06-16 06:59:34 -0700 (Fri, 16 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=596&view=rev Log Message: ----------- Bug fix: when new messages were received in a background tab, the corresponding scrollbar was not scrolled as expected. Modified Paths: -------------- trunk/themes/default/templates/pfcgui.js.tpl.php Modified: trunk/themes/default/templates/pfcgui.js.tpl.php =================================================================== --- trunk/themes/default/templates/pfcgui.js.tpl.php 2006-06-16 12:13:17 UTC (rev 595) +++ trunk/themes/default/templates/pfcgui.js.tpl.php 2006-06-16 13:59:34 UTC (rev 596) @@ -18,6 +18,7 @@ this.chatcontent = $H(); this.onlinecontent = $H(); this.scrollpos = $H(); + this.elttoscroll = $H(); }, /** @@ -25,7 +26,12 @@ */ scrollDown: function(tabid, elttoscroll) { - if (this.getTabId() != tabid) return; /* do nothing if this is not the current tab or it will reset the scrollbar position to 0 */ + if (this.getTabId() != tabid) + { + if (!this.elttoscroll[tabid]) this.elttoscroll[tabid] = Array(); + this.elttoscroll[tabid].push(elttoscroll); + return; + } var content = this.getChatContentFromTabId(tabid); content.scrollTop += elttoscroll.offsetHeight+2; this.scrollpos[tabid] = content.scrollTop; @@ -38,7 +44,7 @@ setTabById: function(tabid) { - // first of all save the scroll post of the visible tab + // first of all save the scroll pos of the visible tab var content = this.getChatContentFromTabId(this.current_tab_id); this.scrollpos[this.current_tab_id] = content.scrollTop; @@ -46,7 +52,7 @@ this.current_tab = ''; this.current_tab_id = ''; var tab_to_show = null; - // try to fine the tab to select and select it! + // try to fine the tab to select and select it! for (var i=0; i<this.tabids.length; i++) { var tabtitle = $('<?php echo $prefix; ?>channel_title'+this.tabids[i]); @@ -69,6 +75,16 @@ // show the new selected tab tab_to_show.style.display = 'block'; + + // scroll the new posted message + if (this.elttoscroll[tabid]) + { + // on by one + for (var i=0; i<this.elttoscroll[tabid].length; i++) + this.scrollDown(tabid,this.elttoscroll[tabid][i]); + this.elttoscroll[tabid] = Array(); + } + // restore the scroll pos var content = this.getChatContentFromTabId(tabid); content.scrollTop = this.scrollpos[tabid]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |