hgweb: toggleDiffstat function instead of showDiffstat and hideDiffstat
This eliminates the need of two almost equal functions, makes the code cleaner.
--- a/mercurial/templates/paper/changeset.tmpl Wed Jul 03 21:50:20 2013 +0900
+++ b/mercurial/templates/paper/changeset.tmpl Fri Jul 12 16:01:11 2013 +0400
@@ -66,9 +66,9 @@
<th class="diffstat">diffstat</th>
<td class="diffstat">
{diffsummary}
- <a id="diffstatexpand" href="javascript:showDiffstat()"/>[<tt>+</tt>]</a>
+ <a id="diffstatexpand" href="javascript:toggleDiffstat()"/>[<tt>+</tt>]</a>
<div id="diffstatdetails" style="display:none;">
- <a href="javascript:hideDiffstat()"/>[<tt>-</tt>]</a>
+ <a href="javascript:toggleDiffstat()"/>[<tt>-</tt>]</a>
<p>
<table>{diffstat}</table>
</div>
--- a/mercurial/templates/static/mercurial.js Wed Jul 03 21:50:20 2013 +0900
+++ b/mercurial/templates/static/mercurial.js Fri Jul 12 16:01:11 2013 +0400
@@ -265,12 +265,9 @@
}
})(document, RegExp, Math, isNaN, Date, false, true)
-function showDiffstat() {
- document.getElementById('diffstatdetails').style.display = 'inline';
- document.getElementById('diffstatexpand').style.display = 'none';
+function toggleDiffstat() {
+ var curdetails = document.getElementById('diffstatdetails').style.display;
+ var curexpand = curdetails == 'none' ? 'inline' : 'none';
+ document.getElementById('diffstatdetails').style.display = curexpand;
+ document.getElementById('diffstatexpand').style.display = curdetails;
}
-
-function hideDiffstat() {
- document.getElementById('diffstatdetails').style.display = 'none';
- document.getElementById('diffstatexpand').style.display = 'inline';
-}
--- a/tests/test-hgweb-commands.t Wed Jul 03 21:50:20 2013 +0900
+++ b/tests/test-hgweb-commands.t Fri Jul 12 16:01:11 2013 +0400
@@ -423,9 +423,9 @@
<td class="diffstat">
2 files changed, 2 insertions(+), 0 deletions(-)
- <a id="diffstatexpand" href="javascript:showDiffstat()"/>[<tt>+</tt>]</a>
+ <a id="diffstatexpand" href="javascript:toggleDiffstat()"/>[<tt>+</tt>]</a>
<div id="diffstatdetails" style="display:none;">
- <a href="javascript:hideDiffstat()"/>[<tt>-</tt>]</a>
+ <a href="javascript:toggleDiffstat()"/>[<tt>-</tt>]</a>
<p>
<table> <tr class="parity0">
<td class="diffstat-file"><a href="#l1.1">da/foo</a></td>
--- a/tests/test-hgweb-diffs.t Wed Jul 03 21:50:20 2013 +0900
+++ b/tests/test-hgweb-diffs.t Fri Jul 12 16:01:11 2013 +0400
@@ -115,9 +115,9 @@
<td class="diffstat">
2 files changed, 2 insertions(+), 0 deletions(-)
- <a id="diffstatexpand" href="javascript:showDiffstat()"/>[<tt>+</tt>]</a>
+ <a id="diffstatexpand" href="javascript:toggleDiffstat()"/>[<tt>+</tt>]</a>
<div id="diffstatdetails" style="display:none;">
- <a href="javascript:hideDiffstat()"/>[<tt>-</tt>]</a>
+ <a href="javascript:toggleDiffstat()"/>[<tt>-</tt>]</a>
<p>
<table> <tr class="parity0">
<td class="diffstat-file"><a href="#l1.1">a</a></td>
@@ -376,9 +376,9 @@
<td class="diffstat">
2 files changed, 2 insertions(+), 0 deletions(-)
- <a id="diffstatexpand" href="javascript:showDiffstat()"/>[<tt>+</tt>]</a>
+ <a id="diffstatexpand" href="javascript:toggleDiffstat()"/>[<tt>+</tt>]</a>
<div id="diffstatdetails" style="display:none;">
- <a href="javascript:hideDiffstat()"/>[<tt>-</tt>]</a>
+ <a href="javascript:toggleDiffstat()"/>[<tt>-</tt>]</a>
<p>
<table> <tr class="parity0">
<td class="diffstat-file"><a href="#l1.1">a</a></td>
--- a/tests/test-hgweb-removed.t Wed Jul 03 21:50:20 2013 +0900
+++ b/tests/test-hgweb-removed.t Fri Jul 12 16:01:11 2013 +0400
@@ -96,9 +96,9 @@
<td class="diffstat">
1 files changed, 0 insertions(+), 1 deletions(-)
- <a id="diffstatexpand" href="javascript:showDiffstat()"/>[<tt>+</tt>]</a>
+ <a id="diffstatexpand" href="javascript:toggleDiffstat()"/>[<tt>+</tt>]</a>
<div id="diffstatdetails" style="display:none;">
- <a href="javascript:hideDiffstat()"/>[<tt>-</tt>]</a>
+ <a href="javascript:toggleDiffstat()"/>[<tt>-</tt>]</a>
<p>
<table> <tr class="parity0">
<td class="diffstat-file"><a href="#l1.1">a</a></td>