1 var searchBarExpanded = false;
2 /* our search selector boxes */
6 var isFrontPage = false;
9 G.evt.common.init.push(searchBarInit);
11 /* if set by the org selector, this will be the location used the
12 next time the search is submitted */
13 var newSearchLocation;
14 var newSearchDepth = null;
17 function searchBarInit() {
19 _ts = G.ui.searchbar.type_selector;
20 _fs = G.ui.searchbar.form_selector;
22 try{G.ui.searchbar.text.focus();}catch(e){}
23 G.ui.searchbar.text.onkeydown =
24 function(evt) {if(userPressedEnter(evt)) { searchBarSubmit(); } };
26 function(evt) {if(userPressedEnter(evt)) { searchBarSubmit(); } };
28 function(evt) {if(userPressedEnter(evt)) { searchBarSubmit(); } };
30 G.ui.searchbar.submit.onclick = searchBarSubmit;
32 /* set up the selector objects, etc */
33 G.ui.searchbar.text.value = (getTerm() != null) ? getTerm() : "";
34 if (!isFrontPage) G.ui.searchbar.facets.value = (getFacet() != null) ? getFacet() : "";
35 setSelector(_ts, getStype());
36 setSelector(_fs, getForm());
41 if(!isFrontPage && (findCurrentPage() != MYOPAC)) {
42 attachEvt('common','depthChanged', searchBarSubmit);
45 if( (limit = $('opac.result.limit2avail')) ) {
46 if(getAvail()) limit.checked = true;
47 if(getSort() && getSortDir())
48 setSelector($('opac.result.sort'), getSort()+'.'+getSortDir());
52 function searchBarSubmit(isFilterSort) {
54 var text = G.ui.searchbar.text.value;
55 var facet_text = isFrontPage ? '' : G.ui.searchbar.facets.value;
59 if(!text || text == "") return;
61 var d = (newSearchDepth != null) ? newSearchDepth : depthSelGetDepth();
66 if(SHOW_MR_DEFAULT || findCurrentPage() == MRESULT) {
70 args[PARAM_RTYPE] = _ts.options[_ts.selectedIndex].value;
73 args[PARAM_STYPE] = _ts.options[_ts.selectedIndex].value;
74 args[PARAM_TERM] = text;
75 args[PARAM_FACET] = facet_text;
76 args[PARAM_LOCATION] = depthSelGetNewLoc();
77 args[PARAM_DEPTH] = d;
78 args[PARAM_FORM] = _fs.options[_fs.selectedIndex].value;
80 if($('opac.result.limit2avail')) {
81 args[PARAM_AVAIL] = ($('opac.result.limit2avail').checked) ? 1 : '';
82 if( (val = getSelectorVal($('opac.result.sort'))) ) {
83 args[PARAM_SORT] = val.split('.')[0]
84 args[PARAM_SORT_DIR] = val.split('.')[1]
88 goTo(buildOPACLink(args));