Skip to content
Snippets Groups Projects
Commit 97c73f81 authored by Chris Hallberg's avatar Chris Hallberg
Browse files

Merge cleanup and simplification from PR 510.

parent 7f1e8aa4
No related merge requests found
...@@ -151,18 +151,13 @@ function ajaxLoadTab($newTab, tabid, setHash) { ...@@ -151,18 +151,13 @@ function ajaxLoadTab($newTab, tabid, setHash) {
var urlroot = '/' + chunks[0] + '/' + chunks[1]; 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: // Request the tab via AJAX:
$.ajax({ $.ajax({
url: path + urlroot + '/AjaxTab', url: path + urlroot + '/AjaxTab',
type: 'POST', type: 'POST',
data: {tab: tabid}, data: {tab: tabid},
success: function(data) { success: function(data) {
$newTab.html(data).addClass('active'); $newTab.html(data);
$newTab.closest('.record-tabs').find('.'+tabid).tab('show');
registerTabEvents(); registerTabEvents();
if(typeof syn_get_widget === "function") { if(typeof syn_get_widget === "function") {
syn_get_widget(); syn_get_widget();
...@@ -238,7 +233,7 @@ function applyRecordTabHash() { ...@@ -238,7 +233,7 @@ function applyRecordTabHash() {
if (newTab.length == 0 || newTab == '#tabnav') { if (newTab.length == 0 || newTab == '#tabnav') {
$initiallyActiveTab.click(); $initiallyActiveTab.click();
} else if (newTab.length > 0 && '#' + activeTab != newTab) { } else if (newTab.length > 0 && '#' + activeTab != newTab) {
$(newTab).click(); $('.'+newTab.substr(1)).click();
} }
} }
...@@ -286,9 +281,9 @@ function recordDocReady() { ...@@ -286,9 +281,9 @@ function recordDocReady() {
var tabid = this.className; var tabid = this.className;
var $top = $(this).closest('.record-tabs'); var $top = $(this).closest('.record-tabs');
$top.find('.tab-pane.active').removeClass('active'); $top.find('.tab-pane.active').removeClass('active');
$(this).tab('show');
if ($top.find('.'+tabid+'-tab').length > 0) { if ($top.find('.'+tabid+'-tab').length > 0) {
$top.find('.'+tabid+'-tab').addClass('active'); $top.find('.'+tabid+'-tab').addClass('active');
$(this).tab('show');
window.location.hash = tabid; window.location.hash = tabid;
return false; return false;
} else { } else {
...@@ -298,10 +293,9 @@ function recordDocReady() { ...@@ -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>'); 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); $top.find('.tab-content').append(newTab);
return ajaxLoadTab(newTab, tabid); return ajaxLoadTab(newTab, tabid, !$(this).parent().hasClass('initiallyActive'));
} }
}); });
$('.initiallyActive a').click();
applyRecordTabHash(); applyRecordTabHash();
/* --- LIGHTBOX --- */ /* --- LIGHTBOX --- */
......
...@@ -78,10 +78,12 @@ ...@@ -78,10 +78,12 @@
<? endif; ?> <? endif; ?>
<div class="collectionDetails<?=$tree ? 'Tree' : ''?> tab-content" id="record-tabs"> <div class="tab-content record-tabs collectionDetails<?=$tree ? 'Tree' : ''?>">
<div class="tab-pane active" id="<?=$this->activeTab ?>-tab"> <? if (!$this->ajaxTabs || !isset($activeTabObj) || !$activeTabObj->supportsAjax()): ?>
<?=isset($activeTabObj) ? $this->record($this->driver)->getTab($activeTabObj) : '' ?> <div class="tab-pane active <?=$this->activeTab ?>-tab">
</div> <?=isset($activeTabObj) ? $this->record($this->driver)->getTab($activeTabObj) : '' ?>
</div>
<? endif ?>
</div> </div>
<?=$this->driver->supportsCoinsOpenURL()?'<span class="Z3988" title="'.$this->escapeHtmlAttr($this->driver->getCoinsOpenURL()).'"></span>':''?> <?=$this->driver->supportsCoinsOpenURL()?'<span class="Z3988" title="'.$this->escapeHtmlAttr($this->driver->getCoinsOpenURL()).'"></span>':''?>
......
...@@ -74,9 +74,9 @@ ...@@ -74,9 +74,9 @@
<? endforeach; ?> <? endforeach; ?>
</ul> </ul>
<div class="tab-content" id="record-tabs"> <div class="tab-content record-tabs">
<? if (!$this->ajaxTabs || !isset($activeTabObj) || !$activeTabObj->supportsAjax()): ?> <? 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) : '' ?> <?=isset($activeTabObj) ? $this->record($this->driver)->getTab($activeTabObj) : '' ?>
</div> </div>
<? endif; ?> <? endif; ?>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment