From a63abb63756cf5e2df6ca53a856c1179cf97581f Mon Sep 17 00:00:00 2001
From: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Date: Thu, 6 Oct 2011 12:06:09 -0400
Subject: [PATCH] Acq: fix a bug that sometimes prevents the general search
 page from loading

Within Acquisitions General Search, javascript included from one file
in the <head> relies on the variable "localeStrings" being initialized
by javascript included from a file in <body>.  Sometimes the wrong
javascript wins the race, you get an error about localeStrings being
undefined in the Javascript console, and the page stops loading.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
---
 Open-ILS/web/js/ui/default/acq/common/li_table.js | 6 ++++--
 Open-ILS/web/js/ui/default/acq/search/unified.js  | 6 ++++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/Open-ILS/web/js/ui/default/acq/common/li_table.js b/Open-ILS/web/js/ui/default/acq/common/li_table.js
index 1178515e1d..3733314c0f 100644
--- a/Open-ILS/web/js/ui/default/acq/common/li_table.js
+++ b/Open-ILS/web/js/ui/default/acq/common/li_table.js
@@ -15,8 +15,10 @@ dojo.require('openils.widget.ProgressDialog');
 dojo.require('openils.PermaCrud');
 dojo.require("openils.widget.PCrudAutocompleteBox");
 
-dojo.requireLocalization('openils.acq', 'acq');
-var localeStrings = dojo.i18n.getLocalization('openils.acq', 'acq');
+if (!localeStrings) {   /* we can do this because javascript doesn't have block scope */
+    dojo.requireLocalization('openils.acq', 'acq');
+    var localeStrings = dojo.i18n.getLocalization('openils.acq', 'acq');
+}
 const XUL_OPAC_WRAPPER = 'chrome://open_ils_staff_client/content/cat/opac.xul';
 var li_exportable_attrs = ["issn", "isbn", "upc"];
 
diff --git a/Open-ILS/web/js/ui/default/acq/search/unified.js b/Open-ILS/web/js/ui/default/acq/search/unified.js
index 8ff340e8f0..02e1d681b5 100644
--- a/Open-ILS/web/js/ui/default/acq/search/unified.js
+++ b/Open-ILS/web/js/ui/default/acq/search/unified.js
@@ -5,6 +5,12 @@ dojo.require("openils.widget.AutoWidget");
 dojo.require("openils.widget.XULTermLoader");
 dojo.require("openils.PermaCrud");
 
+if (!localeStrings) {   /* we can do this because javascript doesn't have block 
+                           scope */
+    dojo.requireLocalization('openils.acq', 'acq');
+    var localeStrings = dojo.i18n.getLocalization('openils.acq', 'acq');
+}
+
 var termSelectorFactory;
 var termManager;
 var resultManager;
-- 
2.11.0