From 07c3def05b18077a00600b13fad2803e5439e775 Mon Sep 17 00:00:00 2001
From: Chris Hallberg <crhallberg@gmail.com>
Date: Tue, 20 Jan 2015 11:04:02 -0500
Subject: [PATCH] Manual merge of Pull Request #277 with an additional check
 for a null response.

---
 themes/bootstrap3/js/record.js | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/themes/bootstrap3/js/record.js b/themes/bootstrap3/js/record.js
index 3513c023a72..5507934e7b8 100644
--- a/themes/bootstrap3/js/record.js
+++ b/themes/bootstrap3/js/record.js
@@ -151,10 +151,9 @@ function registerTabEvents() {
 function ajaxLoadTab(tabid) {
   var id = $('.hiddenId')[0].value;
   // Grab the part of the url that is the Controller and Record ID
-  var urlroot = document.URL.match(new RegExp('/[^/]+/'+id+'(/|\\b)'));
-  urlroot = urlroot.slice(-1);
-  if(urlroot.substring(-1) != '/') {
-    urlroot += '/';
+  var urlroot = document.URL.match(new RegExp('/[^/]+/'+id)) + "/";
+  if(urlroot == "null/") {
+    return true;
   }
   $.ajax({
     url: path + urlroot + 'AjaxTab',
@@ -170,6 +169,7 @@ function ajaxLoadTab(tabid) {
       }
     }
   });
+  return false;
 }
 
 $(document).ready(function(){
@@ -178,21 +178,20 @@ $(document).ready(function(){
 
   $('ul.recordTabs a').click(function (e) {
     if($(this).parents('li.active').length > 0) {
-      window.location.href = $(this).attr('href');
-      return;
+      return true;
     }
     var tabid = $(this).attr('id').toLowerCase();
     if($('#'+tabid+'-tab').length > 0) {
       $('#record-tabs .tab-pane.active').removeClass('active');
       $('#'+tabid+'-tab').addClass('active');
       $('#'+tabid).tab('show');
+      return false;
     } else {
       $('#record-tabs').append('<div class="tab-pane" id="'+tabid+'-tab"><i class="fa fa-spinner fa-spin"></i> '+vufindString.loading+'...</div>');
       $('#record-tabs .tab-pane.active').removeClass('active');
       $('#'+tabid+'-tab').addClass('active');
-      ajaxLoadTab(tabid);
+      return ajaxLoadTab(tabid);
     }
-    return false;
   });
 
   /* --- LIGHTBOX --- */
-- 
GitLab