[diffoscope] 01/01: html-dir output: add +/- buttons to toggle visibility of parts of the diff
Ximin Luo
infinity0 at debian.org
Fri Dec 2 11:55:10 CET 2016
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch master
in repository diffoscope.
commit d89cd7c7a46436bb9118a87795c8b105446b480a
Author: Ximin Luo <infinity0 at debian.org>
Date: Fri Dec 2 11:55:02 2016 +0100
html-dir output: add +/- buttons to toggle visibility of parts of the diff
---
diffoscope/presenters/html.py | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/diffoscope/presenters/html.py b/diffoscope/presenters/html.py
index 599a052..8f6c89d 100644
--- a/diffoscope/presenters/html.py
+++ b/diffoscope/presenters/html.py
@@ -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>"
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list