From: phasefx Date: Wed, 24 Nov 2010 15:20:44 +0000 (+0000) Subject: merge r18806 from rel_1_6 for caching this setting (at least within a given page... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=b1c2e1546f8a886c5dddfb6ef2fc93aa9c1f2887;p=working%2FEvergreen.git merge r18806 from rel_1_6 for caching this setting (at least within a given page load) git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_6_1@18844 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/opac/common/js/opac_utils.js b/Open-ILS/web/opac/common/js/opac_utils.js index b62ad4bb9f..0e8b640937 100644 --- a/Open-ILS/web/opac/common/js/opac_utils.js +++ b/Open-ILS/web/opac/common/js/opac_utils.js @@ -796,17 +796,34 @@ function drawOrgTree() { //setTimeout( 'buildOrgSelector(G.ui.common.org_tree, orgTreeSelector);', 10 ); setTimeout( 'buildOrgSelector(G.ui.common.org_tree, orgTreeSelector);', 1 ); } - + +var checkOrgHiding_cached = false; +var checkOrgHiding_cached_context_org; +var checkOrgHiding_cached_depth; function checkOrgHiding() { - var context_org = getOrigLocation() || globalOrgTree.id(); - var depth = fetchOrgSettingDefault( context_org, 'opac.org_unit_hiding.depth'); - if (isXUL()) { - return false; // disable org hiding for staff client - } - if ( findOrgDepth( context_org ) < depth ) { - return false; // disable org hiding if Original Location doesn't make sense with setting depth (avoids disjointed org selectors) - } - return { 'org' : findOrgUnit(context_org), 'depth' : depth }; + if (isXUL()) { + return false; // disable org hiding for staff client + } + var context_org = getOrigLocation() || globalOrgTree.id(); + var depth; + if (checkOrgHiding_cached) { + if (checkOrgHiding_cached_context_org != context_org) { + checkOrgHiding_cached_context_org = context_org; + checkOrgHiding_cached_depth = undefined; + checkOrgHiding_cached = false; + } else { + depth = checkOrgHiding_cached_depth; + } + } else { + depth = fetchOrgSettingDefault( context_org, 'opac.org_unit_hiding.depth'); + checkOrgHiding_cached_depth = depth; + checkOrgHiding_cached_context_org = context_org; + checkOrgHiding_cached = true; + } + if ( findOrgDepth( context_org ) < depth ) { + return false; // disable org hiding if Original Location doesn't make sense with setting depth (avoids disjointed org selectors) + } + return { 'org' : findOrgUnit(context_org), 'depth' : depth }; } var orgTreeSelector;