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

Don't show +/- controls for differences with no children

parent 8b88f0e4
No related branches found
No related tags found
No related merge requests found
......@@ -121,6 +121,12 @@ class Difference(object):
sum(v.size() for v in self._visuals))
return self._size_cache
def has_children(self):
"""Whether there are children.
Useful for e.g. choosing whether to display [+]/[-] controls."""
return self._unified_diff is not None or self._details or self._visuals
@staticmethod
def from_feeder(feeder1, feeder2, path1, path2, source=None, comment=None, **kwargs):
try:
......
......@@ -486,12 +486,13 @@ def output_difference(difference, print_func, css_url, directory, parents):
print_func(u'<div class="difference">')
try:
print_func(u'<div class="diffheader">')
diffcontrol = ("diffcontrol", u'[−]') if difference.has_children() else ("diffcontrol-nochildren", u'[∘]')
if difference.source1 == difference.source2:
print_func(u'<div class="diffcontrol">[−]</div>')
print_func(u'<div class="%s">%s</div>' % diffcontrol)
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 class="%s diffcontrol-double">%s</div>' % diffcontrol)
print_func(u'<div><span class="source">%s</span> vs.</div>'
% html.escape(difference.source1))
print_func(u'<div><span class="source">%s</span>'
......
......@@ -119,7 +119,7 @@ HEADER = """<!DOCTYPE html>
background: #faa;
cursor: pointer;
}
.diffoscope .diffcontrol {
.diffoscope .diffcontrol, .diffoscope .diffcontrol-nochildren {
float: left;
margin-right: 0.3em;
cursor: pointer;
......@@ -190,6 +190,7 @@ $(function() {
});
diffcontrols.attr('title','shift-click to show/hide all children too.');
diffcontrols.show();
$(".diffcontrol-nochildren").show();
});
</script>
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment