From f371abcce8947f7ddb88a0ae7a4f7f9bc7290e77 Mon Sep 17 00:00:00 2001 From: Chris Hallberg <crhallberg@gmail.com> Date: Tue, 22 Jul 2014 12:07:23 -0400 Subject: [PATCH] VuDL fix 2 - Bootstrap 2 --- themes/bootstrap/js/vudl/record.js | 17 +++++++++++++++-- themes/bootstrap/templates/vudl/record.phtml | 12 ++++++------ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/themes/bootstrap/js/vudl/record.js b/themes/bootstrap/js/vudl/record.js index 697c3318010..13a75a9032c 100644 --- a/themes/bootstrap/js/vudl/record.js +++ b/themes/bootstrap/js/vudl/record.js @@ -115,7 +115,7 @@ function prevPage() { $('.page-link.selected').prev('.page-link').click(); scrollToSelected(); } -function nextPage() { +function nextPage() { $('.page-link.selected').next('.page-link').click(); scrollToSelected(); } @@ -124,6 +124,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 @@ -168,7 +171,7 @@ $(document).ready(function() { $('.page-link').click(function() { $('.page-link.selected').removeClass('selected'); $(this).addClass('selected'); - }); + }); // Load clicked items $('.unloaded').click(function() { scrollToSelected(); @@ -182,6 +185,16 @@ $(document).ready(function() { }); 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/bootstrap/templates/vudl/record.phtml b/themes/bootstrap/templates/vudl/record.phtml index 3195f1fe3a0..bcfd2e4e047 100644 --- a/themes/bootstrap/templates/vudl/record.phtml +++ b/themes/bootstrap/templates/vudl/record.phtml @@ -1,12 +1,12 @@ <? $this->headTitle($this->translate($this->title) .' - '. $this->details['title']['value']); - + // Multiple breadcrumbs $this->layout()->breadcrumbs = $this->parents; $this->layout()->title = $this->details['title']['value']; $this->layout()->breadcrumbEnd = $this->breadcrumbEnd; $this->layout()->from = $this->from; - + // Get first list name foreach($this->outline as $list=>$v) { if($list == 'counts') continue; @@ -34,14 +34,14 @@ // AUDIO //$this->headLink()->appendStylesheet('jplayer.css'); $this->headScript()->appendFile('http://www.google.com/jsapi'); - + // Compact header $this->layout()->headerType = 'record'; $this->layout()->vudlID = $this->id; $this->layout()->hierarchyID = $this->hierarchyID; $this->layout()->parents = $this->parents; $this->layout()->siblings = $this->siblings; - + function json_php_encode($op, $quotes = false) { if($quotes) { return str_replace('"', "'", str_replace("'", "\\'", str_replace('\/', '/', json_encode($op)))); @@ -54,7 +54,7 @@ google.load("swfobject", "2.2"); var documentID = '<?=$this->id ?>'; var initPage = $.parseJSON('<?=json_encode($this->outline['lists'][$this->initList][$this->initPage], JSON_HEX_APOS | JSON_HEX_AMP) ?>'); - + counts = $.parseJSON('<?=json_encode($this->outline['counts'], JSON_HEX_APOS | JSON_HEX_AMP) ?>'); <? if(count($this->outline['lists'][0]) >= $this->outline['counts'][0]): ?> loading_pages = false; @@ -123,7 +123,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