Move expand/collapse in separate function

This commit is contained in:
Jesse van den Kieboom 2013-12-28 15:50:22 +01:00
parent 09d8641b1d
commit 7c91a7e3ff

View file

@ -123,6 +123,27 @@ function write_commit(commit)
var html_builder_worker = 0;
var html_builder_tick = 0;
function expand_collapse()
{
var expander = $(this);
// If expanded, will be true
var toExpand = expander.text() == "+";
if (toExpand)
{
// next step to close it
expander.text("-");
}
else
{
// next step is to open it
expander.text("+");
}
expander.closest('tbody').toggleClass("collapsed");
}
function update_diff(id, lsettings)
{
if (html_builder_worker)
@ -192,26 +213,7 @@ function update_diff(id, lsettings)
content.html(event.data.diff_html);
$(".expander").click(function()
{
var expander = $(this);
// If expanded, will be true
var toExpand = expander.text() == "+";
if (toExpand)
{
// next step to close it
expander.text("-");
}
else
{
// next step is to open it
expander.text("+");
}
expander.closest('tbody').toggleClass("collapsed");
});
$(".expander").click(expand_collapse);
}
}