From 7157cdf15f032a23a3dfa178638cddfe036ceb35 Mon Sep 17 00:00:00 2001
From: Chris Hallberg <crhallberg@gmail.com>
Date: Wed, 24 Feb 2016 16:08:45 -0500
Subject: [PATCH] Simplify VuFind object and instantiate as early as possible.
 - Replace getters with public properties for simplicity/perforamnce.

---
 themes/bootstrap3/js/cart.js                  |  2 +-
 themes/bootstrap3/js/check_item_statuses.js   |  2 +-
 themes/bootstrap3/js/check_save_statuses.js   |  2 +-
 themes/bootstrap3/js/common.js                | 33 +++++++++----------
 themes/bootstrap3/js/facets.js                |  2 +-
 themes/bootstrap3/js/hierarchyTree.js         |  8 ++---
 themes/bootstrap3/js/hold.js                  |  2 +-
 themes/bootstrap3/js/ill.js                   |  2 +-
 themes/bootstrap3/js/keep_alive.js            |  2 +-
 themes/bootstrap3/js/lightbox.js              |  8 ++---
 themes/bootstrap3/js/openurl.js               |  2 +-
 themes/bootstrap3/js/record.js                | 14 ++++----
 themes/bootstrap3/js/vudl/record.js           |  2 +-
 .../Recommend/EuropeanaResultsDeferred.phtml  |  2 +-
 .../OpenLibrarySubjectsDeferred.phtml         |  2 +-
 .../templates/Recommend/PubDateVisAjax.phtml  |  2 +-
 .../Recommend/ResultGoogleMapAjax.phtml       |  4 +--
 .../Recommend/SummonBestBetsDeferred.phtml    |  2 +-
 .../Recommend/SummonDatabasesDeferred.phtml   |  2 +-
 .../Recommend/SummonResultsDeferred.phtml     |  2 +-
 themes/bootstrap3/templates/cart/cart.phtml   |  2 +-
 .../templates/combined/results-ajax.phtml     |  2 +-
 .../bootstrap3/templates/layout/layout.phtml  |  6 +++-
 23 files changed, 54 insertions(+), 53 deletions(-)

