Skip to content
Snippets Groups Projects
Commit d89cd7c7 authored by Ximin Luo's avatar Ximin Luo
Browse files

html-dir output: add +/- buttons to toggle visibility of parts of the diff

parent 4727cce3
No related branches found
No related tags found
No related merge requests found
......@@ -156,6 +156,15 @@ HEADER = """<!DOCTYPE html>
background: #faa;
cursor: pointer;
}
.diffcontrol {
float: left;
margin-right: 0.3em;
cursor: pointer;
display: none; /* currently, only available in html-dir output where jquery is enabled */
}
.diffcontrol-double {
line-height: 200%%;
}
</style>
%(css_link)s
</head>
......@@ -192,6 +201,26 @@ $(function() {
return false;
};
$(".ondemand td").on('click', load_cont);
var diffcontrols = $(".diffcontrol")
diffcontrols.on('click', function(evt) {
var control = $(this);
var target = control.parent().siblings('table.diff, div.difference');
var orig = target;
if (evt.shiftKey) {
var parent = control.parent().parent();
control = parent.find('.diffcontrol');
target = parent.find('table.diff, div.difference');
}
if (orig.is(":visible")) {
target.hide();
control.text("[+]");
} else {
target.show();
control.text("[−]");
}
});
diffcontrols.attr('title','shift-click to show/hide all children too.');
diffcontrols.show();
});
</script>
"""
......@@ -661,9 +690,11 @@ def output_difference(difference, print_func, css_url, directory, parents):
try:
print_func(u"<div class='diffheader'>")
if difference.source1 == difference.source2:
print_func(u"<div class='diffcontrol'>[−]</div>")
print_func(u"<div><span class='source'>%s<span>"
% html.escape(difference.source1))
else:
print_func(u"<div class='diffcontrol diffcontrol-double'>[−]</div>")
print_func(u"<div><span class='source'>%s</span> vs.</div>"
% html.escape(difference.source1))
print_func(u"<div><span class='source'>%s</span>"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment