1 var searchBarExpanded = false;
2 /* our search selector boxes */
6 G.evt.common.init.push(searchBarInit);
9 /* if set by the org selector, this will be the location used the
10 next time the search is submitted */
11 var newSearchLocation;
13 function searchBarInit() {
15 _ts = G.ui.searchbar.type_selector;
16 _ds = G.ui.searchbar.depth_selector;
17 _fs = G.ui.searchbar.form_selector;
19 G.ui.searchbar.text.focus();
20 G.ui.searchbar.text.onkeydown =
21 function(evt) {if(userPressedEnter(evt)) searchBarSubmit();};
23 G.ui.searchbar.submit.onclick = searchBarSubmit;
24 G.ui.searchbar.tag.onclick = searchBarToggle;
26 /* set up the selector objects, etc */
27 G.ui.searchbar.text.value = (getTerm() != null) ? getTerm() : "";
28 setSelector(_ts, getStype());
29 setSelector(_ds, getDepth());
30 setSelector(_fs, getForm());
31 G.ui.searchbar.location_tag.onclick = _opacHandleLocationTagClick;
34 function _opacHandleLocationTagClick() {
35 orgTreeSelector.openTo(
36 (newSearchLocation != null) ? parseInt(newSearchLocation) : getLocation(), true );
37 swapCanvas(G.ui.common.org_container);
40 function updateLoc(location, depth) {
41 if( location != null )
42 newSearchLocation = location;
44 setSelector(G.ui.searchbar.depth_selector, depth);
46 function searchBarSubmit() {
48 var text = G.ui.searchbar.text.value;
49 if(!text || text == "") return;
54 args[PARAM_OFFSET] = 0;
55 args[PARAM_TERM] = text;
56 args[PARAM_STYPE] = _ts.options[_ts.selectedIndex].value;
57 args[PARAM_LOCATION] = newSearchLocation;
58 args[PARAM_DEPTH] = parseInt(_ds.options[_ds.selectedIndex].value);
59 args[PARAM_FORM] = _fs.options[_fs.selectedIndex].value;
61 goTo(buildOPACLink(args));
65 function searchBarToggle() {
66 if(searchBarExpanded) {
67 hideMe(G.ui.searchbar.extra_row);
68 hideMe(G.ui.searchbar.tag_on);
69 unHideMe(G.ui.searchbar.tag_off);
71 unHideMe(G.ui.searchbar.extra_row);
72 hideMe(G.ui.searchbar.tag_off);
73 unHideMe(G.ui.searchbar.tag_on);
75 searchBarExpanded = !searchBarExpanded;