From: Jason Etheridge Date: Mon, 4 Feb 2013 07:34:36 +0000 (-0500) Subject: re-implement testString X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f6a7f97c4002649d01eb111761fa9d35c5ff45e8;p=working%2FEvergreen.git re-implement testString Signed-off-by: Jason Etheridge --- diff --git a/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js b/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js index 09c8671cec..0c0fb5e7bc 100644 --- a/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js +++ b/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js @@ -634,3 +634,12 @@ alert('Error in global_utils.js, widget_prompt(): ' + E); } } + + function testString(bundle,key) { + try { + if ($(bundle).getString(key)) { + return true; + } + } catch(E) {} + return false; + } diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu.js b/Open-ILS/xul/staff_client/chrome/content/main/menu.js index 9c5174f657..4d5a470f6e 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu.js @@ -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 += '