From 97c73f814196a156b1cd96ae168c3cac4b07de24 Mon Sep 17 00:00:00 2001 From: Chris Hallberg <crhallberg@gmail.com> Date: Wed, 2 Dec 2015 12:26:04 -0500 Subject: [PATCH] Merge cleanup and simplification from PR 510. --- themes/bootstrap3/js/record.js | 14 ++++---------- themes/bootstrap3/templates/collection/view.phtml | 10 ++++++---- themes/bootstrap3/templates/record/view.phtml | 4 ++-- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/themes/bootstrap3/js/record.js b/themes/bootstrap3/js/record.js index 73e64b1bbbb..fb0ab767abb 100644 --- a/themes/bootstrap3/js/record.js +++ b/themes/bootstrap3/js/record.js @@ -151,18 +151,13 @@ function ajaxLoadTab($newTab, tabid, setHash) { var urlroot = '/' + chunks[0] + '/' + chunks[1]; } - $('#record-tabs .tab-pane.active').removeClass('active'); - $('.'+tabid+'-tab').addClass('active'); - $('.'+tabid).tab('show'); - // Request the tab via AJAX: $.ajax({ url: path + urlroot + '/AjaxTab', type: 'POST', data: {tab: tabid}, success: function(data) { - $newTab.html(data).addClass('active'); - $newTab.closest('.record-tabs').find('.'+tabid).tab('show'); + $newTab.html(data); registerTabEvents(); if(typeof syn_get_widget === "function") { syn_get_widget(); @@ -238,7 +233,7 @@ function applyRecordTabHash() { if (newTab.length == 0 || newTab == '#tabnav') { $initiallyActiveTab.click(); } else if (newTab.length > 0 && '#' + activeTab != newTab) { - $(newTab).click(); + $('.'+newTab.substr(1)).click(); } } @@ -286,9 +281,9 @@ function recordDocReady() { var tabid = this.className; var $top = $(this).closest('.record-tabs'); $top.find('.tab-pane.active').removeClass('active'); + $(this).tab('show'); if ($top.find('.'+tabid+'-tab').length > 0) { $top.find('.'+tabid+'-tab').addClass('active'); - $(this).tab('show'); window.location.hash = tabid; return false; } else { @@ -298,10 +293,9 @@ function recordDocReady() { } var newTab = $('<div class="tab-pane active '+tabid+'-tab"><i class="fa fa-spinner fa-spin"></i> '+VuFind.translate('loading')+'...</div>'); $top.find('.tab-content').append(newTab); - return ajaxLoadTab(newTab, tabid); + return ajaxLoadTab(newTab, tabid, !$(this).parent().hasClass('initiallyActive')); } }); - $('.initiallyActive a').click(); applyRecordTabHash(); /* --- LIGHTBOX --- */ diff --git a/themes/bootstrap3/templates/collection/view.phtml b/themes/bootstrap3/templates/collection/view.phtml index b84d64f33de..8f9e9047502 100644 --- a/themes/bootstrap3/templates/collection/view.phtml +++ b/themes/bootstrap3/templates/collection/view.phtml @@ -78,10 +78,12 @@ <? endif; ?> - <div class="collectionDetails<?=$tree ? 'Tree' : ''?> tab-content" id="record-tabs"> - <div class="tab-pane active" id="<?=$this->activeTab ?>-tab"> - <?=isset($activeTabObj) ? $this->record($this->driver)->getTab($activeTabObj) : '' ?> - </div> + <div class="tab-content record-tabs collectionDetails<?=$tree ? 'Tree' : ''?>"> + <? if (!$this->ajaxTabs || !isset($activeTabObj) || !$activeTabObj->supportsAjax()): ?> + <div class="tab-pane active <?=$this->activeTab ?>-tab"> + <?=isset($activeTabObj) ? $this->record($this->driver)->getTab($activeTabObj) : '' ?> + </div> + <? endif ?> </div> <?=$this->driver->supportsCoinsOpenURL()?'<span class="Z3988" title="'.$this->escapeHtmlAttr($this->driver->getCoinsOpenURL()).'"></span>':''?> diff --git a/themes/bootstrap3/templates/record/view.phtml b/themes/bootstrap3/templates/record/view.phtml index 0b6f84b25c4..934cfb6fb68 100644 --- a/themes/bootstrap3/templates/record/view.phtml +++ b/themes/bootstrap3/templates/record/view.phtml @@ -74,9 +74,9 @@ <? endforeach; ?> </ul> - <div class="tab-content" id="record-tabs"> + <div class="tab-content record-tabs"> <? if (!$this->ajaxTabs || !isset($activeTabObj) || !$activeTabObj->supportsAjax()): ?> - <div class="tab-pane active" id="<?=$this->activeTab ?>-tab"> + <div class="tab-pane active <?=$this->activeTab ?>-tab"> <?=isset($activeTabObj) ? $this->record($this->driver)->getTab($activeTabObj) : '' ?> </div> <? endif; ?> -- GitLab