From 2810ddc4b75fb3aece47e46da83e436a764e878e Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Tue, 10 Nov 2015 11:56:24 -0500
Subject: [PATCH] Fixed AJAX tabs when VuFind is installed at site root. -
 Resolves VUFIND-1138.

---
 themes/bootstrap3/js/record.js | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/themes/bootstrap3/js/record.js b/themes/bootstrap3/js/record.js
index f59ffe8a3d3..00d0af6c54d 100644
--- a/themes/bootstrap3/js/record.js
+++ b/themes/bootstrap3/js/record.js
@@ -156,9 +156,16 @@ function ajaxLoadTab(tabid, setHash) {
   // Parse out the base URL for the current record:
   var urlParts = document.URL.split(/[?#]/);
   var urlWithoutFragment = urlParts[0];
-  var pathInUrl = urlWithoutFragment.indexOf(path);
-  var chunks = urlWithoutFragment.substring(pathInUrl + path.length + 1).split('/');
-  var urlroot = '/' + chunks[0] + '/' + chunks[1];
+  if (path == '') {
+    // special case -- VuFind installed at site root:
+    var chunks = urlWithoutFragment.split('/');
+    var urlroot = '/' + chunks[3] + '/' + chunks[4];
+  } else {
+    // standard case -- VuFind has its own path under site:
+    var pathInUrl = urlWithoutFragment.indexOf(path);
+    var chunks = urlWithoutFragment.substring(pathInUrl + path.length + 1).split('/');
+    var urlroot = '/' + chunks[0] + '/' + chunks[1];
+  }
 
   // Request the tab via AJAX:
   $.ajax({
-- 
GitLab