From 76935f4afa8cd8991b59673aa1471592dbd750be Mon Sep 17 00:00:00 2001
From: Chris Hallberg <crhallberg@gmail.com>
Date: Tue, 22 Jul 2014 12:05:08 -0400
Subject: [PATCH] VuDL fixes to scrolling behaviour and bottom item padding.

---
 themes/bootstrap3/js/vudl/record.js           | 13 +++++++++++++
 themes/bootstrap3/templates/vudl/record.phtml |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/themes/bootstrap3/js/vudl/record.js b/themes/bootstrap3/js/vudl/record.js
index dfd1ce9412d..24d2c76e5cc 100644
--- a/themes/bootstrap3/js/vudl/record.js
+++ b/themes/bootstrap3/js/vudl/record.js
@@ -123,6 +123,9 @@ function scrollToSelected() {
     scrollTop: $('#collapse1 .selected').offset().top-$('#collapse1').offset().top+$('#collapse1').scrollTop()-12
   });
 }
+function scrollAdjust() {
+  $('#collapse1').scrollTop($('#'+topScrollItem).offset().top-$('#collapse1').offset().top+$('#collapse1').scrollTop());
+}
 // Accordion size
 function resizeAccordions(offset) {
   var accordionHeight = window.innerHeight // Window height
@@ -181,6 +184,16 @@ $(document).ready(function() {
   $('#side-nav-toggle').click(toggleSideNav);
   setTimeout(findVisible, 1000);
   ajaxGetView(initPage);
+  // Track top item in the scroll bar
+  $('.accordion-body').scroll(function(e){
+    var pageLinks = $('.page-link');
+    for(var i=0;i<pageLinks.length;i++) {
+      if($(pageLinks[i]).position().top >= 0) {
+        topScrollItem = pageLinks[i].id;
+        break;
+      }
+    }
+  });
 });
 // Initial alignment
 $( window ).load( scrollToSelected );
diff --git a/themes/bootstrap3/templates/vudl/record.phtml b/themes/bootstrap3/templates/vudl/record.phtml
index 722aa026dae..6a6d40d7be5 100644
--- a/themes/bootstrap3/templates/vudl/record.phtml
+++ b/themes/bootstrap3/templates/vudl/record.phtml
@@ -112,7 +112,7 @@
             <? endforeach; ?>
             <!-- POST LOADING PLACEHOLDERS -->
             <? if(isset($this->outline['counts'][$key])): ?>
-              <? for($i=$this->page+count($list);$i<$this->outline['counts'][$key];$i++): ?>
+              <? for($i=$this->initPage+count($list);$i<$this->outline['counts'][$key];$i++): ?>
                 <a class="page-link unloaded" id="item<?=($i) ?>" title="<?=$i ?>">Loading...</a>
               <? endfor; ?>
             <? endif; ?>
-- 
GitLab