From 13b4f3e1e0102ba184ac3c3aafd788c1252f470d Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Mon, 7 Dec 2015 11:03:19 -0500 Subject: [PATCH] Eliminated hard-coded 'VuFind' from JS code. --- themes/bootstrap3/js/cart.js | 2 +- themes/bootstrap3/js/common.js | 5 ++++- themes/bootstrap3/templates/layout/layout.phtml | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/themes/bootstrap3/js/cart.js b/themes/bootstrap3/js/cart.js index cacf52b22ec..4ae75110008 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'; + source = VuFind.getDefaultSearchBackend(); } var cartItems = getCartItems(); var cartSources = getCartSources(); diff --git a/themes/bootstrap3/js/common.js b/themes/bootstrap3/js/common.js index 6ec9358ddd7..ae597c91b79 100644 --- a/themes/bootstrap3/js/common.js +++ b/themes/bootstrap3/js/common.js @@ -1,13 +1,16 @@ /*global btoa, console, hexEncode, isPhoneNumberValid, Lightbox, rc4Encrypt, unescape, VuFind */ -function VuFindNamespace(p, s) { +function VuFindNamespace(p, s, dsb) { + var defaultSearchBackend = dsb; var path = p; var strings = s; + 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 }; diff --git a/themes/bootstrap3/templates/layout/layout.phtml b/themes/bootstrap3/templates/layout/layout.phtml index 46ae0fcf243..05f797740b3 100644 --- a/themes/bootstrap3/templates/layout/layout.phtml +++ b/themes/bootstrap3/templates/layout/layout.phtml @@ -98,7 +98,8 @@ <? $root = rtrim($this->url('home'), '/'); $translations = $this->jsTranslations()->getJSON(); - $setupJS = "var VuFind = new VuFindNamespace('{$root}', {$translations});"; + $dsb = DEFAULT_SEARCH_BACKEND; + $setupJS = "var VuFind = new VuFindNamespace('{$root}', {$translations}, '{$dsb}');"; $this->headScript()->appendScript($setupJS); ?> <?=$this->headScript()?> -- GitLab