Skip to content

Commit

Permalink
pass whether the post is a root post to the processPostEvent handlers.
Browse files Browse the repository at this point in the history
  • Loading branch information
arhughes committed Mar 10, 2010
1 parent 14c9af1 commit 80ca89f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
5 changes: 4 additions & 1 deletion chromeshack_posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ ChromeShack =

processPost: function(item, root_id)
{
processPostEvent.raise(item, root_id);
var ul = item.parentNode;
var div = ul.parentNode;
var is_root_post = (div.className.indexOf("root") >= 0);
processPostEvent.raise(item, root_id, is_root_post);
},

processPostBox: function(postbox)
Expand Down
4 changes: 2 additions & 2 deletions init_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ Event.prototype.addHandler = function(callback)
this.eventHandlers.push(callback);
}

Event.prototype.raise = function(arg1, arg2)
Event.prototype.raise = function(arg1, arg2, arg3)
{
for (var i = 0; i < this.eventHandlers.length; i++)
{
this.eventHandlers[i](arg1, arg2);
this.eventHandlers[i](arg1, arg2, arg3);
}
}

Expand Down
34 changes: 19 additions & 15 deletions scripts/collapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,31 @@ if (getSetting("enabled_scripts").contains("collapse_threads"))
{
collapsed: getSetting("collapsed_threads"),

toggle: function(item, id)
toggle: function(item, id, is_root_post)
{
var root = document.getElementById("root_" + id);
// only process for root posts
if (root)
if (is_root_post)
{
var postmeta = getDescendentByTagAndClassName(item, "div", "postmeta");
var root = document.getElementById("root_" + id);
// root should never be null, but check anyway
if (root)
{
var postmeta = getDescendentByTagAndClassName(item, "div", "postmeta");

var close = getDescendentByTagAndClassName(postmeta, "a", "closepost");
var show = getDescendentByTagAndClassName(postmeta, "a", "showpost");
close.addEventListener("click", function() { Collapse.close(id); });
show.addEventListener("click", function() { Collapse.show(id); });
var close = getDescendentByTagAndClassName(postmeta, "a", "closepost");
var show = getDescendentByTagAndClassName(postmeta, "a", "showpost");
close.addEventListener("click", function() { Collapse.close(id); });
show.addEventListener("click", function() { Collapse.show(id); });

// this thread should be collapsed
if (Collapse.collapsed.contains(id))
{
root.className += " collapsed";
show.className = "showpost";
close.className = "closepost hidden";
}
// this thread should be collapsed
if (Collapse.collapsed.contains(id))
{
root.className += " collapsed";
show.className = "showpost";
close.className = "closepost hidden";
}

}
}
},

Expand Down

0 comments on commit 80ca89f

Please sign in to comment.