Allow side by side commitdiff TOC to show the chosen diff and hide the
[gitphp.git] / js / commitdiff.js
blob:a/js/commitdiff.js -> blob:b/js/commitdiff.js
--- 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() {

comments