adium-1.4 2697:f5cbe34603f0: A few fixes to Template.html and Re...
commits at adium.im
commits at adium.im
Sat Oct 31 05:38:36 UTC 2009
details: http://hg.adium.im/adium-1.4/rev/f5cbe34603f0
revision: 2697:f5cbe34603f0
author: Stephen Holt <sholt at adium.im>
date: Sat Oct 31 01:35:18 2009 -0400
A few fixes to Template.html and Renkoo message style:
* Template.html:
* Add CoalescedHTML.setAppendElementMethod(func): This allows a theme to adjust the default way nodes are appended to the DOM.
* the supplied function takes a documentFragment.
* Renkoo:
* Fix smooth scroll and fade-in (for last element added in a coalescing session only).
* Fix #insert position in nextContent template.
diffs (162 lines):
diff -r e8fd2be67e50 -r f5cbe34603f0 Plugins/WebKit Message View/Template.html
--- a/Plugins/WebKit Message View/Template.html Fri Oct 30 21:43:45 2009 -0400
+++ b/Plugins/WebKit Message View/Template.html Sat Oct 31 01:35:18 2009 -0400
@@ -28,6 +28,19 @@
this.isConsecutive = undefined;
this.shouldScroll = undefined;
+ var appendElement = undefined;
+
+ // hook in a custom method to append new data
+ // to the chat.
+ this.setAppendElementMethod = function (func) {
+ if(typeof func === 'function')
+ appendElement = func;
+ }
+
+ this.setAppendElementMethod(function (elem) {
+ document.getElementById("Chat").appendChild(elem);
+ });
+
function outputHTML() {
var insert = document.getElementById("insert");
if(!!insert && self.isConsecutive) {
@@ -36,7 +49,7 @@
if(insert)
insert.parentNode.removeChild(insert);
// insert the documentFragment into the live DOM
- document.getElementById("Chat").appendChild(self.fragment);
+ appendElement(self.fragment);
}
alignChat(self.shouldScroll);
@@ -294,9 +307,10 @@
alignChat(true/*nearBottom()*/); //nearBottom buggy with inactive tabs
}
- function adiumOnLoad() {
+ function initStyle() {
alignChat(true);
- coalescedHTML = new CoalescedHTML();
+ if(!coalescedHTML)
+ coalescedHTML = new CoalescedHTML();
}
</script>
@@ -320,7 +334,7 @@
</style>
</head>
-<body onload="adiumOnLoad();" style="==bodyBackground==">
+<body onload="initStyle();" style="==bodyBackground==">
%@
<div id="Chat">
</div>
diff -r e8fd2be67e50 -r f5cbe34603f0 Resources/Message Styles/renkoo.AdiumMessageStyle/Contents/Resources/Footer.html
--- a/Resources/Message Styles/renkoo.AdiumMessageStyle/Contents/Resources/Footer.html Fri Oct 30 21:43:45 2009 -0400
+++ b/Resources/Message Styles/renkoo.AdiumMessageStyle/Contents/Resources/Footer.html Sat Oct 31 01:35:18 2009 -0400
@@ -176,42 +176,48 @@
Fadomatic.prototype._updateOpacity = null;
+ // overload scrollingo for smooth scroll.
+ var intervall_scroll;
+ function scrollToBottom() {
+ //document.body.scrollTop = (document.body.scrollHeight-window.innerHeight);
+ //return;
+ if ( intervall_scroll ) clearInterval( intervall_scroll );
+ intervall_scroll = setInterval( function() {
+ var target_scroll = (document.body.scrollHeight-window.innerHeight);
+ var scrolldiff = target_scroll - document.body.scrollTop;
+ if ( document.body.scrollTop != target_scroll ) {
+ var saved_scroll = document.body.scrollTop;
+ document.body.scrollTop += scrolldiff / 5 + ( scrolldiff >= 0 ? (scrolldiff != 0 ) : -1 );
+ } else {
+ saved_scroll = -1;
+ clearInterval( intervall_scroll );
+ }
+ } , 10 );
+ return;
+ }
// Override CoalescedHTML methods
- function outputHTML() {
- var insert = document.getElementById("insert");
- if(!!insert && coalescedHTML.isConsecutive) {
- insert.parentNode.replaceChild(coalescedHTML.fragment, insert);
- } else {
- if(insert)
- insert.parentNode.removeChild(insert);
- // insert the documentFragment into the live DOM
- try {
- var fader = new Fadomatic(coalescedHTML.fragment, 9, 0, 0, 95);
- } catch(e) {
- trace(e);
- }
- fader.fadeIn();
+ function initStyle() {
+ if(null == document.getElementById("heading")){
+ document.getElementsByTagName('body').item(0).style.marginTop = "5px";
}
- alignChat(coalescedHTML.shouldScroll);
-
- // reset state to empty/non-coalescing
- coalescedHTML.shouldScroll = undefined;
- coalescedHTML.isConsecutive = undefined;
- coalescedHTML.isCoalescing = false;
- coalescedHTML.coalesceRounds = 0;
- }
-
- CoalescedHTML.prototype.coalesce = function() {
- window.clearTimeout(this.timeoutID);
- this.timeoutID = window.setTimeout(outputHTML, 25);
- this.isCoalescing = true;
- this.coalesceRounds += 1;
- if(400 < self.coalesceRounds)
- this.cancel();
+ if(!coalescedHTML)
+ coalescedHTML = new CoalescedHTML();
+
+ coalescedHTML.setAppendElementMethod(function (elem) {
+ document.getElementById("Chat").appendChild(elem);
+ if(!coalescedHTML.isConsecutive) {
+ var node = document.getElementById("Chat").lastElementChild;
+ try {
+ var fader = new Fadomatic(node, 9, 0, 0, 95);
+ } catch (e) {
+ appendHTML("<p>" + e + "</p>");
+ }
+ fader.fadeIn();
+ }
+ alignChat(true);
+ });
}
-
-
</script>
\ No newline at end of file
diff -r e8fd2be67e50 -r f5cbe34603f0 Resources/Message Styles/renkoo.AdiumMessageStyle/Contents/Resources/Incoming/NextContent.html
--- a/Resources/Message Styles/renkoo.AdiumMessageStyle/Contents/Resources/Incoming/NextContent.html Fri Oct 30 21:43:45 2009 -0400
+++ b/Resources/Message Styles/renkoo.AdiumMessageStyle/Contents/Resources/Incoming/NextContent.html Sat Oct 31 01:35:18 2009 -0400
@@ -5,6 +5,5 @@
%message%
<div class="timeStamp">%time%</div>
</div>
- <span id="insert"></span>
</div>
-
+<span id="insert"></span>
\ No newline at end of file
diff -r e8fd2be67e50 -r f5cbe34603f0 Resources/Message Styles/renkoo.AdiumMessageStyle/Contents/Resources/Outgoing/NextContent.html
--- a/Resources/Message Styles/renkoo.AdiumMessageStyle/Contents/Resources/Outgoing/NextContent.html Fri Oct 30 21:43:45 2009 -0400
+++ b/Resources/Message Styles/renkoo.AdiumMessageStyle/Contents/Resources/Outgoing/NextContent.html Sat Oct 31 01:35:18 2009 -0400
@@ -4,6 +4,5 @@
%message%
<div class="timeStamp">%time%</div>
</div>
- <span id="insert"></span>
</div>
-
+<span id="insert"></span>
More information about the commits
mailing list