var PREF_HITS_PER = 'opac.hits_per_page';
var PREF_DEF_FONT = 'opac.default_font';
var PREF_HOLD_NOTIFY = 'opac.hold_notify';
+var PREF_DEF_LOCATION = 'opac.default_search_location';
+var PREF_DEF_DEPTH = 'opac.default_search_depth';
/* container for global variables shared accross pages */
function init() {
-
runEvt('common','init');
if( getOrigLocation() == 0 ) ORIGLOC = LOCATION;
var cgi = new CGI();
if( grabUser() ) {
if( cgi.param(PARAM_LOCATION) == null ) {
- LOCATION = G.user.ws_ou();
- DEPTH = findOrgDepth(G.user.ws_ou());
+ var org = G.user.prefs[PREF_DEF_LOCATION];
+ var depth = G.user.prefs[PREF_DEF_DEPTH];
+
+ if(!org) org = G.use.ws_ou();
+ if(!depth) depth = findOrgDepth(org);
+
+ LOCATION = org;
+ DEPTH = DEPTH;
}
}
G.user.prefs[PREF_HITS_PER] = getSelectorVal($('prefs_hits_per'));
G.user.prefs[PREF_DEF_FONT] = getSelectorVal($('prefs_def_font'));
G.user.prefs[PREF_HOLD_NOTIFY] = getSelectorVal($('prefs_hold_notify'));
+ G.user.prefs[PREF_DEF_LOCATION] = getSelectorVal($('prefs_def_location'));
+ G.user.prefs[PREF_DEF_DEPTH] = getSelectorVal($('prefs_def_range'));
+
if(commitUserPrefs())
alert($('prefs_update_success').innerHTML);
else alert($('prefs_update_failure').innerHTML);
myOPACShowHitsPer();
myOPACShowDefFont();
myOPACShowHoldNotify();
+ myOPACShowDefLocation();
hideMe($('myopac_prefs_loading'));
}
+var defSearchLocationDrawn = false;
+var defDepthIndex = 0;
+function myOPACShowDefLocation() {
+
+ var selector = $('prefs_def_location');
+ var rsel = $('prefs_def_range');
+
+ var org = G.user.prefs[PREF_DEF_LOCATION];
+ if(!org) org = G.user.home_ou();
+
+ if(!defSearchLocationDrawn) {
+ defSearchLocationDrawn = true;
+ buildOrgSel(selector, globalOrgTree, 0);
+
+ globalOrgTypes = globalOrgTypes.sort(
+ function(a, b) {
+ if( a.depth() < b.depth() ) return -1;
+ return 1;
+ }
+ );
+
+ iterate(globalOrgTypes,
+ function(t) {
+ if( t.depth() <= findOrgDepth(org) ) {
+ setSelectorVal(rsel, defDepthIndex++, t.opac_label(), t.depth());
+ if( t.depth() == findOrgDepth(org) )
+ setSelector(rsel, t.depth());
+ }
+ }
+ );
+ }
+
+ setSelector(selector, org);
+}
+
function myOPACShowHitsPer() {
var hits = 10;
if(G.user.prefs[PREF_HITS_PER])
unHideMe(G.ui.sidebar.logged_in_as);
hideMe(G.ui.sidebar.loginbox);
runEvt( 'common', 'loggedIn');
- runEvt( "common", "locationChanged", G.user.home_ou(), findOrgDepth(G.user.home_ou()) );
+
+ var org = G.user.prefs[PREF_DEF_LOCATION];
+ if(!org) org = G.user.home_ou();
+
+ var depth = G.user.prefs[PREF_DEF_DEPTH];
+ if(! ( depth && depth <= findOrgDepth(org)) )
+ depth = findOrgDepth(org);
+
+ runEvt( "common", "locationChanged", org, depth);
}