Allow side by side commitdiff TOC to show the chosen diff and hide the
Allow side by side commitdiff TOC to show the chosen diff and hide the
rest

--- a/css/gitphp.css
+++ b/css/gitphp.css
@@ -131,6 +131,14 @@
 	width: 50%;
 }
 
+/*
+ * side-by-side commitdiff
+ */
+div.commitDiffSBS div.SBSTOC .showAll
+{
+	display: none;
+}
+
 
 /*
  * Geshi styles

--- a/css/gitphpskin.css
+++ b/css/gitphpskin.css
@@ -416,6 +416,11 @@
 	word-wrap: break-word;
 }
 
+div.commitDiffSBS div.SBSTOC a
+{
+	text-decoration: none;
+}
+
 div.commitDiffSBS div.SBSTOC ul
 {
 	margin-left: 8px;
@@ -425,6 +430,11 @@
 div.commitDiffSBS div.SBSTOC .listcount
 {
 	list-style-type: none;
+}
+
+div.commitDiffSBS div.SBSTOC .activeItem
+{
+	background-color: #edece6;
 }
 
 div.commitDiffSBS .SBSContent

--- a/js/commitdiff.js
+++ b/js/commitdiff.js
@@ -32,6 +32,43 @@
 			sbsTOC.css('top', TOCtop);
 		}
 	});
+
+	$('a.SBSTOCItem').click(function() {
+		var clickedItem = $(this).get(0);
+		$('a.SBSTOCItem').each(function(index, value) {
+			if (clickedItem == value) {
+				$(this).parent().addClass('activeItem');
+			} else {
+				$(this).parent().removeClass('activeItem');
+			}
+		});
+		var clickedId = $(this).attr('href').substring(1);
+		$('div.diffBlob').each(function() {
+			if ($(this).attr('id') == clickedId) {
+				$(this).slideDown('fast');
+			} else {
+				$(this).slideUp('fast');
+			}
+		});
+		$('a.showAll').show();
+		if ($(document).scrollTop() > $('div.SBSContent').offset().top) {
+			$('html, body').animate({
+				scrollTop: $('div.SBSContent').offset().top
+			}, 200);
+		}
+		return false;
+	});
+	$('a.showAll').click(function() {
+		$('a.SBSTOCItem').parent().removeClass('activeItem');
+		$('div.diffBlob').slideDown('fast');
+		$(this).hide();
+		if ($(document).scrollTop() > $('div.SBSContent').offset().top) {
+			$('html, body').animate({
+				scrollTop: $('div.SBSContent').offset().top
+			}, 200);
+		}
+		return false;
+	});
 };
 
 $(document).ready(function() {

--- a/templates/commitdiff.tpl
+++ b/templates/commitdiff.tpl
@@ -38,10 +38,10 @@
      <div class="SBSTOC">
        <ul>
        <li class="listcount">
-       {t count=$treediff->Count() 1=$treediff->Count() plural="%1 files changed:"}%1 file changed:{/t}</li>
+       {t count=$treediff->Count() 1=$treediff->Count() plural="%1 files changed:"}%1 file changed:{/t} <a href="#" class="showAll">(show all)</a></li>
        {foreach from=$treediff item=filediff}
        <li>
-       <a href="#{$filediff->GetFromHash()}_{$filediff->GetToHash()}">
+       <a href="#{$filediff->GetFromHash()}_{$filediff->GetToHash()}" class="SBSTOCItem">
        {if $filediff->GetStatus() == 'A'}
          {if $filediff->GetToFile()}{$filediff->GetToFile()}{else}{$filediff->GetToHash()}{/if} {t}(new){/t}
        {elseif $filediff->GetStatus() == 'D'}

comments