re-implement testString
authorJason Etheridge <jason@esilibrary.com>
Mon, 4 Feb 2013 07:34:36 +0000 (02:34 -0500)
committerJason Etheridge <jason@esilibrary.com>
Mon, 4 Feb 2013 07:38:51 +0000 (02:38 -0500)
Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js
Open-ILS/xul/staff_client/chrome/content/main/menu.js
Open-ILS/xul/staff_client/server/cat/bib_brief.js
Open-ILS/xul/staff_client/server/cat/z3950.js

index 09c8671..0c0fb5e 100644 (file)
             alert('Error in global_utils.js, widget_prompt(): ' + E);
         }
     }
+
+    function testString(bundle,key) {
+        try {
+            if ($(bundle).getString(key)) {
+                return true;
+            }
+        } catch(E) {}
+        return false;
+    }
index 9c5174f..4d5a470 100644 (file)
@@ -128,7 +128,7 @@ main.menu.prototype = {
         for(var i = 0; i < hotkeysets.length; i++) {
             var keysetname = hotkeysets[i];
             var menuitem = document.createElement('menuitem');
-            if(offlineStrings.testString('hotkey.' + keysetname))
+            if(testString('offlineStrings','hotkey.' + keysetname))
                 menuitem.setAttribute('label',offlineStrings.getString('hotkey.' + keysetname));
             else
                 menuitem.setAttribute('label',keysetname);
@@ -1905,7 +1905,7 @@ main.menu.prototype = {
             var tab = this.controller.view.tabs.childNodes[i];
             tab.curindex = i;
             tab.label = i + ' ' + tab.origlabel;
-            if(doAccessKeys && offlineStrings.testString('menu.tab' + i + '.accesskey')) {
+            if(doAccessKeys && testString('offlineStrings','menu.tab' + i + '.accesskey')) {
                 tab.accessKey = offlineStrings.getString('menu.tab' + i + '.accesskey');
             }
         }
@@ -1960,7 +1960,7 @@ main.menu.prototype = {
         this.controller.view.panels.appendChild(panel);
         tab.curindex = this.controller.view.tabs.childNodes.length - 1;
         if(!xulG.pref.getBoolPref('open-ils.disable_accesskeys_on_tabs')) {
-            if(offlineStrings.testString('menu.tab' + tab.curindex + '.accesskey')) {
+            if(testString('offlineStrings','menu.tab' + tab.curindex + '.accesskey')) {
                 tab.accessKey = offlineStrings.getString('menu.tab' + tab.curindex + '.accesskey');
             }
         }
@@ -2619,7 +2619,7 @@ commands:
 
                 // If we have more than one context this should label each entry with where it came from
                 // Likely most useful for distinguishing assets from bookings
-                if(context != valid_r[i].type && offlineStrings.testString('barcode_choice.' + valid_r[i].type + '_label'))
+                if(context != valid_r[i].type && testString('offlineStrings','barcode_choice.' + valid_r[i].type + '_label'))
                     button_label = offlineStrings.getFormattedString('barcode_choice.' + valid_r[i].type + '_label', [button_label]);
 
                 xml += '<button label="' + button_label + '" name="fancy_submit" value="' + i + '"/>';
index 0f527d6..f0e4fff 100644 (file)
@@ -277,12 +277,12 @@ function dynamic_grid_replacement(mode) {
             label.setAttribute('control',name);
             label.setAttribute('class','emphasis');
             label.setAttribute('value',
-                catStrings.testString('staff.cat.bib_brief.'+name+'.label')
+                testString('catStrings','staff.cat.bib_brief.'+name+'.label')
                 ? catStrings.getString('staff.cat.bib_brief.'+name+'.label')
                 : name
             );
             label.setAttribute('accesskey',
-                catStrings.testString('staff.cat.bib_brief.'+name+'.accesskey')
+                testString('catStrings','staff.cat.bib_brief.'+name+'.accesskey')
                 ? catStrings.getString('staff.cat.bib_brief.'+name+'.accesskey')
                 : name
             );
index cf78b11..f8a1cf8 100644 (file)
@@ -330,7 +330,7 @@ cat.z3950.prototype = {
                                                         }
                                                         if (attr.label) {
                                                             attrs[i].labels[ attr.label ] = true;
-                                                        } else if (document.getElementById('commonStrings').testString('staff.z39_50.search_class.' + i)) {
+                                                        } else if (testString('commonStrings','staff.z39_50.search_class.' + i)) {
                                                             attrs[i].labels[ document.getElementById('commonStrings').getString('staff.z39_50.search_class.' + i) ] = true;
                                                         } else if (attr.name) {
                                                             attrs[i].labels[ attr.name ] = true;