diff --git a/module/VuFind/src/VuFind/RecordTab/AbstractBase.php b/module/VuFind/src/VuFind/RecordTab/AbstractBase.php index fad767f1ffea70be9ae61b82b7182f51e6d562e8..a88673550007997b907c19244016b3c83d8ed1a0 100644 --- a/module/VuFind/src/VuFind/RecordTab/AbstractBase.php +++ b/module/VuFind/src/VuFind/RecordTab/AbstractBase.php @@ -74,6 +74,17 @@ abstract class AbstractBase implements TabInterface return true; } + /** + * Can this tab be loaded via AJAX? + * + * @return bool + */ + public function supportsAjax() + { + // Assume we can load by AJAX; subclasses may add rules. + return true; + } + /** * Set the record driver * diff --git a/module/VuFind/src/VuFind/RecordTab/Map.php b/module/VuFind/src/VuFind/RecordTab/Map.php index 7ba348de69a634545af1d4f6bb54b7e5845a70d7..6161004bd39bae38c992aa0861deb384e37645d5 100644 --- a/module/VuFind/src/VuFind/RecordTab/Map.php +++ b/module/VuFind/src/VuFind/RecordTab/Map.php @@ -55,6 +55,17 @@ class Map extends AbstractBase $this->enabled = $enabled; } + /** + * Can this tab be loaded via AJAX? + * + * @return bool + */ + public function supportsAjax() + { + // No, Google script magic required + return false; + } + /** * Get the on-screen description for this tab. * diff --git a/themes/bootstrap3/js/record.js b/themes/bootstrap3/js/record.js index 7780b98786fbc391270a81d079f53dccc3535eb9..c6fbf98627d89eef7c237eaccbf36aa29a563c9b 100644 --- a/themes/bootstrap3/js/record.js +++ b/themes/bootstrap3/js/record.js @@ -150,9 +150,11 @@ function registerTabEvents() { function ajaxLoadTab(tabid) { var id = $('.hiddenId')[0].value; - // Grab the part of the url that is the Controller and Record ID + // Try to parse out the controller portion of the URL. If this fails, or if + // we're flagged to skip AJAX for this tab, just return true and let the + // browser handle it. var urlroot = document.URL.match(new RegExp('/[^/]+/'+id)); - if(!urlroot) { + if(!urlroot || document.getElementById(tabid).parentNode.className.indexOf('noajax') > -1) { return true; } $.ajax({ diff --git a/themes/bootstrap3/templates/collection/view.phtml b/themes/bootstrap3/templates/collection/view.phtml index 54f5b7bffca04a0e18dbf6b9e61679ed55501a5f..2bd1d8491fbd2f330049d095a99060bd633c4e81 100644 --- a/themes/bootstrap3/templates/collection/view.phtml +++ b/themes/bootstrap3/templates/collection/view.phtml @@ -61,13 +61,16 @@ <? foreach ($this->tabs as $tab => $obj): ?> <? // add current tab to breadcrumbs if applicable: $desc = $obj->getDescription(); - $isCurrent = (strtolower($this->activeTab) == strtolower($tab)); - if ($isCurrent) { + $tab_classes = array(); + if (0 === strcasecmp($this->activeTab, $tab)) { + $tab_classes[] = 'active'; $this->layout()->breadcrumbs .= ' <li class="active">' . $this->transEsc($desc) . '</li>'; $activeTabObj = $obj; } + if (!$obj->isVisible()) { $tab_classes = 'hidden'; } + if (!$obj->supportsAjax()) { $tab_classes = 'noajax'; } ?> - <li<?=$isCurrent ? ' class="active"' : ''?>> + <li<?=count($tab_classes) > 0 ? ' class="' . implode(' ', $tab_classes) . '"' : ''?>> <a id="<?=strtolower($tab) ?>" href="<?=$this->recordLink()->getTabUrl($this->driver, $tab)?>#tabnav"><?=$this->transEsc($desc)?></a> </li> <? endforeach; ?> diff --git a/themes/bootstrap3/templates/record/view.phtml b/themes/bootstrap3/templates/record/view.phtml index cf36cc3d14f54719a51ada8ef74b38f40c8d6337..aca9e7e39810970bf36d02d20a73330e4a311fdd 100644 --- a/themes/bootstrap3/templates/record/view.phtml +++ b/themes/bootstrap3/templates/record/view.phtml @@ -55,14 +55,14 @@ <? foreach ($this->tabs as $tab => $obj): ?> <? // add current tab to breadcrumbs if applicable: $desc = $obj->getDescription(); - $isCurrent = (strtolower($this->activeTab) == strtolower($tab)); - if ($isCurrent) { + $tab_classes = array(); + if (0 === strcasecmp($this->activeTab, $tab)) { + $tab_classes[] = 'active'; $this->layout()->breadcrumbs .= '<li class="active">' . $this->transEsc($desc) . '</li>'; $activeTabObj = $obj; } - $tab_classes = array(); - if ($isCurrent) $tab_classes[] = 'active'; - if (!$obj->isVisible()) $tab_classes[] = 'hidden'; + if (!$obj->isVisible()) { $tab_classes[] = 'hidden'; } + if (!$obj->supportsAjax()) { $tab_classes[] = 'noajax'; } ?> <li<?=count($tab_classes) > 0 ? ' class="' . implode(' ', $tab_classes) . '"' : ''?>> <a id="<?=strtolower($tab) ?>" href="<?=$this->recordLink()->getTabUrl($this->driver, $tab)?>#tabnav"><?=$this->transEsc($desc)?></a>