adium 2750:5fd4260e1b0d: Correct alignment for appending next me...

commits at adium.im commits at adium.im
Tue Oct 20 03:44:09 UTC 2009


details:	http://hg.adium.im/adium/rev/5fd4260e1b0d
revision:	2750:5fd4260e1b0d
author:		Stephen Holt <sholt at adium.im>
date:		Mon Oct 19 19:26:30 2009 -0400

Correct alignment for appending next messages in single user chats.

Also, actually increment our coalesceRounds, and max out at 500 (5s).

diffs (78 lines):

diff -r 6c65e4eeb0db -r 5fd4260e1b0d Plugins/WebKit Message View/Template.html
--- a/Plugins/WebKit Message View/Template.html	Mon Oct 19 18:12:00 2009 -0400
+++ b/Plugins/WebKit Message View/Template.html	Mon Oct 19 19:26:30 2009 -0400
@@ -33,8 +33,8 @@
 					insert.parentNode.removeChild(insert);
 				
 				var documentFragment = document.createDocumentFragment();
-				for (var i = 0; i < self.fragment.children.length; i++) {
-					documentFragment.appendChild(self.fragment.children[i]);
+				while(self.fragment.hasChildNodes()) {
+					documentFragment.appendChild(self.fragment.firstChild);
 				}
 				
 				document.getElementById("Chat").appendChild(documentFragment);
@@ -49,14 +49,15 @@
 			function createHTMLNode(html) {
 				var newMessage = document.createElement("div");
 				newMessage.innerHTML = html;
-				return newMessage.childNodes;
+				return newMessage.firstChild;
 			}
 			
 			this.coalesce = function() {
 				window.clearTimeout(self.timeoutID);
 				self.timeoutID = window.setTimeout(outputHTML, 10);
 				self.isCoalescing = true;
-				if(100 < self.coalesceRounds)
+				self.coalesceRounds += 1;
+				if(500 < self.coalesceRounds)
 					self.cancel();
 			}
 			
@@ -70,24 +71,22 @@
 			}
 			
 			this.append = function(html, shouldScroll) {
+				var node = createHTMLNode(html);
 				var insert = self.fragment.querySelector("#insert");
-				if(insert)
+				if(insert) {
 					insert.parentNode.removeChild(insert);
-				
-				var node = createHTMLNode(html);
-				for (var i = 0; i < node.length; i++) {
-					self.fragment.appendChild(node[i].cloneNode(true));
 				}
+				self.fragment.appendChild(node);
 
 				if(shouldScroll) self.shouldScroll = shouldScroll;
 				self.coalesce();
 			}
 			
 			this.appendNext = function(html, shouldScroll) {
-				insert = self.fragment.querySelector("#insert");
+				var insert = self.fragment.querySelector("#insert");
 				if(insert) {
 					var node = createHTMLNode(html);
-					insert.parentNode.replaceChild(node[0].cloneNode(true),insert);
+					insert.insertBefore(node);
 				} else {
 					self.append(html, shouldScroll);
 				}
@@ -112,7 +111,6 @@
 		function appendNextMessage(html){
 			var shouldScroll = nearBottom();
 			appendNextMessageNoScroll(html, shouldScroll);
-			alignChat(shouldScroll);
 		}
 		
 		function appendNextMessageNoScroll(html, shouldScroll){
@@ -130,6 +128,7 @@
 
 					//swap
 					insert.parentNode.replaceChild(newNode,insert);
+					alignChat(shouldScroll);
 				} else {
 					appendMessageNoScroll(html);
 				}




More information about the commits mailing list