diff --git a/themes/bootstrap3/js/cart.js b/themes/bootstrap3/js/cart.js
index 4ae75110008..1bba92ed8c7 100644
--- a/themes/bootstrap3/js/cart.js
+++ b/themes/bootstrap3/js/cart.js
@@ -36,7 +36,7 @@ function getFullCartItems() {
 
 function addItemToCart(id,source) {
   if(!source) {
-    source = VuFind.getDefaultSearchBackend();
+    source = VuFind.defaultSearchBackend;
   }
   var cartItems = getCartItems();
   var cartSources = getCartSources();
diff --git a/themes/bootstrap3/js/check_item_statuses.js b/themes/bootstrap3/js/check_item_statuses.js
index 04dec21f4a7..21089fd02f5 100644
--- a/themes/bootstrap3/js/check_item_statuses.js
+++ b/themes/bootstrap3/js/check_item_statuses.js
@@ -12,7 +12,7 @@ function checkItemStatuses() {
   $.ajax({
     dataType: 'json',
     method: 'POST',
-    url: VuFind.getPath() + '/AJAX/JSON?method=getItemStatuses',
+    url: VuFind.path + '/AJAX/JSON?method=getItemStatuses',
     data: {id:id}
   })
   .done(function(response) {
diff --git a/themes/bootstrap3/js/check_save_statuses.js b/themes/bootstrap3/js/check_save_statuses.js
index d1c9e6966c7..1ff432fbb67 100644
--- a/themes/bootstrap3/js/check_save_statuses.js
+++ b/themes/bootstrap3/js/check_save_statuses.js
@@ -20,7 +20,7 @@ function checkSaveStatuses() {
     $.ajax({
       dataType: 'json',
       method: 'POST',
-      url: VuFind.getPath() + '/AJAX/JSON?method=getSaveStatuses',
+      url: VuFind.path + '/AJAX/JSON?method=getSaveStatuses',
       data: {id:ids, 'source':srcs}
     })
     .done(function(response) {
diff --git a/themes/bootstrap3/js/common.js b/themes/bootstrap3/js/common.js
index de3aa050569..833e45a6c2a 100644
--- a/themes/bootstrap3/js/common.js
+++ b/themes/bootstrap3/js/common.js
@@ -3,20 +3,17 @@
 // IE 9< console polyfill
 window.console = window.console || {log: function () {}};
 
-function VuFindNamespace(p, s, dsb) {
-  var defaultSearchBackend = dsb;
-  var path = p;
-  var strings = s;
+var VuFind = {
+  defaultSearchBackend: null,
+  path: null,
+  translations: {},
 
-  var getDefaultSearchBackend = function() { return defaultSearchBackend; };
-  var getPath = function() { return path; };
-  var translate = function(op) { return strings[op] || op; };
-
-  return {
-    getDefaultSearchBackend: getDefaultSearchBackend,
-    getPath: getPath,
-    translate: translate
-  };
+  addTranslations: function(s) {
+    for (var i in s) {
+      this.translations[i] = s[i];
+    }
+  },
+  translate: function(op) { return this.translations[op] || op; }
 }
 
 /* --- GLOBAL FUNCTIONS --- */
@@ -116,7 +113,7 @@ function bulkActionSubmit($form) {
   }
   if (submit == 'print') {
     //redirect page
-    var url = VuFind.getPath() + '/Records/Home?print=true';
+    var url = VuFind.path + '/Records/Home?print=true';
     for(var i=0;i<checks.length;i++) {
       url += '&id[]='+checks[i].value;
     }
@@ -198,7 +195,7 @@ function newAccountHandler(html) {
 // This is a full handler for the login form
 function ajaxLogin(form) {
   Lightbox.ajax({
-    url: VuFind.getPath() + '/AJAX/JSON?method=getSalt',
+    url: VuFind.path + '/AJAX/JSON?method=getSalt',
     dataType: 'json'
   })
   .done(function(response) {
@@ -224,7 +221,7 @@ function ajaxLogin(form) {
     // login via ajax
     Lightbox.ajax({
       type: 'POST',
-      url: VuFind.getPath() + '/AJAX/JSON?method=login',
+      url: VuFind.path + '/AJAX/JSON?method=login',
       dataType: 'json',
       data: params
     })
@@ -310,7 +307,7 @@ function setupAutocomplete() {
           hiddenFilters.push($(this).val());
         });
         $.fn.autocomplete.ajax({
-          url: VuFind.getPath() + '/AJAX/JSON',
+          url: VuFind.path + '/AJAX/JSON',
           data: {
             q:query,
             method:'getACSuggestions',
@@ -431,7 +428,7 @@ $(document).ready(function() {
       window.print();
     });
     // Make an ajax call to ensure that ajaxStop is triggered
-    $.getJSON(VuFind.getPath() + '/AJAX/JSON', {method: 'keepAlive'});
+    $.getJSON(VuFind.path + '/AJAX/JSON', {method: 'keepAlive'});
   }
 
   // Advanced facets
diff --git a/themes/bootstrap3/js/facets.js b/themes/bootstrap3/js/facets.js
index 77461c61c55..f906209f4c0 100644
--- a/themes/bootstrap3/js/facets.js
+++ b/themes/bootstrap3/js/facets.js
@@ -72,7 +72,7 @@ function initFacetTree(treeNode, inSidebar)
   } else {
     treeNode.prepend('<div><i class="fa fa-spinner fa-spin"></i><div>');
   }
-  $.getJSON(VuFind.getPath() + '/AJAX/JSON?' + query,
+  $.getJSON(VuFind.path + '/AJAX/JSON?' + query,
     {
       method: "getFacetData",
       facetName: facet,
diff --git a/themes/bootstrap3/js/hierarchyTree.js b/themes/bootstrap3/js/hierarchyTree.js
index a4f24c9de44..3c228b4f896 100644
--- a/themes/bootstrap3/js/hierarchyTree.js
+++ b/themes/bootstrap3/js/hierarchyTree.js
@@ -26,7 +26,7 @@ function html_entity_decode(string, quote_style) {
 
 function getRecord(recordID) {
   $.ajax({
-    url: VuFind.getPath() + '/Hierarchy/GetRecord?' + $.param({id: recordID}),
+    url: VuFind.path + '/Hierarchy/GetRecord?' + $.param({id: recordID}),
     dataType: 'html'
   })
   .done(function(response) {
@@ -72,7 +72,7 @@ function doTreeSearch() {
       searchAjax.abort();
     }
     searchAjax = $.ajax({
-      "url" : VuFind.getPath() + '/Hierarchy/SearchTree?' + $.param({
+      "url" : VuFind.path + '/Hierarchy/SearchTree?' + $.param({
         'lookfor': keyword,
         'hierarchyID': hierarchyID,
         'type': $("#treeSearchType").val()
@@ -126,7 +126,7 @@ function buildJSONNodes(xml) {
 
 function buildTreeWithXml(cb) {
   $.ajax({
-    'url': VuFind.getPath() + '/Hierarchy/GetTree',
+    'url': VuFind.path + '/Hierarchy/GetTree',
     'data': {
       'hierarchyID': hierarchyID,
       'id': recordID,
@@ -188,7 +188,7 @@ $(document).ready(function() {
       'core' : {
         'data' : function (obj, cb) {
           $.ajax({
-            'url': VuFind.getPath() + '/Hierarchy/GetTreeJSON',
+            'url': VuFind.path + '/Hierarchy/GetTreeJSON',
             'data': {
               'hierarchyID': hierarchyID,
               'id': recordID
diff --git a/themes/bootstrap3/js/hold.js b/themes/bootstrap3/js/hold.js
index a34780b1ba5..8e9b8594813 100644
--- a/themes/bootstrap3/js/hold.js
+++ b/themes/bootstrap3/js/hold.js
@@ -17,7 +17,7 @@ function setUpHoldRequestForm(recordId) {
       data: params,
       dataType: 'json',
       cache: false,
-      url: VuFind.getPath() + '/AJAX/JSON'
+      url: VuFind.path + '/AJAX/JSON'
     })
     .done(function(response) {
       var defaultValue = $('#pickUpLocation').data('default');
diff --git a/themes/bootstrap3/js/ill.js b/themes/bootstrap3/js/ill.js
index cdef12d3c19..7b67942cac5 100644
--- a/themes/bootstrap3/js/ill.js
+++ b/themes/bootstrap3/js/ill.js
@@ -3,7 +3,7 @@ function setUpILLRequestForm(recordId) {
   $("#ILLRequestForm #pickupLibrary").change(function() {
     $("#ILLRequestForm #pickupLibraryLocation option").remove();
     $("#ILLRequestForm #pickupLibraryLocationLabel i").addClass("fa fa-spinner icon-spin");
-    var url = VuFind.getPath() + '/AJAX/JSON?' + $.param({
+    var url = VuFind.path + '/AJAX/JSON?' + $.param({
       id: recordId,
       method:'getLibraryPickupLocations',
       pickupLib: $("#ILLRequestForm #pickupLibrary").val()
diff --git a/themes/bootstrap3/js/keep_alive.js b/themes/bootstrap3/js/keep_alive.js
index d0e45d79b4d..7df79b51986 100644
--- a/themes/bootstrap3/js/keep_alive.js
+++ b/themes/bootstrap3/js/keep_alive.js
@@ -2,6 +2,6 @@
 
 $(document).ready(function() {
   window.setInterval(function() {
-    $.getJSON(VuFind.getPath() + '/AJAX/JSON', {method: 'keepAlive'});
+    $.getJSON(VuFind.path + '/AJAX/JSON', {method: 'keepAlive'});
   }, keepAliveInterval * 1000);
 });
diff --git a/themes/bootstrap3/js/lightbox.js b/themes/bootstrap3/js/lightbox.js
index 45dbcd28eb9..a6c46d283f5 100644
--- a/themes/bootstrap3/js/lightbox.js
+++ b/themes/bootstrap3/js/lightbox.js
@@ -271,7 +271,7 @@ var Lightbox = {
    */
   get: function(controller, action, get, post, callback) {
     // Build URL
-    var url = VuFind.getPath()+'/AJAX/JSON?method=getLightbox&submodule='+controller+'&subaction='+action;
+    var url = VuFind.path+'/AJAX/JSON?method=getLightbox&submodule='+controller+'&subaction='+action;
     if(typeof get !== "undefined" && get !== {}) {
       url += '&'+$.param(get);
     }
@@ -394,7 +394,7 @@ var Lightbox = {
     var POST = $form.attr('method') && $form.attr('method').toUpperCase() == 'POST';
     if($form.attr('action')) {
       // Parse action location
-      var path = VuFind.getPath();
+      var path = VuFind.path;
       var action = $form.attr('action').substring($form.attr('action').indexOf(path)+path.length+1);
       var params = action.split('?');
       action = action.split('/');
@@ -420,7 +420,7 @@ function getListUrlFromHTML(html) {
   if (typeof listUrl === 'undefined') {
     var listID = fakePage.find('[name="listID"]');
     if(listID.length > 0) {
-      listUrl = VuFind.getPath() + '/MyResearch/MyList/'+listID.val();
+      listUrl = VuFind.path + '/MyResearch/MyList/'+listID.val();
     }
   }
   var message = VuFind.translate('bulk_save_success');
@@ -484,7 +484,7 @@ $(document).ready(function() {
 
   Lightbox.addFormHandler('exportForm', function(evt) {
     Lightbox.ajax({
-      url: VuFind.getPath() + '/AJAX/JSON?' + $.param({method:'exportFavorites'}),
+      url: VuFind.path + '/AJAX/JSON?' + $.param({method:'exportFavorites'}),
       type:'POST',
       dataType:'json',
       data:Lightbox.getFormData($(evt.target))
diff --git a/themes/bootstrap3/js/openurl.js b/themes/bootstrap3/js/openurl.js
index 88f50d1dbd4..7540bf15aef 100644
--- a/themes/bootstrap3/js/openurl.js
+++ b/themes/bootstrap3/js/openurl.js
@@ -2,7 +2,7 @@
 
 function loadResolverLinks($target, openUrl, searchClassId) {
   $target.addClass('ajax_availability');
-  var url = VuFind.getPath() + '/AJAX/JSON?' + $.param({method:'getResolverLinks',openurl:openUrl,searchClassId:searchClassId});
+  var url = VuFind.path + '/AJAX/JSON?' + $.param({method:'getResolverLinks',openurl:openUrl,searchClassId:searchClassId});
   $.ajax({
     dataType: 'json',
     url: url
diff --git a/themes/bootstrap3/js/record.js b/themes/bootstrap3/js/record.js
index 6ed8710bde7..fc9b2bbb914 100644
--- a/themes/bootstrap3/js/record.js
+++ b/themes/bootstrap3/js/record.js
@@ -8,7 +8,7 @@ function checkRequestIsValid(element, requestType) {
   var vars = deparam(element.href);
   vars['id'] = recordId;
 
-  var url = VuFind.getPath() + '/AJAX/JSON?' + $.param({method:'checkRequestIsValid', id: recordId, requestType: requestType, data: vars});
+  var url = VuFind.path + '/AJAX/JSON?' + $.param({method:'checkRequestIsValid', id: recordId, requestType: requestType, data: vars});
   $.ajax({
     dataType: 'json',
     cache: false,
@@ -41,7 +41,7 @@ function setUpCheckRequest() {
 }
 
 function deleteRecordComment(element, recordId, recordSource, commentId) {
-  var url = VuFind.getPath() + '/AJAX/JSON?' + $.param({method:'deleteRecordComment',id:commentId});
+  var url = VuFind.path + '/AJAX/JSON?' + $.param({method:'deleteRecordComment',id:commentId});
   $.ajax({
     dataType: 'json',
     url: url
@@ -52,7 +52,7 @@ function deleteRecordComment(element, recordId, recordSource, commentId) {
 }
 
 function refreshCommentList($target, recordId, recordSource) {
-  var url = VuFind.getPath() + '/AJAX/JSON?' + $.param({method:'getRecordCommentsAsHTML',id:recordId,'source':recordSource});
+  var url = VuFind.path + '/AJAX/JSON?' + $.param({method:'getRecordCommentsAsHTML',id:recordId,'source':recordSource});
   $.ajax({
     dataType: 'json',
     url: url
@@ -77,7 +77,7 @@ function registerAjaxCommentRecord() {
     var form = this;
     var id = form.id.value;
     var recordSource = form.source.value;
-    var url = VuFind.getPath() + '/AJAX/JSON?' + $.param({method:'commentRecord'});
+    var url = VuFind.path + '/AJAX/JSON?' + $.param({method:'commentRecord'});
     var data = {
       comment:form.comment.value,
       id:id,
@@ -134,7 +134,7 @@ function ajaxLoadTab($newTab, tabid, setHash) {
   // Parse out the base URL for the current record:
   var urlParts = document.URL.split(/[?#]/);
   var urlWithoutFragment = urlParts[0];
-  var path = VuFind.getPath();
+  var path = VuFind.path;
   var urlroot = null;
   if (path === '') {
     // special case -- VuFind installed at site root:
@@ -175,7 +175,7 @@ function refreshTagList(target, loggedin) {
   var recordSource = $(target).find('.hiddenSource').val();
   var $tagList = $(target).find('.tagList');
   if ($tagList.length > 0) {
-    var url = VuFind.getPath() + '/AJAX/JSON?' + $.param({method:'getRecordTags',id:recordId,'source':recordSource});
+    var url = VuFind.path + '/AJAX/JSON?' + $.param({method:'getRecordTags',id:recordId,'source':recordSource});
     $.ajax({
       dataType: 'html',
       url: url
@@ -203,7 +203,7 @@ function ajaxTagUpdate(link, tag, remove) {
   var recordId = $target.find('.hiddenId').val();
   var recordSource = $target.find('.hiddenSource').val();
   $.ajax({
-    url:VuFind.getPath() + '/AJAX/JSON?method=tagRecord',
+    url:VuFind.path + '/AJAX/JSON?method=tagRecord',
     method:'POST',
     data:{
       tag:'"'+tag.replace(/\+/g, ' ')+'"',
diff --git a/themes/bootstrap3/js/vudl/record.js b/themes/bootstrap3/js/vudl/record.js
index 9e62e5ab5cb..7aa7f4ae882 100644
--- a/themes/bootstrap3/js/vudl/record.js
+++ b/themes/bootstrap3/js/vudl/record.js
@@ -50,7 +50,7 @@ function updateTechInfo(record) {
     if(typeof d.data.type !== "undefined") {
       $('#download-button .details').html(d.data.type+' ~ '+d.data.size);
     }
-    $('#file-download').attr('action', VuFind.getPath()+'/files/'+record.id+'/'+downloadSrc+'?download=true');
+    $('#file-download').attr('action', VuFind.path+'/files/'+record.id+'/'+downloadSrc+'?download=true');
   })
   .fail(function(response, textStatus) {
     console.log(response, textStatus);
diff --git a/themes/bootstrap3/templates/Recommend/EuropeanaResultsDeferred.phtml b/themes/bootstrap3/templates/Recommend/EuropeanaResultsDeferred.phtml
index 626186af6ee..70c5271da00 100644
--- a/themes/bootstrap3/templates/Recommend/EuropeanaResultsDeferred.phtml
+++ b/themes/bootstrap3/templates/Recommend/EuropeanaResultsDeferred.phtml
@@ -1,6 +1,6 @@
 <?
     // Set up Javascript for use below:
-    $loadJs = 'var url = VuFind.getPath() + "/AJAX/Recommend?' . $this->recommend->getUrlParams() . '";'
+    $loadJs = 'var url = VuFind.path + "/AJAX/Recommend?' . $this->recommend->getUrlParams() . '";'
         . "\$('#EuropeanaDeferredRecommend').load(url);";
 ?>
 <div id="EuropeanaDeferredRecommend">
diff --git a/themes/bootstrap3/templates/Recommend/OpenLibrarySubjectsDeferred.phtml b/themes/bootstrap3/templates/Recommend/OpenLibrarySubjectsDeferred.phtml
index abbddb3b7b5..aec3a025b25 100644
--- a/themes/bootstrap3/templates/Recommend/OpenLibrarySubjectsDeferred.phtml
+++ b/themes/bootstrap3/templates/Recommend/OpenLibrarySubjectsDeferred.phtml
@@ -1,6 +1,6 @@
 <?
     // Set up Javascript for use below:
-    $loadJs = 'var url = VuFind.getPath() + "/AJAX/Recommend?' . $this->recommend->getUrlParams() . '";'
+    $loadJs = 'var url = VuFind.path + "/AJAX/Recommend?' . $this->recommend->getUrlParams() . '";'
         . "\$('#openLibraryDeferredRecommend').load(url);";
 ?>
 <div id="openLibraryDeferredRecommend">
diff --git a/themes/bootstrap3/templates/Recommend/PubDateVisAjax.phtml b/themes/bootstrap3/templates/Recommend/PubDateVisAjax.phtml
index fb19996e019..67f43cad8fd 100644
--- a/themes/bootstrap3/templates/Recommend/PubDateVisAjax.phtml
+++ b/themes/bootstrap3/templates/Recommend/PubDateVisAjax.phtml
@@ -21,7 +21,7 @@
   <div id="dateVisColorSettings"><!-- do not delete! used for passing CSS to Javascript --></div>
   <?
     $js = "loadVis('" . $this->recommend->getFacetFields() . "', '"
-        . $this->recommend->getSearchParams() . "', VuFind.getPath(), "
+        . $this->recommend->getSearchParams() . "', VuFind.path, "
         . $this->recommend->getZooming() . ");";
     echo $this->inlineScript(\Zend\View\Helper\HeadScript::SCRIPT, $js, 'SET');
   ?>
diff --git a/themes/bootstrap3/templates/Recommend/ResultGoogleMapAjax.phtml b/themes/bootstrap3/templates/Recommend/ResultGoogleMapAjax.phtml
index 341f452897c..6daed32b9a5 100644
--- a/themes/bootstrap3/templates/Recommend/ResultGoogleMapAjax.phtml
+++ b/themes/bootstrap3/templates/Recommend/ResultGoogleMapAjax.phtml
@@ -96,7 +96,7 @@ var myOptions;
 var map;
 var infowindow = new google.maps.InfoWindow({maxWidth: 480, minWidth: 480});
   function initialize() {
-    var url = VuFind.getPath()+'/AJAX/json?method=getMapData&<?=$searchParams ?>';
+    var url = VuFind.path+'/AJAX/json?method=getMapData&<?=$searchParams ?>';
     //alert('go: ' + url);
     $.getJSON(url, function(data){
       //alert(data);
@@ -171,7 +171,7 @@ var infowindow = new google.maps.InfoWindow({maxWidth: 480, minWidth: 480});
     else{// code for IE6, IE5
       xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
     }
-    var ajaxUrl = VuFind.getPath()+'/AJAX/ResultGoogleMapInfo?limit=5&filter[]=long_lat%3A"' + marker.loc_facet+'"&<?=$searchParams ?>';
+    var ajaxUrl = VuFind.path+'/AJAX/ResultGoogleMapInfo?limit=5&filter[]=long_lat%3A"' + marker.loc_facet+'"&<?=$searchParams ?>';
     xmlhttp.open("GET", ajaxUrl, false);
     xmlhttp.send();
 
diff --git a/themes/bootstrap3/templates/Recommend/SummonBestBetsDeferred.phtml b/themes/bootstrap3/templates/Recommend/SummonBestBetsDeferred.phtml
index 5a31f9811cc..ef315eb767c 100644
--- a/themes/bootstrap3/templates/Recommend/SummonBestBetsDeferred.phtml
+++ b/themes/bootstrap3/templates/Recommend/SummonBestBetsDeferred.phtml
@@ -1,6 +1,6 @@
 <?
   // Set up Javascript for use below:
-  $loadJs = 'var url = VuFind.getPath() + "/AJAX/Recommend?' . $this->recommend->getUrlParams() . '";'
+  $loadJs = 'var url = VuFind.path + "/AJAX/Recommend?' . $this->recommend->getUrlParams() . '";'
     . "\$('#SummonDeferredBestBets').load(url);";
 ?>
 <div id="SummonDeferredBestBets">
diff --git a/themes/bootstrap3/templates/Recommend/SummonDatabasesDeferred.phtml b/themes/bootstrap3/templates/Recommend/SummonDatabasesDeferred.phtml
index 454d5f42e80..0b9f2caa70d 100644
--- a/themes/bootstrap3/templates/Recommend/SummonDatabasesDeferred.phtml
+++ b/themes/bootstrap3/templates/Recommend/SummonDatabasesDeferred.phtml
@@ -1,6 +1,6 @@
 <?
   // Set up Javascript for use below:
-  $loadJs = 'var url = VuFind.getPath() + "/AJAX/Recommend?' . $this->recommend->getUrlParams() . '";'
+  $loadJs = 'var url = VuFind.path + "/AJAX/Recommend?' . $this->recommend->getUrlParams() . '";'
     . "\$('#SummonDeferredDatabases').load(url);";
 ?>
 <div id="SummonDeferredDatabases">
diff --git a/themes/bootstrap3/templates/Recommend/SummonResultsDeferred.phtml b/themes/bootstrap3/templates/Recommend/SummonResultsDeferred.phtml
index ed9b5d54006..e97c79492b2 100644
--- a/themes/bootstrap3/templates/Recommend/SummonResultsDeferred.phtml
+++ b/themes/bootstrap3/templates/Recommend/SummonResultsDeferred.phtml
@@ -1,6 +1,6 @@
 <?
   // Set up Javascript for use below:
-  $loadJs = 'var url = VuFind.getPath() + "/AJAX/Recommend?' . $this->recommend->getUrlParams() . '";'
+  $loadJs = 'var url = VuFind.path + "/AJAX/Recommend?' . $this->recommend->getUrlParams() . '";'
     . "\$('#SummonDeferredRecommend').load(url);";
 ?>
 <div id="SummonDeferredRecommend">
diff --git a/themes/bootstrap3/templates/cart/cart.phtml b/themes/bootstrap3/templates/cart/cart.phtml
index 4efe7527d07..c372dc1e25c 100644
--- a/themes/bootstrap3/templates/cart/cart.phtml
+++ b/themes/bootstrap3/templates/cart/cart.phtml
@@ -72,7 +72,7 @@
     }
   }
   function submitCartForm(elem, data) {
-    var url = VuFind.getPath() + '/AJAX/JSON?method=getLightbox&submodule=Cart&subaction=Home';
+    var url = VuFind.path + '/AJAX/JSON?method=getLightbox&submodule=Cart&subaction=Home';
     $.post(url, data, determineCallback(elem));
   }
   function submitFormWithIds(elem, data) {
diff --git a/themes/bootstrap3/templates/combined/results-ajax.phtml b/themes/bootstrap3/templates/combined/results-ajax.phtml
index fdbed6eb826..6d150814a48 100644
--- a/themes/bootstrap3/templates/combined/results-ajax.phtml
+++ b/themes/bootstrap3/templates/combined/results-ajax.phtml
@@ -13,7 +13,7 @@
     $lookforEncoded = urlencode($lookfor);
     $loadJs = <<<JS
 $(document).ready(function(){
-    var url = VuFind.getPath() + '/Combined/Result?id=$searchClassIdEncoded&lookfor=$lookforEncoded';
+    var url = VuFind.path + '/Combined/Result?id=$searchClassIdEncoded&lookfor=$lookforEncoded';
     $('$targetIdHtmlEscaped').load(url, '', function(responseText) {
         if (responseText.length == 0) {
             $('$targetIdHtmlEscaped').hide();
diff --git a/themes/bootstrap3/templates/layout/layout.phtml b/themes/bootstrap3/templates/layout/layout.phtml
index 05f797740b3..d252393c727 100644
--- a/themes/bootstrap3/templates/layout/layout.phtml
+++ b/themes/bootstrap3/templates/layout/layout.phtml
@@ -99,7 +99,11 @@
       $root = rtrim($this->url('home'), '/');
       $translations = $this->jsTranslations()->getJSON();
       $dsb = DEFAULT_SEARCH_BACKEND;
-      $setupJS = "var VuFind = new VuFindNamespace('{$root}', {$translations}, '{$dsb}');";
+      $setupJS = <<<JS
+VuFind.path = '{$root}';
+VuFind.defaultSearchBackend = '{$dsb}';
+VuFind.addTranslations({$translations});
+JS;
       $this->headScript()->appendScript($setupJS);
     ?>
     <?=$this->headScript()?>
-- 
GitLab