Add a count to the side by side table of contents
Add a count to the side by side table of contents

--- a/css/gitphpskin.css
+++ b/css/gitphpskin.css
@@ -418,8 +418,13 @@
 
 div.commitDiffSBS div.SBSTOC ul
 {
-	margin-left: 5px;
-	padding-left: 5px;
+	margin-left: 8px;
+	padding-left: 8px;
+}
+
+div.commitDiffSBS div.SBSTOC .listcount
+{
+	list-style-type: none;
 }
 
 div.commitDiffSBS .SBSContent

--- a/include/controller/Controller_Commitdiff.class.php
+++ b/include/controller/Controller_Commitdiff.class.php
@@ -138,6 +138,7 @@
 
 		if (isset($this->params['sidebyside']) && ($this->params['sidebyside'] === true)) {
 			$this->tpl->assign('sidebyside', true);
+			$this->tpl->assign('extrascripts', array('commitdiff'));
 		}
 
 		$treediff = new GitPHP_TreeDiff($this->project, $this->params['hash'], (isset($this->params['hashparent']) ? $this->params['hashparent'] : ''));

file:b/js/commitdiff.js (new)
--- /dev/null
+++ b/js/commitdiff.js
@@ -1,1 +1,40 @@
+/*
+ * GitPHP javascript commitdiff
+ * 
+ * Javascript enhancements to make side-by-side
+ * commitdiff more usable
+ *
+ * @author Christopher Han <xiphux@gmail.com>
+ * @copyright Copyright (c) 2011 Christopher Han
+ * @package GitPHP
+ */
 
+var TOCYloc = null;
+var TOCposition = null;
+var TOCtop = null;
+
+function initSBSCommitDiff() {
+	var sbsTOC = $('div.commitDiffSBS div.SBSTOC');
+	if (sbsTOC.size() < 1) {
+		return;
+	}
+
+	TOCYloc = sbsTOC.position().top;
+	TOCposition = sbsTOC.css('position');
+	TOCtop = sbsTOC.css('top');
+	$(window).scroll(function() {
+		var windowYloc = $(document).scrollTop();
+		if (windowYloc > TOCYloc) {
+			sbsTOC.css('position', 'fixed');
+			sbsTOC.css('top', '0px');
+		} else {
+			sbsTOC.css('position', TOCposition);
+			sbsTOC.css('top', TOCtop);
+		}
+	});
+};
+
+$(document).ready(function() {
+	initSBSCommitDiff();
+});
+

--- a/templates/commitdiff.tpl
+++ b/templates/commitdiff.tpl
@@ -37,6 +37,8 @@
 
      <div class="SBSTOC">
        <ul>
+       <li class="listcount">
+       {t count=$treediff->Count() 1=$treediff->Count() plural="%1 files changed:"}%1 file changed:{/t}</li>
        {foreach from=$treediff item=filediff}
        <li>
        <a href="#{$filediff->GetFromHash()}_{$filediff->GetToHash()}">

comments